:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --border: #e2e5ef;
  --text: #1c2033;
  --muted: #5d6479;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0ff;
  --accent: #0891b2;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --heat: 79, 70, 229;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 50, .05), 0 6px 24px rgba(20, 24, 50, .06);
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220; --surface: #171b2e; --surface-2: #1e2339; --border: #2a3050; --text: #e7e9f3;
    --muted: #9aa1bd; --primary: #818cf8; --primary-2: #a5b4fc; --primary-soft: #252b4d; --heat: 129, 140, 248;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1220; --surface: #171b2e; --surface-2: #1e2339; --border: #2a3050; --text: #e7e9f3;
  --muted: #9aa1bd; --primary: #818cf8; --primary-2: #a5b4fc; --primary-soft: #252b4d; --heat: 129, 140, 248;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .7em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
a { color: var(--primary); }

.top {
  background: linear-gradient(120deg, #312e81, #4f46e5 45%, #0891b2);
  color: #fff; padding: 22px 16px 26px;
}
.top-in { max-width: 1320px; margin: 0 auto; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { display: flex; gap: 14px; align-items: center; }
.logo { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.top h1 { font-size: 1.45rem; margin: 0; }
.top p { margin: 2px 0 0; opacity: .85; font-size: .92rem; }
.theme-btn { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 10px; padding: 8px 12px; cursor: pointer; font: inherit; }

.wrap { max-width: 1320px; margin: -14px auto 40px; padding: 0 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; min-width: 0; }
.card.flat { box-shadow: none; }

/* Korpus */
.corpus-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
@media (max-width: 900px) { .corpus-grid { grid-template-columns: 1fr; } }
textarea, input[type=text], input[type=number], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; outline: none;
}
textarea { min-height: 190px; resize: vertical; font-size: .93rem; }
textarea:focus, input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label.f { display: block; font-size: .82rem; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.field { margin-bottom: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; margin: 6px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 10px; padding: 10px 16px; font: inherit;
  font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 6px 11px; font-size: .88rem; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .6; cursor: wait; }
.hint { font-size: .82rem; color: var(--muted); }

.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 11px; min-width: 96px; }
.stat b { display: block; font-size: 1.12rem; }
.stat span { font-size: .76rem; color: var(--muted); }

/* Sekmeler */
.tabs {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; overflow-x: auto; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; scrollbar-width: thin;
}
.tabs button {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active { background: var(--primary); color: #fff; }
.tabs .sep { flex: 0 0 1px; background: var(--border); margin: 4px 4px; }
.tab { display: none; }
.tab.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid2, .grid3, .split { grid-template-columns: 1fr; } }

/* Bilgi kutuları */
.info { background: var(--primary-soft); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 12px; padding: 14px 16px; }
.info h3 { color: var(--primary); display: flex; gap: 8px; align-items: center; }
.info ul { margin: .3em 0 .6em; padding-left: 1.2em; }
.info li { margin: .2em 0; }
.formula {
  font-family: "Cambria Math", "Times New Roman", serif; font-size: 1.08rem; background: var(--surface); border: 1px dashed var(--border);
  border-radius: 10px; padding: 10px 14px; margin: 8px 0; overflow-x: auto; white-space: nowrap;
}
.formula small { font-family: system-ui, sans-serif; color: var(--muted); font-size: .78rem; display: block; white-space: normal; }
.note { font-size: .86rem; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin: 8px 0; }
.note.warn { border-left: 4px solid var(--warn); }
.note.ok { border-left: 4px solid var(--ok); }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); margin-left: 6px; vertical-align: middle; }

/* Akış diyagramı */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px; margin: 10px 0; }
.flow .node {
  flex: 1 1 120px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; text-align: center;
  position: relative; box-shadow: var(--shadow);
}
.flow .node b { display: block; font-size: .9rem; }
.flow .node span { font-size: .76rem; color: var(--muted); }
.flow .node .ic { font-size: 1.4rem; display: block; }
.flow .arrow { display: grid; place-items: center; color: var(--primary); font-weight: 800; font-size: 1.2rem; }
.flow.vertical { flex-direction: column; }
.flow.vertical .arrow { transform: none; }

/* Adımlar */
.steps { display: grid; gap: 10px; }
.step { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.step-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.step-h b { display: flex; gap: 8px; align-items: center; }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-grid; place-items: center; font-size: .8rem; flex: 0 0 auto; }
.step .out { font-family: var(--mono); font-size: .84rem; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* Token çipleri */
.chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 220px; overflow: auto; }
.chip { font-family: var(--mono); font-size: .8rem; padding: 3px 8px; border-radius: 7px; background: var(--primary-soft); color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
.chip.rm { background: rgba(220,38,38,.1); text-decoration: line-through; color: var(--err); }
.chip.st { background: rgba(22,163,74,.12); }
.chip i { font-style: normal; color: var(--muted); font-size: .72rem; margin-left: 4px; }
.chip.c0 { background: #e0e7ff; color: #1e1b4b; } .chip.c1 { background: #cffafe; color: #083344; }
.chip.c2 { background: #dcfce7; color: #052e16; } .chip.c3 { background: #ffedd5; color: #431407; }
.chip.c4 { background: #fce7f3; color: #500724; } .chip.c5 { background: #ede9fe; color: #2e1065; }

/* Tablolar */
.tbl-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; font-size: .8rem; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.heat td.v { text-align: center; font-family: var(--mono); font-size: .8rem; min-width: 44px; }
.heat th.rot { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; padding: 8px 4px; }
.heat td.rl, .heat th.rl { position: sticky; left: 0; background: var(--surface-2); z-index: 2; font-weight: 600; }
.heat th.rl { z-index: 3; }
tr.hl td { background: var(--primary-soft); }

.chart-box { position: relative; height: 340px; }
.chart-box.tall { height: 460px; }
.chart-box.short { height: 240px; }
#cloudWrap { position: relative; width: 100%; height: 480px; border-radius: 12px; background: var(--surface-2); overflow: hidden; }
#cloudCanvas { width: 100%; height: 100%; display: block; }
#cloudTip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); padding: 4px 9px; border-radius: 7px; font-size: .82rem; display: none; }

.doclist { display: grid; gap: 6px; max-height: 360px; overflow: auto; }
.doc { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: .88rem; }
.doc b { color: var(--primary); margin-right: 6px; }
.vec { font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; overflow-x: auto; white-space: nowrap; margin: 4px 0; }

.gen { font-size: 1.08rem; line-height: 2; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; min-height: 60px; }
.gen .w { padding: 2px 5px; border-radius: 6px; margin: 0 1px; cursor: help; }
.gen .ctx { background: var(--surface); border: 1px dashed var(--border); }
.gen .end { color: var(--muted); }

.slider { display: flex; align-items: center; gap: 10px; }
.slider input { flex: 1; accent-color: var(--primary); }
.slider output { min-width: 48px; font-family: var(--mono); font-weight: 700; text-align: right; }

.pill-group { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.pill-group button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--muted); font-weight: 600; }
.pill-group button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.cmp th:first-child { width: 160px; }
.cmp td { white-space: normal; vertical-align: top; }

.toast { position: fixed; right: 16px; bottom: 16px; background: var(--err); color: #fff; padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; max-width: 420px; display: none; }
.loading { position: fixed; inset: 0; background: rgba(15,18,32,.25); display: none; place-items: center; z-index: 90; }
.loading.on { display: grid; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); font-size: .9rem; padding: 20px; text-align: center; border: 1px dashed var(--border); border-radius: 12px; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.kpi .stat b { font-size: 1.3rem; color: var(--primary); }
footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 10px 16px 30px; }
.mt { margin-top: 14px; }
.mb0 { margin-bottom: 0; }

mark { background: rgba(234, 179, 8, .35); color: inherit; border-radius: 3px; padding: 0 2px; }
.tabs .sep + button { margin-left: 2px; }
