/* ==========================================================================
   Makale Editörü V2 — Word benzeri profesyonel arayüz
   ========================================================================== */

:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-serif: 'Georgia', 'Charter', 'Times New Roman', serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --bg-app: #eceef3;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --surface-3: #eaecf1;
  --paper: #ffffff;
  --border: #e0e3ea;
  --border-strong: #cfd3dd;

  --text: #1a1d23;
  --text-2: #565c66;
  --text-3: #8b909b;

  --accent: #2b6cff;
  --accent-hover: #1f5ae6;
  --accent-soft: #eaf1ff;
  --accent-2: #7c3aed;

  --ai: #7c3aed;
  --ai-soft: #f3eefe;
  --ai-grad: linear-gradient(135deg, #7c3aed, #2b6cff);

  --success: #12915a;
  --success-soft: #e6f6ee;
  --danger: #dc3838;
  --danger-soft: #fdecec;
  --warn: #c47d1a;

  --add-bg: #d6f5e0; --add-text: #0f6b39;
  --del-bg: #fdd9d9; --del-text: #a11;

  --shadow-sm: 0 1px 2px rgba(20,25,40,.07), 0 1px 3px rgba(20,25,40,.05);
  --shadow-md: 0 4px 14px rgba(20,25,40,.09), 0 2px 5px rgba(20,25,40,.05);
  --shadow-lg: 0 16px 48px rgba(20,25,40,.20), 0 6px 16px rgba(20,25,40,.10);

  --radius: 9px; --radius-sm: 6px; --radius-lg: 15px;
  --ribbon-h: 92px;
}

[data-theme="dark"] {
  --bg-app: #0a0c10;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --surface-3: #232833;
  --paper: #1b1f27;
  --border: #262c37;
  --border-strong: #333a47;

  --text: #e9ebef; --text-2: #a7adb8; --text-3: #6a7180;

  --accent: #5b8cff; --accent-hover: #6f9bff; --accent-soft: #17233d;
  --ai: #a78bfa; --ai-soft: #211a3a; --ai-grad: linear-gradient(135deg, #a78bfa, #5b8cff);

  --success: #34d399; --success-soft: #10281f;
  --danger: #f87171; --danger-soft: #2a1717; --warn: #e0a94a;
  --add-bg: #10331f; --add-text: #6ee7a0; --del-bg: #3a1a1a; --del-text: #f8a8a8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font-ui);
  background: var(--bg-app); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ============================ ÜST BAŞLIK ============================ */
.titlebar {
  height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: var(--ai-grad); color: #fff; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14.5px; }
.brand svg { width: 22px; height: 22px; }
.tb-doc { flex: 1; max-width: 560px; margin: 0 auto; }
.tb-doc input {
  width: 100%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12);
  color: #fff; font-size: 14px; font-weight: 600; padding: 7px 13px; border-radius: 8px;
  text-align: center; transition: .15s;
}
.tb-doc input::placeholder { color: rgba(255,255,255,.7); }
.tb-doc input:focus { outline: none; background: rgba(255,255,255,.22); text-align: left; }
.tb-actions { display: flex; align-items: center; gap: 6px; }
.tb-btn {
  height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; font-size: 13px; font-weight: 550; transition: .14s;
}
.tb-btn:hover { background: rgba(255,255,255,.26); }
.tb-btn svg { width: 16px; height: 16px; }
.tb-btn.icon { width: 34px; padding: 0; justify-content: center; }
.save-pill { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255,255,255,.9); padding: 0 6px; }
.save-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.6); }
.save-pill.saved .dot { background: #86efac; }
.save-pill.saving .dot { background: #fde047; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ============================ RIBBON ============================ */
.ribbon { flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 30; }
.ribbon-tabs { display: flex; gap: 2px; padding: 4px 10px 0; border-bottom: 1px solid var(--border); }
.ribbon-tab {
  padding: 7px 16px; border: none; background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; border-radius: 7px 7px 0 0; position: relative; transition: .13s;
}
.ribbon-tab:hover { background: var(--surface-2); color: var(--text); }
.ribbon-tab.active { color: var(--accent); background: var(--surface-2); }
.ribbon-tab.active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.ribbon-tab.ai-tab.active { color: var(--ai); }
.ribbon-tab.ai-tab.active::after { background: var(--ai); }

.ribbon-panels { padding: 8px 12px; min-height: 62px; }
.ribbon-panel { display: none; align-items: stretch; gap: 4px; overflow-x: auto; }
.ribbon-panel.active { display: flex; }
.ribbon-panel::-webkit-scrollbar { height: 0; }

.rgroup { display: flex; flex-direction: column; gap: 4px; padding: 0 8px; border-right: 1px solid var(--border); }
.rgroup:last-child { border-right: none; }
.rgroup-row { display: flex; align-items: center; gap: 3px; }
.rgroup-label { font-size: 10px; color: var(--text-3); text-align: center; margin-top: 1px; letter-spacing: .02em; }

.rbtn {
  height: 30px; min-width: 30px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text-2);
  font-size: 12.5px; font-weight: 550; transition: .12s;
}
.rbtn:hover { background: var(--surface-3); color: var(--text); }
.rbtn.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.rbtn svg { width: 16px; height: 16px; }
.rbtn.big { flex-direction: column; height: 52px; min-width: 56px; gap: 3px; font-size: 11px; }
.rbtn.big svg { width: 20px; height: 20px; }
.rbtn.ai-btn { background: var(--ai-soft); color: var(--ai); border-color: color-mix(in srgb, var(--ai) 25%, transparent); }
.rbtn.ai-btn:hover { background: color-mix(in srgb, var(--ai) 15%, transparent); }
.rbtn:disabled { opacity: .4; cursor: not-allowed; }

.rsel {
  height: 30px; padding: 0 6px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); border-radius: 6px; font-size: 12.5px; font-weight: 500;
}
.rsel.font { width: 130px; } .rsel.size { width: 72px; } .rsel.style { width: 122px; }
.rsep { width: 1px; background: var(--border); margin: 2px 3px; align-self: stretch; }

/* Renk seçici */
.color-btn { position: relative; flex-direction: column; gap: 1px; height: 30px; padding: 3px 6px 2px; }
.color-btn .bar { width: 16px; height: 3px; border-radius: 2px; }
.color-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 8px; width: 176px;
}
.color-pop.show { display: block; }
.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.color-swatch { width: 17px; height: 17px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; transition: transform .1s; }
.color-swatch:hover { transform: scale(1.18); }
.color-none { grid-column: 1/-1; font-size: 11.5px; color: var(--text-2); padding: 4px; text-align: center; border-radius: 5px; margin-top: 4px; background: var(--surface-2); }
.color-none:hover { background: var(--surface-3); }

/* ============================ ANA ============================ */
.main { flex: 1; display: flex; min-height: 0; overflow: hidden; }

.editor-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor-scroll { flex: 1; overflow-y: auto; padding: 28px 20px 120px; scroll-behavior: smooth; background: var(--bg-app); }

.page {
  max-width: 820px; margin: 0 auto; background: var(--paper); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); border-radius: 4px; transition: transform .2s, box-shadow .2s;
  transform-origin: top center;
}
.editor {
  padding: 64px 76px; min-height: 900px; outline: none;
  font-family: var(--font-serif); font-size: 17px; line-height: 1.7; color: var(--text);
}
.editor:focus { box-shadow: none; }
.editor h1 { font-size: 2em; line-height: 1.2; margin: .3em 0 .5em; font-weight: 700; }
.editor h2 { font-size: 1.5em; margin: 1.3em 0 .4em; font-weight: 650; }
.editor h3 { font-size: 1.22em; margin: 1.1em 0 .3em; font-weight: 650; }
.editor h4 { font-size: 1.06em; margin: 1em 0 .3em; font-weight: 700; }
.editor p { margin: 0 0 .9em; }
.editor blockquote { border-left: 3px solid var(--accent); margin: 1.1em 0; padding: .3em 0 .3em 1.2em; color: var(--text-2); font-style: italic; }
.editor ul, .editor ol { margin: 0 0 .9em; padding-left: 1.6em; }
.editor li { margin: .3em 0; }
.editor a { color: var(--accent); text-decoration: underline; }
.editor hr { border: none; border-top: 1px solid var(--border-strong); margin: 1.8em 0; }
.editor code { font-family: var(--font-mono); font-size: .85em; background: var(--surface-3); padding: .1em .4em; border-radius: 5px; }
.editor pre { font-family: var(--font-mono); font-size: .82em; background: var(--surface-3); padding: 1em 1.2em; border-radius: 9px; overflow-x: auto; }
.editor pre code { background: none; padding: 0; }
.editor img { max-width: 100%; height: auto; border-radius: 6px; }
.editor table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.editor th, .editor td { border: 1px solid var(--border-strong); padding: 8px 11px; text-align: left; }
.editor th { background: var(--surface-2); font-weight: 650; }
.editor table.selected-tbl, .editor td.tbl-cell-active { outline: 2px solid var(--accent); }
.editor:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.editor .search-hit { background: #ffe58a; color: #111; border-radius: 2px; }
.editor .search-hit.current { background: #ff9f43; }
/* Grafikler */
.editor .mk-chart { margin: 1.2em auto; text-align: center; border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); max-width: 620px; position: relative; cursor: pointer; transition: box-shadow .15s; }
.editor .mk-chart:hover { box-shadow: var(--shadow-md); }
.editor .mk-chart::after { content: '✎ düzenlemek için çift tıklayın'; position: absolute; top: 6px; right: 10px; font-family: var(--font-ui); font-size: 10px; color: var(--text-3); opacity: 0; transition: .15s; }
.editor .mk-chart:hover::after { opacity: 1; }
.editor .mk-chart svg { display: block; margin: 0 auto; }
/* Grafik modal satırları */
.chart-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.chart-row .c-label { flex: 2; height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 7px; font-size: 13px; }
.chart-row .c-value { flex: 1; height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 7px; font-size: 13px; }
.chart-row input:focus { outline: none; border-color: var(--accent); }
.chart-row .chart-del { width: 30px; height: 32px; border: 1px solid var(--border); background: var(--surface-2); color: var(--danger); border-radius: 7px; font-size: 18px; line-height: 1; flex-shrink: 0; }
.chart-row .chart-del:hover { background: var(--danger-soft); }
.ai-flash { animation: aiFlash 1.4s ease; }
@keyframes aiFlash { 0% { background: color-mix(in srgb, var(--ai) 30%, transparent); } 100% { background: transparent; } }
.ai-writing { border-radius: 3px; }
.ai-writing::after { content: '▋'; color: var(--ai); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ============================ AI PANEL ============================ */
.ai-pane {
  width: 400px; flex-shrink: 0; display: flex; flex-direction: column; position: relative;
  background: var(--surface); border-left: 1px solid var(--border); min-height: 0;
}
.ai-pane.collapsed { width: 0 !important; overflow: hidden; border-left: none; }
/* Yeniden boyutlandırma tutamağı */
.ai-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 15; }
.ai-resize::after { content: ''; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s; }
.ai-resize:hover::after, .ai-resize.active::after { background: var(--ai); }
.ai-head { flex-shrink: 0; display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ai-head .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--ai-grad); display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.ai-head .logo svg { width: 17px; height: 17px; }
.ai-head h2 { font-size: 14.5px; font-weight: 700; margin: 0; flex: 1; }
.ai-head .sub { font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.ai-head .badge { font-size: 10px; font-weight: 600; color: var(--ai); background: var(--ai-soft); padding: 3px 8px; border-radius: 20px; }

.ai-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
/* Çocuklar KÜÇÜLMESİN — yükseklik kısıtlıyken flexbox composer'ı ezip şeride dönüştürmesin, panel kaydırılsın */
.ai-body > * { flex-shrink: 0; }
.ai-composer { flex-shrink: 0; }

/* Ana AI komut kutusu */
.ai-composer { border: 1.5px solid var(--border-strong); border-radius: 14px; background: var(--surface-2); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.ai-composer:focus-within { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }
.ai-composer textarea {
  width: 100%; border: none; background: transparent; color: var(--text); resize: none;
  padding: 12px 13px 4px; font-size: 14px; line-height: 1.55; min-height: 62px; max-height: 200px;
}
.ai-composer textarea:focus { outline: none; }
.ai-composer textarea::placeholder { color: var(--text-3); }
.ai-comp-bar { display: flex; align-items: center; gap: 6px; padding: 7px 9px; }
.ai-mode-tabs { display: flex; gap: 3px; flex: 1; }
.ai-mode {
  height: 28px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 7px; font-size: 11.5px; font-weight: 600; transition: .12s;
}
.ai-mode svg { width: 13px; height: 13px; }
.ai-mode.active { background: var(--ai-soft); color: var(--ai); border-color: color-mix(in srgb, var(--ai) 30%, transparent); }
.ai-send {
  width: 34px; height: 34px; border-radius: 9px; border: none; background: var(--ai-grad); color: #fff;
  display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--shadow-sm); transition: .13s;
}
.ai-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ai-send:disabled { opacity: .5; }
.ai-send svg { width: 17px; height: 17px; }

.ai-hint { font-size: 11px; color: var(--text-3); padding: 0 4px; display: flex; align-items: center; gap: 5px; min-height: 15px; }
.ai-hint svg { width: 12px; height: 12px; }
.ai-hint b { color: var(--ai); }

/* Uzunluk seçici satırı */
.ai-len-row { display: flex; align-items: center; gap: 8px; padding: 2px 2px; }
.ai-len-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.ai-len-lbl svg { width: 13px; height: 13px; color: var(--ai); }
.ai-len { flex: 1; height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 8px; font-size: 12.5px; font-weight: 550; }
.ai-len:focus { outline: none; border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }

/* İlerleme çubuğu (uzun makale) */
.ai-prog { height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.ai-prog-bar { height: 100%; width: 0; background: var(--ai-grad); border-radius: 4px; transition: width .4s ease; }

/* APA atıf toggle */
.ai-apa-row { display: flex; align-items: center; gap: 8px; padding: 3px 2px; cursor: pointer; user-select: none; }
.ai-apa-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.apa-sw { width: 34px; height: 19px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; flex-shrink: 0; transition: .18s; }
.apa-sw::after { content: ''; position: absolute; top: 1px; left: 1px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: .18s; }
.ai-apa-row input:checked + .apa-sw { background: var(--ai); border-color: var(--ai); }
.ai-apa-row input:checked + .apa-sw::after { transform: translateX(15px); }
.apa-txt { font-size: 11.5px; font-weight: 550; color: var(--text-2); }
.apa-txt b { color: var(--ai); font-weight: 650; }

/* Kaynak tür rozetleri */
.research-item .src-article { background: var(--ai-soft); color: var(--ai); }
.research-item .src-book { background: var(--success-soft); color: var(--success); }
.research-item .src-wikipedia { background: var(--surface-3); color: var(--text-2); }
.research-item .src { padding: 1px 6px; border-radius: 10px; font-weight: 600; }

/* Kapsam */
.scope-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 9px; }
.scope-tab { flex: 1; height: 30px; border: none; background: transparent; color: var(--text-2); border-radius: 6px; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 5px; transition: .12s; }
.scope-tab svg { width: 13px; height: 13px; }
.scope-tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* Hızlı işlemler */
.ai-sect-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 2px 2px 0; display: flex; align-items: center; gap: 6px; }
.ai-sect-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 20px;
  color: var(--text); font-size: 12.5px; font-weight: 550; transition: .12s;
}
.ai-chip:hover { border-color: var(--ai); background: var(--ai-soft); color: var(--ai); transform: translateY(-1px); }
.ai-chip svg { width: 14px; height: 14px; }

/* Çıktı */
.ai-out-wrap { display: none; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.ai-out-wrap.show { display: flex; }
.ai-out-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.ai-out-head .lbl { font-size: 12px; font-weight: 650; flex: 1; display: flex; align-items: center; gap: 7px; }
.ai-out-head .spin { width: 13px; height: 13px; border: 2px solid var(--border-strong); border-top-color: var(--ai); border-radius: 50%; animation: spin .7s linear infinite; display: none; }
.ai-out-wrap.loading .spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-out { padding: 12px 14px; max-height: 340px; overflow-y: auto; font-size: 13.5px; line-height: 1.65; }
.ai-out p { margin: 0 0 .6em; } .ai-out h1,.ai-out h2,.ai-out h3 { margin: .5em 0 .3em; line-height: 1.3; }
.ai-out h1 { font-size: 1.25em; } .ai-out h2 { font-size: 1.12em; } .ai-out h3 { font-size: 1.02em; }
.ai-out ul, .ai-out ol { margin: 0 0 .6em; padding-left: 1.3em; } .ai-out li { margin: .2em 0; }
.ai-out strong { font-weight: 680; } .ai-out code { font-family: var(--font-mono); font-size: .85em; background: var(--surface-3); padding: .1em .35em; border-radius: 4px; }
.ai-out a { color: var(--accent); } .ai-out.cursor::after { content: '▋'; color: var(--ai); animation: blink 1s step-end infinite; }
.ai-out-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.oa { height: 31px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: .12s; }
.oa svg { width: 14px; height: 14px; } .oa:hover { background: var(--surface-2); }
.oa.primary { background: var(--ai-grad); border: none; color: #fff; } .oa.primary:hover { filter: brightness(1.08); }
.oa.danger { color: var(--danger); border-color: transparent; } .oa.danger:hover { background: var(--danger-soft); }

/* Araştırma sonuçları */
.research-box { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 10px 12px; }
.research-box .rh { font-size: 11px; font-weight: 700; color: var(--ai); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.research-item { padding: 6px 0; border-top: 1px solid var(--border); font-size: 12px; }
.research-item:first-of-type { border-top: none; }
.research-item a { color: var(--accent); font-weight: 600; text-decoration: none; }
.research-item a:hover { text-decoration: underline; }
.research-item p { margin: 2px 0 0; color: var(--text-2); font-size: 11.5px; line-height: 1.45; }
.research-item .src { font-size: 9.5px; color: var(--text-3); text-transform: uppercase; }

/* ============================ DURUM ÇUBUĞU ============================ */
.statusbar { height: 28px; flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--surface); border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }
.statusbar .st { display: flex; align-items: center; gap: 5px; }
.statusbar .st b { color: var(--text-2); font-weight: 650; font-variant-numeric: tabular-nums; }
.statusbar .sp { flex: 1; }
.zoom-ctl { display: flex; align-items: center; gap: 2px; }
.zoom-ctl button { width: 22px; height: 20px; border: none; background: transparent; color: var(--text-2); border-radius: 4px; font-size: 14px; }
.zoom-ctl button:hover { background: var(--surface-3); }

/* ============================ MODAL ============================ */
.overlay { position: fixed; inset: 0; z-index: 90; background: rgba(8,10,18,.5); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; padding: 22px; }
.overlay.show { display: flex; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(920px, 100%); max-height: 88vh; display: flex; flex-direction: column; animation: mup .2s; }
.modal.sm { width: min(440px, 100%); }
@keyframes mup { from { opacity: 0; transform: scale(.97) translateY(8px); } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-h h3 { margin: 0; font-size: 15.5px; font-weight: 650; flex: 1; }
.modal-b { flex: 1; overflow-y: auto; padding: 18px; }
.modal-f { display: flex; align-items: center; gap: 9px; padding: 13px 18px; border-top: 1px solid var(--border); }
.modal-f .sp { flex: 1; }
.btn { height: 36px; padding: 0 15px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 8px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; transition: .12s; }
.btn:hover { background: var(--surface-2); } .btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-hover); }
.btn.ai { background: var(--ai-grad); border: none; color: #fff; }
.field { margin-bottom: 13px; } .field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 8px; font-size: 13.5px; }
.field textarea { height: auto; min-height: 80px; padding: 10px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-pick { display: grid; grid-template-columns: repeat(8, 26px); gap: 3px; }
.grid-pick .cell { width: 26px; height: 24px; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; }
.grid-pick .cell.on { background: var(--accent-soft); border-color: var(--accent); }

/* Bul & Değiştir */
.find-modal { margin-top: 80px; }   /* masaüstü: tepeden biraz aşağıda */
.fr-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.fr-row input { flex: 1; height: 40px; padding: 0 11px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 8px; font-size: 14px; }
.fr-row input:focus { outline: none; border-color: var(--accent); }
.fr-info { font-size: 12px; color: var(--text-2); }

/* Diff */
.diff-tabs { display: flex; gap: 3px; padding: 10px 18px 0; }
.diff-tab { padding: 7px 14px; border: none; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; border-radius: 7px 7px 0 0; border-bottom: 2px solid transparent; }
.diff-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.diff-view { font-family: var(--font-serif); font-size: 15px; line-height: 1.7; }
.diff-view ins { background: var(--add-bg); color: var(--add-text); text-decoration: none; border-radius: 3px; }
.diff-view del { background: var(--del-bg); color: var(--del-text); border-radius: 3px; }
.diff-view p { margin: 0 0 1em; }
.preview-view { font-family: var(--font-serif); font-size: 15px; line-height: 1.7; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-3); } .legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; } .legend .add { background: var(--add-bg); } .legend .del { background: var(--del-bg); }
.diff-stat { font-size: 12px; color: var(--text-3); } .diff-stat b.p { color: var(--success); } .diff-stat b.m { color: var(--danger); }

/* ============================ DROPZONE / BUSY / TOAST ============================ */
.dropzone { position: fixed; inset: 0; z-index: 100; background: color-mix(in srgb, var(--ai) 14%, rgba(10,12,20,.55)); backdrop-filter: blur(3px); display: none; place-items: center; }
.dropzone.show { display: grid; }
.dropzone .card { background: var(--surface); border: 2px dashed var(--ai); border-radius: var(--radius-lg); padding: 44px 60px; text-align: center; box-shadow: var(--shadow-lg); pointer-events: none; }
.dropzone .card svg { width: 52px; height: 52px; color: var(--ai); margin-bottom: 12px; }
.dropzone .card h3 { margin: 0 0 5px; font-size: 18px; } .dropzone .card p { margin: 0; color: var(--text-2); font-size: 13px; }
.busy { position: fixed; inset: 0; z-index: 150; background: color-mix(in srgb, var(--bg-app) 68%, transparent); backdrop-filter: blur(2px); display: none; place-items: center; flex-direction: column; }
.busy.show { display: grid; }
.busy .spin { width: 44px; height: 44px; border: 3px solid var(--border-strong); border-top-color: var(--ai); border-radius: 50%; animation: spin .7s linear infinite; }
.busy p { margin-top: 13px; font-size: 14px; color: var(--text-2); font-weight: 550; }
.toasts { position: fixed; bottom: 42px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550; animation: tin .25s cubic-bezier(.2,.9,.3,1.3); pointer-events: auto; max-width: 440px; }
@keyframes tin { from { opacity: 0; transform: translateY(12px) scale(.96); } }
.toast.leaving { animation: tout .25s forwards; } @keyframes tout { to { opacity: 0; transform: translateY(8px); } }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success svg { color: var(--success); } .toast.error svg { color: var(--danger); } .toast.info svg { color: var(--accent); }

/* Menü (export) */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 45; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: none; }
.menu.show { display: block; animation: mup .13s; }
.menu-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-3); padding: 7px 9px 4px; }
.menu-item { display: flex; align-items: center; gap: 11px; padding: 9px; border: none; background: transparent; color: var(--text); border-radius: 8px; font-size: 13.5px; font-weight: 550; text-align: left; width: 100%; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .mi { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-3); color: var(--accent); font-size: 9.5px; font-weight: 800; flex-shrink: 0; }
.menu-item small { display: block; font-weight: 450; color: var(--text-3); font-size: 11px; }

.mobile-only { display: none; }

/* Yüzen AI butonu (FAB) — yalnızca mobil */
.ai-fab { display: none; }
.ai-sheet-handle { display: none; }
.ai-backdrop { display: none; }

@media (max-width: 1150px) { .ai-pane { width: 340px; } .editor { padding: 48px 44px; } .rgroup-label { display: none; } }

/* ======================= TABLET / MOBİL (≤ 900px) ======================= */
@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }

  /* Üst çubuk sadeleşir: başlık görünür, aksiyonlar simge */
  .tb-doc { display: block; max-width: none; flex: 1; margin: 0 4px; }
  .tb-doc input { font-size: 16px; padding: 8px 10px; }   /* 16px: iOS yakınlaşmasını önle */
  .titlebar { gap: 8px; padding: 0 max(10px, env(safe-area-inset-left)) 0 max(10px, env(safe-area-inset-left)); }
  .brand span { display: none; }               /* logo kalır, yazı gizlenir */
  .brand svg { width: 24px; height: 24px; }
  .tb-actions { gap: 4px; }
  .tb-btn span { display: none; }               /* İçe/Dışa Aktar → yalnızca simge */
  .tb-btn { padding: 0; width: 38px; height: 38px; justify-content: center; }
  .save-pill { display: none; }                 /* durum küçük ekranda gizli */
  #panelToggle { display: none; }               /* yerine FAB kullanılır */

  /* Ribbon — dokunmatik uyumlu, yatay kaydırılır */
  .ribbon-tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .ribbon-tabs::-webkit-scrollbar { display: none; }
  .ribbon-tab { padding: 9px 14px; flex-shrink: 0; font-size: 13.5px; }
  .ribbon-panels { padding: 6px 8px; }
  .rbtn { height: 36px; min-width: 36px; }       /* daha büyük dokunma hedefi */
  .rbtn.big { height: 54px; min-width: 60px; }
  .rsel { height: 36px; font-size: 14px; }

  /* Editör tam genişlik (AI paneli mobilde fixed/bottom-sheet olduğundan main tek çocuklu) */
  .main { min-height: 0; }
  .editor-pane { min-height: 0; }
  .editor-scroll { padding: 16px 10px 96px; -webkit-overflow-scrolling: touch; }
  .page { border-radius: 6px; }
  .editor { padding: 26px 20px; font-size: 16.5px; }

  /* AI paneli = alttan açılan sayfa (bottom sheet) */
  .ai-pane {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100% !important;
    height: 90vh; max-height: 90vh; z-index: 80;
    border-left: none; border-top: 1px solid var(--border);
    border-radius: 22px 22px 0 0; box-shadow: 0 -12px 44px rgba(10,12,20,.28);
    transform: translateY(0); transition: transform .3s cubic-bezier(.32,.72,0,1);
  }
  .ai-pane.collapsed { transform: translateY(101%); box-shadow: none; }
  .ai-resize { display: none; }                 /* mobilde sürükleyerek boyutlandırma yok */
  .ai-sheet-handle { display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 9px auto 3px; flex-shrink: 0; }
  .ai-head { padding: 6px 16px 12px; }
  .ai-body { padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); }
  .ai-composer textarea { font-size: 16px; }    /* iOS yakınlaşmasını önle */
  .ai-len, .tone-select, .rsel, .field input, .field select,
  .fr-row input, .chart-row .c-label, .chart-row .c-value { font-size: 16px; }

  /* Dokunma hedeflerini büyüt (≥40-44px) */
  .ai-mode { height: 40px; padding: 0 12px; }
  .scope-tab { height: 40px; }
  .ai-chip { min-height: 40px; }
  .oa { height: 40px; }
  .chart-row .c-label, .chart-row .c-value { height: 42px; }
  .chart-row .chart-del { width: 42px; height: 42px; font-size: 20px; }
  .grid-pick { grid-template-columns: repeat(8, 30px); gap: 4px; }
  .grid-pick .cell { width: 30px; height: 28px; }
  /* Renk paleti kutucukları — parmakla seçilebilir */
  .color-pop { width: auto; min-width: 232px; }
  .color-grid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .color-swatch { width: 30px; height: 30px; }

  /* Arka örtü */
  .ai-backdrop { display: block; position: fixed; inset: 0; z-index: 75; background: rgba(8,10,18,.45); opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
  .ai-backdrop.show { opacity: 1; visibility: visible; }

  /* Yüzen AI butonu */
  .ai-fab {
    display: inline-flex; align-items: center; gap: 7px;
    position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 70;
    height: 52px; padding: 0 20px 0 16px; border: none; border-radius: 28px;
    background: var(--ai-grad); color: #fff; font-weight: 700; font-size: 15px;
    box-shadow: 0 8px 24px rgba(124,58,237,.42); transition: transform .15s, box-shadow .15s;
  }
  .ai-fab:active { transform: scale(.95); }
  .ai-fab svg { width: 22px; height: 22px; }
  .ai-fab.busy { background: var(--danger); box-shadow: 0 8px 24px rgba(220,56,56,.42); }
  .ai-fab.busy svg { animation: spin .8s linear infinite; }

  /* Durum çubuğu sade — safe-area ve FAB ile çakışmayı önle */
  .statusbar { height: auto; min-height: 30px; padding: 4px 12px calc(4px + env(safe-area-inset-bottom)); gap: 12px; }
  .statusbar .st:nth-child(2) { display: none; }  /* karakter sayısını gizle */
  .zoom-ctl { display: none; }                    /* mobilde parmakla yakınlaştırma; buton çakışmasını önler */

  /* Modallar = alttan açılan sayfa */
  .overlay { align-items: flex-end; padding: 0; }
  .modal, .modal.sm { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; animation: sheetUp .28s cubic-bezier(.32,.72,0,1); }
  .modal-b { padding: 16px; }
  .field input, .field select, .field textarea { height: 44px; }
  .field textarea { height: auto; }
  .btn { height: 44px; }                          /* dokunma hedefi */
  #findModal.overlay { align-items: flex-start; }
  #findModal .modal { margin-top: 0; border-radius: 0 0 20px 20px; }
  .chart-modal-body, .modal-b[style*="flex"] { flex-direction: column !important; }

  /* Export menüsü ekranı taşmasın */
  .menu { right: 0; left: auto; min-width: 220px; max-width: calc(100vw - 24px); }
}
@keyframes sheetUp { from { transform: translateY(100%); } }

/* ======================= KÜÇÜK TELEFON (≤ 560px) ======================= */
@media (max-width: 560px) {
  .titlebar { height: 52px; }
  .ai-fab span { display: inline; }
  .editor { padding: 22px 16px; font-size: 16px; }
  .editor h1 { font-size: 1.7em; }
  .editor h2 { font-size: 1.35em; }
  .ribbon-panel { gap: 2px; }
  .rgroup { padding: 0 6px; }
  .ai-chips { gap: 5px; }
  .ai-chip { font-size: 12.5px; padding: 8px 11px; }
  .ai-mode { padding: 0 8px; font-size: 11px; }
  .ai-mode span, .ai-mode { gap: 4px; }
  .modal-h h3 { font-size: 15px; }
  .diff-legend { display: none; }
}
