:root {
  --bg: #f7f2ea;
  --surface: #fffdf8;
  --surface-2: #fdf7ee;
  --ink: #2d2118;
  --muted: #6d5d4;
  --line: #e6dacb;
  --brand: #32513b;
  --brand-dark: #203629;
  --brand-2: #886a35;
  --brand-3: #ece1cf;
  --danger: #9f2f2f;
  --warning: #7a4d00;
  --shadow: 0 16px 35px rgba(45, 33, 24, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff8e8 0, var(--bg) 42%, #f1e6d9 100%);
  color: var(--ink);
  min-height: 100vh;
}
a { color: var(--brand); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.skip-link { position: absolute; top: -80px; left: 1rem; background: var(--ink); color: white; padding: .75rem 1rem; border-radius: 999px; z-index: 100; }
.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  background: rgba(247, 242, 234, .92);
  border-bottom: 1px solid rgba(230, 218, 203, .9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 3vw, 2.5rem);
}
.brand-block { display: flex; align-items: center; gap: .85rem; min-width: 220px; }
.brand-mark { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; background: var(--brand); color: white; font-weight: 800; box-shadow: var(--shadow); }
.brand-block h1 { font-size: clamp(1.1rem, 2vw, 1.45rem); margin: .1rem 0 0; line-height: 1.1; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; color: var(--brand-2); font-size: .73rem; font-weight: 800; margin: 0 0 .35rem; }
.primary-nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.primary-nav a {
  position: relative;
  text-decoration: none;
  color: var(--ink);
  font-weight: 750;
  padding: .62rem .75rem;
  border-radius: 999px;
  font-size: .92rem;
}
.primary-nav a:hover, .primary-nav a:focus, .primary-nav a.active { background: var(--brand-3); color: var(--brand-dark); outline: none; }
.primary-nav a[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -3.05rem;
  width: max-content;
  max-width: 260px;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: .55rem .7rem;
  font-size: .78rem;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, bottom .16s ease;
  box-shadow: var(--shadow);
  z-index: 50;
}
.primary-nav a[data-tip]:hover::after, .primary-nav a[data-tip]:focus::after { opacity: 1; bottom: -3.35rem; }
.menu-toggle { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .65rem 1rem; font-weight: 800; }

main { width: min(1180px, calc(100% - 2rem)); margin: 1.5rem auto 4rem; }
.view { display: none; animation: fadeIn .18s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.hero-card, .section-header, .form-card, .notice-card, .workspace-card, .stat-card, .admin-card, .post-card, .task-card, .record-item, .help-card {
  background: rgba(255, 253, 248, .92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card { display: grid; grid-template-columns: 1.6fr .9fr; gap: 1.5rem; padding: clamp(1.25rem, 3vw, 2.25rem); }
h2 { font-size: clamp(1.55rem, 3vw, 2.45rem); margin: .1rem 0 .65rem; line-height: 1.08; }
h3 { margin: 0 0 .45rem; }
p { line-height: 1.55; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 760px; }
.privacy-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 1.25rem; }
.privacy-card ul { padding-left: 1.25rem; }
.hero-actions, .section-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.button, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: .78rem 1rem;
  text-decoration: none;
  font-weight: 850;
  min-height: 42px;
}
.button.primary { background: var(--brand); color: white; border-color: var(--brand); }
.button.ghost { background: rgba(255, 255, 255, .55); }
.link-button { border: 0; color: var(--brand); padding: 0; background: transparent; min-height: 0; }
.button:hover, .link-button:hover { filter: brightness(.98); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .9rem; margin: 1rem 0; }
.stat-card { padding: 1rem; text-align: center; }
.stat-card span { display: block; font-size: 2rem; font-weight: 900; color: var(--brand); }
.stat-card p { margin: .2rem 0 0; color: var(--muted); font-weight: 750; }
.workspace-grid, .admin-grid, .help-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1rem; }
.workspace-card, .admin-card, .help-card { padding: 1.2rem; }
.workspace-card p, .help-card p { color: var(--muted); }
.notice-card { padding: 1rem 1.15rem; margin: 1rem 0; }
.notice-card.warning { border-color: #d8ac6b; background: #fff5df; color: var(--warning); }

.section-header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: 1.25rem; margin-bottom: 1rem; }
.breadcrumb { margin: 0 0 .55rem; color: var(--muted); font-size: .92rem; }
.breadcrumb a { font-weight: 800; }
.helper-text { margin: 0; color: var(--muted); max-width: 850px; }
.help-dot {
  width: 24px; height: 24px; border-radius: 999px; border: 1px solid var(--brand-2); background: #fff7e6; color: var(--brand-2); font-weight: 900; vertical-align: middle; margin-left: .25rem;
}
.tool-row { display: grid; grid-template-columns: 1.2fr .7fr .7fr; gap: .85rem; align-items: end; margin: 1rem 0; }
label span { display: block; font-weight: 800; margin: 0 0 .35rem; color: var(--ink); }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 14px; padding: .78rem .9rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(50,81,59,.18); border-color: var(--brand); }

.form-card { padding: 1.25rem; margin: 1rem 0; }
.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: .95rem; }
.grid-form .full { grid-column: 1 / -1; }
.post-list, .task-list, .record-list { display: grid; gap: 1rem; margin-top: 1rem; }
.post-card, .task-card, .record-item { padding: 1.15rem; }
.post-topline, .task-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.post-meta, .task-meta { color: var(--muted); font-size: .88rem; font-weight: 760; margin: 0 0 .25rem; }
.status-pill { display: inline-flex; align-items: center; background: var(--brand-3); color: var(--brand-dark); border-radius: 999px; padding: .45rem .65rem; font-size: .82rem; font-weight: 900; white-space: nowrap; }
.post-body, .task-notes { white-space: pre-wrap; }
.evidence-block, .suggestion-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: .9rem; margin: .75rem 0; color: var(--muted); }
.post-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.post-actions button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .55rem .75rem; font-weight: 800; }
.post-actions button.danger { color: var(--danger); }
.task-card { border-left: 6px solid var(--brand); }
.land-record { border-left: 6px solid var(--brand-2); }
.intake-record { border-left: 6px solid #3f5d86; }
.raw-details { margin: .75rem 0; }
.raw-details summary { cursor: pointer; font-weight: 850; color: var(--brand); }
.raw-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: .85rem; max-height: 260px; overflow: auto; }
.memory-record { border-left: 6px solid #6d5d4f; }
.workflow-list { margin: 0; padding-left: 1.25rem; }
.workflow-list li { margin: .25rem 0; }

.modal-card { border: 0; padding: 0; border-radius: var(--radius); width: min(760px, calc(100% - 2rem)); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal-card::backdrop { background: rgba(32, 28, 21, .48); }
.modal-shell { margin: 0; background: var(--surface); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.2rem; }
.icon-button { border: 0; background: var(--brand-3); border-radius: 999px; width: 36px; height: 36px; font-size: 1.25rem; }
.ai-preview { background: var(--surface-2); border: 1px dashed var(--brand-2); border-radius: 16px; padding: 1rem; }
.ai-preview p { margin-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: .85rem 1rem; border-radius: 14px; box-shadow: var(--shadow); max-width: min(640px, calc(100% - 2rem)); z-index: 90; opacity: 0; transition: transform .2s ease, opacity .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  .site-header { align-items: flex-start; }
  .menu-toggle { display: inline-flex; }
  .primary-nav { display: none; position: absolute; top: 78px; left: 1rem; right: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: .75rem; box-shadow: var(--shadow); flex-direction: column; align-items: stretch; }
  .primary-nav.open { display: flex; }
  .primary-nav a[data-tip]::after { display: none; }
  .hero-card, .workspace-grid, .admin-grid, .help-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; }
  .tool-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { width: min(100% - 1rem, 1180px); margin-top: .75rem; }
  .brand-mark { width: 44px; height: 44px; border-radius: 15px; }
  .brand-block { min-width: 0; }
  .brand-block h1 { font-size: 1.05rem; }
  .eyebrow { font-size: .66rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .post-topline, .task-topline { flex-direction: column; }
  .button { width: 100%; }
  .hero-actions .button, .section-actions .button { width: auto; }
}

.upload-box {
  border: 1px dashed var(--brand-2);
  border-radius: 18px;
  padding: 1rem;
  background: #fff8e8;
}
.upload-box input[type="file"] {
  background: #fff;
  border-style: dashed;
}
.upload-box small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  margin-top: .45rem;
}
.file-status {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 760;
  padding: .8rem .9rem;
}

.ask-ai-record { border-left: 6px solid #7a5e99; }
.ask-answer { white-space: pre-wrap; }
.ask-matches ul, .ask-next-steps ul { margin-bottom: 0; }
