:root {
  --ink: #14221f;
  --muted: #5c6b66;
  --line: #e4e7e6;
  --line-strong: #d5dbd8;
  --bg: #f3f5f4;
  --card: #ffffff;
  --sidebar: #10211f;
  --sidebar-text: #d5e3df;
  --sidebar-faint: #8eaaa4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #e7f5f2;
  --warn: #9a3412;
  --warn-soft: #fff4ed;
  --danger: #9f1239;
  --danger-soft: #fff1f2;
  --ok: #047857;
  --shadow: 0 1px 2px rgba(16, 33, 31, .06), 0 8px 24px rgba(16, 33, 31, .04);
  --sans: "Segoe UI", system-ui, sans-serif;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent-dark); }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.03em; }
h1 { font-size: 28px; }
h2 { font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #f4fffd;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 600;
}
.btn:hover { background: var(--accent-dark); }
.btn-ghost, button.btn-ghost {
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
}
.logo {
  width: 18px; height: 18px; border-radius: 5px;
  background: conic-gradient(from 140deg, #5eead4, #0f766e 55%, #134e4a);
  display: inline-block;
}

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: flex; align-items: center; gap: 8px;
  color: white; text-decoration: none; font-weight: 700; letter-spacing: -0.03em;
}
.nav-close, .nav-open { display: none; }
.workspace, .account {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 18px 4px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}
.account { margin-top: auto; grid-template-columns: 36px minmax(0, 1fr); }
.account form { grid-column: 1 / -1; }
.account .btn-ghost { color: var(--sidebar-faint); padding: 0; }
.workspace strong, .account strong { display: block; color: white; font-size: 14px; }
.workspace small, .account small, .account-copy small {
  display: block; color: var(--sidebar-faint); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: #1d4f49; color: #d8fff8; font-size: 12px; font-weight: 700;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  margin: 14px 10px 6px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-faint);
}
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--sidebar-text); text-decoration: none;
  padding: 8px 10px; border-radius: 8px;
}
.side-nav a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-nav a.active, .side-nav a:hover { background: rgba(255,255,255,.08); color: white; }
.workspace-main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 244, .9);
  position: sticky; top: 0; z-index: 5;
}
.topbar-status { margin: 0; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--warn); display: inline-block; }
main { padding: 28px 32px 64px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 20px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lede { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 0; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: 13px; font-weight: 600; text-decoration: none; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metrics a {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; text-decoration: none; color: inherit;
}
.metrics span { color: var(--muted); font-size: 13px; }
.metrics strong { display: block; font-size: 32px; letter-spacing: -0.04em; margin-top: 4px; }
.columns { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; margin-bottom: 16px; }
.columns-form { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  font-weight: 450;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #99f6e4; border-color: var(--accent); }
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 3px 8px;
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 12px; font-weight: 700;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok { background: #ecfdf5; color: var(--ok); }
.badge-high { background: #ecfdf5; color: #047857; }
.badge-steady { background: var(--accent-soft); color: var(--accent-dark); }
.badge-cooling { background: #fff7ed; color: #9a3412; }
.badge-quiet { background: #f3f4f6; color: #4b5563; }
.btn-secondary, button.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  background: white; color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 9px 14px; text-decoration: none; font-weight: 600;
}
.btn-secondary:hover { border-color: var(--accent); }
a.person { text-decoration: none; color: inherit; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist a {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  text-decoration: none; color: inherit; padding: 8px; border-radius: 8px;
}
.checklist a:hover { background: var(--bg); }
.checklist strong, .record-list strong, .member-list strong, .person strong { display: block; }
.checklist small, .record-list small, .member-list small, .person small { color: var(--muted); }
.checklist em { font-style: normal; color: var(--muted); font-size: 12px; }
.check {
  width: 18px; height: 18px; border-radius: 99px; border: 1.5px solid var(--line-strong);
}
.checklist .done .check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px white; }
.record-list, .activity, .member-list { list-style: none; margin: 0; padding: 0; }
.record-list li, .activity li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px;
  align-items: center; padding: 10px 0; border-top: 1px solid var(--line);
}
.record-list a { text-decoration: none; color: inherit; }
.activity li { grid-template-columns: 180px minmax(0, 1fr) auto; }
.activity span { color: var(--muted); }
.activity time, .record-list time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty { padding: 18px 4px; color: var(--muted); display: grid; gap: 12px; justify-items: start; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
tr:hover td { background: #f8fbfa; }
.person, .member-list li { display: flex; gap: 10px; align-items: center; }
.member-list li { padding: 8px 0; }
.row-link { font-weight: 700; text-decoration: none; }
.search { margin-bottom: 8px; max-width: 280px; }
.inline { display: flex; gap: 8px; align-items: end; }
.grow { flex: 1; }
.filter-empty { color: var(--muted); }
.settings-form { max-width: 640px; margin-bottom: 16px; }
.facts { margin: 0; display: grid; gap: 10px; }
.facts div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan-card { display: grid; gap: 8px; align-content: start; }
.plan-card p { margin: 0; color: var(--muted); }

.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 30; display: grid; gap: 8px; width: min(360px, calc(100% - 32px)); }
.flash { margin: 0; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); }
.notice { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdd3; }

.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.auth-brand {
  background: var(--sidebar); color: white;
  padding: 40px 48px; display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.auth-brand h1 { font-size: 40px; max-width: 14ch; }
.auth-brand ul { margin: 0; padding-left: 18px; color: var(--sidebar-text); display: grid; gap: 8px; }
.auth-panel { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(420px, 100%); display: grid; gap: 8px; }
.mode-public { background: var(--bg); }
.public-wrap { width: min(560px, calc(100% - 32px)); margin: 48px auto 64px; display: grid; gap: 16px; }
.public-brand { color: var(--ink); }
.public-card { background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; display: grid; gap: 14px; }
.topics { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.topics legend { font-weight: 700; margin-bottom: 4px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkline input { width: auto; }
.message-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 10px; }
.steps small { display: block; color: var(--muted); }
.metrics > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.metrics > div span { color: var(--muted); font-size: 13px; }
.metrics > div strong { display: block; font-size: 32px; letter-spacing: -0.04em; margin-top: 4px; }
.decision { display: grid; gap: 8px; margin-top: 12px; }
.decision p { margin: 0; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.auth-card .lede { margin-bottom: 8px; }

.mode-editor { background: #e9eeec; overflow: hidden; }
.editor-app { height: 100vh; display: grid; grid-template-rows: 56px minmax(0, 1fr); }
.editor-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px; background: white; border-bottom: 1px solid var(--line);
}
.editor-bar .back { color: var(--muted); text-decoration: none; font-weight: 600; }
.editor-bar .back:hover { color: var(--ink); }
#editor-title { font-size: 15px; }
.status { color: var(--muted); font-size: 12px; margin-right: auto; }
.preview-as { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.preview-as select { width: auto; }
.editor { min-height: 0; display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px; }
.rail, .inspector { background: white; overflow: auto; padding: 8px 12px 20px; }
.rail { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); display: grid; align-content: start; gap: 18px; }
.inspector section { display: grid; gap: 10px; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette button, .block-tools button {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.palette button:hover, .block-tools button:hover { border-color: var(--accent); }
.block-list { display: grid; gap: 6px; }
.block-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: white;
}
.block-row.selected { border-color: var(--accent); background: var(--accent-soft); }
.block-pick { background: transparent; border: 0; text-align: left; padding: 0; display: grid; min-width: 0; }
.block-pick strong { font-size: 13px; }
.block-pick small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-tools { display: flex; gap: 2px; }
.block-tools button { padding: 4px 6px; font-size: 12px; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 16px; gap: 10px; }
.stage-frame {
  flex: 1; min-height: 0; background: white; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.stage-frame iframe { width: 100%; height: 100%; border: 0; background: white; }
.subject-line { margin: 0; background: white; border-radius: 12px; padding: 10px 14px; }
.subject-line span { color: var(--muted); font-weight: 650; margin-right: 8px; }
.journey-outline { background: white; border-radius: 16px; box-shadow: var(--shadow); padding: 22px 24px; overflow: auto; }
.journey-outline p { margin-top: 0; }
.source-drawer { flex: 0 0 auto; background: white; border-radius: 12px; border: 1px solid var(--line); }
.source-drawer summary { cursor: pointer; padding: 10px 12px; font-weight: 650; }
#liquid-source, #text-source { margin: 0; padding: 0 12px 12px; max-height: 180px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field-row input[type="color"] { height: 40px; padding: 4px; }
.tabs { display: flex; gap: 6px; margin: 0 0 10px; }
.tab { background: white; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.plain-text { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; margin: 0; }
.preview-context { margin: 0; color: var(--muted); font-size: 12px; }
.inline-fields { display: flex; gap: 6px; align-items: center; }
.inline-fields input { flex: 1; min-width: 0; }
.section-list { display: grid; gap: 6px; }
.section-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.section-row button { text-align: left; }
.fields-table td form { display: inline; }
.test-result { margin: 0; font-size: 12px; color: var(--muted); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 88vw); z-index: 20;
    transform: translateX(-105%); transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: none; }
  .nav-open, .nav-close { display: inline-flex; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
  .nav-close { color: white; border-color: rgba(255,255,255,.2); }
  .columns, .columns-form, .metrics, .plan-grid, .auth, .editor { grid-template-columns: 1fr; }
  .activity li { grid-template-columns: 1fr; }
  .editor-app { height: auto; min-height: 100vh; }
  .stage-frame { height: 520px; }
  .mode-editor { overflow: auto; }
  main { padding: 20px 16px 48px; }
  .auth-brand { display: none; }
}
