:root {
  --paper: #ffffff;
  --wash: #f4f7fc;
  --ink: #18253b;
  --muted: #52627a;
  --line: #dce3ee;
  --blue: #2853d7;
  --blue-dark: #1c3fa9;
  --blue-soft: #e9efff;
  --error: #a23434;
  --error-wash: #fff1ef;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button, a, select, input, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, a, input, select, textarea, summary { outline-offset: 4px; }
:focus-visible { outline: 3px solid var(--blue); }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
a { color: var(--blue); }
button, a { touch-action: manipulation; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 10; background: var(--paper); padding: 12px; }
.skip-link:focus { top: 12px; }
.app-header { min-height: 76px; flex-shrink: 0; padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.brand, .header-actions { display: flex; align-items: center; gap: 18px; }
.wordmark { font-size: 32px; font-weight: 800; letter-spacing: -1.9px; line-height: 1; }
.wordmark span { color: var(--blue); }
.pilot-label { color: var(--muted); font-size: 14px; }
.identity { font-size: 13px; color: var(--muted); max-width: 210px; overflow-wrap: anywhere; }
.language-label { font-size: 13px; color: var(--muted); }
select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 28px 9px 12px; color: var(--ink); background: var(--paper); min-height: 42px; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar { padding: 28px 18px 20px; background: var(--wash); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.new-button { display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid #b8c8f7; background: var(--paper); border-radius: 12px; min-height: 46px; font-weight: 600; color: var(--blue-dark); }
.new-button span:first-child { font-size: 23px; font-weight: 400; line-height: 1; }
.new-button:hover, .quiet-button:hover { background: var(--blue-soft); }
.view-switch { display: flex; flex-direction: column; gap: 4px; }
.view-button { text-align: left; border: 0; padding: 10px 12px; min-height: 42px; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; }
.view-button[aria-pressed="true"] { color: var(--ink); background: #e6ebf5; font-weight: 600; }
.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.list-heading h2 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.text-button { border: 0; background: transparent; padding: 7px 2px; color: var(--blue-dark); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.sidebar-note { font-size: 13px; color: var(--muted); margin: -8px 0 0; }
.session-list { padding: 0; margin: -10px -5px 0; list-style: none; overflow-y: auto; flex: 1; min-height: 0; }
.session-item { width: 100%; text-align: left; padding: 13px 12px; border: 1px solid transparent; border-radius: 10px; background: transparent; display: grid; gap: 5px; margin: 3px 0; }
.session-item:hover { background: #e9eef7; }
.session-item[aria-current="true"] { border-color: #b8c8f7; background: var(--paper); }
.session-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.session-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.flag-count { color: var(--blue-dark); }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 18px; font-size: 12px; line-height: 1.6; color: var(--muted); display: flex; gap: 9px; }
.small-dot { width: 7px; height: 7px; background: var(--blue); border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.main { min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.welcome { width: min(100%, 620px); margin: auto; padding: 40px 38px; }
.sign-in { width: min(100%, 620px); margin: auto; padding: 40px 38px; overflow-y: auto; }
.sign-in h1 { font-size: clamp(28px, 3vw, 38px); line-height: 1.2; letter-spacing: -1px; }
.sign-in-note { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 24px; }
.google-button { min-height: 44px; margin-top: 14px; }
.sign-in .form-error { color: var(--error); line-height: 1.6; font-size: 14px; margin: 14px 0; }
.google-button.is-busy { pointer-events: none; opacity: .5; }
.welcome-symbol { width: 54px; height: 54px; background: var(--blue-soft); color: var(--blue-dark); display: grid; place-items: center; border-radius: 18px 18px 18px 4px; font-size: 34px; letter-spacing: -2px; font-weight: 700; margin-bottom: 25px; }
.welcome h1 { font-size: clamp(28px, 3vw, 38px); line-height: 1.2; letter-spacing: -1px; font-weight: 650; margin-bottom: 16px; }
.welcome-lead { color: var(--muted); font-size: 16px; line-height: 1.7; max-width: 48ch; }
.start-form { margin-top: 26px; display: grid; gap: 12px; }
.start-form > label:first-child, #flag-form > label { font-weight: 600; font-size: 13px; }
.start-form > select { width: fit-content; min-width: 150px; }
.privacy-note { margin: 8px 0 0; padding: 18px 0 8px 18px; border-left: 3px solid #b8c8f7; }
.privacy-note h2 { font-size: 15px; margin-bottom: 8px; }
.privacy-note p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--muted); }
.consent-label { display: flex; align-items: flex-start; gap: 11px; font-size: 13px; line-height: 1.6; margin: 12px 0 4px; }
.consent-label input { width: 19px; height: 19px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--blue); }
.primary-button { border: 1px solid transparent; background: var(--blue); color: white; border-radius: 10px; padding: 12px 18px; min-height: 46px; font-weight: 600; font-size: 14px; }
.primary-button:hover:not(:disabled) { background: var(--blue-dark); }
.start-form > .primary-button { justify-self: start; margin-top: 4px; }
.form-status { min-height: 18px; color: var(--muted); font-size: 13px; margin-bottom: 0; }
.quiet-button { display: inline-flex; align-items: center; justify-content: center; padding: 9px 12px; min-height: 42px; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; font-size: 13px; text-decoration: none; }
.conversation { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.conversation-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 23px 32px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.conversation-header h1 { margin: 0 0 5px; font-size: 18px; font-weight: 600; }
.conversation-header p { margin: 0; font-size: 12px; color: var(--muted); }
.review-metadata { padding: 10px 32px; border-bottom: 1px solid var(--line); font-size: 12px; background: var(--wash); }
.review-metadata summary { cursor: pointer; padding: 4px 0; color: var(--muted); }
.review-metadata dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin-bottom: 4px; }
.review-metadata dt { color: var(--muted); }
.review-metadata dd { margin: 0; overflow-wrap: anywhere; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 30px max(30px, calc((100% - 760px) / 2)); scroll-padding: 24px; }
.message { margin: 0 0 28px; max-width: 100%; }
.message-heading { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.message-heading time { color: var(--muted); }
.message-text { font-size: 16px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.message-user { margin-left: 14%; }
.message-user .message-text { background: var(--blue-soft); border-radius: 16px 16px 4px 16px; padding: 15px 20px; }
.message-user .message-heading { justify-content: flex-end; }
.message-assistant { padding-right: 6%; }
.message-assistant .message-heading::before { content: "s."; display: grid; place-items: center; width: 24px; height: 24px; color: var(--blue-dark); background: var(--blue-soft); border-radius: 8px 8px 8px 2px; font-weight: 700; font-size: 17px; letter-spacing: -1px; }
.message-error .message-text { color: var(--error); font-size: 14px; }
.message-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.flag-button { border: 0; background: transparent; color: var(--muted); padding: 8px 2px; min-height: 34px; font-size: 12px; }
.flag-button:hover { color: var(--blue); text-decoration: underline; }
.flag-button:disabled { opacity: 1; color: var(--blue-dark); }
.message-feedback { padding: 10px 13px; margin-top: 10px; border-left: 2px solid #b8c8f7; background: var(--wash); font-size: 13px; line-height: 1.6; }
.feedback-author { font-weight: 600; display: block; margin-bottom: 3px; }
.feedback-comment { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-status { min-height: 24px; padding: 2px 32px; font-size: 13px; color: var(--muted); }
.composer { width: min(100%, 824px); margin: 0 auto; padding: 10px 32px 18px; flex-shrink: 0; }
.composer-field { display: flex; align-items: flex-end; gap: 10px; border: 1px solid #bdc9de; border-radius: 16px; padding: 10px; background: var(--paper); }
.composer-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.composer textarea { border: 0; outline: none; padding: 8px; min-height: 54px; max-height: 180px; resize: vertical; width: 100%; line-height: 1.6; color: var(--ink); background: var(--paper); font-size: 16px; }
.composer textarea:disabled { background: var(--paper); color: var(--muted); }
.composer-note { font-size: 11px; line-height: 1.6; color: var(--muted); margin: 10px 2px 0; }
.read-only-note { padding: 16px 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; margin: 0; }
.retry-panel { margin: 4px 32px 10px; padding: 14px; border: 1px solid #ddc7a9; border-radius: 10px; background: #fff9f0; font-size: 13px; line-height: 1.6; }
.retry-panel p { margin-bottom: 9px; }
.notice { margin: 16px 24px 0; padding: 14px 16px; border-radius: 10px; font-size: 14px; line-height: 1.6; }
.notice p { margin: 0; }
.notice-error { background: var(--error-wash); color: var(--error); }
dialog { border: 1px solid var(--line); border-radius: 18px; width: min(530px, calc(100% - 32px)); padding: 28px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: rgba(24, 37, 59, .35); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.dialog-heading h2 { font-size: 21px; line-height: 1.4; margin: 0; }
#flag-form > p { color: var(--muted); font-size: 14px; line-height: 1.7; }
#flag-comment { display: block; width: 100%; resize: vertical; min-height: 110px; border: 1px solid #bdc9de; border-radius: 9px; padding: 12px; line-height: 1.6; margin: 9px 0; font-size: 16px; }
#flag-form > .form-error { color: var(--error); min-height: 18px; }
.menu-toggle { display: none; }
.noscript-note { padding: 24px; background: var(--error-wash); }

@media (max-width: 780px) {
  .app-header { min-height: 68px; padding: 15px 18px; }
  .brand, .header-actions { gap: 10px; }
  .pilot-label { font-size: 12px; max-width: 75px; line-height: 1.4; }
  .wordmark { font-size: 28px; }
  .identity, .language-label { display: none; }
  .header-actions select { max-width: 100px; font-size: 12px; padding-left: 8px; }
  .menu-toggle { display: inline-flex; font-size: 12px; padding: 8px; }
  .workspace { display: flex; flex-direction: column; }
  .sidebar { display: none; max-height: 48dvh; padding: 16px 18px; border-right: 0; border-bottom: 1px solid var(--line); flex-shrink: 0; gap: 14px; }
  .sidebar.is-open { display: flex; }
  .view-switch { flex-direction: row; }
  .sidebar-footer { display: none; }
  .session-list { min-height: 50px; }
  .main { flex: 1; }
  .welcome, .sign-in { padding: 30px 24px; }
  #sign-out { font-size: 12px; padding: 8px; }
  .welcome-symbol { margin-bottom: 18px; }
  .welcome-lead { font-size: 15px; }
  .conversation-header { padding: 17px 20px; }
  .conversation-header h1 { font-size: 16px; }
  .conversation-header .quiet-button { font-size: 11px; max-width: 115px; text-align: center; }
  .messages { padding: 24px 22px 8px; }
  .message-assistant { padding-right: 0; }
  .message-user { margin-left: 8%; }
  .message-text { font-size: 15px; line-height: 1.8; }
  .message-user .message-text { padding: 12px 15px; }
  .composer { padding: 8px 14px max(12px, env(safe-area-inset-bottom)); }
  .composer-field { gap: 2px; padding: 7px; }
  .composer .primary-button { padding: 11px 12px; }
  .composer-note { font-size: 10px; margin-top: 7px; }
  .chat-status { padding: 2px 22px; }
  .retry-panel { margin: 4px 16px 8px; }
  .review-metadata { padding: 9px 20px; }
  .read-only-note { padding: 14px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
