* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); word-break: keep-all; overflow-wrap: anywhere; }
button, a, textarea { font: inherit; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
a { color: var(--accent); text-underline-offset: .2em; }
button:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .55; cursor: wait; }
.sr { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.page-width { width: min(1192px, calc(100% - 88px)); margin-inline: auto; }
#app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.masthead { background: #fff; flex: none; border-top: 4px solid var(--mint); }
.mast-row, .wordmark, #account, .utility-row { display: flex; align-items: center; }
.mast-row { min-height: 80px; justify-content: space-between; gap: 16px; }
.wordmark { gap: 21px; text-decoration: none; color: var(--ink); }
.wordmark span { border-left: 1px solid #bdc6c3; padding-left: 19px; font-size: 18px; line-height: 24px; font-weight: 700; letter-spacing: -.04em; }
#account a { text-decoration: none; font-weight: 600; color: var(--ink); }
#account a:hover { color: var(--accent); text-decoration: underline; }
#account { min-width: 0; min-height: 34px; font-size: 14px; }
.utility { flex: none; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.utility-row { gap: 16px; height: 41px; }
.utility-row button { display: inline-flex; align-items: center; gap: 7px; padding: 3px 1px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.utility-row button:hover { color: var(--accent); }
.menu-icon { width: 15px; height: 12px; border-block: 1.5px solid currentColor; display: inline-grid; align-items: center; }
.menu-icon::before { content: ''; border-top: 1.5px solid; }
#new span { font-size: 18px; line-height: 1; }
#section-label, #edition-date { color: var(--muted); font-size: 13px; }
#section-label:empty { display: none; }
#section-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#section-label { border-left: 1px solid var(--rule); padding-left: 14px; }
#edition-date { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }

#stage { flex: 1; min-height: 0; overflow: hidden; }
#spread { display: flex; flex-direction: column; width: min(802px, calc(100% - 64px)); height: 100%; }
#desk { width: 100%; flex: none; padding: 8px 0 max(14px, env(safe-area-inset-bottom)); }
#empty-chat { padding: 12px 0; }
#empty-chat h1 { margin: 0 0 12px; font: 700 26px/1.4 var(--headline); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { color: var(--accent); border: 1px solid var(--rule); border-radius: 4px; padding: 5px 10px; font-size: 14px; }
.suggestions button:hover { background: var(--wash); }
#read-only { color: var(--muted); text-align: center; font-size: 14px; }
#share { color: var(--accent); }
#sharing { padding-block: 8px 14px; font-size: 14px; }
#sharing p { margin: 0 0 8px; }
#sharing button { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 4px; }
#copy-share { color: var(--accent); }
#composer { padding: 15px 20px 12px; border: 1px solid #899e9b; border-radius: 8px; background: white; }
#composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.reading-status { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
.memory-reason { padding: 8px 11px; margin: 9px 0; border-left: 3px solid var(--accent); background: var(--wash); font-size: 14px; line-height: 1.6; }
.memory-reason strong { color: #005f5c; display: block; }
textarea { display: block; border: 0; padding: 12px 0 3px; width: 100%; resize: none; line-height: 1.45; font-size: 16px; color: var(--ink); background: transparent; }
textarea:focus-visible { outline: none; }
textarea::placeholder { color: #667270; }
.form-foot { display: flex; justify-content: flex-end; }
#notice { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
#notice:empty { display: none; }
#send { width: 37px; height: 37px; flex: none; border-radius: 50%; background: var(--accent); color: white; font: 23px/1 var(--sans); }
#send:hover { background: #004e4c; }
#send[data-busy=true] { font-size: 15px; background: var(--ink); }
#focus { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--accent); }
#focus button { font-size: 18px; }

#shade { position: fixed; inset: 0; z-index: 5; background: #14222055; }
#rail { position: fixed; z-index: 6; inset: 0 auto 0 0; width: min(348px, 87vw); padding: 25px 23px; display: flex; flex-direction: column; background: #fff; border-top: 4px solid var(--mint); box-shadow: 10px 0 32px #17262514; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.drawer-head h2 { margin: 0; font: 700 26px/1.3 var(--headline); }
#close-menu { font: 26px/1 var(--sans); width: 36px; height: 36px; }
.recent { min-height: 0; overflow: auto; }
.recent h3, #empty-nav { font-size: 13px; color: var(--muted); margin: 18px 0 9px; }
#threads a { color: inherit; text-decoration: none; width: 100%; display: block; padding: 10px 9px; text-align: left; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#threads a[aria-current=true], #threads a:hover { background: var(--wash); color: var(--accent); }

#conversation { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; margin-inline: -12px; padding: 28px 12px 8px; }
.turn { margin: 0 0 32px; }
.question { margin: 0 0 17px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); font: 700 clamp(23px, 2.1vw, 31px)/1.4 var(--headline); letter-spacing: -.035em; }
.assistant-head { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 14px; font-weight: 700; }
.assistant-head::before { content: ''; width: 16px; height: 3px; background: var(--mint); }
.steps { font-size: 13px; color: var(--muted); margin: 8px 0; }
.steps summary { cursor: pointer; width: fit-content; }
.steps ol { border-left: 2px solid var(--rule); margin: 8px 0; padding-left: 29px; line-height: 1.8; }
.steps li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.turn-progress { margin: 8px 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.progress-step { color: var(--muted); font-weight: 400; }
.steps[open] + .turn-progress .progress-step { display: none; }
.progress-dots { display: inline-flex; gap: 3px; margin-inline-start: 5px; vertical-align: .12em; }
.progress-dots > span { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .progress-dots > span { animation: progress-pulse 1.4s ease-in-out infinite; }
  .progress-dots > span:nth-child(2) { animation-delay: .16s; }
  .progress-dots > span:nth-child(3) { animation-delay: .32s; }
  @keyframes progress-pulse {
    0%, 65%, 100% { opacity: .35; }
    30% { opacity: 1; }
  }
}
.answer { white-space: pre-wrap; line-height: 1.82; font-size: 16px; margin: 16px 0; }
.answer .marker { display: inline-block; color: var(--accent); background: var(--wash); font: 600 12px/1.55 var(--sans); padding-inline: 4px; text-decoration: none; border-radius: 2px; vertical-align: .12em; }
.answer .marker:hover { text-decoration: underline; }
.sources { border-top: 1px solid var(--ink); margin: 20px 0 12px; }
.sources h3 { font: 700 18px/1.35 var(--headline); margin: 11px 0 5px; }
.source { display: flex; align-items: baseline; gap: 9px; border-bottom: 1px solid var(--rule); padding: 9px 0; font-size: 14px; }
.source small { min-width: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
.source a { flex: 1; color: var(--ink); text-decoration: none; }
.source a:hover { color: var(--accent); text-decoration: underline; }
.source button, .answer-actions button { flex: none; font-size: 12px; color: var(--accent); border: 1px solid #a9c6c3; padding: 5px 9px; border-radius: 4px; }
.source button:hover, .answer-actions button:hover { background: var(--wash); }
.answer-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.md-table-wrap, .md-pre { max-width: 100%; overflow: auto; }
.md-table { border-collapse: collapse; font-size: .9em; }
.md-table th, .md-table td { border: 1px solid var(--rule); padding: 5px 8px; }
.md-list { white-space: normal; padding-left: 24px; }
.md-list li { margin-block: 6px; }

.login { min-height: 100dvh; display: grid; place-items: center; }
.login main { width: min(420px, 90%); padding: 24px 0; border-top: 3px solid var(--mint); }
.login .hani-logo { width: 98px; }
.login h1 { font: 700 29px var(--headline); margin: 24px 0 10px; }
.login p { color: var(--muted); }
.login a, .login button { display: inline-block; font-size: 14px; margin: 8px 10px 8px 0; }
.login button { color: #fff; background: var(--accent); padding: 5px 10px; border-radius: 4px; }

@media (max-width: 900px) {
  .page-width { width: calc(100% - 48px); }
}
@media (max-width: 700px) {
  .page-width { width: calc(100% - 36px); }
  .mast-row { min-height: 58px; gap: 8px; }
  .wordmark { gap: 10px; }
  .hani-logo { width: 84px; }
  .wordmark span { font-size: 14px; padding-left: 10px; line-height: 19px; }
  #account { gap: 4px; font-size: 12px; }
  #account .profile-name { max-width: 22vw; }
  .utility-row { gap: 13px; height: 38px; }
  #edition-date { font-size: 11px; }
  .utility-row:has(#share:not([hidden])) #edition-date { display: none; }
  #section-label { display: none; }
  #composer { padding: 11px 13px 10px; }
  #spread { width: calc(100% - 32px); }
  #conversation { padding-top: 18px; margin-inline: -6px; padding-inline: 6px; }
  #desk { margin: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .question { font-size: 24px; }
  .source { font-size: 13px; gap: 6px; }
  .answer { font-size: 15px; }
}
@media (max-width: 370px) {
  .wordmark span { font-size: 12px; }
  .utility-row { gap: 9px; }
}
.answer .md-h3, .answer h3 { font: 700 21px/1.4 var(--headline); margin: 17px 0 5px; }
.sources summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 9px 0; font-size: 13px; }
