:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6eb;
  --text: #15181e; --muted: #667085; --accent: #3b5bdb; --accent-text: #fff;
  --planner: #7048e8; --developer: #1c7ed6; --reviewer: #e8590c; --system: #868e96; --user: #2b8a3e;
  --ok: #2b8a3e; --warn: #e67700; --bad: #c92a2a;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1e222b; --border: #2a2f3a;
    --text: #e7e9ee; --muted: #8b93a3; --accent: #5c7cfa;
    --planner: #9775fa; --developer: #4dabf7; --reviewer: #ff922b; --system: #868e96; --user: #51cf66;
    --ok: #51cf66; --warn: #fcc419; --bad: #ff6b6b; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #1e222b; --border: #2a2f3a;
  --text: #e7e9ee; --muted: #8b93a3; --accent: #5c7cfa;
  --planner: #9775fa; --developer: #4dabf7; --reviewer: #ff922b; --system: #868e96; --user: #51cf66;
  --ok: #51cf66; --warn: #fcc419; --bad: #ff6b6b; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h2 { font-size: 18px; margin: 2px 0 0; }
h3 { font-size: 14px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--bad); min-height: 1em; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--text); width: 36px; height: 36px; border-radius: 50%; font-size: 15px; cursor: pointer; flex: none; }

input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Giriş */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); padding: 24px; display: grid; gap: 12px; }

/* Üst bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.logo { color: var(--accent); }
.spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.live.on i { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Ajan durum kartları */
.agents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 14px 16px 0; }
.agent { padding: 10px 12px; border-left: 4px solid var(--c); min-width: 0; }
.agent b { display: block; font-size: 13px; color: var(--c); }
.agent span { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent.idle span { color: var(--muted); }

.tabs { display: flex; gap: 4px; padding: 14px 16px 0; }
.tabs button { flex: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 12px; border-radius: 999px; cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }
main { padding: 14px 16px calc(32px + env(safe-area-inset-bottom)); }

/* Pano */
.board { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { min-width: 0; }
.col-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 2px 8px; }
.col-head .n { background: var(--surface-2); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.col-body { display: grid; gap: 8px; }
.empty { color: var(--muted); font-size: 13px; padding: 10px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }
.task { padding: 10px 12px; cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.task:hover { border-color: var(--accent); }
.task .t { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.task .m { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.task.active { border-color: var(--c, var(--accent)); box-shadow: 0 0 0 1px var(--c, var(--accent)); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 999px;
  padding: 1px 8px; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); }
.spin { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: blink 1s infinite alternate; }
@keyframes blink { to { opacity: .2; } }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .board { grid-template-columns: 1fr; }
  .agents { gap: 6px; }
  .agent { padding: 8px 10px; }
  .agent .muted { display: none; }
  .col.is-empty { display: none; }
  .topbar .btn.ghost { display: none; }
  .live span { display: none; }
}

/* Log */
.feed { padding: 4px 0; }
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.log li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.log .hdr { display: flex; gap: 8px; min-width: 0; }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .who { font-weight: 700; color: var(--c); }
.log .txt { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.log .tool .txt { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.log .error .txt { color: var(--bad); }
.log .result .txt { color: var(--ok); font-weight: 600; }
.log .ref { color: var(--accent); cursor: pointer; }
@media (max-width: 700px) {
  .log li { grid-template-columns: 1fr; gap: 2px; }
}

/* Hedefler */
.goals { display: grid; gap: 10px; }
.goal { padding: 12px 14px; }
.goal .g { white-space: pre-wrap; overflow-wrap: anywhere; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--ok); }

/* Alt sayfa / diyalog */
dialog.sheet { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0;
  width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); border-radius: 16px; }
dialog.sheet.small { width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 16px 8px;
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet-body { padding: 8px 16px 20px; }
@media (max-width: 700px) {
  dialog.sheet, dialog.sheet.small { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.videos { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 12px; }
.videos video { width: 100%; max-height: 60dvh; border-radius: 10px; background: #000; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.qa { padding: 12px; margin-bottom: 12px; border-left: 4px solid var(--c); }
.qa ul { margin: 6px 0 0; padding-left: 18px; }
#td-log { border: 1px solid var(--border); border-radius: var(--radius); max-height: 50dvh; overflow: auto; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 150%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: transform .2s, visibility .2s; z-index: 50; max-width: calc(100vw - 32px); visibility: hidden; }
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ─────────────── Dijital ofis ─────────────── */
.office { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.office-stage { padding: 8px; overflow: hidden; background:
  radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--accent) 7%, var(--surface)) 0%, var(--surface) 70%); }
#office-svg { display: block; width: 100%; height: auto; max-height: calc(100dvh - 170px); }
.office-side { padding: 12px; max-height: calc(100dvh - 150px); overflow: auto; position: sticky; top: 70px; }
@media (max-width: 960px) {
  .office { grid-template-columns: 1fr; }
  .office-side { position: static; max-height: none; }
  #office-svg { max-height: none; }
}

.iso-floor { fill: var(--surface-2); stroke: var(--border); }
.iso-door { fill: color-mix(in srgb, var(--accent) 25%, transparent); stroke: var(--accent); stroke-dasharray: 4 3; }
.iso-door-label { fill: var(--accent); font: 700 12px system-ui; text-anchor: middle; }
.room-floor { fill: color-mix(in srgb, var(--dept) 16%, var(--surface)); stroke: color-mix(in srgb, var(--dept) 50%, transparent); }
.room-wall { fill: color-mix(in srgb, var(--dept) 10%, rgba(255,255,255,.35)); stroke: color-mix(in srgb, var(--dept) 45%, var(--border)); stroke-width: 1; }
.room-wall.side { fill: color-mix(in srgb, var(--dept) 6%, rgba(255,255,255,.22)); }
.room-wall.low { fill: rgba(255,255,255,.18); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .room-wall { fill: color-mix(in srgb, var(--dept) 14%, rgba(255,255,255,.04)); } }
.room-label rect { fill: var(--dept); }
.room-label text { fill: #fff; font: 800 10px system-ui; letter-spacing: .04em; }

.desk-top { fill: #d9a066; stroke: #a8743f; stroke-width: .6; }
.desk-side { fill: #b97f45; }
.desk-side.dark { fill: #96622f; }
.monitor { fill: #2b2f38; }
.agent-node { cursor: pointer; outline: none; }
.agent-node .avatar { fill: var(--surface); stroke: var(--dept); stroke-width: 2.5; transition: opacity .3s; }
.agent-node .emoji { font-size: 15px; text-anchor: middle; pointer-events: none; }
.agent-node .dot { fill: var(--muted); stroke: var(--surface); stroke-width: 1.5; }
.agent-node .pulse { fill: none; stroke: var(--dept); stroke-width: 2; opacity: 0; }
.agent-node .name-bg { fill: var(--surface); stroke: var(--border); }
.agent-node .name { fill: var(--text); font: 600 9.5px system-ui; text-anchor: middle; }
.agent-node:not(.busy) .avatar, .agent-node:not(.busy) .emoji { opacity: .55; }
.agent-node.busy .dot { fill: var(--ok); }
.agent-node.busy .pulse { animation: agent-pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes agent-pulse { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.7); } }
.agent-node:hover .avatar, .agent-node:focus-visible .avatar, .agent-node.selected .avatar { stroke-width: 4; opacity: 1; }
.agent-node.selected .name-bg { fill: var(--dept); stroke: var(--dept); }
.agent-node.selected .name { fill: #fff; }
.bubble { opacity: 0; transition: opacity .3s; pointer-events: none; }
.agent-node.busy .bubble { opacity: 1; }
.bubble rect { fill: var(--text); }
.bubble text { fill: var(--bg); font: 600 9px system-ui; text-anchor: middle; }

.link { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 5; opacity: .7; animation: dash 1s linear infinite; }
.link.question { stroke: var(--warn); }
.link.root { stroke: var(--muted); opacity: .4; }
@keyframes dash { to { stroke-dashoffset: -11; } }
.flyer circle { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.flyer.question circle { fill: var(--warn); }
.flyer.return circle { fill: var(--ok); }
.flyer text { font: 700 11px system-ui; text-anchor: middle; fill: #fff; }
.flyer .flyer-label { fill: var(--text); font: 600 10px system-ui; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }

/* Yan panel */
.side-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 4px 2px 8px; }
.side-title:not(:first-child) { margin-top: 16px; }
.side-agent, .job-row, .mission-chip, .file-row { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  font: inherit; color: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.side-agent { border-left: 4px solid var(--dept); }
.side-agent small, .job-row small { display: block; font-size: 12px; overflow-wrap: anywhere; }
.se { font-size: 20px; line-height: 1; }
.se.big { font-size: 30px; }
.role-head { display: flex; gap: 10px; align-items: center; padding-bottom: 10px; border-bottom: 3px solid var(--dept); margin-bottom: 8px; }
.role-head > div { flex: 1; }
.job-row { flex-direction: column; gap: 2px; }
.job-row.s-working { border-color: var(--ok); }
.mission-chip { flex-direction: column; gap: 2px; }
.mission-chip .ms { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.mission-chip.s-working .ms { color: var(--ok); }
.mission-chip.s-awaiting_approval { border-color: var(--warn); }
.mission-chip.s-awaiting_approval .ms { color: var(--warn); }
.mission-chip .mt { font-weight: 600; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mission-chip .mc { font-size: 12px; color: var(--muted); }
#role-log { border: 1px solid var(--border); border-radius: var(--radius); max-height: 45dvh; overflow: auto; }
#role-log li { grid-template-columns: 1fr; gap: 2px; }

/* Görev detayı: iş ağacı ve teslimatlar */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree { padding-left: 0; }
.tree li { position: relative; margin: 4px 0; }
.tree ul li::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 50%; width: 10px; border-left: 2px solid var(--border); border-bottom: 2px solid var(--border); border-bottom-left-radius: 6px; height: 18px; }
.tree summary { list-style: none; cursor: pointer; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.tree summary::-webkit-details-marker { display: none; }
.tree li.s-working > details > summary { border-color: var(--ok); }
.tree li.s-failed > details > summary { border-color: var(--bad); }
.tree .tag { float: right; font-size: 12px; color: var(--muted); margin-left: 8px; }
.job-body { padding: 8px 10px; font-size: 13px; display: grid; gap: 4px; }
.files { display: grid; gap: 0; }
.file-row { align-items: center; justify-content: space-between; }
.file-row.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.preview:not(:empty) { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; overflow-wrap: anywhere; }
.md { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4, .md h5 { text-transform: none; letter-spacing: 0; color: var(--text); margin: 16px 0 6px; }
.md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4, .md h5 { font-size: 14px; }
.md p { margin: 6px 0; }
.md ul { margin: 6px 0; padding-left: 20px; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.md pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; font-size: 12.5px; }
.md .tbl { overflow-x: auto; margin: 8px 0; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.md td { border: 1px solid var(--border); padding: 5px 8px; vertical-align: top; }
.md tr:first-child td { font-weight: 700; background: var(--surface-2); }
.md a { color: var(--accent); }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; margin-bottom: 12px; }
@media (max-width: 700px) {
  .topbar #btn-brand, .topbar #btn-goal { display: none; }
  .tabs { overflow-x: auto; }
}

a.job-row { text-decoration: none; color: inherit; }

/* ─── Fikir hattı ─── */
.ideas { display: block; }
.ideas-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; }
.ideas-top .spacer { flex: 1; }
.ledger-mini { text-align: right; }
.count { font-size: 12px; background: var(--border); color: var(--text); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.idea-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.idea-card p { margin: 0; line-height: 1.45; }
.idea-head { display: flex; gap: 12px; align-items: flex-start; }
.score { flex: none; display: inline-flex; align-items: baseline; gap: 1px; font-weight: 800; font-size: 20px; border-radius: 12px; padding: 6px 10px; }
.score small { font-size: 11px; font-weight: 600; opacity: .7; }
.score.pass { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.score.fail { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); font-size: 15px; padding: 4px 8px; }
.bars { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 150px 1fr 22px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar i { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.bar b { display: block; height: 100%; background: var(--accent); }
.bar em { font-style: normal; text-align: right; color: var(--text); font-weight: 700; }
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.duel > div { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; line-height: 1.4; }
.duel small { display: block; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.idea-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.idea-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.idea-row { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.idea-row details { flex: 1; min-width: 0; }
.idea-row summary { cursor: pointer; list-style: none; }
.idea-row p { margin: 6px 0 0; font-size: 13px; line-height: 1.45; }
.idea-row .score { font-size: 14px; padding: 3px 7px; }
.prio { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--border); }
.row-actions { display: flex; gap: 6px; flex: none; }
.row-actions .btn { padding: 4px 10px; font-size: 13px; }
details.fold > summary { list-style: none; cursor: pointer; }
details.fold > summary h3 { display: inline-block; }
details.fold > summary h3::before { content: "▸ "; }
details.fold[open] > summary h3::before { content: "▾ "; }
#ledger-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
#ledger-body th, #ledger-body td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
@media (max-width: 640px) {
  .idea-grid { grid-template-columns: 1fr; }
  .duel { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 110px 1fr 22px; }
  .idea-row { flex-wrap: wrap; }
}
