:root {
  --page-width: 1320px;
  --page-inset: max(3vw, 16px);
  --paper: #f5f2e9;
  --surface: #fffcf5;
  --ink: #222b29;
  --teal: #12584e;
  --edge: #c9c9b8;
  --muted: #55605a;
  --header: #173e37;
  --header-ink: #faf6e9;
  --header-line: #d19e55;
  --tab-hover: #e4e9df;
  color: var(--ink);
  background: var(--paper);
  font: 16px system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--teal); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button, .primary {
  border: 1px solid var(--teal);
  border-radius: 3px;
  background: transparent;
  color: var(--teal);
  padding: .48rem .9rem;
}
button:disabled { cursor: default; opacity: .6; }
button:active:not(:disabled) { opacity: .8; }
.primary { display: inline-block; background: var(--teal); color: white; font-weight: 600; text-decoration: none; }
.primary:hover:not(:disabled) { filter: brightness(1.16); }
input:not([type=checkbox]), select, textarea {
  min-width: 0;
  max-width: 100%;
  padding: .55rem .7rem;
  background: var(--surface);
  border: 1px solid #929b8e;
  border-radius: 3px;
}
:focus-visible { outline: 2px solid #aa5b27; outline-offset: 3px; }
body:has(> .page-scroll) { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
main { max-width: var(--page-width); margin: auto; padding: 1.8rem var(--page-inset) 3rem; }
h1, h2, h3 { font-family: Georgia, serif; font-weight: 500; line-height: 1.13; }
h1 { font-size: clamp(2.2rem, 4vw, 3.8rem); margin: .25rem 0 1rem; }
h2 { font-size: clamp(1.6rem, 2.6vw, 2.35rem); margin: .45rem 0 1rem; }
p { line-height: 1.55; }
small { color: var(--muted); }
.shell-header, .library-tabs { flex: none; }
.shell-header {
  --edge-inset: clamp(6px, .65vw, 14px);
  --brand-gap: .4rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem var(--edge-inset) .35rem calc(var(--edge-inset) + .225rem);
  color: var(--header-ink);
  background: var(--header);
  border-bottom: 4px solid var(--header-line);
}
.shell-title { margin: 0; min-width: 0; overflow-wrap: anywhere; font: 600 1.5rem Georgia, serif; color: inherit; }
.site-brand { display: inline-flex; align-items: center; gap: var(--brand-gap); text-decoration: none; }
.shell-tools { margin-left: auto; }
.shell-action { display: grid; place-items: center; background: transparent; color: inherit; border: 0; padding: .3rem .45rem; }
.shell-action:hover, .shell-action:focus-visible { background: #ffffff20; }
.shell-action svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#account-control { padding-block: 1px; }
#account-control svg { width: 29px; height: 29px; }
.library-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: clamp(.3rem, 1vw, 1rem);
  padding-inline: clamp(12px, 1.3vw, 28px);
  background: var(--paper);
  border-bottom: 1px solid var(--edge);
}
.library-tabs :is(a, button) {
  display: inline-flex;
  align-items: center;
  padding: .55rem .45rem .4rem;
  color: var(--teal);
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  text-decoration: none;
}
.library-tabs [aria-current] { border-color: var(--teal); font-weight: 700; }
.library-tabs :is(a, button):is(:hover, :focus-visible) { background: var(--tab-hover); }
.shell-content { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.page-scroll { scrollbar-gutter: stable; }
.page-scroll:focus-visible { outline-offset: -2px; }
.ui-dialog {
  padding: 0;
  width: min(46rem, 96vw);
  max-width: 96vw;
  max-height: 92dvh;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: .3rem;
  color: var(--ink);
  background: var(--paper);
}
.ui-dialog[open] { display: flex; flex-direction: column; }
.ui-dialog::backdrop { background: #102823b3; }
.ui-dialog[data-size=small] { width: min(32rem, 96vw); }
.ui-dialog > .shell-header { column-gap: var(--brand-gap); }
.ui-dialog > .shell-content { padding: 1rem; }
.tablewrap { overflow: auto; max-height: 65vh; margin: 1rem 0; border: 1px solid var(--edge); background: var(--surface); }
.tablewrap table { border-collapse: collapse; font-size: .94rem; width: 100%; }
.tablewrap th, .tablewrap td { padding: .65rem; text-align: left; border-bottom: 1px solid var(--edge); }
.tablewrap th { position: sticky; top: 0; background: var(--tab-hover); }
.tablewrap tbody tr:nth-child(even) { background: #173e3708; }
.tablewrap tbody tr:last-child td { border-bottom: 0; }
.tablewrap td:last-child { min-width: 9rem; }
.visually-hidden, #room-composer label[for=room-message] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.profile-play {
  --paper: #f7f3eb;
  --header: #17362d;
  --header-line: #cba46a;
  --teal: #175743;
  --tab-hover: #e3ece2;
}
.play-hero {
  padding: clamp(1.5rem, 6vw, 5.5rem);
  border-radius: .5rem;
  background: #17362d;
  color: #fff9ee;
}
.play-hero h1 { font-size: clamp(2.55rem, 7vw, 6rem); }
.play-hero p { max-width: 38ch; margin: 0 0 1.65rem; font-size: clamp(1.05rem, 2.2vw, 1.35rem); }
.play-hero a { color: #fff9ee; }
.play-hero .primary { background: #f2ca89; border-color: #f2ca89; color: #22352a; }
.play-hero .coming-soon { pointer-events: none; }
.play-hero :focus-visible, .shell-header :focus-visible { outline-color: #f2ca89; }
.home-details { max-width: 55ch; padding: clamp(1rem, 3vw, 2.25rem) 0; }
.page-actions, .room-heading, .composer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1rem; }
.room-heading { justify-content: space-between; margin-bottom: 1rem; }
.room-heading p { margin: 0; }
.room-heading time { color: var(--muted); font-variant-numeric: tabular-nums; }
.information-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 1rem;
  margin-block: 1.5rem;
}
.information-panels section { padding: 1.15rem 1.25rem; background: var(--surface); border: 1px solid var(--edge); border-radius: .25rem; }
.information-panels h2 { font-size: 1.5rem; margin: 0; }
.information-panels p { margin-bottom: 0; }
.picker-options { list-style: none; display: grid; gap: .5rem; padding: 0; margin: .75rem 0 0; }
.picker-options button { width: 100%; padding: .65rem .75rem; text-align: left; }
.picker-options button:hover:not(:disabled) { background: var(--tab-hover); }
.picker-search { width: 100%; margin-bottom: .25rem; }
.ui-dialog > .shell-content:has(.picker-options) { overflow: auto; }
.picker-heading { font-size: 1.4rem; margin-block: 0 .5rem; }
.picker-heading:not(:first-child) { margin-top: 1rem; }
.notice-error { color: #8d281e; }
.room-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 1rem; }
.room-viewer { align-self: start; border-radius: .4rem; overflow: hidden; }
.room-conversation {
  display: flex;
  flex-direction: column;
  min-height: min(35rem, 76dvh);
  border: 1px solid var(--edge);
  border-radius: .4rem;
  background: var(--surface);
}
.room-conversation h2 { margin: 0; padding: 1rem; border-bottom: 1px solid var(--edge); font-size: 1.5rem; }
.room-name-form { display: grid; gap: .6rem; }
.room-name-form button { justify-self: start; }
.room-name-form p { margin: 0; }
.room-messages { flex: 1 1 auto; min-height: 9rem; max-height: 54dvh; overflow: auto; padding: .75rem 1rem; margin: 0; list-style: none; }
.room-messages > li { padding: .45rem 0; }
.room-messages > li + li { border-top: 1px solid var(--edge); }
.room-messages strong { overflow-wrap: anywhere; }
.room-messages p { margin: .2rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.room-messages time { color: var(--muted); margin-inline-start: .6rem; font-size: .8rem; }
.room-message-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: .2rem .6rem; }
.room-message-meta { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .25rem .4rem; margin-inline-start: auto; }
.room-messages .room-message-meta time { margin-inline-start: 0; white-space: nowrap; }
.room-delivery {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--teal);
  font-size: .75rem;
}
.room-delivery-icon { display: inline-block; text-align: center; min-width: .85em; font-weight: 700; }
.room-delivery[data-state=pending] .room-delivery-icon {
  width: .8rem;
  height: .8rem;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: room-delivery-spin .8s linear infinite;
}
@keyframes room-delivery-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .room-delivery[data-state=pending] .room-delivery-icon { animation: none; }
}
.room-delivery[data-state=failed] { color: #8d281e; }
.room-delivery[data-state=failed] .room-delivery-icon { display: none; }
.room-delivery .room-retry { padding: .1rem .3rem; font-size: inherit; color: inherit; border-color: currentColor; }
.room-markdown { overflow-wrap: anywhere; }
.room-markdown :is(ol, ul) { margin: .25rem 0; padding-inline-start: 1.25rem; }
.room-markdown li { white-space: pre-wrap; }
.room-markdown code { padding: 0 .2em; border-radius: .2rem; background: #f5f2e9; }
.room-messages .room-game-action {
  margin-block: .25rem;
  padding: .35rem .6rem;
  border: 1px solid var(--edge);
  border-radius: .25rem;
  background: var(--tab-hover);
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.35;
}
.room-messages .room-game-action p { margin: .1rem 0 0; line-height: inherit; }
.room-messages .room-game-action time { font-size: inherit; }
#room-composer { display: grid; gap: .4rem; padding: .85rem 1rem; border-top: 1px solid var(--edge); }
#room-message { width: 100%; resize: vertical; border-radius: .5rem; }
#room-send { display: none; }
.composer-actions { justify-content: space-between; }
#composer-status { margin: 0; font-size: .9rem; }
.login-form, .settings-form, .settings-fields, #admin-demos { display: grid; gap: .8rem; }
.login-form { max-width: 21rem; }
.settings-form { max-width: 48rem; }
.login-form label, .settings-fields label { display: grid; gap: .3rem; }
.settings-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.login-form button, .settings-form > button { justify-self: start; }
.settings-form fieldset { margin: 0; border: 1px solid var(--edge); }
.settings-form p { margin: 0; }
.check-label { display: flex; align-items: baseline; gap: .5rem; }
.admin-rooms { margin-top: 2rem; }
@media (max-width: 760px) {
  .room-layout { grid-template-columns: minmax(0, 1fr); }
  .room-conversation { min-height: 20rem; }
  .library-tabs { padding-inline: .35rem; gap: 0 .2rem; }
  .library-tabs :is(a, button) { font-size: .9rem; }
}
.account-link { color: var(--header-ink); padding-right: .35rem; }

.room-model-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; padding: .65rem 1rem; border-bottom: 1px solid var(--edge); }
.companion-choice { display: grid; gap: .25rem; min-width: 0; max-width: 100%; }
.room-model-controls small:not(:empty) { flex-basis: 100%; }

.ui-dialog[data-size=wide] { width: min(84rem, 96vw); }
.tablewrap .sort-heading { padding: 0; color: inherit; border: 0; text-align: inherit; font-weight: inherit; }
.tablewrap [aria-sort=ascending] .sort-heading::after { content: ' ▲'; }
.tablewrap [aria-sort=descending] .sort-heading::after { content: ' ▼'; }
.tablewrap .dialog-row { cursor: pointer; }
.tablewrap .dialog-row:is(:hover,:focus-within) > td { background: #12584e17; }
.tablewrap .table-empty { color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: .25rem; font-variant-numeric: tabular-nums; }
.pager button { color: inherit; border: 0; padding: .3rem .45rem; line-height: 1; }
.pager button:disabled { opacity: .35; }
.pager svg { display: block; width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.7; }
.pager .pager-count { min-inline-size: 16ch; }
.shell-pager { flex: none; align-self: stretch; padding: .15rem .5rem; border-bottom: 1px solid var(--edge); }
