:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --card: #fff;
  --ink: #203c34;
  --mute: #61736b;
  --acc: #245c48;
  --line: #dce5dc;
  --soft: #edf3eb;
  --danger: #ac3434;
  --sidebar: 252px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.65 system-ui, sans-serif; }
button, select, input, textarea { font: inherit; }
button, a, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 11px; padding: 10px 18px; background: var(--acc); color: #fff; font-weight: 600; transition: background .15s, box-shadow .15s; }
button:hover { background: #193f32; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { color: var(--acc); background: transparent; }
button.ghost:hover { background: var(--soft); }
button.danger { background: var(--danger); }
:focus-visible { outline: 3px solid #bc7130; outline-offset: 3px; }
a { color: var(--acc); text-underline-offset: 3px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -.025em; }
h2 { font-size: 24px; }
h3 { font-size: 20px; margin-bottom: 16px; }
h4 { margin: 20px 0 10px; }
label { color: var(--mute); font-size: 13px; font-weight: 600; }
input, textarea, select { width: 100%; min-width: 0; padding: 11px 13px; margin: 6px 0 16px; color: var(--ink); background: #fcfdfb; border: 1px solid #cbd7cd; border-radius: 10px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; margin: 4px 8px 4px 0; accent-color: var(--acc); }
input[type="file"] { padding: 10px; }
input::file-selector-button { padding: 7px 12px; margin-right: 12px; border: 0; border-radius: 6px; background: var(--soft); color: var(--ink); cursor: pointer; }
input.priority { width: 100px; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 12px 20px; background: var(--card); border-radius: 10px; }
.skip-link:focus { top: 12px; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar); padding: 30px 18px 20px; background: #f0f3eb; border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.brand-row { display: flex; justify-content: space-between; align-items: center; padding: 0 10px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 29px; font-weight: 750; letter-spacing: -.06em; text-decoration: none; }
.brand-mark, .coach-avatar { display: inline-grid; place-items: center; flex-shrink: 0; background: var(--acc); color: white; font: italic 30px Georgia, serif; border-radius: 16px 16px 16px 4px; width: 42px; height: 42px; }
.brand-period { color: #bc7130; margin-left: -9px; }
.brand-caption { margin: 14px 10px 28px; color: var(--mute); font-size: 12px; }
.workspace-context { margin: 0 8px 22px; padding: 16px 0; border-block: 1px solid var(--line); }
.eyebrow { display: block; color: var(--mute); font-size: 10px; font-weight: 700; letter-spacing: .13em; }
#workspace-name { display: block; margin-top: 6px; font-size: 14px; overflow-wrap: anywhere; }
#nav { display: flex; flex-direction: column; gap: 14px; }
.nav-section { display: flex; flex-direction: column; gap: 4px; }
.nav-section-title { margin: 0 14px 3px; color: var(--mute); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
#nav button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-align: left; font-size: 13px; font-weight: 550; color: #4b6257; }
#nav button.active { background: #dce9d9; color: #1d4c37; font-weight: 700; }
#nav button.nav-primary { margin-bottom: 8px; background: var(--acc); color: white; box-shadow: 0 3px 8px #214f4312; }
#nav button.nav-primary:hover { background: #193f32; }
#nav button.nav-primary.active { box-shadow: inset 3px 0 0 #b5d296; }
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: 25px 10px 0; }
.sidebar-note { color: var(--mute); font: italic 15px Georgia, serif; }
#who { padding-top: 12px; font-size: 12px; overflow-wrap: anywhere; }
#who button { font-size: 12px; padding: 6px 0; }
.app-content { margin-left: var(--sidebar); min-width: 0; }
.topbar { height: 96px; padding: 18px 36px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.page-context { min-width: 0; flex: 1; }
#page-title { font-size: 20px; margin: 4px 0 0; overflow-wrap: anywhere; }
.mobile-only { display: none; }
.icon-button { display: inline-grid; place-items: center; padding: 8px; min-width: 44px; min-height: 44px; color: var(--ink); background: transparent; font-size: 26px; }
.icon-button:hover { background: var(--soft); }
.icon-button.mobile-only { display: none; }
main { max-width: 1080px; margin: 0 auto; padding: 30px 36px 40px; }
main:focus { outline: none; }
.view-content { min-width: 0; }
.card { min-width: 0; padding: 26px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 4px 18px #213c3403; overflow-wrap: anywhere; }
.card > :last-child { margin-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; max-width: 100%; min-width: 0; }
.grow { flex: 1 1 180px !important; }
.item { padding: 18px 0; border-top: 1px solid var(--line); }
.item.sup { opacity: .6; }
.tag { display: inline-block; padding: 2px 9px; margin: 4px 5px 4px 0; background: var(--soft); border-radius: 6px; color: #425f4b; font-size: 11px; }
.src { color: var(--mute); font-size: 12px; }
.err { color: var(--danger); overflow-wrap: anywhere; }
.hero { padding: 8px 2px 22px; }
.hero .eyebrow { color: #8c572a; }
.hero h2 { margin: 9px 0; font: 38px/1.2 Georgia, serif; letter-spacing: -.03em; }
.hero p { color: var(--mute); max-width: 540px; margin: 0; }
.workspace-card .workspace-name { display: block; font-size: 17px; font-weight: 650; }
.workspace-card .src { display: block; margin-top: 5px; }
.auth-card { max-width: 460px; margin: 5vh auto; padding: 36px; }
.auth-card h2 { font: 32px/1.2 Georgia, serif; }
.google-auth { display: none; justify-items: center; gap: 12px; padding: 18px; margin: 22px 0 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.google-auth.enabled { display: grid; }
.google-auth .src { margin: 0; text-align: center; }
#google-sign-in { min-height: 40px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; color: var(--mute); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.email-auth { padding-top: 4px; }
main.chat-layout { padding-top: 24px; padding-bottom: 24px; max-width: 1160px; }
.chat-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "chat memory"; gap: 18px; align-items: start; }
.chat-workspace .chat-heading { flex-wrap: wrap; }
.chat-workspace .chat-thread-controls { flex-wrap: wrap; width: 100%; margin-left: 0; }
.chat-workspace .chat-thread-controls select { min-width: 0; max-width: 220px; }
.chat-card { grid-area: chat; display: flex; flex-direction: column; height: calc(100dvh - 144px); min-height: 320px; margin: 0; padding: 0; overflow: hidden; }
.chat-heading { display: flex; gap: 9px; align-items: center; padding: 20px 26px; border-bottom: 1px solid var(--line); }
.chat-heading h2 { font-size: 14px; letter-spacing: 0; margin: 0; }
.chat-thread-controls { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.chat-thread-controls label { display: flex; align-items: center; gap: 8px; }
.chat-thread-controls label span { white-space: nowrap; }
.chat-thread-controls select { min-width: 180px; max-width: 360px; margin: 0; padding: 7px 10px; }
.chat-thread-controls button { white-space: nowrap; padding: 8px 12px; }
.chat-thread-controls .chat-share-control { flex-shrink: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5a8256; }
.chat-card > .err { padding: 8px 26px 0; margin-bottom: 0; }
.memory-preview { grid-area: memory; padding: 20px; margin: 0; max-height: calc(100dvh - 144px); overflow-y: auto; background: #fbfcfa; }
.memory-preview details > summary { cursor: pointer; font-size: 12px; font-weight: 650; color: var(--acc); }
.memory-body { padding-top: 8px; }
.memory-status { margin: 6px 0; color: var(--mute); font-size: 11px; }
.memory-columns { display: grid; gap: 20px; font-size: 12px; }
.memory-columns > div { min-width: 0; }
.memory-columns strong { display: block; margin-bottom: 3px; }
.memory-list p { margin: 8px 0; overflow-wrap: anywhere; }
.memory-action { color: var(--mute); font-size: 10px; margin-right: 5px; }
.memory-empty { color: var(--mute); }
#log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; padding: 28px; scrollbar-width: thin; }
.chat-welcome { text-align: center; align-self: center; margin: auto; max-width: 420px; padding: 30px 12px; }
.chat-welcome .coach-avatar { margin-bottom: 24px; width: 58px; height: 58px; font-size: 40px; background: #e6eedf; color: var(--acc); }
.chat-welcome h2 { font: 32px/1.2 Georgia, serif; }
.chat-welcome p { color: var(--mute); font-size: 14px; margin-bottom: 0; }
.msg { max-width: 88%; padding: 15px 20px; border-radius: 16px; overflow-wrap: anywhere; flex-shrink: 0; font-size: 14px; }
.msg.user { background: var(--acc); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.ai { background: #f0f4ed; border-bottom-left-radius: 4px; }
.msg.initial-answer { background: #faf6ea; border: 1px dashed #cbbf9a; }
.initial-answer > summary { cursor: pointer; font-weight: 650; list-style: none; }
.initial-answer > summary::-webkit-details-marker { display: none; }
.initial-answer > summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 7px; border: 1px solid currentColor; border-radius: 50%; font-size: 14px; line-height: 1; }
.initial-answer[open] > summary::before { content: "−"; }
.initial-answer-content { padding-top: 12px; }
.streaming-note { display: block; margin: 3px 0 8px; color: #64715f; font-size: 12px; }
.msg p { margin: 0 0 12px; }
.msg p:last-child { margin-bottom: 0; }
.msg h2, .msg h3, .msg h4 { font: inherit; font-weight: 700; margin: 14px 0 8px; }
.msg ul, .msg ol { margin: 8px 0; padding-left: 22px; }
.msg a { color: inherit; }
.msg pre, .json-value, .source-text, pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg blockquote { margin: 10px 0; border-left: 3px solid #b5c8af; padding-left: 14px; }
.chat-composer { padding: 16px 22px 18px; background: #fff; border-top: 1px solid var(--line); }
.chat-composer textarea { margin: 0 0 8px; border: 0; background: transparent; padding: 8px 4px; resize: none; max-height: 180px; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.composer-actions .src { font-size: 10px; }
.send-button { white-space: nowrap; padding: 9px 20px; }
.waiting { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--mute); font-size: 12px; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--acc); animation: typing 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
#ai-debug { min-width: 0; font-size: 12px; }
#ai-debug > summary { cursor: pointer; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--mute); white-space: nowrap; }
#ai-debug-panel { position: absolute; z-index: 30; right: 24px; top: 80px; width: min(720px, calc(100vw - var(--sidebar) - 48px)); max-height: 70dvh; overflow: auto; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 60px #203c3420; }
#ai-debug-list > details { padding: 12px 0; border-top: 1px solid var(--line); }
.json-tree { margin-left: 12px; }
.json-tree summary { cursor: pointer; overflow-wrap: anywhere; }
.json-value { font-family: monospace; }
.relationship-map { overflow-x: auto; }
.relationship-map svg { display: block; width: 100%; min-width: 640px; height: auto; }
.markdown-preview { background: var(--soft); border-radius: 10px; margin: 12px 0; padding: 12px 16px; }
table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 13px; }
td, th { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
summary { cursor: pointer; }
.nav-backdrop { position: fixed; inset: 0; z-index: 35; border: 0; border-radius: 0; background: #142a2359; }
@media (min-width: 761px) { .nav-backdrop { display: none; } }
@media (max-width: 1000px) and (min-width: 761px) {
  :root { --sidebar: 222px; }
  .sidebar { padding-inline: 12px; }
  .topbar { padding-inline: 24px; }
  main { padding-inline: 24px; }
}
@media (max-width: 760px) {
  .app-content { margin-left: 0; }
  .sidebar { width: min(300px, calc(100vw - 48px)); padding-top: 22px; box-shadow: 8px 0 40px #203c3420; }
  .icon-button.mobile-only { display: inline-grid; }
  .topbar { height: 80px; padding: 12px 16px; gap: 10px; }
  .topbar .eyebrow { font-size: 8px; letter-spacing: .1em; }
  #page-title { font-size: 17px; }
  #ai-debug { display: none; }
  main { padding: 22px 16px; }
  .card { padding: 20px; margin-bottom: 16px; border-radius: 14px; }
  .hero h2 { font-size: 31px; }
  .hero p { font-size: 13px; }
  .row { gap: 8px; }
  .auth-card { margin-top: 20px; }
  main.chat-layout { padding: 0; }
  .chat-card { border: 0; border-radius: 0; min-height: 240px; height: calc(100dvh - 124px); margin: 0; padding: 0; }
  .chat-heading { padding: 13px 16px; flex-wrap: wrap; }
  .chat-thread-controls { width: 100%; margin-left: 0; }
  .chat-thread-controls label { flex: 1; min-width: 0; }
  .chat-thread-controls select { flex: 1; max-width: none; }
  .chat-workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "memory" "chat"; gap: 0; }
  .memory-preview { padding: 0; max-height: none; border: 0; border-radius: 0; box-shadow: none; background: #fbfcfa; }
  .memory-preview details > summary { min-height: 44px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .memory-preview details[open] > summary { border-bottom: 1px solid var(--line); }
  .memory-body { padding: 12px 16px 16px; }
  .memory-columns { gap: 10px; }
  #log { padding: 20px 16px; gap: 14px; }
  .msg { max-width: 94%; padding: 13px 16px; }
  .chat-welcome h2 { font-size: 28px; }
  .chat-welcome { padding: 20px 10px; }
  .chat-composer { padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }
  .composer-actions .src { max-width: 180px; line-height: 1.4; }
  .send-button { min-height: 44px; }
  button { min-height: 44px; }
  input, textarea, select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
