/* Grafik uygulaması (/grafik/) */

html, .app-body { height: 100%; }
.app-body { overflow: hidden; overscroll-behavior: none; }
.app {
  height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  --wl-w: 300px;
  --tools-w: 46px;
}
.app.wl-collapsed { --wl-w: 0px; }

/* Üst çubuk */
.topbar {
  display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px; min-width: 0;
  border-bottom: 1px solid var(--border); background: var(--surface); position: relative; z-index: 20;
}
.topbar-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-controls { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.app-brand { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px 0 4px; height: 36px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14.5px; border-radius: var(--radius); }
.app-brand:hover { background: var(--surface-2); }
.app-brand .brand-mark { width: 22px; height: 22px; }

.topbar .search-input { width: 160px; text-transform: uppercase; font-weight: 600; }
.topbar .search-input::placeholder { text-transform: none; font-weight: 400; }

.quote { display: flex; align-items: baseline; gap: 8px; padding: 0 8px; white-space: nowrap; min-width: 0; }
.quote-name { font-size: 13px; color: var(--text-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; align-self: center; }
.quote-price { font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.quote-change { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.quote .badge { align-self: center; }

.divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex: none; }
.intervals { display: flex; gap: 1px; }
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; min-width: 32px; padding: 0 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; flex: none;
}
.tb-btn:hover { background: var(--surface-2); color: var(--text); }
.tb-btn[aria-pressed='true'], .tb-btn[aria-expanded='true'] { color: var(--accent-text); background: var(--accent-soft); }
[data-theme-toggle].tb-btn[aria-pressed] { color: var(--text-2); background: transparent; }
[data-theme-toggle].tb-btn:hover { color: var(--text); background: var(--surface-2); }
.tb-btn svg { width: 18px; height: 18px; flex: none; }
.tb-icon { padding: 0; width: 32px; }
.intervals .tb-btn { font-size: 13px; min-width: 34px; padding: 0 6px; }
.topbar-controls .wl-toggle-desktop { margin-left: auto; }
.topbar-controls .account-wrap { margin-left: auto; }
.topbar-controls .account-wrap + .wl-toggle-desktop { margin-left: 2px; }
.account-wrap { display: flex; align-items: center; gap: 4px; }
.account-wrap a.tb-btn { text-decoration: none; }
.tb-signup { min-height: 28px; height: 28px; padding: 0 10px; font-size: 13px; flex: none; }
.tb-signup[hidden] { display: none; }
.tb-signup .lbl-short { display: none; }
.chart-type { display: flex; gap: 1px; }
.tb-btn[hidden] { display: none; }
.account-menu { min-width: 220px; }
.account-who { display: grid; gap: 2px; padding: 6px 8px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.account-name { font-size: 14px; font-weight: 600; color: var(--text); }
.account-email { font-size: 12px; color: var(--text-3); }
.account-name, .account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: 38px; padding: 0 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.wl-toggle-mobile { display: none; }

.menu-wrap { position: relative; }
.popover {
  position: fixed; z-index: 60; min-width: 260px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow);
}
.popover[hidden] { display: none; }
.popover-title { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 8px; }
.ind-list { border: 0; margin: 0; padding: 0; min-width: 0; }
.ind-option { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.ind-option:hover { background: var(--surface-2); }
.ind-option input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.ind-option .ind-code { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); margin-left: auto; }
.ind-group { font-size: 11px; color: var(--text-3); padding: 8px 8px 2px; }

/* Çalışma alanı */
.workspace {
  display: grid; grid-template-columns: var(--tools-w) minmax(0, 1fr) var(--wl-w);
  min-height: 0; position: relative;
}

.tools {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; overflow-x: hidden;
}
.tool-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
}
.tool-btn:hover { background: var(--surface-2); color: var(--text); }
.tool-btn[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent-text); }
.tool-btn[aria-pressed='true']::before { content: ''; position: absolute; left: -5px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent); }
.tool-btn:disabled { opacity: 0.4; cursor: default; background: transparent; }
.tool-btn svg { width: 20px; height: 20px; }
.tools-sep { width: 24px; height: 1px; background: var(--border); margin: 6px 0; flex: none; }

.chart-region { position: relative; min-width: 0; min-height: 0; background: var(--chart-bg); }
.chart { position: absolute; inset: 0; }
.chart-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: color-mix(in srgb, var(--chart-bg) 80%, transparent); z-index: 5; }
.chart-overlay[hidden] { display: none; }
.chart-overlay-box { max-width: 420px; text-align: center; display: grid; gap: 14px; justify-items: center; color: var(--text-2); font-size: 15px; }
.chart-overlay[data-state='error'] .chart-overlay-box p::before { content: ''; display: block; width: 28px; height: 2px; background: var(--down); margin: 0 auto 14px; }
.draw-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; margin: 0;
  padding: 6px 12px; border-radius: var(--radius); background: var(--surface-3); color: var(--text); font-size: 13px; pointer-events: none;
  max-width: calc(100% - 24px); text-align: center;
}
.draw-hint[hidden] { display: none; }

/* İzleme listesi */
.watchlist {
  display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
  border-left: 1px solid var(--border); background: var(--surface);
}
.app.wl-collapsed .watchlist { display: none; }
.wl-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 6px; }
.wl-head h2 { font-size: 13px; font-weight: 600; }
.wl-close { display: none; }
.wl-add { display: flex; gap: 6px; padding: 4px 12px 10px; }
.input-sm { min-height: 30px; height: 30px; font-size: 13px; padding: 0 8px; text-transform: uppercase; font-weight: 600; }
.input-sm::placeholder { text-transform: none; font-weight: 400; }
.wl-add .btn { min-height: 30px; }
.wl-cols, .wl-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 64px 28px; align-items: center; gap: 4px; }
.wl-cols { padding: 6px 12px; font-size: 11px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.wl-cols span:nth-child(2), .wl-cols span:nth-child(3) { text-align: right; }
.wl-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.wl-item { position: relative; border-bottom: 1px solid var(--border); }
.wl-row {
  width: 100%; min-height: 40px; padding: 3px 0 3px 12px; border: 0; background: transparent; text-align: left; color: var(--text);
}
.wl-item:hover { background: var(--surface-2); }
.wl-item[aria-current='true'] { background: var(--accent-soft); }
.wl-item[aria-current='true']::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.wl-sym { display: grid; min-width: 0; }
.wl-sym b { font-weight: 600; font-size: 13px; }
.wl-sym small { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-price, .wl-chg { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.wl-remove {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center; opacity: 0;
}
.wl-item:hover .wl-remove, .wl-remove:focus-visible { opacity: 1; }
.wl-remove:hover { color: var(--down); background: var(--surface-3); }
.wl-remove svg { width: 14px; height: 14px; }
@media (hover: none) { .wl-remove { opacity: 1; } }
.wl-status { padding: 8px 12px; font-size: 12px; color: var(--text-3); min-height: 32px; border-top: 1px solid var(--border); }
.wl-empty { padding: 16px 12px; font-size: 13px; color: var(--text-2); }

.backdrop { display: none; }

/* Durum çubuğu */
.statusbar {
  display: flex; flex-wrap: nowrap; gap: 16px; align-items: center; height: 26px; padding: 0 12px;
  border-top: 1px solid var(--border); background: var(--surface); font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden;
}
.statusbar-note { margin-left: auto; }
/* Yumuşak kayıt çağrısı durum çubuğunun üstünde */
.app-body .signup-nudge { bottom: 36px; }
.sync-status { color: var(--warn); overflow: hidden; text-overflow: ellipsis; }
.sync-status[hidden] { display: none; }

/* Diyaloglar */
.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 18px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: var(--overlay); }
.dialog h2 { font-size: 17px; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-wide { width: min(640px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; position: sticky; top: 0; background: var(--surface); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 0 20px 20px; font-size: 15px; color: var(--text-2); }
.dialog-body > * + * { margin-top: 12px; }
.dialog-body h3 { font-size: 15px; color: var(--text); margin-top: 20px; }
.dialog-body h2 { font-size: 16px; color: var(--text); margin-top: 20px; }
.dialog-body ul, .dialog-body ol { padding-left: 20px; }
.dialog-body kbd { font-size: 12px; padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--bg); }
.todo { font-family: var(--font-mono); font-size: 12px; color: var(--warn); }

/* Orta genişlik */
@media (max-width: 1519px) {
  .tb-signup .lbl-long { display: none; }
  .tb-signup .lbl-short { display: inline; }
  .quote-name { display: none; }
}
@media (max-width: 1360px) {
  /* Kayıt düğmesine yer: marka adı gizlenir (logo kalır), arama daralır */
  .app-brand-name { display: none; }
  .app-brand { padding: 0 4px; }
  .topbar .search-input { width: 130px; }
}
@media (max-width: 1180px) {
  /* Göstergeler düğmesi yalnızca simge; etiket ekran okuyucuda kalır */
  #indicators-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app { --wl-w: 260px; }
  .app.wl-collapsed { --wl-w: 0px; }
}
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; padding: 0 6px; row-gap: 0; }
  .topbar-main { width: 100%; height: 48px; }
  .topbar-controls { height: 44px; border-top: 1px solid var(--border); margin: 0 -6px; padding: 0 6px; width: calc(100% + 12px); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .topbar-controls::-webkit-scrollbar { display: none; }
  .quote { margin-left: auto; }
}

/* Mobil: alt araç çubuğu, çekmece izleme listesi */
@media (max-width: 760px) {
  .app { --tools-w: 0px; }
  .app-brand-name { display: none; }
  .app-brand { padding: 0 4px; }
  .topbar-main { gap: 6px; }
  .topbar .search { flex: 1 1 100px; min-width: 0; }
  .topbar .search-input { width: 100%; min-width: 0; height: 38px; font-size: 16px; padding-right: 6px; }
  .quote {
    flex: none; padding: 0; display: grid; grid-template-columns: auto auto; justify-items: end;
    align-items: baseline; column-gap: 6px; row-gap: 2px; margin-left: 0;
  }
  .quote .badge { grid-column: 1 / -1; height: 18px; font-size: 11px; padding: 0 6px; }
  .quote-price { font-size: 14px; }
  .quote-change { font-size: 12px; }
  .wl-toggle-mobile { display: inline-flex; width: 44px; height: 44px; flex: none; }
  .wl-toggle-desktop { display: none !important; }
  .tb-btn { height: 40px; min-width: 40px; }
  .intervals .tb-btn { min-width: 42px; }
  .tb-icon { width: 40px; }
  .tb-signup { height: 34px; min-height: 34px; }
  .app-body .signup-nudge { bottom: calc(80px + env(safe-area-inset-bottom)); }

  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .chart-region { grid-row: 1; }
  .tools {
    grid-row: 2; flex-direction: row; justify-content: flex-start; gap: 2px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .tools::-webkit-scrollbar { display: none; }
  .tool-btn { width: 44px; height: 44px; }
  .tool-btn[aria-pressed='true']::before { left: 10px; right: 10px; top: auto; bottom: -3px; width: auto; height: 2px; }
  .tools-sep { width: 1px; height: 24px; margin: 0 4px; }

  .watchlist {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(340px, 88vw);
    border-left: 1px solid var(--border-strong); box-shadow: var(--shadow);
    transform: translateX(100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app.wl-collapsed .watchlist { display: flex; }
  .app.wl-open .watchlist { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .wl-close { display: inline-flex; width: 44px; height: 44px; }
  .wl-row { min-height: 52px; }
  .wl-cols, .wl-row { grid-template-columns: minmax(0, 1fr) 84px 64px 40px; }
  .wl-remove { width: 40px; height: 40px; right: 0; }
  .backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.45); }
  .app.wl-open .backdrop { display: block; }
  .backdrop[hidden] { display: none !important; }

  .statusbar { height: 24px; font-size: 11px; gap: 10px; }
  .statusbar-tz, #status-updated { display: none; }
  .draw-hint { top: 8px; font-size: 12px; }
  .popover { left: 8px !important; right: 8px; min-width: 0; }
}
@media (max-width: 380px) {
  .quote-price { font-size: 13px; }
  .quote-change { font-size: 11px; }
  .app-brand .brand-mark { width: 22px; height: 22px; }
}
