@font-face {
  font-family: Fraunces;
  src: url("fonts/fraunces-latin.eb2486760f75.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Archivo;
  src: url("fonts/archivo-latin.cd56e2ec63d7.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #11120f;
  --side: #151612;
  --surface: #1b1d19;
  --surface-raised: #22241f;
  --line: #34362d;
  --text: #f2ede0;
  --muted: #aaa99c;
  --amber: #d9a65f;
  --amber-soft: #30291e;
  --error: #f0a194;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Archivo, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
h1, h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 3.2vw, 2.8rem); line-height: 1.15; }
h2 { font-size: 1.4rem; line-height: 1.25; }
h3 { text-wrap: balance; }
p { text-wrap: pretty; }
.muted { color: var(--muted); line-height: 1.6; }
.eyebrow {
  margin: 0 0 9px;
  color: var(--amber);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* App frame and navigation */
.shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-width: 0;
  padding: 25px 14px 20px;
  background: var(--side);
  border-right: 1px solid var(--line);
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; }
.brand, .login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}
.brand { padding: 0 10px; }
.brand-mark {
  display: inline-grid;
  flex: 0 0 30px;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #6b5130;
  border-radius: 8px;
}
.sidebar nav { margin-top: 36px; overflow-y: auto; }
.nav-primary, .nav-group-links { display: grid; gap: 2px; }
.sidebar nav a, .nav-group summary {
  display: flex;
  align-items: center;
  min-height: 41px;
  padding: 9px 13px;
  color: var(--muted);
  border-radius: 7px;
  font-size: .91rem;
}
.sidebar nav a:hover, .nav-group summary:hover { color: var(--text); background: var(--surface-raised); }
.sidebar nav a[aria-current="page"] { color: var(--text); background: var(--amber-soft); font-weight: 700; }
.nav-secondary { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.nav-group summary { justify-content: space-between; cursor: pointer; list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; font-weight: 400; }
.nav-group[open] summary::after { content: "−"; }
.nav-group-links { padding: 1px 0 9px 13px; }
.nav-group-links a { font-size: .85rem !important; min-height: 37px !important; }
.side-footer { margin-top: auto; padding: 18px 10px 0; color: var(--muted); font-size: .78rem; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #9db784; vertical-align: 1px; }
.nav-toggle { display: none; align-items: center; gap: 12px; padding: 8px 11px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 7px; font-weight: 700; }
.main-wrap { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 61px;
  padding: 10px clamp(24px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}
.topbar-location strong { color: var(--text); font-weight: 600; }
.slash { padding: 0 8px; color: #75786b; }
.top-actions { display: flex; align-items: center; gap: 19px; flex-shrink: 0; }
.top-actions form { margin: 0; }
.text-button { padding: 5px 0; color: var(--muted); background: none; border: 0; font-size: .78rem; }
.text-button:hover { color: var(--text); }
.content { width: 100%; max-width: 1160px; margin: 0 auto; padding: 40px clamp(24px, 4vw, 52px) 80px; }

/* Shared page structure */
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-heading .muted { max-width: 660px; margin: 10px 0 0; }
.detail-heading h1 { max-width: 900px; font-size: clamp(1.8rem, 2.6vw, 2.4rem); overflow-wrap: anywhere; }
.phase-pill, .count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #55432c;
  border-radius: 999px;
  font-size: .73rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.panel, .welcome-panel {
  min-width: 0;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.full-panel { margin-top: 18px; }
.draft-panel { margin-bottom: 18px; }
.panel > h2 + .stack-form { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.panel-head .eyebrow { margin-bottom: 6px; }
.panel-head > a { color: var(--amber); font-size: .78rem; white-space: nowrap; }
.panel-head > a:hover, .empty a:hover, .quick-links a:hover { text-decoration: underline; }
.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row strong { display: block; font-size: .91rem; font-weight: 600; overflow-wrap: anywhere; }
.row p { margin: 5px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.5; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 4px 9px; color: #c0d5a8; background: #293127; border: 1px solid #3e5138; border-radius: 999px; font-size: .7rem; white-space: nowrap; }
.empty { padding: 22px 0 4px; color: var(--muted); line-height: 1.6; }
.empty a, .source-link, .edit-link { color: var(--amber); }
.list-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); align-items: start; gap: 18px; }
.list-grid > .create-panel { grid-column: 2; grid-row: 1; }
.list-grid > .panel:not(.create-panel) { grid-column: 1; grid-row: 1; }
.create-panel h2 { margin-bottom: 10px; }
.create-panel > .muted { margin: 0 0 23px; }
.stack-form { display: grid; gap: 10px; }
.stack-form label, .form-field label { color: #d8d4c8; font-size: .82rem; font-weight: 600; }
.stack-form input, .stack-form textarea, .stack-form select,
.autonomy-form input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: #141612;
  border: 1px solid #494d42;
  border-radius: 7px;
  outline: none;
}
.stack-form textarea { min-height: 94px; resize: vertical; }
.create-panel textarea { height: 118px; }
.create-panel #id_body { height: 190px; }
.stack-form input:focus, .stack-form textarea:focus, .stack-form select:focus,
.autonomy-form input[type="number"]:focus { border-color: var(--amber); box-shadow: 0 0 0 3px #d9a65f24; }
.button { display: inline-flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 43px; padding: 10px 15px; border-radius: 7px; font-size: .84rem; font-weight: 700; line-height: 1.25; }
.button.primary { color: #17130d; background: var(--amber); border: 1px solid var(--amber); }
.button.primary:hover { background: #ebbb7c; }
.button.secondary { color: var(--text); background: var(--surface-raised); border: 1px solid #4a4c42; }
.button.secondary:hover { border-color: #797461; }
.stack-form > .button, .autonomy-form > .button { justify-self: start; margin-top: 9px; }
.form-error { color: var(--error); font-size: .8rem; }
.form-error ul { margin: 4px 0; padding-left: 18px; }
.stack-form .errorlist { margin: 0 0 4px; padding-left: 18px; color: var(--error); font-size: .8rem; }
.notice { margin-bottom: 20px; padding: 14px 17px; color: #e0c89f; background: var(--amber-soft); border: 1px solid #57432b; border-radius: 8px; }
.notice strong { color: var(--text); }
.timestamp { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.research-row { color: inherit; }
.research-row:hover { color: var(--amber); }
.edit-link, .source-link { display: inline-block; margin-top: 9px; font-size: .78rem; }
.timestamp + .edit-link { margin-left: 10px; }
.edit-link:hover, .source-link:hover { text-decoration: underline; }
.report-text { padding-top: 16px; color: var(--text); line-height: 1.75; overflow-wrap: anywhere; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 28px; }
.inline-actions select { padding: 9px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 7px; }
.danger-form { margin-top: 24px; }
.danger-form .text-button { color: var(--error); }
.search-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; max-width: 700px; margin-bottom: 22px; }
.search-form label { grid-column: 1 / -1; }
.form-field { display: grid; gap: 9px; }
.form-field[hidden] { display: none; }
.action-link { width: fit-content; margin-top: 18px; }

/* Overview */
.welcome-panel { padding: 31px 33px 24px; margin-bottom: 18px; }
.welcome-panel h1 { max-width: 720px; }
.welcome-panel > .muted { margin: 10px 0 22px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.welcome-actions .button { min-width: 150px; }
.welcome-status { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 28px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.welcome-status .status-dot { flex: 0 0 auto; }
.welcome-status a { margin-left: auto; color: var(--amber); }
.welcome-status a:hover { text-decoration: underline; }
.attention-panel { margin-bottom: 18px; }
.attention-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.attention-item:last-child { border-bottom: 0; padding-bottom: 0; }
.attention-item div { min-width: 0; }
.attention-item small { display: block; margin-bottom: 5px; color: var(--amber); font-size: .69rem; font-weight: 700; text-transform: uppercase; }
.attention-item strong { display: block; font-size: .9rem; overflow-wrap: anywhere; }
.attention-item p { margin: 4px 0 0; color: var(--muted); font-size: .77rem; line-height: 1.45; }
.attention-item > span { flex: 0 0 auto; color: var(--amber); font-size: .75rem; }
.attention-item:hover strong { text-decoration: underline; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.quick-links { display: flex; flex-wrap: wrap; gap: 12px 23px; margin-top: 20px; color: var(--muted); font-size: .78rem; }

/* Chat, reports, and markdown */
.connection-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; max-width: 850px; margin-bottom: 18px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: .78rem; }
.connection-strip .muted { margin-right: auto; }
.connection-strip a { color: var(--amber); }
.chat-panel { max-width: 850px; }
.messages { min-height: 180px; }
.message { display: flex; gap: 13px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.message-avatar { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; color: var(--amber); background: var(--amber-soft); border-radius: 8px; font-size: .66rem; }
.message > div { min-width: 0; }
.message p { margin: 0 0 8px; line-height: 1.6; }
.message small { color: var(--muted); font-size: .73rem; }
.chat-form { margin-top: 18px; }
.rendered-markdown { overflow-wrap: anywhere; }
.rendered-markdown h2 { margin: 1.4em 0 .5em; font-size: 1.3rem; }
.rendered-markdown h3 { margin: 1.3em 0 .5em; font-size: 1.08rem; }
.rendered-markdown p { margin: 1em 0; }
.rendered-markdown ul, .rendered-markdown ol { padding-left: 1.5em; }
.rendered-markdown li { margin: .35em 0; }
.rendered-markdown a { color: var(--amber); text-decoration: underline; }
.rendered-markdown code { padding: .1em .3em; background: #2b2d26; border-radius: 4px; }
.rendered-markdown pre { overflow: auto; padding: 14px; background: #141612; border: 1px solid var(--line); border-radius: 7px; }
.rendered-markdown pre code { padding: 0; background: transparent; }
.message .rendered-markdown p:first-child { margin-top: 0; }
.message .rendered-markdown p:last-child { margin-bottom: 8px; }

/* Autonomous work */
.autonomy-control { max-width: 860px; margin-bottom: 18px; }
.autonomy-status { margin: 18px 0 19px; }
.autonomy-form { display: grid; gap: 20px; }
.autonomy-options { display: grid; gap: 4px; }
.check-field { display: flex; align-items: center; gap: 11px; min-height: 40px; cursor: pointer; font-size: .88rem; }
.check-field input { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; accent-color: var(--amber); }
.autonomy-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.autonomy-form .form-field label { line-height: 1.4; }
.autonomy-form input[type="number"] { max-width: 120px; }
.autonomy-history { margin-bottom: 18px; }
.autonomy-action { padding: 17px 0; border-bottom: 1px solid var(--line); }
.autonomy-action:last-child { border-bottom: 0; padding-bottom: 0; }
.autonomy-action-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.autonomy-action-head small { color: var(--amber); font-size: .72rem; }
.autonomy-action h3 { margin: 5px 0 0; font-size: 1.03rem; font-weight: 600; }
.autonomy-action p { margin: 9px 0 0; font-size: .82rem; line-height: 1.55; overflow-wrap: anywhere; }
.autonomy-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 11px; }
.autonomy-links a { color: var(--amber); font-size: .78rem; }
.autonomy-links a:hover { text-decoration: underline; }
.disclosure { max-width: 860px; margin: 0 0 12px; padding: 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.disclosure > summary { padding: 15px 0; color: var(--text); cursor: pointer; font-weight: 600; }
.disclosure > summary:hover { color: var(--amber); }
.disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.disclosure > .muted { margin: 13px 0 17px; font-size: .82rem; }
.older-proposals { max-width: none; margin: 16px 0 0; }
.action-factors { margin-top: 9px; color: var(--muted); font-size: .75rem; }
.action-factors summary { width: fit-content; cursor: pointer; }
.action-factors p { margin: 5px 0 0; }
.autonomy-steps { padding-left: 21px; margin: 15px 0; line-height: 1.6; }
.autonomy-steps li { margin: 8px 0; }

/* Sign in */
.login-wrap { display: grid; min-height: 100dvh; place-items: center; padding: 20px; }
.login-card { width: min(100%, 430px); padding: 37px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.login-brand { margin-bottom: 38px; }
.login-card h1 { font-size: 2.3rem; }
.login-card .muted { margin: 9px 0 25px; }
.login-foot { margin: 25px 0 0; color: var(--muted); text-align: center; font-size: .75rem; }

@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar { position: relative; height: auto; padding: 15px 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { margin-top: 15px; overflow: visible; }
  .sidebar.has-nav-toggle .nav-toggle { display: inline-flex; }
  .sidebar.has-nav-toggle #workspace-nav { display: none; }
  .sidebar.has-nav-toggle.nav-open #workspace-nav { display: block; max-height: calc(100dvh - 95px); overflow-y: auto; }
  .nav-primary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .nav-secondary { margin-top: 12px; padding-top: 9px; }
  .side-footer { display: none; }
  .content { max-width: 920px; padding-top: 30px; }
}

@media (max-width: 760px) {
  .list-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .list-grid > .create-panel, .list-grid > .panel:not(.create-panel) { grid-column: auto; grid-row: auto; }
  .search-form { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .sidebar { padding: 13px 16px; }
  .brand { padding: 0; font-size: .92rem; }
  .nav-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { min-height: 50px; padding: 8px 16px; font-size: .73rem; }
  .topbar-location { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { gap: 11px; }
  .content { padding: 27px 16px 60px; }
  .page-heading { flex-direction: column; gap: 13px; margin-bottom: 22px; }
  .panel, .welcome-panel { padding: 19px; }
  .welcome-panel > .muted { margin-bottom: 20px; }
  .welcome-actions .button { width: 100%; }
  .welcome-status a { margin-left: 15px; }
  .attention-item { align-items: flex-start; flex-direction: column; gap: 6px; }
  .autonomy-limits { grid-template-columns: 1fr; gap: 14px; }
  .autonomy-action-head { flex-direction: column; gap: 8px; }
  .login-card { padding: 27px; }
}
