:root {
  color-scheme: light;
  --ink: #203954;
  --muted: #506479;
  --line: #d5dfe6;
  --divider: #e1e7ec;
  --control-line: #8294a7;
  --paper: #fff;
  --blue: #28568b;
  --blue-hover: #1e446f;
  --sky: #e6eff8;
  --gold: #b69a65;
  --gold-line: #d6c7a7;
  --page-wash: linear-gradient(125deg, #f0f6fa 0%, #fafcfd 33%, #fff 62%, #f8f6f0);
  font: 15px/1.6 Inter, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: #fafcfd;
  accent-color: var(--blue);
}
* { box-sizing: border-box; }
body, dl, dd, ol, p, h1, h2, form { margin: 0; }
body { min-height: 100vh; min-height: 100svh; background: var(--page-wash); }
button, input { font: inherit; }
button, .button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.shell { max-width: 1120px; margin: 0 auto; padding: 0 36px; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--gold-line); }
.bar, .brand, .heading, .refresh, .panel-head, .meter-legend, .rows > div, .events li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.bar { min-height: 68px; }
.brand { gap: 11px; font-size: 16px; font-weight: 750; }
.brand-icon {
  display: inline-grid;
  place-items: center;
  position: relative;
  width: 1.7em;
  height: 1.7em;
  flex: none;
  color: #2b486b;
}
.brand-icon::before {
  content: "";
  position: absolute;
  inset: 15% 1%;
  border: 1px solid #b3985f;
  border-radius: 50%;
  transform: rotate(-26deg);
}
.brand-icon::after { content: "F"; font: italic 600 1.5em/1 Georgia, serif; }
.link-button { border: 0; padding: 7px 0 7px 10px; color: var(--muted); background: none; }
.link-button:hover { color: var(--ink); text-decoration: underline; }
.heading { margin: 44px 0 23px; align-items: end; }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.25; letter-spacing: -.065em; }
h2 { font-size: 19px; line-height: 1.4; letter-spacing: -.035em; }
.intro { margin-top: 6px; color: var(--muted); }
.sep { color: var(--muted); padding: 0 4px; }
.refresh { color: var(--muted); font-size: 13px; }
time, .mono, .big-number, .reading strong { font-variant-numeric: tabular-nums; }
.button, .primary { border-radius: 7px; font-weight: 650; text-decoration: none; }
.button { padding: 7px 12px; color: var(--blue); border: 1px solid var(--control-line); background: var(--paper); }
.button:hover { background: var(--sky); }
.host-panel {
  background: linear-gradient(115deg, #fbf8f1, #f8fafc 46%, #e7f0f9);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 29px 27px;
}
.panel-head { border-bottom: 1px solid var(--gold-line); padding-bottom: 16px; }
.chip { border: 1px solid var(--control-line); border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--ink); }
.memory-grid { display: grid; grid-template-columns: 1.45fr .8fr .8fr; align-items: start; gap: 30px; margin-top: 24px; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 550; }
.big-number { font-size: 54px; line-height: 1.16; font-weight: 620; letter-spacing: -.055em; }
.big-number small, .reading small { font-size: 16px; margin-left: 6px; font-weight: 450; letter-spacing: 0; }
.reading { border-left: 1px solid var(--line); padding-left: 25px; }
.reading strong { display: block; font-size: 28px; line-height: 1.7; letter-spacing: -.04em; }
meter { appearance: none; display: block; width: 100%; height: 8px; margin: 14px 0 6px; background: var(--line); border: 0; border-radius: 10px; }
meter::-webkit-meter-bar { background: var(--line); border: 0; border-radius: 10px; height: 8px; }
meter::-webkit-meter-optimum-value { background: var(--blue); border-radius: 10px; }
meter::-moz-meter-bar { background: var(--blue); border-radius: 10px; }
.meter-legend { font-size: 12px; color: var(--muted); }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 23px 26px; }
.card h2 { margin-bottom: 15px; }
.rows > div, .events li { min-height: 42px; border-top: 1px solid var(--divider); padding: 7px 0; }
.rows dt, .events li { font-size: 14px; }
.rows dt small { color: var(--muted); margin-left: 5px; }
.rows dd { font-size: 13px; text-align: right; }
.state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.state::before { content: ""; border-radius: 50%; width: 7px; height: 7px; background: var(--control-line); }
.live, .chat-link { color: var(--blue); }
.live::before { background: var(--blue); }
.mono, .events time { font-family: "SFMono-Regular", Consolas, monospace; }
.events { list-style: none; padding: 0; }
.events time { font-size: 12px; color: var(--muted); }
.event-card { margin-bottom: 44px; }
.login-form { margin-top: 26px; display: grid; gap: 8px; }
.login-form label { font-size: 14px; font-weight: 650; }
.login-form input { width: 100%; padding: 9px 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--control-line); border-radius: 6px; }
.primary { margin-top: 10px; padding: 10px; color: white; background: var(--blue); border: 0; }
.primary:hover { background: var(--blue-hover); }
.error { color: #a12e2e; font-size: 13px; }
@media (max-width: 720px) {
  .shell { padding: 0 18px; }
  .bar { min-height: 56px; }
  .heading { margin-top: 32px; align-items: start; flex-direction: column; }
  .refresh { width: 100%; }
  .host-panel, .card { padding: 19px; }
  .memory-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
  .capacity { grid-column: 1/-1; }
  .reading { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .columns { grid-template-columns: 1fr; }
}

.top-nav { display: flex; align-items: center; align-self: stretch; gap: 18px; margin-right: auto; margin-left: 20px; }
.top-nav a { display: grid; align-items: center; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; text-decoration: none; }
.top-nav a:hover { color: var(--blue); }
.top-nav a[aria-current] { color: var(--blue); border-color: var(--gold); }
.chat-link { font-weight: 650; }
.chat-heading { align-items: baseline; }
.muted { color: var(--muted); font-size: 13px; }
.chat-context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.chat-context select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--control-line); border-radius: 7px; padding: 5px 8px; }
.model-control { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.chat-heading + .model-control { margin: -6px 0 16px; }
.card .model-control { border-top: 1px solid var(--line); padding-top: 12px; }
.model-residency, .model-detail { color: var(--muted); font-size: 13px; }
.model-detail:not(:empty) { flex-basis: 100%; }
.model-control .button { margin-left: auto; font-size: 13px; }
.unload-model:disabled { opacity: .65; cursor: wait; }
.chat-layout { display: grid; grid-template-columns: minmax(180px, 245px) minmax(0, 1fr); gap: 18px; margin-bottom: 26px; }
.history { padding: 18px 14px; }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 4px 14px; }
.history-head h2 { margin: 0; }
.history-account { margin: 0 4px 8px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.history-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 4px 10px; }
.history-actions .button { font-size: 13px; }
.import-notice { margin: 0 4px 8px; font-size: 13px; color: var(--ink); }
.import-notice:empty { margin: 0; }
.history nav { display: grid; align-content: start; gap: 4px; max-height: 58vh; overflow: auto; }
.history nav a { color: var(--muted); text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 9px; border-radius: 5px; }
.history nav a:hover { background: #f0f6fa; color: var(--blue); }
.history nav a[aria-current] { background: var(--sky); color: var(--blue); box-shadow: inset 2px 0 var(--blue); }
.history .muted { padding: 8px; }
.chat-panel { display: flex; flex-direction: column; height: clamp(390px, 71dvh, 850px); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.conversation-bar { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.title-view, .participant-names, .participant-names > div { display: flex; align-items: center; gap: 8px; }
.title-view a { margin-left: auto; }
#delete-chat, #delete-notice { color: #943d48; }
#delete-notice { font-size: 13px; }
#delete-dialog { width: min(400px, 90vw); box-sizing: border-box; padding: 22px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
#delete-dialog::backdrop { background: rgb(25 43 64 / 35%); }
#delete-dialog h2 { font-size: 19px; }
#delete-dialog p { margin: 12px 0 20px; overflow-wrap: anywhere; max-height: 45dvh; overflow-y: auto; }
#delete-dialog form { display: flex; justify-content: flex-end; gap: 8px; }
#delete-dialog .primary { background: #913744; }
.participant-names { flex-wrap: wrap; gap: 0 18px; font-size: 13px; }
.participant-names > div { max-width: 100%; min-width: 0; }
.participant-names strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.conversation-bar .link-button { flex: none; padding: 5px 3px; font-size: 13px; }
.rename-form:not([hidden]) { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 6px; }
.rename-form label, #rename-notice { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.rename-form input { min-width: 0; padding: 5px 8px; color: var(--ink); border: 1px solid var(--control-line); border-radius: 6px; }
#rename-notice:empty { display: none; }
.conversation-bar h2 { min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-bar .button { flex: none; font-size: 13px; }
.rp-settings { border-bottom: 1px solid var(--line); padding: 8px 16px; font-size: 13px; }
.rp-settings summary { color: var(--blue); cursor: pointer; font-weight: 650; }
.rp-settings summary span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.rp-settings form { display: grid; gap: 5px; margin-top: 8px; }
.rp-settings textarea { width: 100%; font: inherit; color: var(--ink); padding: 7px 8px; border: 1px solid var(--control-line); border-radius: 6px; resize: vertical; max-height: 18vh; }
.prompt-rules { max-height: 18vh; margin-top: 8px; padding: 7px 8px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 6px; }
.rp-settings small, .rp-actions { color: var(--muted); }
.rp-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.rp-actions .button { font-size: 13px; }
.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; }
.message { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 17px; }
.message[hidden] { display: none; }
.message.mine { align-items: flex-end; }
.turn-actions, #edit-mode:not([hidden]) { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.turn-actions .link-button { padding: 3px 6px; }
.turn-actions [data-version] { min-width: 26px; font-size: 16px; }
.turn-actions button:disabled { opacity: .45; }
.transcript[data-busy="true"] .turn-actions { visibility: hidden; }
.editing-message .bubble { outline: 2px solid var(--blue); }
#edit-mode { margin-bottom: 5px; }
.message strong, .turn-note { font-size: 12px; color: var(--muted); margin: 2px 4px; }
.message strong { max-width: 100%; overflow-wrap: anywhere; }
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.mine .bubble { background: var(--sky); max-width: 90%; border-radius: 10px 10px 2px 10px; padding: 9px 13px; }
.reply .bubble { padding: 3px 4px; }
.greeting .bubble { background: var(--page-wash); border: 1px solid var(--line); border-radius: 2px 10px 10px; padding: 9px 13px; }
.turn-note:empty { display: none; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; }
.composer textarea { width: 100%; padding: 7px 8px; border: 1px solid var(--control-line); border-radius: 6px; resize: vertical; max-height: 160px; font: inherit; color: var(--ink); }
.composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 5px; }
.composer-actions button { margin: 0; padding: 7px 15px; }
.composer-actions #send:disabled { opacity: .5; cursor: default; }
.tag-setting { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; font-size: 13px; cursor: pointer; }
.tag-report { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.tag-report summary { cursor: pointer; color: var(--blue); }
.tag-report p { white-space: pre-wrap; }
#notice { margin-right: auto; color: #933; font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 720px) {
  .top-nav { margin-left: 0; gap: 9px; font-size: 13px; }
  .brand { font-size: 14px; gap: 6px; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .chat-heading { gap: 4px; margin: 20px 0 12px; }
  .history { padding: 10px 14px; }
  .history-head { padding: 0 0 5px; }
  .history nav { display: flex; gap: 6px; overflow-x: auto; }
  .history nav a { max-width: 200px; flex-shrink: 0; padding: 4px 8px; }
  .chat-panel { height: max(330px, 65dvh); }
  .transcript { padding: 12px; }
}

.login-form .checkbox { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-weight: 450; }
.login-form .checkbox input { width: auto; }
.login-form label small, .users small { color: var(--muted); font-weight: 450; }
.setup-return { display: inline-block; margin-top: 20px; }
.setup-address { margin-top: 12px; font-size: 14px; }
.setup-address code { display: block; overflow-wrap: anywhere; }
#setup-feedback:empty { display: none; }
.account-layout, .member-records { display: grid; gap: 16px; }
.account-layout, .record-transcript { margin-bottom: 24px; }
.account-layout .login-form { max-width: 32rem; }
.account-password { max-width: 520px; margin-bottom: 24px; }
.users { margin: 0; padding: 0; list-style: none; }
.users li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.user-entry, .access-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-entry { width: 100%; padding: 6px 2px; color: var(--blue); text-decoration: none; }
.user-entry:hover strong { text-decoration: underline; }
.user-entry small, .user-entry > span:last-child { color: var(--muted); font-size: 13px; }
.member-layout { align-items: start; }
.member-layout > *, .member-records > * { min-width: 0; }
.record-scroll {
  max-height: min(19rem, 42vh);
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.record-scroll::-webkit-scrollbar { width: 9px; }
.record-scroll::-webkit-scrollbar-track { background: var(--page-wash); }
.record-scroll::-webkit-scrollbar-thumb { background: var(--control-line); border-radius: 6px; }
.record-transcript .record-scroll { max-height: min(40rem, 62vh); }
.history-entry { flex-wrap: wrap; gap: 2px 12px; }
.record-title, .generation-records li { overflow-wrap: anywhere; }
.record-turn + .record-turn, .generation-records li + li { border-top: 1px solid var(--line); padding-top: 12px; }
.record-turn > time, .generation-records time { color: var(--muted); font-size: 13px; }
.record-turn > time { display: block; margin-bottom: 8px; }
.generation-records { list-style: none; margin: 0; padding: 0; }
.generation-records li { margin-bottom: 12px; }
.record-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; font-size: 14px; }
.record-pager a { color: var(--blue); }
.access-form { display: grid; gap: 12px; }
.access-form fieldset { margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 7px; }
.access-form legend { padding: 0 4px; font-weight: 650; }
.access-field { padding: 5px 0; }
.access-field select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--control-line); border-radius: 6px; padding: 4px 16px; }
.member-activity { margin: 12px 0; }
.member-activity time { flex-shrink: 0; }
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; padding-block: 8px; }
  .bar .top-nav { order: 1; width: 100%; gap: 16px; }
  .top-nav a { padding: 4px 0; }
}
.users strong { overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .bar { flex-wrap: wrap; gap: 4px 12px; }
  .bar .top-nav { order: 1; width: 100%; margin: 0; padding-bottom: 5px; }
}

.entry {
  display: grid;
  align-content: center;
  padding: clamp(28px, 6vh, 80px) clamp(16px, 4vw, 42px);
  word-break: keep-all;
}
.entry-shell { width: min(100%, 900px); min-width: 0; margin-inline: auto; }
.entry-masthead {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px 2px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.035em;
}
.entry-masthead::after {
  content: "";
  flex: 1;
  height: 1px;
  margin-left: 7px;
  background: linear-gradient(to right, #cfc1a4, transparent);
}
.entry-masthead .brand-icon { width: 30px; height: 30px; }
.entry-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 16px 52px -16px rgb(46 72 105 / 20%);
}
.entry-banner {
  display: grid;
  align-items: center;
  width: 100%;
  aspect-ratio: 3 / 1;
  border-bottom: 1px solid var(--gold-line);
  background: #faf6ee url("/static/tea-salon.jpg") center / cover no-repeat;
}
.entry-banner-title {
  padding-inline-start: 7%;
  color: #263e5a;
  font-size: clamp(28px, 3.8vw, 46px);
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: -.055em;
}
.entry-banner-title::after {
  content: "";
  display: block;
  width: 48px;
  height: 2px;
  margin-top: .42em;
  background: var(--gold);
}
.entry-content { max-width: 560px; margin: auto; padding: 30px 24px 36px; }
.entry-content h1 { display: flex; align-items: center; gap: 16px; font-size: 25px; letter-spacing: -.05em; }
.entry-content h1::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
.entry .login-form { gap: 8px; margin-top: 18px; }
.login-credentials { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.login-field { display: grid; min-width: 0; gap: 5px; }
.entry .login-form input:not([type="checkbox"]) { min-height: 43px; border-color: #a2b2c3; border-radius: 4px; }
.entry .login-form .checkbox { margin-top: 3px; color: var(--muted); }
.entry .checkbox input { width: 16px; height: 16px; margin: 0; }
.entry .primary, .entry .setup-return {
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  border: 0;
  border-radius: 4px;
  background: var(--blue);
  color: white;
  font-weight: 700;
}
.entry .setup-return { margin-top: 20px; }
.entry .primary:hover, .entry .setup-return:hover { background: var(--blue-hover); }
@media (max-width: 600px) {
  .entry-masthead { font-size: 18px; }
  .entry-banner {
    min-height: 140px;
    background-image: linear-gradient(90deg, #fbf7f1 0%, rgb(251 247 241 / 84%) 25%, transparent 56%), url("/static/tea-salon.jpg");
    background-position: right center;
  }
  .entry-banner-title { padding-inline-start: 6%; font-size: clamp(23px, 5.6vw, 32px); }
  .entry-content { padding: 23px 20px 26px; }
  .login-credentials { grid-template-columns: 1fr; gap: 10px; }
}

.document-library { padding: 10px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.document-library summary, .search-record summary, .turn-sources summary { cursor: pointer; color: var(--blue); }
.document-library ul { padding: 0; list-style: none; }
.document-library li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.document-library li span, .turn-sources { overflow-wrap: anywhere; }
.document-library small, #doc-notice, .turn-sources small { display: block; margin: 4px 0; }
.file-label { display: inline-block; position: relative; cursor: pointer; }
.file-label input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-label:focus-within { outline: 2px solid var(--blue); }
.turn-sources, .search-record { overflow-wrap: anywhere; margin-top: 5px; font-size: .85rem; }
.turn-sources ol { padding-left: 1.6em; }
.turn-sources p { margin: 0 0 8px; }

.image-layout { display: grid; grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr); align-items: start; gap: 20px; }
.image-compose form { display: grid; gap: 12px; }
.image-compose textarea { width: 100%; resize: vertical; padding: 12px; border: 1px solid var(--control-line); border-radius: 7px; color: var(--ink); background: var(--paper); font: inherit; }
.image-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.image-submit { display: grid; grid-template-columns: minmax(0, 1fr) max-content; align-items: center; gap: 12px; }
.image-submit small { overflow-wrap: anywhere; }
.image-submit .primary { margin: 0; min-width: 5em; padding: 9px 18px; white-space: nowrap; }
.image-submit .primary:disabled { opacity: .5; cursor: default; }
.image-submit small, .image-meta time { color: var(--muted); font-size: 13px; }
.image-job { border-top: 1px solid var(--line); padding: 16px 0; }
.image-description {
  margin: 8px 0;
  padding: .5rem .75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  line-height: 1.5;
  max-height: calc(6em + 1rem + 2px);
  overflow-y: auto;
  overflow-wrap: anywhere;
}
.image-description p { white-space: pre-wrap; }
.image-description p + strong { display: block; margin-top: .5rem; }
.image-error { color: var(--muted); }
.image-error:empty, #image-notice:empty { display: none; }
.image-job img { display: block; max-width: 100%; height: auto; border-radius: 6px; margin: 10px 0; }
@media (max-width: 760px) { .image-layout { grid-template-columns: 1fr; } }
