:root {
  --ink: #251d18;
  --muted: #7d7068;
  --paper: #f6efe5;
  --panel: rgba(255, 250, 241, .78);
  --line: rgba(61, 44, 34, .12);
  --sage: #8fa88a;
  --moss: #536f4b;
  --clay: #d68b62;
  --rose: #e9b7a5;
  --shadow: 0 24px 80px rgba(62, 45, 30, .18);
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: Athelas, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  background:
    radial-gradient(circle at 13% 8%, rgba(214,139,98,.42), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(143,168,138,.52), transparent 24rem),
    linear-gradient(135deg, #f8f0e4 0%, #efe1d1 55%, #e8d7ca 100%);
}
body::before { content:""; position:fixed; inset:0; pointer-events:none; opacity:.34; background-image: radial-gradient(rgba(37,29,24,.16) .7px, transparent .7px); background-size: 7px 7px; mix-blend-mode:multiply; }
button, input { font: inherit; }
.shell { min-height: 100vh; padding: clamp(18px, 3vw, 42px); display: grid; place-items: center; }
.login, .portal { width: min(1180px, 100%); }
.login { max-width: 620px; padding: clamp(28px, 5vw, 56px); border: 1px solid var(--line); background: var(--panel); border-radius: 34px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.brandmark { width: 74px; height: 74px; display:grid; place-items:center; border-radius: 24px 24px 24px 8px; background: var(--ink); color: var(--paper); letter-spacing:.08em; font-weight: 800; }
.brandmark.small { width: 48px; height: 48px; border-radius: 17px 17px 17px 6px; font-size: 14px; }
.eyebrow { margin: 0 0 8px; color: var(--moss); text-transform: uppercase; letter-spacing: .16em; font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
h1, h2 { margin: 0; line-height: .96; letter-spacing: -.045em; }
.login h1 { margin-top: 24px; font-size: clamp(42px, 8vw, 78px); }
.muted, .side-copy { color: var(--muted); font-size: 18px; line-height: 1.45; }
.login-form { display:flex; gap: 10px; margin-top: 28px; }
input { width: 100%; border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; background: rgba(255,255,255,.54); color: var(--ink); outline: none; }
input:focus { border-color: rgba(83,111,75,.55); box-shadow: 0 0 0 5px rgba(143,168,138,.18); }
button { border: 0; cursor: pointer; border-radius: 18px; padding: 15px 20px; background: var(--ink); color: var(--paper); transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
button:hover, .action-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(61,44,34,.14); }
.error { color: #9b3c2f; min-height: 1.2em; }
.portal { display:grid; grid-template-columns: 260px minmax(0, 1fr) 310px; gap: 18px; align-items: stretch; }
.side-card, .chat-card, .actions { border: 1px solid var(--line); background: var(--panel); border-radius: 34px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.side-card { padding: 24px; display:flex; flex-direction:column; min-height: 720px; }
.topline { display:flex; align-items:center; gap: 14px; }
.topline h2 { font-size: 34px; }
.status-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; margin-bottom: 14px; }
.status-grid div { padding: 16px; border:1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.28); }
.status-grid span { display:block; font-size: 30px; font-weight: 800; }
.status-grid small { color: var(--muted); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.chat-card { padding: 22px; min-height: 720px; display:flex; flex-direction:column; }
.chat-head { display:flex; justify-content:space-between; gap:18px; padding: 6px 6px 18px; border-bottom: 1px solid var(--line); }
.chat-head h1 { font-size: clamp(34px, 5vw, 60px); max-width: 620px; }
.live-dot { height: fit-content; display:flex; align-items:center; gap: 8px; padding: 9px 12px; border-radius: 999px; background: rgba(143,168,138,.18); color: var(--moss); font: 700 12px ui-monospace, monospace; text-transform:uppercase; letter-spacing:.08em; }
.live-dot span { width: 8px; height: 8px; border-radius:50%; background: var(--sage); box-shadow: 0 0 0 6px rgba(143,168,138,.18); }
.messages { flex:1; overflow:auto; padding: 24px 6px; display:flex; flex-direction:column; gap: 12px; }
.bubble { max-width: 76%; padding: 14px 16px; border-radius: 20px; line-height:1.38; animation: appear .28s ease both; }
.bubble.assistant { align-self:flex-start; background: rgba(255,255,255,.55); border: 1px solid var(--line); border-bottom-left-radius: 7px; }
.bubble.user { align-self:flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 7px; }
.composer { display:flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions { padding: 18px; display:flex; flex-direction:column; gap: 12px; }
.action-card { width:100%; text-align:left; color: var(--ink); background: rgba(255,255,255,.36); border:1px solid var(--line); border-radius: 28px; padding: 20px; min-height: 116px; display:flex; flex-direction:column; justify-content:space-between; }
.action-card span { color: var(--clay); font: 800 12px ui-monospace, monospace; letter-spacing:.12em; }
.action-card strong { font-size: 24px; letter-spacing:-.03em; }
.action-card em { color: var(--muted); font-style: normal; }
.action-card.warm { background: linear-gradient(135deg, rgba(214,139,98,.18), rgba(255,255,255,.36)); }
.files { margin-top:auto; padding: 18px; border-radius: 24px; background: rgba(37,29,24,.06); border: 1px solid var(--line); max-height: 230px; overflow:auto; }
.files-list { display:flex; flex-direction:column; gap: 8px; }
.file-row { color: var(--ink); text-decoration:none; padding: 10px 0; border-top: 1px solid var(--line); display:block; }
.file-row small { display:block; color: var(--muted); margin-top: 2px; }
@keyframes appear { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }
@media (max-width: 980px) { .portal { grid-template-columns: 1fr; } .side-card, .chat-card { min-height: auto; } .actions { order: 2; } .side-card { order: 3; } }
@media (max-width: 620px) { .shell { padding: 10px; } .login-form, .composer { flex-direction: column; } .login, .side-card, .chat-card, .actions { border-radius: 24px; } .bubble { max-width: 92%; } }

/* Security/UX guard: before authentication, the app shell must not be visible below the login card. */
[hidden] { display: none !important; }
body:has(#loginPanel:not([hidden])) { overflow: hidden; }
body:has(#loginPanel:not([hidden])) .shell { min-height: 100svh; }
