/* ─── Ta-ala Legal Portal — Ledger Light · Modern ────────────────────────────
   The approved campaign system (Gloock monuments, Geist Mono evidence, warm
   paper #FAF8F3, ink #16150F) modernized: Claude-style grotesque for all UI,
   SwiftUI-rounded surfaces, dark ink buttons, sage/olive in place of green.
   Aesop store meets Aman resorts: earthy, quiet, certain. */

:root {
  /* paper & ink — from the approved deck */
  --paper: #faf8f3;
  --paper-2: #f3f0e7;
  --paper-3: #ece8db;
  --ink: #16150f;
  --ink-2: #2b291f;          /* button hover */
  --ink-soft: #57534a;
  --grey: #8a8474;           /* warm olive-grey */
  /* dried sage / khaki-olive — desaturated, never green-green */
  --olive: #63604a;          /* primary accent — dried olive */
  --olive-deep: #4a4836;
  --sage: #a29f8a;
  --sage-tint: rgba(99, 96, 74, 0.09);
  --sage-ring: rgba(99, 96, 74, 0.18);
  --red: #7a2e1d;
  --hair: rgba(22, 21, 15, 0.13);
  --hair-strong: rgba(22, 21, 15, 0.24);
  /* type — Claude grotesque UI · Gloock monuments · Geist Mono evidence */
  --sans: "Styrene B", "Styrene A", "Space Grotesk", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Gloock", "New York", Georgia, "Times New Roman", serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* SwiftUI-continuous radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;
  --shadow-soft: 0 1px 2px rgba(22, 21, 15, 0.04), 0 10px 30px rgba(22, 21, 15, 0.06);
  --sidebar-w: 268px;
  --sidebar-w-min: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--olive); color: var(--paper); }

/* whispered register — evidence captions */
.mono-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--grey);
}
.mono-label.ink { color: var(--ink-soft); }
.mono-label.green { color: var(--olive); }

/* monumental register — Gloock, used sparingly */
.display { font-family: var(--serif); font-weight: 400; letter-spacing: 0; }

.hairline { border: 0; border-top: 1px solid var(--hair); }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--olive); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── buttons — dark, rounded, SwiftUI ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 500; letter-spacing: 0.01em;
  padding: 10px 18px; border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--paper-2); color: var(--ink); transition: all .16s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-3); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); }
.btn.small { padding: 7px 13px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn.ghost { background: transparent; color: var(--grey); }
.btn.ghost:hover { color: var(--ink); background: var(--paper-2); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--sage-ring);
}

/* ── inputs ── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field input, .field textarea, .field select {
  background: rgba(255, 255, 255, .6); border: 1px solid var(--hair);
  border-radius: var(--r-sm); padding: 11px 14px; outline: none;
  font-family: var(--sans); font-size: 15px; transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--olive); box-shadow: 0 0 0 3px var(--sage-ring);
}

/* ═══ LOGIN ═══ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px;
}
.login-card { width: 460px; max-width: 100%; }
.login-mast { text-align: center; margin-bottom: 40px; }
.login-mast .rule-word {
  display: flex; align-items: center; gap: 14px; justify-content: center; margin-bottom: 22px;
}
.login-mast .rule-word::before, .login-mast .rule-word::after {
  content: ""; height: 1px; background: var(--hair-strong); flex: 1;
}
.login-mast h1 { font-family: var(--serif); font-size: 62px; font-weight: 400; line-height: 1; letter-spacing: 0.005em; }
.login-mast h1 .accent { color: var(--olive); font-style: normal; }
.login-box {
  border: 1px solid var(--hair); background: rgba(255, 255, 255, .45);
  border-radius: var(--r-lg); box-shadow: var(--shadow-soft); padding: 34px 34px 28px;
}
.login-tabs { display: flex; gap: 6px; margin-bottom: 26px; background: var(--paper-2); border-radius: var(--r-md); padding: 4px; }
.login-tabs button {
  flex: 1; padding: 9px 0; font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--grey); border-radius: var(--r-sm); transition: all .15s ease;
}
.login-tabs button.active { color: var(--ink); background: var(--paper); box-shadow: 0 1px 3px rgba(22,21,15,.08); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error { color: var(--red); font-size: 14px; min-height: 20px; }
.fb-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border: 1px solid var(--hair-strong); border-radius: var(--r-md); padding: 11px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 500; transition: all .15s ease;
}
.fb-btn:hover { border-color: var(--ink); background: rgba(255,255,255,.5); }
.login-foot { margin-top: 26px; text-align: center; }

/* ═══ APP SHELL ═══ */
#app { display: none; height: 100vh; }
#app.on { display: flex; }

/* ── sidebar ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; height: 100%;
  border-right: 1px solid var(--hair);
  display: flex; flex-direction: column;
  background: var(--paper-2);
  transition: width .22s ease;
  overflow: hidden;
}
.sidebar.min { width: var(--sidebar-w-min); }
.side-mast { padding: 22px 20px 18px; border-bottom: 1px solid var(--hair); }
.side-mast .brand { font-family: var(--serif); font-size: 24px; font-weight: 400; line-height: 1.05; white-space: nowrap; }
.side-mast .brand em { color: var(--olive); font-style: normal; }
.sidebar.min .side-mast .brand-full { display: none; }
.side-mast .brand-min { display: none; font-family: var(--serif); font-weight: 400; font-size: 24px; }
.sidebar.min .side-mast .brand-min { display: block; text-align: center; }
.side-mast .mono-label { margin-top: 5px; }
.sidebar.min .side-mast .mono-label { display: none; }

.side-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-section { padding: 12px 12px 6px; }
.sidebar.min .nav-section { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; color: var(--ink-soft); text-align: left;
  border-radius: var(--r-md); font-size: 14.5px; font-weight: 450;
  transition: all .13s ease; margin-bottom: 2px;
}
.nav-item .ni-ico { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .55); color: var(--ink); }
.nav-item.active { color: var(--olive-deep); background: var(--sage-tint); font-weight: 500; }
.nav-item .ni-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.min .nav-item { justify-content: center; padding: 13px 0; }
.sidebar.min .nav-item .ni-label, .sidebar.min .nav-item .ni-badge { display: none; }
.ni-badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--olive);
  background: var(--sage-tint); border-radius: var(--r-pill); padding: 2px 8px;
}
.nav-case { padding-left: 34px; font-size: 14px; }
.sidebar.min .nav-case { display: none; }

.side-foot { border-top: 1px solid var(--hair); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--paper);
}
.side-foot .sf-name { flex: 1; min-width: 0; }
.side-foot .sf-name div:first-child { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.min .sf-name, .sidebar.min .sf-out { display: none; }
.side-collapse {
  width: 100%; padding: 10px; border-top: 1px solid var(--hair);
  font-family: var(--mono); font-size: 11px; color: var(--grey); letter-spacing: .1em;
}
.side-collapse:hover { color: var(--ink); }

/* ── main ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.view { flex: 1; overflow-y: auto; padding: 44px 52px; }

/* ═══ DASHBOARD ═══ */
.dash-hello { margin-bottom: 8px; }
.dash-hello h2 { font-family: var(--serif); font-size: 42px; font-weight: 400; line-height: 1.1; }
.dash-hello h2 em { color: var(--olive); font-style: normal; }
.dash-sub { color: var(--grey); margin-top: 6px; font-size: 15px; }
.dash-stats {
  display: flex; gap: 14px; margin: 34px 0;
}
.stat {
  flex: 1; padding: 22px 26px; background: rgba(255, 255, 255, .5);
  border: 1px solid var(--hair); border-radius: var(--r-lg);
}
.stat .num { font-family: var(--serif); font-size: 42px; font-weight: 400; line-height: 1; }
.stat .num.green { color: var(--olive); }
.stat .mono-label { margin-top: 10px; }

.case-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; margin-top: 18px; }
.case-card {
  border: 1px solid var(--hair); background: rgba(255, 255, 255, .5);
  border-radius: var(--r-lg); padding: 26px; cursor: pointer;
  transition: all .16s ease; position: relative;
}
.case-card:hover { border-color: var(--hair-strong); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.case-card h3 { font-family: var(--sans); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 10px 0 8px; }
.case-card p { color: var(--ink-soft); font-size: 14px; max-height: 63px; overflow: hidden; }
.case-card .cc-foot { display: flex; gap: 16px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hair); }
.stamp {
  display: inline-block; font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase;
  border-radius: var(--r-pill); padding: 4px 11px; background: var(--paper-2); color: var(--ink-soft);
}
.stamp.active { color: var(--olive-deep); background: var(--sage-tint); }
.stamp.monitoring { color: #7a6420; background: rgba(122, 100, 32, .1); }
.stamp.closed { color: var(--grey); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 40px; }
.section-head h4 { font-family: var(--sans); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

/* ═══ CASE VIEW ═══ */
.case-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.case-head {
  padding: 20px 30px 16px; border-bottom: 1px solid var(--hair);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.case-head h2 { font-family: var(--serif); font-size: 24px; font-weight: 400; }
.case-head .presence { margin-left: auto; display: flex; align-items: center; }
.presence .avatar { width: 28px; height: 28px; font-size: 10px; margin-left: -7px; border: 2px solid var(--paper); }
.presence .avatar:first-child { margin-left: 0; }
.presence .p-count { margin-left: 10px; }

.case-body { flex: 1; display: flex; min-height: 0; }
.pane-chat { flex: 1.15; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--hair); }
.pane-work { flex: 1; min-width: 0; display: flex; flex-direction: column; background: rgba(255, 255, 255, .25); }

/* chat */
.chat-scroll { flex: 1; overflow-y: auto; padding: 26px 30px; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 92%; }
.msg .m-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.msg .m-author { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.msg .m-title { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--grey); }
.msg .m-time { font-family: var(--mono); font-size: 9.5px; color: var(--grey); margin-left: auto; }
.msg .m-body { font-size: 15px; }
.msg .m-body p { margin-bottom: 8px; }
.msg .m-body p:last-child { margin-bottom: 0; }
.msg .m-body strong { font-weight: 600; }
.msg .m-body code { font-family: var(--mono); font-size: 12.5px; background: var(--paper-2); border-radius: 5px; padding: 1px 5px; }
.msg .m-body ul, .msg .m-body ol { padding-left: 22px; margin: 6px 0; }
.msg .m-body h1, .msg .m-body h2, .msg .m-body h3 { font-family: var(--sans); font-weight: 600; font-size: 16px; margin: 10px 0 4px; }
.msg.agent { border-left: 2px solid var(--sage); padding-left: 14px; }
.msg.agent .m-author { color: var(--olive-deep); }
.msg.system { align-self: center; text-align: center; max-width: 84%; }
.msg.system .m-body { font-size: 13px; color: var(--grey); }
.msg.me { align-self: flex-end; }
.msg.me .m-body {
  background: var(--sage-tint); border: 1px solid var(--sage-ring);
  border-radius: var(--r-md); border-bottom-right-radius: 6px; padding: 10px 14px;
}
.msg .file-chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px;
  border: 1px solid var(--hair); border-radius: var(--r-sm); background: rgba(255,255,255,.5);
  padding: 8px 12px; font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: all .14s ease;
}
.file-chip:hover { border-color: var(--olive); color: var(--olive-deep); }

.agent-status {
  padding: 8px 30px; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--olive);
  border-top: 1px solid var(--hair); display: none; align-items: center; gap: 10px;
}
.agent-status.on { display: flex; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.composer { border-top: 1px solid var(--hair); padding: 16px 30px 20px; }
.composer .c-box { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--hair); border-radius: var(--r-md);
  background: rgba(255, 255, 255, .65); padding: 12px 15px; min-height: 48px; max-height: 160px;
  outline: none; font-size: 15px; transition: border-color .15s ease, box-shadow .15s ease;
}
.composer textarea:focus { border-color: var(--olive); box-shadow: 0 0 0 3px var(--sage-ring); }
.composer .c-hint { margin-top: 8px; display: flex; gap: 14px; align-items: center; }

/* workspace */
.work-tabs { display: flex; gap: 6px; padding: 12px 18px 0; border-bottom: 1px solid var(--hair); }
.work-tabs button {
  padding: 9px 16px 11px; font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--grey); border-radius: var(--r-sm) var(--r-sm) 0 0; transition: all .14s ease;
}
.work-tabs button:hover { color: var(--ink); }
.work-tabs button.active { color: var(--olive-deep); background: var(--sage-tint); }
.work-body { flex: 1; overflow-y: auto; padding: 22px 26px; }
.work-actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

.file-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 10px;
  border-radius: var(--r-md); cursor: pointer; transition: background .13s ease;
}
.file-row:hover { background: rgba(255, 255, 255, .6); }
.file-row + .file-row { border-top: 1px solid var(--hair); }
.file-row .f-ico { font-size: 17px; width: 24px; text-align: center; }
.file-row .f-name { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 450; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .f-meta { font-family: var(--mono); font-size: 10px; color: var(--grey); white-space: nowrap; }
.file-row .f-del { color: var(--grey); font-size: 13px; padding: 4px 8px; border-radius: var(--r-sm); }
.file-row .f-del:hover { color: var(--red); background: var(--paper-2); }

.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--hair); }
.task-check {
  width: 18px; height: 18px; border: 1.5px solid var(--hair-strong); border-radius: 7px;
  flex-shrink: 0; margin-top: 3px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--paper); transition: all .14s ease;
}
.task-row.done .task-check { background: var(--olive); border-color: var(--olive); }
.task-row.in_progress .task-check { border-color: var(--olive); color: var(--olive); }
.task-row .t-title { flex: 1; font-size: 14.5px; }
.task-row.done .t-title { color: var(--grey); text-decoration: line-through; }
.task-row .t-assignee { font-family: var(--mono); font-size: 10px; color: var(--olive); white-space: nowrap; }
.task-add { display: flex; gap: 10px; margin-bottom: 16px; }
.task-add input {
  flex: 1; border: 1px solid var(--hair); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .6); padding: 9px 13px; outline: none;
}
.task-add input:focus { border-color: var(--olive); box-shadow: 0 0 0 3px var(--sage-ring); }

.brief-block { margin-bottom: 26px; }
.brief-block p { color: var(--ink-soft); font-size: 15px; margin-top: 8px; }
.roster-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--hair); }

/* ═══ editor modal ═══ */
.modal-back {
  position: fixed; inset: 0; background: rgba(22, 21, 15, .4); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 30px;
  backdrop-filter: blur(3px);
}
.modal-back.on { display: flex; }
.modal {
  background: var(--paper); border: 1px solid var(--hair-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft); width: 860px; max-width: 100%;
  max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--hair); }
.modal-head .mh-name { font-family: var(--sans); font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { flex: 1; overflow: auto; min-height: 300px; }
.modal-body textarea {
  width: 100%; height: 100%; min-height: 460px; border: 0; outline: none; resize: none;
  background: transparent; padding: 24px 28px; font-family: var(--mono); font-size: 13.5px; line-height: 1.65;
}
.modal-body .doc-render { padding: 28px 34px; }
.doc-render h1, .doc-render h2 { font-family: var(--serif); font-weight: 400; margin: 18px 0 8px; }
.doc-render h3 { font-family: var(--sans); font-weight: 600; margin: 14px 0 6px; }
.doc-render p { margin-bottom: 10px; }
.doc-render ul, .doc-render ol { padding-left: 24px; margin-bottom: 10px; }
.doc-render code { font-family: var(--mono); font-size: 12.5px; background: var(--paper-2); border-radius: 5px; padding: 1px 5px; }
.doc-render hr { border: 0; border-top: 1px solid var(--hair); margin: 16px 0; }

/* ═══ MEMBERS ═══ */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; margin-top: 26px; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--hair); }
.member-row .m-name { flex: 1; min-width: 0; }
.member-row .m-name div:first-child { font-weight: 500; }
.member-row .m-name div:last-child { font-family: var(--mono); font-size: 10px; color: var(--grey); }
.invite-code {
  font-family: var(--mono); font-size: 13px; color: var(--olive-deep); letter-spacing: .08em;
  background: var(--sage-tint); border: 1px dashed var(--sage); border-radius: var(--r-sm);
  padding: 4px 10px; cursor: pointer;
}
.invite-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--hair); font-size: 13.5px; }
.form-stack {
  display: flex; flex-direction: column; gap: 14px;
  border: 1px solid var(--hair); border-radius: var(--r-lg);
  padding: 22px; background: rgba(255, 255, 255, .5);
}

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: 13px; font-weight: 500;
  border-radius: var(--r-pill); padding: 11px 22px; z-index: 99; display: none;
  box-shadow: var(--shadow-soft);
}
.toast.on { display: block; }

.empty { color: var(--grey); padding: 22px 0; }

/* ═══ responsive ═══ */
@media (max-width: 1060px) {
  .case-body { flex-direction: column; }
  .pane-chat { border-right: 0; border-bottom: 1px solid var(--hair); flex: 1; }
  .pane-work { flex: 1; }
  .view { padding: 28px 22px; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 40; background: var(--paper-2); height: 100%; box-shadow: 8px 0 30px rgba(0, 0, 0, .12); }
  .sidebar.min { width: 0; border-right: 0; }
  .dash-hello h2 { font-size: 30px; }
  .dash-stats { flex-wrap: wrap; }
  .stat { min-width: 45%; }
}
