:root {
  --bg: #0B0E15;
  --surface: #141A28;
  --surface-strong: #1B2334;
  --ink: #E9EDF5;
  --muted: #8C95A9;
  --line: #232C40;
  --blue: #5B8DEF;
  --green: #3FC9A6;
  --amber: #F2B84B;
  --red: #EF6B6B;
  --purple: #9B7BF5;
  --gold: #F2B84B;
  --gold-ink: #241905;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

body.locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 42px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 750;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(47, 101, 167, 0.3);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 243, 234, 0.96);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

.login-message {
  min-height: 22px;
  color: var(--red);
  font-weight: 750;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #252b2d;
  color: #f8f5ec;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #e7c56b;
  color: #1d2324;
  font-size: 24px;
  font-weight: 900;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.hero-band h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: #cbd2cc;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  text-align: left;
  color: #f8f5ec;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.nav-button:hover,
.nav-button.active {
  background: #f8f5ec;
  color: #252b2d;
}

.sync-panel {
  margin-top: auto;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.09);
  display: grid;
  gap: 6px;
}

.sync-panel p {
  margin: 0;
}

.sync-panel .sync-detail,
.sync-panel span,
.sync-panel strong {
  display: block;
}

.sync-detail {
  margin-top: 2px;
  color: #d7ded9;
  font-size: 13px;
}

.sync-state {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 2px;
}

.sync-state-synced,
.sync-state-saving,
.sync-state-offline,
.sync-state-error {
  color: #d7ded9;
}

.sync-state-synced {
  color: #90d4a5;
}

.sync-state-saving {
  color: #f7d38f;
}

.sync-state-offline,
.sync-state-not-synced,
.sync-state-browser-backup,
.sync-state-could-not-start {
  color: #ef9a9a;
}

.sync-state-error {
  color: #f3a5a5;
}

.main {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h2 {
  font-size: 32px;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions,
.button-row,
.focus-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary {
  background: var(--blue);
  color: white;
}

.secondary,
.file-button {
  background: #e9e4d8;
  color: #242729;
}

.ghost {
  background: transparent;
  color: var(--blue);
  min-height: 34px;
  padding: 6px 8px;
}

.danger {
  width: 100%;
  margin-top: 14px;
  background: #f2d6d6;
  color: #7b2222;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.hero-band,
.panel,
.metric,
.agent-card,
.project-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
  margin-bottom: 18px;
}

.hero-band h3 {
  max-width: 820px;
  margin-top: 4px;
  font-size: 25px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 18px;
}

.metric span {
  font-size: 34px;
  font-weight: 900;
}

.metric p {
  margin: 2px 0 0;
  color: var(--muted);
}

.content-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.content-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-list,
.cards-grid,
.project-list,
.quick-grid,
.updates {
  display: grid;
  gap: 12px;
}

.cards-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mini-card,
.agent-card,
.project-card {
  padding: 16px;
}

.mini-card h4,
.agent-card h3,
.project-card h3 {
  margin: 0 0 6px;
}

.mini-card p,
.agent-card p,
.project-card p,
.helper {
  color: var(--muted);
}

.mini-card p,
.agent-card p,
.project-card p {
  margin: 6px 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 850;
  color: #1f2526;
  background: #e5e1d4;
}

.status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: currentColor;
}

.status-active {
  color: var(--green);
  background: #dff0e8;
}

.status-waiting {
  color: var(--amber);
  background: #f7e8d2;
}

.status-in-progress {
  color: var(--blue);
  background: #dce9f8;
}

.status-blocked {
  color: var(--red);
  background: #f4dddd;
}

.status-done {
  color: var(--green);
  background: #d9eadf;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.check-list li {
  padding: 11px 12px;
  border-left: 4px solid var(--blue);
  background: #f5f0e5;
  border-radius: var(--radius);
}

.update-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.update-item time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--blue);
  color: white;
  text-decoration: none;
  font-weight: 850;
}

.open-link.disabled {
  background: #d9d4c7;
  color: #6f6b63;
  pointer-events: none;
}

.agent-meta,
.project-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: #ece6d9;
  color: #4d4f52;
  font-size: 13px;
  font-weight: 750;
}

.project-toolbar {
  margin-bottom: 14px;
}

.project-toolbar label,
.field,
.settings-field {
  display: grid;
  gap: 7px;
}

.project-toolbar span,
.field span,
.settings-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select,
textarea,
input[type="url"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.detail-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
}

.detail-box strong {
  display: block;
  margin-bottom: 4px;
}

.workflow-intro {
  margin-bottom: 16px;
}

.workflow-intro p {
  max-width: 850px;
  color: var(--muted);
}

.flowchart {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.flow-node,
.flow-arrow {
  min-height: 88px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
  font-weight: 850;
}

.flow-node {
  border: 2px solid #ccd6d4;
  background: var(--surface);
}

.flow-node.person {
  border-color: var(--green);
}

.flow-node.strong {
  border-color: var(--blue);
  background: #eaf1fa;
}

.flow-arrow {
  min-width: 70px;
  color: var(--muted);
  background: #ede7dc;
}

.role-map,
.system-map,
.settings-editor {
  display: grid;
  gap: 12px;
}

.role-map div,
.system-box {
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fffefa;
}

.role-map strong {
  display: block;
}

.role-map span,
.system-box span {
  color: var(--muted);
}

.system-map {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.system-map.lower {
  margin-top: 12px;
}

.system-box.accent {
  border-color: var(--blue);
  background: #eaf1fa;
}

.rules-list {
  margin: 0;
  display: grid;
  gap: 12px;
}

.rules-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.rules-list dt {
  color: var(--muted);
  font-weight: 850;
}

.rules-list dd {
  margin: 3px 0 0;
}

.url-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.url-list code {
  display: block;
  padding: 9px;
  border-radius: var(--radius);
  background: #f0eadf;
  overflow-wrap: anywhere;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  display: none;
}

.settings-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
}

.settings-group h4 {
  margin: 0;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid,
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid.two,
  .cards-grid,
  .system-map {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .hero-band {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 25px;
  }

  .hero-band h3 {
    font-size: 21px;
  }

  .nav-list,
  .metric-grid,
  .quick-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ============ HeroA dark-gold identity (Fable 5 pass) ============ */
.sidebar { background: #10151F; color: var(--ink); border-right: 1px solid var(--line); }
.brand-mark { background: var(--gold); color: var(--gold-ink); }
.login-screen { background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow); }
input, select, textarea { background: var(--surface-strong); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); }
input::placeholder, textarea::placeholder { color: var(--muted); }
button.primary, .primary { background: var(--gold); color: var(--gold-ink); }
button.secondary, .secondary, .file-button { background: var(--surface-strong); color: var(--ink); border: 1px solid var(--line); }
button.ghost, .ghost { background: transparent; color: var(--blue); }
button.danger, .danger { background: rgba(239, 107, 107, 0.14); color: var(--red); border: 1px solid rgba(239, 107, 107, 0.4); }
.status { color: var(--muted); background: var(--surface-strong); }
.status-active { color: var(--green); background: rgba(63, 201, 166, 0.14); }
.status-waiting { color: var(--amber); background: rgba(242, 184, 75, 0.14); }
.status-in-progress { color: var(--blue); background: rgba(91, 141, 239, 0.15); }
.status-blocked { color: var(--red); background: rgba(239, 107, 107, 0.15); }
.status-done { color: var(--green); background: rgba(63, 201, 166, 0.1); }
.check-list li { background: var(--surface-strong); border-left-color: var(--gold); border-radius: 0 var(--radius) var(--radius) 0; }
.open-link { background: var(--gold); color: var(--gold-ink); }
.open-link.disabled { background: var(--surface-strong); color: var(--muted); }
.tag { background: var(--surface-strong); color: var(--muted); }
.flow-node, .system-box, .role-map > div, .detail-box { background: var(--surface-strong); border: 1px solid var(--line); color: var(--ink); }
.flow-node.person { border-color: var(--green); }
.flow-node.strong, .system-box.accent { border-color: var(--gold); background: rgba(242, 184, 75, 0.1); }
.flow-arrow { color: var(--muted); background: transparent; border: 0; }
.panel, .mini-card, .agent-card, .project-card, .update-item { background: var(--surface); border: 1px solid var(--line); }
.hero-band { background: linear-gradient(120deg, rgba(242, 184, 75, 0.12), rgba(91, 141, 239, 0.07)); border: 1px solid var(--line); }
.metric span { color: var(--gold); }
code { background: var(--surface-strong); color: var(--ink); border-radius: 6px; padding: 2px 6px; }
.sync-panel { background: rgba(255, 255, 255, 0.04); }

/* ============ HeroA Brain page ============ */
.heroa-toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.heroa-toolbar label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.heroa-toolbar input, .heroa-toolbar select { min-height: 42px; padding: 8px 12px; }
.heroa-search { flex: 1; min-width: 160px; }
.heroa-search input { width: 100%; }
.heroa-open { display: inline-flex; align-items: center; min-height: 42px; padding: 10px 16px; border-radius: var(--radius); text-decoration: none; font-weight: 750; }
.heroa-today { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }
.heroa-today-date { font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: 0.14em; color: var(--muted); }
.heroa-today-item b { color: var(--gold); margin-right: 4px; }
.heroa-stage { position: relative; height: calc(100vh - 320px); min-height: 460px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
#heroaCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.heroa-hint { position: absolute; left: 14px; bottom: 8px; margin: 0; font-size: 11.5px; color: var(--muted); pointer-events: none; }
.heroa-card { position: absolute; top: 14px; right: 14px; width: 300px; max-height: calc(100% - 28px); overflow: auto; display: none; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px 18px; }
.heroa-card.open { display: flex; }
.heroa-card h3 { margin: 0; font-size: 17px; }
.heroa-card p { margin: 0; color: var(--muted); font-size: 13px; }
.heroa-chip { align-self: flex-start; font: 600 10px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.14em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; color: var(--bg); }
.heroa-src { font: 10.5px ui-monospace, Menlo, monospace; color: var(--muted); word-break: break-all; }
.heroa-src:empty { display: none; }
#heroaCardOpen { display: none; align-self: flex-start; background: var(--gold); color: var(--gold-ink); border-radius: 10px; padding: 9px 14px; font-size: 13px; font-weight: 750; text-decoration: none; }
.heroa-conn-label { font: 600 10px/1 ui-monospace, Menlo, monospace; color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; margin-top: 4px; }
.heroa-conns { display: flex; flex-wrap: wrap; gap: 6px; }
.heroa-conns button { background: var(--surface-strong); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; font-size: 12px; min-height: 0; font-weight: 500; }
.heroa-conns button:hover { border-color: var(--gold); }
.heroa-card-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 16px; min-height: 0; padding: 4px; }
@media (max-width: 720px) {
  .heroa-card { left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: 50%; }
  .heroa-stage { height: calc(100vh - 380px); }
}

/* face logo */
.brand-face { width: 46px; height: 46px; border-radius: 12px; }
.login-card .brand-face { justify-self: start; }
.nav-face { width: 20px; height: 20px; border-radius: 5px; vertical-align: -4px; margin-right: 4px; }

/* ============ Notes: full-page zoom + attachments ============ */
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.zoom-btn { min-height: 0; padding: 3px 9px; font-size: 14px; background: var(--surface-strong); color: var(--muted); border: 1px solid var(--line); border-radius: 7px; }
.zoom-btn:hover { color: var(--gold); border-color: var(--gold); }
.note-zoom { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; gap: 12px; background: var(--bg); padding: clamp(14px, 3vw, 34px); }
.note-zoom[hidden] { display: none; }
.note-zoom-head { display: flex; align-items: center; justify-content: space-between; }
.note-zoom-head h3 { margin: 0; font-size: 22px; }
#noteZoomClose { min-height: 0; width: 40px; height: 40px; border-radius: 10px; background: var(--surface-strong); color: var(--ink); border: 1px solid var(--line); font-size: 16px; }
#noteZoomClose:hover { border-color: var(--gold); color: var(--gold); }
#noteZoomText { flex: 1; width: 100%; resize: none; font-size: 16px; line-height: 1.6; padding: 18px; border-radius: 14px; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.attach-card { background: var(--surface-strong); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; }
.attach-card img { width: 100%; height: 92px; object-fit: cover; border-radius: 8px; }
.attach-icon { height: 92px; display: grid; place-items: center; font-size: 34px; background: var(--surface); border-radius: 8px; }
.attach-name { margin: 0; font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-time { margin: 0; font-size: 11px; color: var(--muted); }
.attach-actions { display: flex; gap: 6px; }
.attach-actions button { flex: 1; min-height: 0; padding: 6px; font-size: 12px; font-weight: 600; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; }
.attach-actions button:hover { border-color: var(--gold); }
