/* ═══════════════════════════════════════════════════
   EM WORKSPACE — DESIGN SYSTEM
   Strategy-grade UI: precise, confident, data-dense
═══════════════════════════════════════════════════ */

:root {
  --bg:          #f4f3ee;
  --surface:     #ffffff;
  --surface-2:   #f9f8f5;
  --border:      #e2e0d8;
  --border-light:#eeece5;
  --text:        #1a1918;
  --text-2:      #4a4845;
  --text-3:      #888580;
  --text-4:      #b0ada8;

  --purple:      #4F46E5;
  --purple-d:    #3730A3;
  --purple-l:    #EEF2FF;
  --purple-m:    #A5B4FC;

  --blue:        #0284C7;
  --blue-l:      #E0F2FE;
  --blue-m:      #7DD3FC;

  --teal:        #0F766E;
  --teal-l:      #CCFBF1;
  --teal-m:      #5EEAD4;

  --green:       #15803D;
  --green-l:     #DCFCE7;
  --green-m:     #86EFAC;

  --amber:       #B45309;
  --amber-l:     #FEF3C7;
  --amber-m:     #FCD34D;

  --orange:      #C2410C;
  --orange-l:    #FFEDD5;
  --orange-m:    #FB923C;

  --red:         #B91C1C;
  --red-l:       #FEE2E2;
  --red-m:       #FCA5A5;

  --pink:        #9D174D;
  --pink-l:      #FCE7F3;
  --pink-m:      #F9A8D4;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 28px rgba(0,0,0,.13), 0 4px 8px rgba(0,0,0,.06);

  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Typography ── */
h1 { font-size: 15px; font-weight: 600; }
h2 { font-size: 14px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
label { font-size: 11px; color: var(--text-3); font-weight: 600; display: block; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Layout ── */
.page { display: none; min-height: 100vh; }
.page.on { display: block; }
.pane { padding: 16px; display: none; }
.pane.on { display: block; }

/* ── Topbar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}
.brand {
  font-size: 15px;
  font-weight: 800;
  color: var(--purple);
  letter-spacing: -.5px;
  white-space: nowrap;
}
.brand span { color: var(--text-3); font-weight: 400; font-size: 13px; }
.topbar-info { display: flex; flex-direction: column; gap: 1px; }
.topbar-info h1 { font-size: 13px; font-weight: 600; color: var(--text); }
.back-btn {
  font-size: 12px; color: var(--purple); cursor: pointer;
  padding: 5px 12px; border: 1px solid var(--purple);
  border-radius: var(--r-full); background: var(--surface);
  white-space: nowrap; transition: all .15s;
}
.back-btn:hover { background: var(--purple-l); }
.sub-badge {
  font-size: 10px; color: var(--text-3);
  background: var(--bg); padding: 2px 9px;
  border-radius: var(--r-full); border: 1px solid var(--border);
}

/* ── Tabs ── */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 18px;
  overflow-x: auto;
  position: sticky;
  top: 52px;
  z-index: 199;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font-size: 12px; padding: 10px 14px;
  cursor: pointer; color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
  transition: all .15s; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--purple); border-bottom-color: var(--purple); font-weight: 600; }

/* ── Buttons ── */
.btn-p {
  font-size: 12px; padding: 7px 16px; border-radius: var(--r-full);
  border: none; background: var(--purple); color: #fff;
  cursor: pointer; font-weight: 600; transition: all .15s;
  white-space: nowrap;
}
.btn-p:hover { background: var(--purple-d); box-shadow: var(--shadow-sm); }
.btn-p:active { transform: scale(.97); }
.btn-s {
  font-size: 12px; padding: 7px 14px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-s:hover { background: var(--bg); border-color: var(--text-3); }
.btn-g {
  font-size: 12px; padding: 7px 16px; border-radius: var(--r-full);
  border: none; background: var(--green); color: #fff;
  cursor: pointer; font-weight: 600; transition: all .15s;
}
.btn-g:hover { background: #166534; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.add-inline {
  font-size: 11px; padding: 4px 12px; border-radius: var(--r-full);
  border: 1px dashed var(--text-4); cursor: pointer;
  color: var(--text-3); background: var(--surface); transition: all .15s;
}
.add-inline:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-l); }
.del-btn {
  font-size: 10px; color: var(--text-4); cursor: pointer;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 7px; transition: all .15s;
}
.del-btn:hover { color: var(--red); border-color: var(--red-m); background: var(--red-l); }
.btn-ai-fab {
  font-size: 11px; padding: 6px 14px; border-radius: var(--r-full);
  border: none; background: var(--purple); color: #fff;
  cursor: pointer; font-weight: 600; display: flex; gap: 5px;
  align-items: center; margin-left: auto; transition: all .15s;
}
.btn-ai-fab:hover { background: var(--purple-d); }

/* ── Forms ── */
.add-form {
  background: var(--surface); border: 1.5px dashed var(--purple-m);
  border-radius: var(--r-lg); padding: 16px 18px;
  margin-bottom: 14px; display: none;
}
.add-form.teal { border-color: var(--teal-m); }
.add-form.green { border-color: var(--green-m); }
.form-title { font-size: 13px; font-weight: 700; color: var(--purple); margin-bottom: 12px; }
.add-form input, .add-form textarea, .add-form select {
  width: 100%; font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 7px 10px; margin-bottom: 9px;
  font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
.add-form input:focus, .add-form textarea:focus, .add-form select:focus {
  outline: none; border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(79,70,229,.08);
}
.add-form textarea { resize: vertical; }
.fr { display: flex; gap: 10px; }
.fr > div { flex: 1; min-width: 0; }
.sec-lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3);
  margin: 13px 0 7px; display: flex; justify-content: space-between; align-items: center;
}

/* ── Cards / surfaces ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.card-sub { font-size: 11px; color: var(--text-3); margin-bottom: 10px; line-height: 1.5; }

/* ── Pills / badges ── */
.pill { display: inline-block; font-size: 10px; padding: 2px 9px; border-radius: var(--r-full); font-weight: 500; }
.p-g { background: var(--green-l); color: var(--green); }
.p-a { background: var(--amber-l); color: var(--amber); }
.p-r { background: var(--red-l); color: var(--red); }
.p-b { background: var(--blue-l); color: var(--blue); }
.p-pu { background: var(--purple-l); color: var(--purple); }
.p-t { background: var(--teal-l); color: var(--teal); }
.p-gr { background: var(--bg); color: var(--text-3); border: 1px solid var(--border); }

/* ── Alert boxes ── */
.alert {
  border-radius: var(--r-md); padding: 10px 13px;
  font-size: 11px; margin-bottom: 10px; line-height: 1.6;
  border-left: 3px solid transparent;
}
.alert-r { background: var(--red-l); border-left-color: var(--red); color: var(--red); }
.alert-a { background: var(--amber-l); border-left-color: var(--amber); color: var(--amber); }
.alert-pu { background: var(--purple-l); border-left-color: var(--purple); color: var(--purple-d); }
.alert-g { background: var(--green-l); border-left-color: var(--green); color: var(--green); }
.alert-b { background: var(--blue-l); border-left-color: var(--blue); color: var(--blue); }

/* ── Stat row ── */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 13px; }
.stat-l { font-size: 10px; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-v { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 10px; color: var(--text-4); margin-top: 1px; }

/* ── Bar charts (progress bars) ── */
.bar-row { margin-bottom: 4px; }
.bar-lbl { font-size: 10px; color: var(--text-2); display: flex; justify-content: space-between; margin-bottom: 2px; }
.bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bfill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.conf-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin: 5px 0; }
.conf-fill { height: 100%; border-radius: 2px; transition: width .4s; }

/* ── Portfolio ── */
.port-body { padding: 20px; max-width: 1280px; }
.proj-main { flex: 1; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 12px; }
.proj-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 16px; cursor: pointer;
  transition: all .2s; position: relative; overflow: hidden;
}
.proj-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--border);
  transition: background .2s;
}
.proj-card:hover { border-color: var(--purple-m); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.proj-card:hover::before { background: var(--purple); }
.proj-card.status-risk::before { background: var(--red); }
.proj-card.status-ok::before { background: var(--green); }
.proj-card.status-warn::before { background: var(--amber); }
.pc-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 5px; padding-right: 28px; }
.pc-sub { font-size: 11px; color: var(--text-3); margin-bottom: 11px; line-height: 1.5; }
.pc-del { position: absolute; top: 12px; right: 12px; }
.pc-meta { font-size: 10px; color: var(--text-4); margin-top: 8px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.dot-r { background: #E24B4A; } .dot-a { background: #F59E0B; } .dot-g { background: #16A34A; }

/* ── Logic Engine ── */
.driver-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px,1fr)); gap: 9px; margin-bottom: 12px; }
.dcard {
  background: var(--blue-l); border: 1.5px solid var(--blue-m);
  border-radius: var(--r-lg); padding: 11px 12px; cursor: pointer;
  transition: all .15s; position: relative;
}
.dcard:hover { border-color: var(--blue); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.dcard.on { border-color: var(--purple); border-width: 2px; background: var(--purple-l); }
.dcard.oob { background: var(--red-l); border-color: var(--red-m); }
.dcard.minor { background: var(--bg); border-color: var(--border); opacity: .75; }
.dcard h4 { font-size: 11px; font-weight: 700; color: #1e40af; margin-bottom: 7px; line-height: 1.3; padding-right: 26px; }
.dcard.oob h4 { color: var(--red); }
.dcard.minor h4 { color: var(--text-3); }
.dcard .del-btn { position: absolute; top: 7px; right: 8px; }

.drill {
  background: var(--surface); border: 2px solid var(--purple);
  border-radius: var(--r-xl); padding: 15px; margin-top: 7px;
  box-shadow: var(--shadow-md);
}
.drill-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.drill-hdr h3 { font-size: 13px; font-weight: 700; color: var(--purple-d); }
.close-x {
  font-size: 11px; color: var(--text-3); cursor: pointer;
  padding: 3px 9px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg);
}
.close-x:hover { border-color: var(--purple); color: var(--purple); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.box { border-radius: var(--r-md); padding: 10px 12px; }
.box.blue { background: var(--blue-l); }
.box.green { background: var(--green-l); }
.box.amber { background: var(--amber-l); }
.box.pink { background: var(--pink-l); }
.blbl { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.box.blue .blbl { color: #1e40af; }
.box.green .blbl { color: var(--green); }
.box.amber .blbl { color: var(--amber); }
.box.pink .blbl { color: var(--pink); }
.btxt {
  font-size: 11px; line-height: 1.6; width: 100%;
  border: none; background: transparent; font-family: inherit;
  resize: none; outline: none; min-height: 44px; cursor: text; color: inherit;
}
.btxt:focus { background: rgba(255,255,255,.8); border-radius: 4px; padding: 2px 4px; }
.box.blue .btxt { color: #1e40af; }
.box.green .btxt { color: var(--green); }
.box.amber .btxt { color: var(--amber); }
.sl-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.sl-row label { font-size: 10px; color: var(--text-3); min-width: 72px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.sl-row input[type=range] { flex: 1; cursor: pointer; accent-color: var(--purple); }
.sl-row span { font-size: 11px; font-weight: 700; min-width: 36px; }

.sub-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 9px; }
.snode {
  background: var(--teal-l); border: 1px solid var(--teal-m);
  border-radius: var(--r-md); padding: 9px 11px; cursor: pointer;
  position: relative; transition: all .15s;
}
.snode:hover { border-color: var(--teal); box-shadow: var(--shadow-sm); }
.snode.on { border-color: var(--teal); border-width: 2px; }
.snode.oob { background: var(--red-l); border-color: var(--red-m); }
.snode.conv { background: var(--pink-l); border-color: var(--pink-m); }
.snode-top { display: flex; justify-content: space-between; gap: 6px; }
.snode-title { font-size: 11px; font-weight: 700; color: #134e4a; flex: 1; line-height: 1.3; padding-right: 32px; }
.snode.oob .snode-title { color: var(--red); }
.snode.conv .snode-title { color: var(--pink); }
.snode-cert { font-size: 10px; font-weight: 700; }
.snode-notes { font-size: 10px; color: #166534; margin-top: 3px; line-height: 1.4; }
.snode.oob .snode-notes { color: var(--red); }
.snode .del-btn { position: absolute; top: 7px; right: 8px; }
.sub-detail {
  background: var(--surface); border: 2px solid var(--teal);
  border-radius: var(--r-md); padding: 12px; margin-top: 6px;
}
.conv-badge {
  font-size: 9px; padding: 1px 6px; border-radius: var(--r-full);
  background: var(--pink-l); color: var(--pink); margin-left: 5px;
  font-weight: 600;
}

/* ── Evidence charts ── */
.ev-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.ev-tab {
  font-size: 10px; padding: 3px 11px; border-radius: var(--r-full);
  border: 1px solid var(--border); cursor: pointer; background: var(--surface); color: var(--text-3);
}
.ev-tab.on { background: var(--purple-l); border-color: var(--purple); color: var(--purple); font-weight: 600; }
.ev-add {
  font-size: 10px; padding: 3px 10px; border-radius: var(--r-full);
  border: 1px dashed var(--text-4); cursor: pointer; color: var(--text-3); background: var(--surface);
}
.ev-rm {
  font-size: 10px; padding: 3px 10px; border-radius: var(--r-full);
  border: 1px solid var(--red-m); cursor: pointer; color: var(--red);
  background: var(--red-l); margin-left: 5px;
}
.ct-row { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 8px; }
.ct {
  font-size: 10px; padding: 2px 9px; border-radius: var(--r-full);
  border: 1px solid var(--border); cursor: pointer; background: var(--surface); color: var(--text-3);
}
.ct.on { background: var(--purple-l); border-color: var(--purple); color: var(--purple); font-weight: 600; }
.chart-area { background: var(--bg); border-radius: var(--r-md); padding: 10px 12px; }
.chart-area label { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-3); font-size: 10px; }
.chart-area textarea {
  width: 100%; height: 64px; font-size: 10px; font-family: monospace;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 5px 8px; resize: vertical; background: var(--surface); color: var(--text);
}
.render-btn {
  font-size: 11px; padding: 5px 14px; border-radius: var(--r-full);
  border: 1px solid var(--purple); cursor: pointer;
  color: var(--purple); background: var(--purple-l); margin-top: 6px;
}
.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px; margin-top: 8px; }

/* ── Answer Engine ── */
.answer-header {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 15px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.ver-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ver-badge {
  font-size: 11px; font-weight: 700; padding: 4px 13px;
  border-radius: var(--r-full); background: var(--purple); color: #fff;
}
.ver-date { font-size: 11px; color: var(--text-4); }
.hist-btn {
  font-size: 11px; padding: 4px 11px; border-radius: var(--r-full);
  border: 1px solid var(--border); cursor: pointer; color: var(--text-3); background: var(--surface);
}
.answer-ta {
  width: 100%; min-height: 72px; font-size: 12px; line-height: 1.7;
  border: 1.5px solid var(--purple-m); border-radius: var(--r-md);
  padding: 10px 13px; resize: vertical; font-family: inherit;
  color: var(--text); background: var(--purple-l);
  transition: all .15s;
}
.answer-ta:focus { outline: none; border-color: var(--purple); background: var(--surface); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.hist-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 13px; margin-bottom: 12px; display: none;
}
.hist-item { padding: 8px 0; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: all .12s; }
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: var(--bg); border-radius: var(--r-sm); padding-left: 5px; }
.hist-ver { font-size: 11px; font-weight: 700; color: var(--purple); }
.hist-date { font-size: 10px; color: var(--text-4); margin-left: 7px; }
.hist-txt { font-size: 11px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }

.sol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 11px; margin-bottom: 14px; }
.sol-block {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-xl); padding: 14px; position: relative;
  transition: all .15s; box-shadow: var(--shadow-sm);
}
.sol-block:hover { border-color: var(--purple-m); box-shadow: var(--shadow-md); }
.sol-block.extra { border-color: var(--teal-m); border-style: dashed; }
.sol-tag {
  font-size: 10px; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--blue-l); color: #1e40af; cursor: pointer;
  display: inline-block; margin-bottom: 7px;
  border: 1px solid var(--blue-m); font-weight: 600; transition: all .15s;
}
.sol-tag:hover { background: var(--purple-l); border-color: var(--purple); color: var(--purple); }
.sol-tag.extra { background: var(--teal-l); color: var(--teal); border-color: var(--teal-m); }
.sol-conf { position: absolute; top: 13px; right: 13px; font-size: 10px; font-weight: 700; }
.sol-del { position: absolute; top: 10px; right: 44px; }
.sol-hl { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 5px; line-height: 1.4; padding-right: 18px; }
.sol-ta {
  width: 100%; min-height: 62px; font-size: 11px; line-height: 1.6;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 9px; resize: vertical; font-family: inherit;
  color: var(--text); background: var(--surface);
}
.sol-ta:focus { outline: none; border-color: var(--purple); background: var(--purple-l); }
.src-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.src-chip {
  font-size: 9px; padding: 2px 8px; border-radius: var(--r-full);
  background: var(--bg); color: var(--text-3); border: 1px solid var(--border);
}

/* Solution architecture drill */
.sol-drill {
  background: var(--surface); border: 2px solid var(--purple);
  border-radius: var(--r-xl); padding: 15px; margin-top: 9px;
  box-shadow: var(--shadow-md);
}
.sol-drill-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.sol-drill-title { font-size: 13px; font-weight: 700; color: var(--purple-d); flex: 1; }
.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 9px; margin-bottom: 11px; }
.arch-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 11px 13px; position: relative; transition: all .15s;
}
.arch-card:hover { border-color: var(--purple-m); background: var(--purple-l); }
.arch-icon { font-size: 18px; margin-bottom: 5px; display: block; }
.arch-title { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; padding-right: 28px; }
.arch-ta {
  width: 100%; min-height: 52px; font-size: 10px; line-height: 1.5;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 4px 7px; resize: vertical; font-family: inherit;
  background: var(--surface); color: var(--text); margin-top: 4px;
}
.arch-ta:focus { outline: none; border-color: var(--purple); }
.arch-src { font-size: 9px; color: var(--text-4); margin-top: 4px; font-style: italic; }
.arch-del { position: absolute; top: 8px; right: 9px; }
.add-arch-form { background: var(--purple-l); border: 1.5px dashed var(--purple-m); border-radius: var(--r-md); padding: 12px; margin-top: 9px; display: none; }
.add-arch-form label { color: var(--purple-d); }
.add-arch-form input, .add-arch-form textarea {
  width: 100%; font-size: 11px; border: 1px solid var(--purple-m);
  border-radius: var(--r-sm); padding: 5px 8px; margin-bottom: 6px;
  font-family: inherit; background: var(--surface); color: var(--text);
}

/* ── AI Proposals ── */
.proposal-card {
  background: var(--surface); border: 2px solid var(--purple);
  border-radius: var(--r-xl); padding: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}
.prop-hdr { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.prop-icon {
  width: 26px; height: 26px; background: var(--purple); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.prop-title { font-size: 13px; font-weight: 700; color: var(--purple-d); flex: 1; }
.prop-reason {
  font-size: 11px; color: var(--text-2); line-height: 1.6;
  margin-bottom: 11px; background: var(--bg); border-radius: var(--r-md); padding: 9px 12px;
}
.diff-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 11px; }
.diff-b { background: var(--red-l); border-radius: var(--r-md); padding: 9px 11px; }
.diff-a { background: var(--green-l); border-radius: var(--r-md); padding: 9px 11px; }
.dlbl { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.diff-b .dlbl { color: var(--red); } .diff-a .dlbl { color: var(--green); }
.dtxt { font-size: 11px; line-height: 1.5; }
.diff-b .dtxt { color: var(--red); } .diff-a .dtxt { color: var(--green); }

/* ── System Map ── */
.map-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px; flex-wrap: wrap; gap: 8px;
}
.map-legend { display: flex; gap: 10px; flex-wrap: wrap; }
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-3); }
.leg-swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.map-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); overflow: auto; position: relative;
  min-height: 560px; cursor: grab; box-shadow: var(--shadow-sm);
}
.map-container:active { cursor: grabbing; }
.node-editor-popup, .edge-editor-popup {
  display: none; position: absolute; z-index: 300;
  background: var(--surface); border: 2px solid var(--purple);
  border-radius: var(--r-lg); padding: 13px 15px;
  box-shadow: var(--shadow-lg); min-width: 230px; max-width: 280px;
}
.popup-title { font-size: 12px; font-weight: 700; color: var(--purple-d); margin-bottom: 8px; }
.popup-desc { font-size: 10px; color: var(--text-3); margin-bottom: 7px; }
.popup-field { width: 100%; font-size: 11px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 5px 8px; font-family: inherit; background: var(--surface); color: var(--text); margin-bottom: 7px; }
.popup-field:focus { outline: none; border-color: var(--purple); }
.popup-slider-row { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.popup-slider-row label { font-size: 10px; color: var(--text-3); min-width: 52px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.popup-slider-row input[type=range] { flex: 1; accent-color: var(--purple); }
.popup-slider-val { font-size: 11px; font-weight: 700; min-width: 34px; }

/* ── Story ── */
.story-ctrl {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 15px;
  margin-bottom: 13px; display: flex; gap: 18px;
  flex-wrap: wrap; align-items: flex-end; box-shadow: var(--shadow-sm);
}
.scg { display: flex; flex-direction: column; gap: 4px; }
.scg label { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 10px; color: var(--text-3); margin-bottom: 0; }
.scg .row { display: flex; align-items: center; gap: 5px; }
.scg .cnt { font-size: 15px; font-weight: 700; min-width: 22px; text-align: center; }
.scg button {
  width: 22px; height: 22px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 14px; color: var(--text); display: flex;
  align-items: center; justify-content: center; transition: all .12s;
}
.scg button:hover { background: var(--bg); border-color: var(--purple); }
.scqa-sec {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 15px;
  margin-bottom: 9px; box-shadow: var(--shadow-sm);
}
.scqa-hdr { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.scqa-letter { font-size: 22px; font-weight: 800; }
.slide-card {
  background: var(--bg); border-radius: var(--r-md);
  padding: 9px 12px; margin-bottom: 5px; cursor: pointer; transition: all .15s;
}
.slide-card:hover { background: var(--purple-l); transform: translateX(2px); }
.slide-num { font-size: 9px; color: var(--text-4); font-weight: 700; margin-bottom: 2px; }
.slide-hl { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; line-height: 1.3; }
.slide-buls { list-style: none; }
.slide-buls li { font-size: 11px; color: var(--text-2); line-height: 1.5; padding-left: 13px; position: relative; margin-bottom: 2px; }
.slide-buls li::before { content: '→'; position: absolute; left: 0; color: var(--purple-m); font-size: 9px; top: 1px; }

/* ── Tracker ── */
.trk-grid { display: flex; flex-direction: column; gap: 12px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-4); border-bottom: 1px solid var(--border); padding: 0 6px 7px; text-align: left; }
.tbl td { padding: 7px 6px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg); }
.tbl input, .tbl select, .tbl textarea {
  font-size: 11px; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 3px 6px; background: transparent; color: var(--text);
  font-family: inherit; width: 100%; transition: all .12s;
}
.tbl input:hover, .tbl select:hover, .tbl textarea:hover { border-color: var(--border); background: var(--surface); }
.tbl input:focus, .tbl select:focus, .tbl textarea:focus { outline: none; border-color: var(--purple); background: var(--surface); }
.add-row-btn {
  font-size: 11px; padding: 5px 14px; border-radius: var(--r-full);
  border: 1px dashed var(--text-4); cursor: pointer;
  color: var(--text-3); background: var(--surface); margin-top: 9px; transition: all .15s;
}
.add-row-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-l); }
.gate-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.gate { background: var(--bg); border-radius: var(--r-lg); padding: 12px; }
.prog-wrap { background: var(--border); border-radius: var(--r-full); height: 5px; overflow: hidden; margin: 6px 0 4px; }
.prog-fill { height: 100%; border-radius: var(--r-full); transition: width .4s; }
.sug-box {
  background: var(--amber-l); border: 1px solid var(--amber-m);
  border-radius: var(--r-md); padding: 10px 13px;
  margin-bottom: 11px; font-size: 11px; color: var(--amber); line-height: 1.9;
}

/* ── AI chat panel ── */
.ai-panel-wrap {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 360px; background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 500;
  display: flex; flex-direction: column;
}
.ai-panel-wrap.open { transform: translateX(0); }
.ai-panel-inner { display: flex; flex-direction: column; height: 100%; }
.ai-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px; border-bottom: 1px solid var(--border);
  background: var(--purple); color: #fff; flex-shrink: 0;
}
.ai-panel-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ai-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #86efac; animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.4} }
.ai-ctx-btn {
  font-size: 10px; padding: 3px 9px; border-radius: var(--r-full);
  border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.15);
  color: #fff; cursor: pointer;
}
.ai-ctx-btn:hover { background: rgba(255,255,255,.25); }
.ai-close {
  font-size: 18px; line-height: 1; cursor: pointer; color: rgba(255,255,255,.8);
  background: none; border: none; padding: 0 3px;
}
.ai-close:hover { color: #fff; }
.ai-ctx-panel {
  background: var(--purple-l); border-bottom: 1px solid var(--purple-m);
  padding: 10px 14px; flex-shrink: 0;
}
.ai-ctx-title { font-size: 10px; font-weight: 700; color: var(--purple); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .06em; }
.ai-ctx-content { font-size: 10px; color: var(--text-2); line-height: 1.7; max-height: 160px; overflow-y: auto; }
.ai-messages { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg-user { display: flex; justify-content: flex-end; }
.ai-msg-ai { display: flex; justify-content: flex-start; }
.ai-bubble-user {
  background: var(--purple); color: #fff;
  border-radius: 16px 16px 4px 16px; padding: 9px 13px;
  font-size: 12px; line-height: 1.5; max-width: 88%;
}
.ai-bubble {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px; padding: 10px 13px;
  font-size: 12px; line-height: 1.6; max-width: 92%; color: var(--text-2);
}
.ai-thinking { display: flex; gap: 4px; align-items: center; padding: 10px 13px; }
.ai-thinking-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); animation: bounce 1.2s infinite; }
.ai-thinking-dot:nth-child(2) { animation-delay: .2s; }
.ai-thinking-dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }
.ai-quick-prompts {
  padding: 0 12px 8px; display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid var(--border-light); flex-shrink: 0;
}
.ai-quick-prompts-title { font-size: 9px; font-weight: 700; color: var(--text-4); text-transform: uppercase; letter-spacing: .07em; padding: 7px 0 4px; }
.qprompt {
  font-size: 11px; padding: 5px 11px; border-radius: var(--r-full);
  border: 1px solid var(--purple-m); cursor: pointer;
  color: var(--purple-d); background: var(--purple-l);
  text-align: left; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; transition: all .12s;
}
.qprompt:hover { background: var(--purple-m); color: var(--purple-d); }
.ai-input-row {
  padding: 9px 12px; display: flex; gap: 7px; align-items: flex-end;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.ai-input {
  flex: 1; font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px 11px; resize: none;
  font-family: inherit; color: var(--text); background: var(--surface);
  line-height: 1.4;
}
.ai-input:focus { outline: none; border-color: var(--purple); }
.ai-send {
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: var(--purple); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .15s;
}
.ai-send:hover { background: var(--purple-d); }
.ai-key-notice {
  padding: 8px 14px; background: var(--amber-l);
  border-top: 1px solid var(--amber-m); display: flex;
  align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ai-key-notice span { font-size: 11px; color: var(--amber); }
.ai-key-notice button {
  font-size: 11px; padding: 3px 10px; border-radius: var(--r-full);
  border: none; background: var(--amber); color: #fff; cursor: pointer;
}

/* AI FAB */
.ai-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 499;
  background: var(--purple); color: #fff; border: none;
  border-radius: var(--r-full); padding: 10px 18px;
  cursor: pointer; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 7px;
  box-shadow: var(--shadow-lg); transition: all .2s;
}
.ai-fab:hover { background: var(--purple-d); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(79,70,229,.4); }
.ai-panel-wrap.open + .ai-fab { display: none; }

/* ── PIN Modal ── */
.pin-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 9999;
  align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.pin-overlay.show { display: flex; }
.pin-box {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 28px 24px; width: 300px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.pin-icon { font-size: 28px; margin-bottom: 10px; }
.pin-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.pin-box p { font-size: 12px; color: var(--text-3); margin-bottom: 14px; line-height: 1.5; }
.pin-inp {
  width: 100%; font-size: 24px; font-weight: 700; text-align: center;
  border: 2px solid var(--border); border-radius: var(--r-md);
  padding: 9px; letter-spacing: 8px; margin-bottom: 11px; font-family: inherit; color: var(--text);
}
.pin-inp:focus { outline: none; border-color: var(--purple); }
.pin-err { font-size: 11px; color: var(--red); margin-bottom: 8px; display: none; }
.pin-row { display: flex; gap: 8px; }
.btn-ok-pin {
  flex: 1; font-size: 12px; padding: 9px; border-radius: var(--r-md);
  border: none; background: var(--red); color: #fff; cursor: pointer; font-weight: 700;
}
.btn-ok-pin:hover { background: #991b1b; }
.btn-cancel-pin {
  flex: 1; font-size: 12px; padding: 9px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-3); cursor: pointer;
}
.btn-cancel-pin:hover { background: var(--bg); }

/* ── AI panel ── */
.ai-panel-section { padding: 11px; background: var(--bg); border-radius: var(--r-md); margin-top: 11px; }
.ai-panel-section-title { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-bottom: 7px; }
.ai-panel-btn {
  font-size: 11px; padding: 6px 12px; border-radius: var(--r-full);
  border: 1px solid var(--purple-m); cursor: pointer;
  color: var(--purple-d); background: var(--purple-l);
  display: block; width: 100%; text-align: left; margin-bottom: 5px; transition: all .12s;
}
.ai-panel-btn:hover { background: #e0e7ff; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2,1fr); }
  .two-col { grid-template-columns: 1fr; }
  .diff-row { grid-template-columns: 1fr; }
  .gate-grid { grid-template-columns: 1fr; }
  .sol-grid { grid-template-columns: 1fr; }
  .driver-grid { grid-template-columns: repeat(2,1fr); }
  .fr { flex-direction: column; }
  .ai-panel-wrap { width: 100%; }
  .proj-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Transitions ── */
.fade-in { animation: fadeIn .2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:none} }

/* ── Story editable slide cards ── */
.story-slide-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px;
  margin-bottom: 7px; transition: border-color .15s;
}
.story-slide-card:hover { border-color: var(--purple-m); }
.slide-headline-input {
  width: 100%; font-size: 12px; font-weight: 700; color: var(--text);
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 5px 8px; margin-bottom: 5px; font-family: inherit;
  background: var(--surface); transition: all .15s;
}
.slide-headline-input:hover { border-color: var(--border); }
.slide-headline-input:focus { outline: none; border-color: var(--purple); background: var(--purple-l); }
.slide-bullet-input {
  width: 100%; font-size: 11px; color: var(--text-2);
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 4px 8px 4px 20px; margin-bottom: 3px; font-family: inherit;
  background: transparent; transition: all .15s;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='8' viewBox='0 0 8 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 1l3 6H1z' fill='%234F46E5' fill-opacity='0.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 6px 7px;
}
.slide-bullet-input:hover { border-color: var(--border); background-color: var(--surface); }
.slide-bullet-input:focus { outline: none; border-color: var(--purple-m); background-color: var(--surface); }
.slide-move-btn {
  font-size: 11px; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text-3); transition: all .12s;
}
.slide-move-btn:hover { background: var(--bg); border-color: var(--purple); color: var(--purple); }
.slide-move-btn:disabled { opacity: .35; cursor: default; }

/* ── System map: left-to-right ── */
.map-container { min-height: 420px; }
.map-node-popup {
  position: absolute; z-index: 400;
  background: var(--surface); border: 2px solid var(--purple);
  border-radius: var(--r-lg); padding: 13px 15px;
  box-shadow: var(--shadow-lg); min-width: 240px; max-width: 290px;
  display: none;
}
.map-node-popup.edge { border-color: var(--teal); }

/* ── Evidence chart grid editor ── */
.ev-hint {
  font-size: 10px; color: var(--purple-d); background: var(--purple-l);
  border-radius: var(--r-sm); padding: 5px 10px; margin-bottom: 8px;
  line-height: 1.5; border-left: 3px solid var(--purple-m);
}
.ev-grid-wrap { background: var(--bg); border-radius: var(--r-md); padding: 10px 12px; }
.ev-grid-scroll { overflow-x: auto; margin-bottom: 8px; }
.ev-grid { border-collapse: collapse; font-size: 11px; min-width: 100%; }
.ev-grid thead { background: var(--surface); }
.ev-grid th { padding: 3px 3px; }
.ev-grid td { padding: 2px 3px; border: 1px solid var(--border-light); }
.ev-grid tr:hover td { background: rgba(79,70,229,.03); }
.ev-row-num { font-size: 9px; color: var(--text-4); text-align: center; width: 20px; padding: 0 3px; border: none !important; }
.ev-col-hdr {
  font-size: 10px; font-weight: 700; color: var(--purple-d);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 3px 6px; width: 90px; background: var(--surface);
  text-align: center; font-family: inherit;
}
.ev-col-hdr:focus { outline: none; border-color: var(--purple); background: var(--purple-l); }
.ev-cell {
  font-size: 11px; border: 1px solid var(--border); border-radius: 3px;
  padding: 3px 6px; width: 90px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .12s;
}
.ev-cell:focus { outline: none; border-color: var(--purple); background: var(--purple-l); }
.ev-cell-lbl { color: var(--text-2); font-weight: 600; width: 110px; }
.ev-cell-num { color: var(--blue); text-align: right; }
.ev-grid-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.ev-grid-btn {
  font-size: 10px; padding: 3px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text-2); transition: all .12s;
}
.ev-grid-btn:hover { background: var(--bg); border-color: var(--purple); color: var(--purple); }
.ev-grid-btn-del:hover { border-color: var(--red-m); color: var(--red); background: var(--red-l); }
.ev-load-tmpl {
  font-size: 10px; padding: 3px 10px; border-radius: var(--r-full);
  border: 1px solid var(--amber-m); background: var(--amber-l);
  cursor: pointer; color: var(--amber); transition: all .12s;
}
.ev-load-tmpl:hover { background: #FDE68A; }
.render-btn {
  font-size: 11px; padding: 5px 16px; border-radius: var(--r-full);
  border: none; cursor: pointer; background: var(--purple);
  color: #fff; font-weight: 700; margin-left: auto; transition: all .15s;
}
.render-btn:hover { background: var(--purple-d); }

/* ── Evidence grid extras ── */
.ev-layout-hint {
  font-size: 10px; color: var(--text-3); background: var(--bg);
  border-radius: var(--r-sm); padding: 4px 10px; margin-bottom: 8px;
  line-height: 1.5; font-style: italic;
}
.ev-grid-meta {
  font-size: 9px; color: var(--text-4); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.ev-col-hdr-lbl { background: var(--bg); color: var(--text-2); font-style: italic; }
.ev-col-hdr-line { background: #E0F2FE; color: #0c4a6e; }
.ev-row-total td { background: var(--purple-l) !important; }
.ev-row-total .ev-cell { background: var(--purple-l); font-weight: 700; color: var(--purple-d); }
.ev-cell-neg { color: var(--red) !important; }
.ev-cell-type { color: var(--text-4); font-style: italic; width: 70px !important; font-size: 10px; }
.ev-row-th { width: 22px; }
