/* LoA Studio — koyu çerçeve + açık belge; tek vurgu: pist amberi */
* { box-sizing: border-box; margin: 0; }
:root {
  --chrome-bg: #14181F;
  --chrome-panel: #1A202A;
  --chrome-raise: #232B37;
  --chrome-line: #2A3140;
  --chrome-ink: #C9D1E0;
  --chrome-muted: #7C8698;
  --accent: #E8A33D;
  --accent-hi: #F2B455;
  --accent-ink: #1A1206;
  --doc-bg: #EEF0F3;
  --card: #FFFFFF;
  --line: #E2E5EB;
  --ink: #1E2430;
  --muted: #6B7280;
  --num: #A56A14;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --red: #E5484D;
  --green: #30A46C;
  --yellow: #F5D90A;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px; color: var(--ink); background: var(--doc-bg);
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ic { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- üst bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px;
  background: var(--chrome-bg); color: var(--chrome-ink);
  border-bottom: 1px solid var(--chrome-line);
}
.brand { font-weight: 650; font-size: 13.5px; letter-spacing: .01em; white-space: nowrap; display: flex; align-items: baseline; gap: 8px; }
.unit-tag {
  font-family: var(--mono); font-style: normal; font-size: 9.5px; letter-spacing: .12em;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 3px; padding: 2px 6px;
}
.doc-name {
  flex: 1; text-align: center; font-size: 12.5px; color: var(--chrome-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.save-state { color: var(--accent); font-size: 11.5px; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 6px; }
.sep { width: 1px; height: 20px; background: var(--chrome-line); margin: 0 4px; }

.icon-btn, .btn {
  display: inline-flex; align-items: center; gap: 7px; height: 30px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--chrome-ink); padding: 0 10px; transition: background .12s, border-color .12s, color .12s;
}
.icon-btn { padding: 0 8px; }
.icon-btn:hover:not(:disabled), .btn:hover:not(:disabled) { background: var(--chrome-raise); }
.icon-btn:disabled, .btn:disabled { opacity: .35; cursor: default; }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hi); }
.btn.ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn.ghost:hover:not(:disabled) { background: #F3F4F6; }

/* ---------- ana düzen ---------- */
main { flex: 1; display: grid; grid-template-columns: 248px minmax(420px, 1fr) minmax(380px, 44%); min-height: 0; }
main > * { min-height: 0; overflow-y: auto; }
body.sidebar-collapsed main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
body.sidebar-collapsed #sidebar { display: none; }

/* ---------- sol panel ---------- */
#sidebar { background: var(--chrome-panel); color: var(--chrome-ink); padding: 14px 10px; scrollbar-width: thin; }
#sidebar h2 {
  font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .14em;
  color: var(--chrome-muted); margin: 16px 8px 8px;
}
#sidebar > #libSection h2:first-child, #sidebar > h2:first-child { margin-top: 2px; }
#sidebar ul { list-style: none; }
#sidebar li {
  position: relative; padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12.5px; color: var(--chrome-ink); line-height: 1.35;
}
#sidebar li:hover { background: var(--chrome-raise); }
#loaList li.active { background: var(--chrome-raise); }
#loaList li.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px;
  border-radius: 2px; background: var(--accent);
}
#loaList li.tmpl { color: var(--chrome-muted); font-style: italic; }
#tree li { padding: 4px 10px 4px 14px; font-size: 12px; color: var(--chrome-muted); }
#tree li:hover { color: var(--chrome-ink); }
#tree li.t-annex { color: var(--chrome-ink); margin-top: 6px; padding-left: 10px; display: flex; gap: 8px; align-items: baseline; }
#tree .ax {
  font-family: var(--mono); font-size: 10px; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 3px; padding: 0 4px; flex: none;
}
#tree li.t-sec { border-left: 1px solid var(--chrome-line); margin-left: 10px; }

/* ---------- editör ---------- */
#editor { padding: 16px 18px; background: var(--doc-bg); }
#editorEmpty { color: var(--muted); padding: 60px 20px; text-align: center; }

#metaPanel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
#metaPanel summary { padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
#metaPanel summary small { color: var(--muted); font-weight: 400; margin-left: 6px; }
#metaFields { padding: 6px 14px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-top: 1px solid var(--line); }
#metaFields label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
#metaFields input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: #FAFBFC; }
#metaFields input:focus { border-color: var(--accent); outline: none; background: #fff; }
#metaFields .wide { grid-column: 1 / -1; }

.mark-hint { font-size: 11px; color: var(--muted); margin: 2px 2px 14px; }
mark.r { background: color-mix(in srgb, var(--red) 45%, white); border-radius: 2px; padding: 0 2px; }
mark.g { background: color-mix(in srgb, var(--green) 38%, white); border-radius: 2px; padding: 0 2px; }
mark.y { background: color-mix(in srgb, var(--yellow) 55%, white); border-radius: 2px; padding: 0 2px; }

.highlight-palette {
  position: fixed; z-index: 1000; display: flex; align-items: center; gap: 3px;
  padding: 4px; border: 1px solid #394252; border-radius: 8px;
  background: #171C24; box-shadow: 0 8px 24px rgba(9, 12, 18, .28);
}
.highlight-palette[hidden] { display: none; }
.highlight-palette button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px; padding: 0; border: 0; border-radius: 5px;
  background: transparent; color: #D7DEEA;
}
.highlight-palette button:hover, .highlight-palette button:focus-visible { background: #29313E; }
.highlight-palette .ic { width: 14px; height: 14px; }
.highlight-swatch { width: 15px; height: 15px; border-radius: 4px; border: 1px solid rgba(255,255,255,.32); }
[data-highlight-action="red"] .highlight-swatch { background: var(--red); }
[data-highlight-action="green"] .highlight-swatch { background: var(--green); }

.chapter {
  margin: 22px 0 8px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px;
}
.chapter hr { flex: 1; border: none; border-top: 1px solid var(--line); }

.blk {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 7px; margin-bottom: 6px; padding: 7px 10px 8px;
  transition: box-shadow .12s, border-color .12s;
}
.blk:hover, .blk:focus-within { border-color: #CBD2DC; box-shadow: 0 1px 6px rgba(20, 24, 31, .07); }
.blk.depth1 { margin-left: 20px; }
.blk.depth2 { margin-left: 40px; }
.blk.depth3 { margin-left: 60px; }
.blk.depth4 { margin-left: 80px; }
.blk-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.blk-num { font-family: var(--mono); font-weight: 600; font-size: 11.5px; color: var(--num); min-width: 44px; }
.blk-type {
  font-size: 8.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: #A6ADBB; user-select: none;
}
.blk-tools { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.blk:hover .blk-tools, .blk:focus-within .blk-tools { opacity: 1; }
.blk-tools button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border: none; border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 11px; font-weight: 600;
}
.blk-tools button:hover { background: #EEF0F3; color: var(--ink); }
.blk-tools .ic { width: 13px; height: 13px; }

.blk textarea, .blk input[type=text] {
  width: 100%; font: inherit; font-size: 12.8px; line-height: 1.45;
  border: 1px solid transparent; border-radius: 5px; padding: 4px 6px;
  resize: vertical; background: transparent; color: var(--ink);
}
.blk textarea:hover, .blk input[type=text]:hover { background: #F7F8FA; }
.blk textarea:focus, .blk input[type=text]:focus { border-color: var(--accent); outline: none; background: #fff; }
.blk textarea { min-height: 2.2em; display: block; }
.blk.section > .blk-head input[type=text] { font-weight: 650; }
.blk .pair { display: grid; grid-template-columns: 112px 1fr; gap: 4px 8px; align-items: center; font-size: 12.5px; margin-top: 2px; }
.blk .pair b { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.block-image { display: grid; gap: 8px; padding-top: 6px; }
.block-image img {
  display: block; max-width: 100%; max-height: 420px; margin: 0 auto;
  object-fit: contain; border: 1px solid var(--line); background: #fff;
}

/* araya ekleme: ince çizgi + tek artı, menüyle */
.add-row {
  position: relative; height: 16px; margin: 0 0 6px;
  display: flex; align-items: center; justify-content: center;
  opacity: .25; transition: opacity .12s;
}
.add-row.mid { height: 12px; margin: -3px 0 3px; opacity: 0; }
.add-row.mid:hover, .add-row.mid:focus-within, .add-row.mid.open { opacity: 1; }
.add-row:hover, .add-row:focus-within, .add-row.open { opacity: 1; }
.add-row::before, .add-row::after {
  content: ''; flex: 1; border-top: 1px dashed #C9CFD9;
}
.add-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin: 0 8px; padding: 0;
  border: 1px solid #C9CFD9; border-radius: 50%; background: var(--card); color: var(--muted);
}
.add-btn:hover { border-color: var(--accent); color: var(--num); }
.add-btn .ic { width: 11px; height: 11px; }
.add-menu[hidden] { display: none; }
.add-menu {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  box-shadow: 0 6px 24px rgba(20, 24, 31, .16); padding: 4px; display: flex; flex-wrap: wrap;
  gap: 2px; width: 300px; justify-content: center;
}
.add-menu button {
  border: none; background: transparent; border-radius: 5px; padding: 5px 9px;
  font-size: 12px; color: var(--ink);
}
.add-menu button:hover { background: #EEF0F3; }

/* ---------- önizleme ---------- */
#preview { border-left: 1px solid var(--chrome-line); background: #20262F; display: flex; }
#previewFrame { flex: 1; border: none; width: 100%; }

/* ---------- diyaloglar ---------- */
.dialog { position: fixed; inset: 0; background: rgba(10, 13, 18, .55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.dialog[hidden] { display: none; }
.dialog-box {
  background: var(--card); border-radius: 10px; padding: 18px 20px; width: 440px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 18px 60px rgba(10, 13, 18, .4);
}
.dialog-box.wide { width: min(880px, 92vw); max-height: 86vh; }
.dialog-box h3 { font-size: 14px; }
.dialog-box label { font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.dialog-box input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
.dialog-box input:focus { border-color: var(--accent); outline: none; }
.dialog-box .hint { font-size: 11px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
.dialog .btn { color: var(--ink); }
.dialog .btn.primary { color: var(--accent-ink); }

.hist-bar { display: flex; gap: 10px; align-items: center; }
.hist-bar select { font: inherit; font-family: var(--mono); font-size: 12px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.diff {
  flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  font-size: 12px; min-height: 220px; background: #FAFBFC;
}
.diff .d-line { padding: 2px 7px; border-radius: 4px; white-space: pre-wrap; line-height: 1.45; }
.diff .d-add { background: #DDF3E1; }
.diff .d-del { background: #FBE0E0; text-decoration: line-through; }
.diff .d-ctx { color: var(--muted); }
.diff .d-info { text-align: center; color: var(--muted); padding: 18px; }

/* ---------- arama ---------- */
.search-box { padding: 0 2px 4px; }
.search-box input {
  width: 100%; font: inherit; font-size: 12.5px; padding: 7px 10px;
  border: 1px solid var(--chrome-line); border-radius: 6px;
  background: var(--chrome-raise); color: var(--chrome-ink);
}
.search-box input::placeholder { color: var(--chrome-muted); }
.search-box input:focus { border-color: var(--accent); outline: none; }
#searchResults { padding: 4px 0; }
.sr-doc {
  font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); margin: 10px 8px 4px;
}
.sr-item { padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.sr-item:hover { background: var(--chrome-raise); }
.sr-num { font-family: var(--mono); font-size: 10.5px; color: var(--accent); flex: none; }
.sr-txt { font-size: 11.5px; color: var(--chrome-muted); overflow: hidden; text-overflow: ellipsis;
          display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-empty { color: var(--chrome-muted); font-size: 12px; padding: 12px 8px; }
.blk.flash { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- tablo grid editörü ---------- */
.tgrid { margin-top: 4px; overflow-x: auto; }
.tgrid table { border-collapse: collapse; width: 100%; }
.tgrid th, .tgrid td { border: 1px solid var(--line); padding: 0; position: relative; }
.tgrid th { background: #F3F4F6; }
.tgrid th input { font-weight: 600; }
.tgrid input {
  width: 100%; border: none; background: transparent; font: inherit; font-size: 12px;
  padding: 5px 7px; min-width: 70px;
}
.tgrid input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.tgrid .tg-rowtools { border: none; width: 26px; background: transparent; text-align: center; }
.tgrid .tg-rowtools button, .tgrid .tg-delcol {
  border: none; background: transparent; color: var(--muted); font-size: 10px;
  padding: 2px 5px; border-radius: 4px; opacity: 0;
}
.tgrid tr:hover .tg-rowtools button, .tgrid th:hover .tg-delcol { opacity: 1; }
.tgrid .tg-rowtools button:hover, .tgrid .tg-delcol:hover { background: #FBE0E0; color: #B3261E; }
.tgrid .tg-delcol { position: absolute; top: 1px; right: 1px; }
.tg-tools { display: flex; gap: 6px; margin-top: 6px; }
.tg-tools button {
  border: 1px dashed #C9CFD9; background: transparent; border-radius: 5px;
  font-size: 11.5px; color: var(--muted); padding: 3px 10px;
}
.tg-tools button:hover { border-color: var(--accent); color: var(--num); }

/* ---------- kaydırma çubukları ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #B7BDC9; border-radius: 5px; border: 2px solid var(--doc-bg); }
#sidebar::-webkit-scrollbar-thumb { background: var(--chrome-line); border-color: var(--chrome-panel); }

/* ---------- dar pencere ---------- */
@media (max-width: 1180px) {
  .btn span { display: none; }
  .btn { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
