:root {
  --ink: #18313d;
  --ink-soft: #49616a;
  --paper: #f5f1e8;
  --paper-light: #fffdf8;
  --line: #d9d1c1;
  --sage: #809274;
  --sage-soft: #dfe6d7;
  --blue: #436477;
  --shadow: 0 24px 70px rgba(24, 49, 61, .12);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 85% 6%, rgba(128, 146, 116, .18), transparent 29rem),
    linear-gradient(135deg, #f8f5ed 0%, #eee9dd 100%);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1380px, calc(100% - 48px)); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 88px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 24px; border-bottom: 1px solid rgba(24,49,61,.12); }
.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 13px; min-width: 0; justify-self: start; }
.brand-mark { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--ink); font-family: Georgia, serif; letter-spacing: .06em; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; font-weight: 500; }
.brand:focus-visible { outline: 3px solid rgba(67,100,119,.25); outline-offset: 4px; border-radius: 4px; }
.project-nav { display: flex; align-items: center; gap: 3px; grid-column: 2; justify-self: center; }
.project-nav-item { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; min-height: 44px; border: 0; border-radius: 10px; padding: 0 16px; color: var(--ink-soft); background: transparent; font-size: .9rem; font-weight: 720; white-space: nowrap; }
.project-nav-item:hover { color: var(--ink); background: rgba(128,146,116,.11); }
.project-nav-item.active { color: var(--ink); background: var(--sage-soft); }
.project-nav-item:focus-visible { outline: 3px solid rgba(67,100,119,.25); outline-offset: 2px; }
.status { display: inline-flex; gap: 9px; align-items: center; color: var(--ink-soft); font-size: .86rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #cf9a4b; box-shadow: 0 0 0 5px rgba(207,154,75,.13); }
.status.ready .status-dot { background: #6d8f5d; box-shadow: 0 0 0 5px rgba(109,143,93,.13); }

main { flex: 1; padding: 58px 0 40px; }
.hero { max-width: 780px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 10px; color: var(--sage); font-size: .76rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; margin: 0; }
h1 { font-size: clamp(2.5rem, 6vw, 5rem); line-height: .98; letter-spacing: -.035em; max-width: 820px; }
.hero > p:last-child { color: var(--ink-soft); line-height: 1.7; font-size: 1.02rem; max-width: 680px; margin: 24px 0 0; }

.panel, .chat-card, .context-card { border: 1px solid rgba(24,49,61,.13); background: rgba(255,253,248,.88); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.auth-panel { border-radius: 24px; padding: clamp(24px, 5vw, 52px); display: grid; grid-template-columns: 1fr minmax(280px, 430px); gap: 60px; align-items: center; }
.auth-panel[hidden], .chat-layout[hidden], .codex-auth-panel[hidden], .chat-card[hidden] { display: none; }
.auth-panel h2, .chat-heading h2 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
.auth-panel p { color: var(--ink-soft); line-height: 1.6; }
form label { display: block; font-weight: 700; font-size: .84rem; margin-bottom: 8px; }
input, textarea { width: 100%; border: 1px solid var(--line); color: var(--ink); background: white; border-radius: 13px; outline: none; }
input { min-height: 52px; padding: 0 15px; }
input:focus, textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 4px rgba(128,146,116,.13); }
form button, .composer button { border: 0; border-radius: 13px; color: white; background: var(--ink); font-weight: 750; padding: 15px 20px; }
.auth-panel form > button { width: 100%; margin-top: 14px; }
.form-message { min-height: 24px; margin: 10px 0 0 !important; color: #9d3e38 !important; font-size: .88rem; }

.chat-layout { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 22px; align-items: stretch; }
.codex-auth-panel { border-radius: 24px; padding: clamp(26px, 5vw, 56px); align-self: stretch; }
.codex-auth-panel h2 { font-size: clamp(2rem, 4vw, 3rem); }
.codex-auth-panel > p:not(.eyebrow) { max-width: 640px; color: var(--ink-soft); line-height: 1.65; }
.codex-auth-panel > button { border: 0; border-radius: 13px; color: white; background: var(--ink); font-weight: 750; padding: 15px 20px; margin-top: 12px; }
.device-code { margin-top: 24px; padding: 20px; border: 1px solid var(--line); background: var(--paper); border-radius: 16px; }
.device-code[hidden] { display: none; }
.device-code span, .device-code strong { display: block; }
.device-code span { color: var(--ink-soft); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.device-code strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(1.7rem, 5vw, 2.8rem); letter-spacing: .08em; margin: 8px 0 16px; }
.device-code a { display: inline-block; color: white; background: var(--blue); border-radius: 12px; padding: 12px 16px; font-weight: 750; text-decoration: none; }
.device-code p { color: var(--ink-soft); font-size: .85rem; margin: 13px 0 0; }
.context-card, .chat-card { border-radius: 24px; }
.context-card { padding: 30px; }
.context-card h2 { font-size: 2rem; }
.context-card > p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.6; font-size: .91rem; }
.chat-history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.chat-history-head .eyebrow { margin-bottom: 5px; }
.chat-history-head h2 { font-size: 1.5rem; }
.new-chat-button { flex: 0 0 38px; width: 38px; height: 38px; border: 0; border-radius: 50%; color: white; background: var(--ink); font-size: 1.25rem; line-height: 1; }
.new-chat-button:hover { background: var(--blue); }
.new-chat-button:focus-visible { outline: 3px solid rgba(67,100,119,.25); outline-offset: 2px; }
.chat-list { display: grid; gap: 7px; max-height: 235px; margin-top: 16px; overflow-y: auto; padding-right: 3px; }
.chat-list-empty { margin: 4px 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.45; }
.chat-list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px; min-width: 0; }
.chat-list-item { width: 100%; min-width: 0; border: 1px solid transparent; border-radius: 11px; padding: 10px 11px; color: var(--ink); background: transparent; text-align: left; }
.chat-list-item:hover { background: rgba(128,146,116,.11); }
.chat-list-item.active { border-color: #cbd6c3; background: #f1f5ed; }
.chat-list-item strong, .chat-list-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-item strong { font-size: .82rem; }
.chat-list-item small { margin-top: 4px; color: var(--ink-soft); font-size: .68rem; }
.chat-delete-button { align-self: stretch; border: 0; border-radius: 10px; padding: 0 8px; color: #8f4d48; background: transparent; font-size: .67rem; font-weight: 750; }
.chat-delete-button:hover { color: #7f2f2a; background: rgba(157,62,56,.1); }
.chat-delete-button:focus-visible { outline: 3px solid rgba(157,62,56,.2); outline-offset: 1px; }
.chat-list-row button:disabled { opacity: .5; cursor: wait; }
.sidebar-divider { height: 1px; background: var(--line); margin: 24px 0; }
.security-summary > p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.55; font-size: .86rem; }
.context-status { display: flex; gap: 10px; align-items: center; margin-top: 20px; padding: 12px; border: 1px solid #cbd6c3; border-radius: 12px; background: #f1f5ed; }
.context-status > span { flex: 0 0 26px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--sage); font-weight: 800; }
.context-status strong, .context-status small { display: block; }
.context-status strong { font-size: .78rem; }
.context-status small { color: var(--ink-soft); font-size: .68rem; margin-top: 2px; }
.memory-note { margin-top: 9px; padding: 10px 12px; border-radius: 11px; background: var(--paper); }
.memory-note strong, .memory-note small { display: block; }
.memory-note strong { font-size: .74rem; }
.memory-note small { margin-top: 3px; color: var(--ink-soft); font-size: .67rem; line-height: 1.35; }
.divider { height: 1px; background: var(--line); margin: 26px 0; }
.mini-title { font-weight: 800; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.prompt-chip { width: 100%; text-align: left; border: 1px solid var(--line); color: var(--ink); background: transparent; border-radius: 12px; padding: 12px 13px; margin-top: 9px; line-height: 1.35; font-size: .86rem; }
.prompt-chip:hover { background: var(--sage-soft); border-color: transparent; }
.text-button { border: 0; background: transparent; color: var(--ink-soft); padding: 10px 0; margin: 18px 12px 0 0; text-decoration: underline; }

.chat-card { min-height: 590px; display: flex; flex-direction: column; overflow: hidden; }
.chat-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 28px 32px 22px; border-bottom: 1px solid var(--line); }
.mode-pill { border: 1px solid #b8c4ae; color: #58704c; background: #eef3e9; border-radius: 999px; padding: 7px 11px; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.messages { flex: 1; padding: 26px 32px; overflow-y: auto; max-height: 52vh; min-height: 310px; }
.message { display: flex; gap: 13px; max-width: 88%; margin: 0 0 22px; }
.message.user { margin-left: auto; flex-direction: row-reverse; }
.avatar { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--sage-soft); font-family: Georgia, serif; }
.message.user .avatar { color: white; background: var(--blue); }
.message > div:last-child { min-width: 0; }
.message strong { font-size: .78rem; letter-spacing: .04em; }
.message p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.62; margin: 5px 0 0; color: var(--ink-soft); }
.message.user p { color: var(--ink); }
.message.pending p::after { content: ""; display: inline-block; width: 1.1em; height: .35em; margin-left: .35em; background: radial-gradient(circle, var(--sage) 2px, transparent 3px) 0 0/6px 6px; animation: drift .9s linear infinite; }
@keyframes drift { to { background-position: 6px 0; } }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 20px 24px 10px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; min-height: 52px; max-height: 160px; padding: 14px 16px; line-height: 1.45; }
.composer button { min-width: 105px; }
.composer button:disabled { opacity: .55; cursor: wait; }
.composer-note { color: var(--ink-soft); font-size: .73rem; margin: 0; padding: 0 28px 20px; }
footer { display: flex; justify-content: space-between; gap: 24px; padding: 24px 0 30px; border-top: 1px solid rgba(24,49,61,.12); color: var(--ink-soft); font-size: .78rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 840px) {
  .shell { width: min(100% - 28px, 720px); }
  .topbar { min-height: 74px; gap: 16px; padding: 12px 0; }
  main { padding-top: 38px; }
  .hero { margin-bottom: 26px; }
  .auth-panel, .chat-layout { grid-template-columns: 1fr; gap: 16px; }
  .auth-panel { gap: 24px; }
  .context-card { padding: 22px; }
  .security-summary, .sidebar-divider { display: none; }
  .chat-list { display: flex; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 0 0 5px; }
  .chat-list-row { flex: 0 0 250px; }
  .chat-list-item { min-width: 0; }
  .quick-prompts { margin-top: 14px; }
  .mini-title { display: none; }
  .prompt-chip { display: inline-block; width: auto; margin-right: 6px; }
  .text-button { margin: 8px 10px 0 0; }
  .chat-card { min-height: 570px; }
  .messages { max-height: 48vh; padding: 22px 18px; }
  .chat-heading { padding: 22px 20px 18px; }
}

@media (max-width: 560px) {
  h1 { font-size: 2.55rem; }
  .hero > p:last-child { font-size: .94rem; }
  .mode-pill { display: none; }
  .context-card { display: block; }
  .chat-history-head h2 { font-size: 1.35rem; }
  .chat-list-row { flex-basis: 225px; }
  .prompt-chip { font-size: .78rem; padding: 9px 10px; margin: 0; }
  .text-button { margin: 10px 0 0; }
  .message { max-width: 96%; }
  .composer { grid-template-columns: 1fr; }
  .composer button { width: 100%; }
  footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 520px) {
  .topbar .brand strong { display: none; }
}

.pod-login-alert{margin:0 0 24px;padding:22px 24px;border:2px solid #a3322e;border-radius:16px;background:#fff0ed;color:#70231f;line-height:1.6}.pod-login-alert[hidden]{display:none!important}.pod-login-alert strong{display:block;font-size:1.1rem}.pod-login-alert p{margin:8px 0}.pod-login-alert a{display:inline-block;margin-top:8px;color:#70231f;font-weight:650;text-decoration:underline}
