/* GD OS — visual language per PRD-006. The philosophy is text; the UI respects reading. */

:root {
  --bg: #0e0f12;
  --panel: #16181d;
  --panel-2: #1c1f26;
  --border: #262a33;
  --text: #e8e6e0;
  --muted: #8b8fa3;
  --accent: #d4a94e;           /* gold — the constitution */
  --c-thought: #9aa0ab;
  --c-observation: #7d8ba1;
  --c-insight: #4ec9d4;
  --c-principle: #5b8def;
  --c-law: #d4a94e;
  --c-framework: #a78bfa;
  --c-lexicon_entry: #4ac0a5;
  --c-content_asset: #6fbf73;
  --c-question: #e0a458;
  --c-doctrine: #e8e6e0;
  --c-case_study: #d97d7d;
  --c-research_note: #b0a48f;
  --c-decision: #c0c4cc;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: Consolas, 'Cascadia Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.65; }
a { color: var(--c-principle); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Обвивката (grid, навигации, drawer) живее в css/layout.css — мобилно-първа.
   Тук остават само компонентните стилове, които изгледите преизползват. */
kbd {
  font-family: var(--mono); font-size: 10.5px; background: rgba(255,255,255,.08);
  padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); margin-left: 6px;
}

/* ---------- main ---------- */
h1.page-title { font-family: var(--serif); font-size: 28px; font-weight: normal; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 28px; font-size: 14px; }

/* ---------- shared components ---------- */
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-family: var(--sans);
}
.btn:hover { border-color: var(--muted); }
.btn-accent { background: var(--accent); color: #16181d; border: none; font-weight: 600; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }

.badge {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px;
  border: 1px solid; letter-spacing: .03em; white-space: nowrap;
}
.maturity { font-size: 11px; color: var(--muted); }
.maturity.canonical { color: var(--accent); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 14px;
}
.card.raw { border-style: dashed; }
.card h3 { font-family: var(--serif); font-weight: normal; font-size: 17px; margin-bottom: 4px; }
.card .meta-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.card .short { color: var(--muted); font-size: 13.5px; font-style: italic; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- dashboard ---------- */
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 26px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 20px; min-width: 120px;
}
.stat .num { font-family: var(--serif); font-size: 30px; color: var(--accent); }
.stat .lbl { font-size: 12px; color: var(--muted); letter-spacing: .05em; }
.pipeline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 26px; font-size: 13px; }
.pipeline .stage {
  background: var(--panel); border: 1px solid var(--border); padding: 6px 12px; border-radius: 8px;
}
.pipeline .stage b { font-family: var(--serif); color: var(--accent); margin-right: 5px; }
.pipeline .arr { color: var(--muted); }
.section-h { font-family: var(--serif); font-size: 18px; margin: 26px 0 12px; font-weight: normal; }
.list-line {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 4px;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.list-line .id { font-family: var(--mono); font-size: 11.5px; }
.suggest { color: var(--muted); font-size: 12.5px; margin-left: auto; text-align: right; }

/* ---------- object detail ---------- */
.obj-head { margin-bottom: 20px; }
.obj-title { font-family: var(--serif); font-size: 26px; font-weight: normal; line-height: 1.3; }
.obj-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.obj-file { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.obj-actions { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.warning {
  background: rgba(224,164,88,.1); border: 1px solid rgba(224,164,88,.4);
  color: var(--c-question); border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: 13.5px;
}
.lineage-box { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
@media (max-width: 900px) { .lineage-box { grid-template-columns: 1fr; } }
.lineage-col { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.lineage-col h4 { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.lineage-item { padding: 4px 0; font-size: 13.5px; }
.edge-list { margin: 4px 0 14px; }
.edge-line { font-size: 13.5px; padding: 3px 0; }
.edge-type { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-right: 8px; }

/* ---------- markdown body ---------- */
.md { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 26px 30px; }
.md h1, .md h2, .md h3 { font-family: var(--serif); font-weight: normal; margin: 18px 0 10px; line-height: 1.3; }
.md h1 { font-size: 23px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16.5px; }
.md h1:first-child, .md h2:first-child { margin-top: 0; }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0 10px 22px; }
.md li { margin: 4px 0; }
.md blockquote { border-left: 3px solid var(--accent); padding: 4px 16px; color: var(--muted); font-style: italic; margin: 12px 0; }
.md code { font-family: var(--mono); font-size: 13px; background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 12px 0; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.md th { background: var(--panel-2); font-weight: 600; }
.md strong { color: #fff; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- inbox / capture ---------- */
.capture-box { display: flex; gap: 10px; margin-bottom: 24px; }
.capture-box textarea {
  flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; font-family: var(--sans); font-size: 15px; resize: vertical; min-height: 54px;
}
.capture-box textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- search ---------- */
.search-input {
  width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; font-size: 16px; margin-bottom: 20px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

/* ---------- law cards ---------- */
.law-card { border-left: 3px solid var(--accent); }
.law-num { font-family: var(--serif); color: var(--accent); font-size: 13px; letter-spacing: .1em; }
.law-statement { font-family: var(--serif); font-size: 19px; margin: 6px 0 4px; line-height: 1.4; }

/* ---------- mind flow ---------- */
#main.wide { max-width: none; padding: 22px 26px 26px; }
.flow-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.flow-controls { display: flex; gap: 6px; margin-bottom: 10px; }
.flow-controls .btn { min-width: 34px; }
#flow-wrap { display: flex; gap: 14px; height: calc(100vh - 158px); min-height: 480px; }
#flow-canvas-box {
  flex: 1; position: relative; overflow: hidden; border-radius: 14px;
  border: 1px solid var(--border);
  background: radial-gradient(ellipse 120% 90% at 50% 0%, #171a21 0%, #101216 55%, #0b0c10 100%);
  box-shadow: inset 0 0 80px rgba(0,0,0,.45);
}
#flow-canvas { width: 100%; height: 100%; cursor: grab; display: block; }
#flow-inspector {
  width: 300px; flex-shrink: 0; background: linear-gradient(180deg, var(--panel) 0%, #14161b 100%);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px; overflow-y: auto;
}
#flow-inspector h3 { font-family: var(--serif); font-weight: normal; font-size: 17px; margin: 6px 0; }
#flow-inspector .hint { color: var(--muted); font-size: 13px; }
.flow-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.flow-filters .chip {
  font-size: 11.5px; padding: 3px 10px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); color: var(--muted); background: var(--panel);
}
.flow-filters .chip.on { color: var(--text); border-color: currentColor; }
.flow-legend { position: absolute; bottom: 10px; left: 12px; font-size: 11px; color: var(--muted); background: rgba(14,15,18,.8); padding: 6px 10px; border-radius: 8px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 26px; width: min(620px, 92vw); max-height: 86vh; overflow-y: auto;
}
.modal h2 { font-family: var(--serif); font-weight: normal; font-size: 20px; margin-bottom: 14px; }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }
.modal input[type=text], .modal textarea, .modal select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-family: var(--sans); font-size: 14px;
}
.modal textarea { min-height: 110px; resize: vertical; }
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.checklist label { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 13.5px; margin: 8px 0; cursor: pointer; }
.checklist input { margin-top: 4px; }
.src-quote {
  background: var(--bg); border-left: 3px solid var(--border); padding: 8px 14px;
  color: var(--muted); font-style: italic; font-size: 13.5px; border-radius: 0 8px 8px 0; margin-bottom: 6px;
}
.error-box { background: rgba(217,125,125,.12); border: 1px solid rgba(217,125,125,.5); color: #e8a0a0; padding: 10px 14px; border-radius: 8px; margin-top: 12px; font-size: 13.5px; }

.empty { color: var(--muted); font-style: italic; padding: 20px 0; }

/* ---------- chat (Асистент) ---------- */
#chat-box { display: flex; flex-direction: column; height: calc(100vh - 300px); min-height: 420px; }
#chat-messages { flex: 1; overflow-y: auto; padding-right: 6px; }
.chat-msg { margin-bottom: 16px; max-width: 760px; }
.chat-msg.user { margin-left: 60px; }
.chat-msg .chat-role { font-size: 11px; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; }
.chat-msg.assistant .chat-role { color: var(--accent); }
.chat-msg .chat-body { padding: 12px 16px; }
.chat-msg.user .chat-body { background: var(--panel-2); }
#chat-box .capture-box textarea { min-height: 46px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel-2); border: 1px solid var(--accent);
  color: var(--text); padding: 12px 18px; border-radius: 10px; z-index: 200; font-size: 14px;
}
