:root {
  font: 16px/1.55 system-ui, sans-serif;
  color: #e1d6e0;
  background: #141018;
  --panel: #1d1620;
  --line: #483443;
  --muted: #b8a5b8;
  --ink: #e1d6e0;
  --pink: #f0adc9;
  --blue: #a8caec;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1,h2,p { margin: 0; }
h1,h2,.brand { font-family: Georgia, 'Times New Roman', serif; font-weight: 500; }
h1 { font-size: clamp(1.45rem, 4vw, 2.25rem); line-height: 1.12; overflow-wrap: anywhere; }
h2 { font-size: 1.38rem; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: #241b28; padding: .53rem .75rem; }
button:hover { background: #332333; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }
.chat-page {
  --chat-column: 57.5rem;
  --chat-gutter: max(clamp(.72rem, 3vw, 2rem), env(safe-area-inset-left), env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  height: var(--phone-height, 100dvh);
  overflow: hidden;
}
.top { flex: none; min-height: 50px; padding: .35rem var(--chat-gutter); display: flex; flex-wrap: wrap; gap: .3rem .85rem; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: #1d141f; }
.top-main, .chat-pages { display: flex; flex-wrap: wrap; align-items: center; gap: .36rem; }
.top-main { gap: .36rem .68rem; }
.brand { text-decoration: none; color: #f0d7e5; font-size: clamp(1.35rem, 3.8vw, 1.9rem); white-space: nowrap; }
.top .brand { font-size: 1.5rem; margin-inline-end: .3rem; }
.brand span { color: var(--pink); margin-right: .25rem; font-size: .8em; }
.beta-mark { display: inline-block; vertical-align: middle; padding: .15em .45em; border: 1px solid #76556b; border-radius: 4px; color: #e9bbd5; font: 650 .36em system-ui, sans-serif; letter-spacing: .07em; text-transform: uppercase; }
.provider { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; text-align: right; }
.top-controls { display: flex; flex-wrap: wrap; min-width: 0; gap: .35rem; align-items: center; justify-content: end; }
.chat-page[data-has-character="true"] .top-controls { display: none; }
.top-controls button { white-space: nowrap; font-size: .9rem; }
.app-link { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #241b28; color: var(--ink); padding: .53rem .75rem; text-decoration: none; white-space: nowrap; font-size: .9rem; }
.app-link:hover { background: #332333; }
.top .app-link, .top button { min-height: 36px; padding: .26rem .62rem; font-size: .85rem; }
.library-toggle { color: #edc7dc; white-space: nowrap; }

.workspace, .story { display: flex; flex: 1; min-height: 0; min-width: 0; }
.story { flex-direction: column; background: radial-gradient(ellipse at top right, #261a29, #141018 55%); }
dialog.library {
  position: fixed;
  inset: 0;
  inset-inline-end: auto;
  margin: 0;
  width: min(22rem, 86vw);
  max-width: none;
  height: var(--phone-height, 100dvh);
  max-height: none;
  padding-block: max(.85rem, env(safe-area-inset-top)) max(.85rem, env(safe-area-inset-bottom));
  padding-inline: max(.9rem, env(safe-area-inset-left)) .9rem;
  border: 0;
  border-inline-end: 1px solid #64475e;
  border-radius: 0 12px 12px 0;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 10px 0 30px #0b060fa6;
}
.library[open] { display: flex; flex-direction: column; gap: .65rem; }
.library::backdrop { background: rgba(10, 7, 12, .6); }
.library-head, .library-bottom button, .import, .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .65rem; }
.library-head { flex-wrap: wrap; gap: .4rem; }
.library-head h2 { margin-inline-end: auto; }
.library-head button { padding: .3rem .52rem; font-size: .86rem; }
#import-card, .library-bottom { flex: none; }
.import, .library-bottom button { width: 100%; text-align: left; }
.import { border-style: dashed; color: #e6bbd5; }
.import span, .library-bottom span { font-size: .76rem; color: var(--muted); }
.characters { display: grid; align-content: start; gap: .38rem; min-height: 0; margin-inline: -.25rem; padding: .25rem; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #67475d #19141d; }
.character-row { display: flex; text-align: left; align-items: center; gap: .65rem; min-width: 0; background: transparent; border-color: transparent; }
.character-row[aria-current="true"] { background: #332234; border-color: #6e4861; }
.character-row span:last-child { overflow-wrap: anywhere; }
.library-bottom { margin-top: auto; display: grid; gap: .45rem; }
.library-bottom #account-username { margin: 0 .15rem; overflow-wrap: anywhere; }
.character-head { display: flex; flex: none; align-items: center; gap: .7rem; padding: .35rem max(var(--chat-gutter), calc((100% - var(--chat-column)) / 2)); border-bottom: 1px solid #3b2b3c; }
.character-summary { display: flex; align-items: center; gap: .65rem; flex: 1; min-width: 0; }
.character-summary .portrait { flex-basis: 39px; height: 39px; font-size: 1.15rem; }
.character-summary h1 { font-size: clamp(1.15rem, 2.2vw, 1.55rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.identity { min-width: 0; flex: 1; }
.identity p { color: var(--muted); font-size: .75rem; }
.chat-controls { flex: none; display: flex; align-items: center; gap: .35rem; }
.chat-controls button { display: inline-grid; place-content: center; place-items: center; min-width: 42px; min-height: 42px; padding: 0 .55rem; font-size: .82rem; line-height: 1.15; white-space: nowrap; }
.chat-controls .chat-proxy { gap: .16rem; }
.chat-proxy-state { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .64rem; }
.chat-proxy-state::before { content: ""; flex: none; width: .34rem; height: .34rem; border-radius: 50%; background: currentColor; }
.chat-proxy[data-state="connected"] .chat-proxy-state { color: #b4d8ba; }
.chat-proxy[data-state="key-needed"] .chat-proxy-state { color: #e8c897; }
#chat-options { font-size: 1.18rem; }
.scene-settings, .persona-control { display: contents; }
.portrait { display: grid; place-items: center; flex: 0 0 52px; height: 52px; border: 1px solid #795168; border-radius: 50%; overflow: hidden; font: 500 1.5rem Georgia, serif; color: var(--pink); background: radial-gradient(circle at top, #4b2c42, #251a2b); }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 29%; }
.portrait, .portrait img { -webkit-touch-callout: none; user-select: none; }
.character-row .portrait { flex-basis: 34px; height: 34px; font-size: 1rem; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #67475d #19141d; scrollbar-gutter: stable both-edges; padding: .9rem var(--chat-gutter); overflow-wrap: anywhere; }
.messages:focus-visible { outline-offset: -2px; }
.empty { width: min(100%, 56ch); margin: min(10vh, 5rem) auto; text-align: center; color: var(--muted); }
.empty h2 { color: #e9d6e5; margin-bottom: .45rem; }
.empty p + button { margin-top: .65rem; }
.scene-list { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.scene-list select { max-width: min(68vw, 320px); }
.message { margin: 0 auto 1.55rem; width: min(100%, var(--chat-column)); background: #211927; border: 1px solid #504057; border-inline-start: 2px solid #906a87; border-radius: 5px 15px 15px 15px; padding: .8rem 1.1rem .95rem; line-height: 1.7; }
.message:last-child { margin-bottom: 0; }
.message.user { background: #51364c; border: 1px solid #8c607d; border-radius: 15px 5px 15px 15px; color: #f4e5ee; }
.message-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .58rem; margin-bottom: .5rem; }
.message-meta header { flex: 1 1 8ch; min-width: 0; margin: 0; color: #edc7dc; font-size: .85rem; font-weight: 650; }
.message-meta .message-portrait { flex-basis: 34px; width: 34px; height: 34px; border-radius: 8px; font-size: 1rem; }
.message-menu-toggle { min-width: 32px; min-height: 32px; padding: 0 .4rem; color: var(--muted); background: transparent; border-color: transparent; font-weight: 700; }
.message-menu-toggle:hover, .message-menu-toggle[aria-expanded="true"] { border-color: var(--line); background: #332333; }
.message-actions { display: none; }
.message-actions[data-open="true"] { display: flex; flex: 1 0 100%; justify-content: flex-end; flex-wrap: wrap; gap: .25rem; }
.message-actions button { padding: .11rem .34rem; font-size: .74rem; background: transparent; color: var(--muted); }
.message.user .message-actions button, .message.user .message-menu-toggle { color: #edcde0; }
.message-actions button:hover { color: var(--ink); background: #332333; }
.message p { white-space: pre-wrap; }
.message p + p { margin-top: .75rem; }
.message q { color: var(--pink); }
:is(.message, .scene-preview) q::before, :is(.message, .scene-preview) q::after { content: none; }
.message em { color: var(--blue); }
.message q em { color: inherit; }
:is(.message, .scene-preview) .text-message {
  background: #151019;
  color: var(--ink);
  padding: .08em .32em;
  border-radius: .25em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.reply-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; margin-top: .75rem; }
.reply-actions button { min-height: 1.9rem; padding: .22rem .55rem; color: #edc7dc; font-size: .8rem; line-height: 1.25; }
.reply-variants { display: inline-flex; align-items: center; gap: .12rem; margin-inline-end: auto; }
.reply-variants .reply-variant-arrow { min-inline-size: 38px; min-block-size: 38px; padding: 0; color: var(--pink); font-size: 1rem; }
.reply-variant-count { min-inline-size: 1.65rem; text-align: center; color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.composer { flex: none; padding: .48rem var(--chat-gutter) max(.7rem, env(safe-area-inset-bottom)); border-top: 1px solid #362936; background: #1b151e; }
.composer-meta, .compose-row, .generation-alert { width: min(100%, var(--chat-column)); margin-inline: auto; }
.generation-alert {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .35rem .65rem;
  padding: .5rem .55rem .5rem .75rem; margin-bottom: .55rem; border: 1px solid #a45970;
  border-radius: .55rem; color: #ffdae4; background: #3d232e; font-size: .85rem; line-height: 1.35;
}
.generation-alert[data-severity="notice"] { border-color: #836947; background: #382b26; color: #f1dbbe; }
.generation-alert-copy { min-width: 0; overflow-wrap: anywhere; }
.generation-alert-copy > p { margin-top: .15rem; }
#generation-alert-details { color: #e1afc1; font-size: .76rem; }
#dismiss-generation-alert { min-width: 42px; min-height: 40px; padding: 0; font-size: 1.2rem; line-height: 1; }
.composer-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .65rem; margin-bottom: .28rem; }
.player-picker { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .83rem; white-space: nowrap; }
.player-picker select { max-width: min(50vw, 15rem); padding: .23rem .45rem; }
.intimacy-control { display: flex; align-items: center; gap: .45rem; }
.intimacy-status { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .4rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.intimacy-status::before { content: ''; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.intimacy-status[data-active="true"] { color: var(--pink); background: #3b2136; border-color: #80536d; }
.memory-count {
  display: inline-flex; flex: none; align-items: center; justify-content: center; gap: .25rem;
  min-width: 4.6rem; min-height: 2rem; padding: .25rem .4rem; color: var(--pink);
  font-size: .76rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap;
}
.memory-count[data-needs-review="true"] { color: #ffc3cd; background: #44202b; border-color: #a55367; }
.memory-count[data-needs-review="true"]:hover { background: #552836; }
#memory-count-warning { font-weight: 800; }
.player-avatar { flex: 0 0 29px; height: 29px; font-size: .8rem; }
#notice { min-width: 0; font-size: .83rem; color: var(--muted); overflow-wrap: anywhere; }
#notice:empty, #notice[data-routine="true"] { display: none; }
.compose-row { display: flex; align-items: stretch; gap: .6rem; }
textarea, input:not([type=checkbox]), select { color: var(--ink); background: #17121b; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .72rem; min-width: 0; }
textarea { resize: vertical; }
#reply { flex: 1; min-height: 56px; max-height: 220px; }
#send,.primary { color: #21151e; background: #dba8c4; border-color: #dba8c4; font-weight: 650; }
#send:hover,.primary:hover { background: #f0bdd8; }
dialog { width: min(calc(100% - 1.5rem), 650px); max-height: calc(100dvh - 1.5rem); overflow: auto; padding: 1.15rem; border: 1px solid #64475e; border-radius: 14px; background: #211823; color: var(--ink); }
dialog::backdrop { background: rgba(10, 7, 12, .78); }
.dialog-head { margin-bottom: .8rem; }
.dialog-foot { display: flex; justify-content: flex-end; margin-top: .9rem; }
dialog label { display: grid; gap: .25rem; margin-bottom: .65rem; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: .85rem 0 0; padding: .55rem .75rem; }
dialog fieldset label { display: flex; align-items: center; gap: .45rem; margin: .2rem 0; }
dialog .intro-editor { margin-bottom: .85rem; }
dialog .intro-editor > label { display: grid; align-items: stretch; margin: .3rem 0 .65rem; }
.intro-option { display: grid; gap: .3rem; padding: .65rem 0; border-top: 1px solid var(--line); }
.intro-option-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.intro-option-head button, #add-intro { font-size: .85rem; }
dialog .intro-option .intro-title { display: grid; align-items: stretch; }
.scene-preview { max-height: min(36dvh, 18rem); overflow: auto; overflow-wrap: anywhere; background: #19141d; border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem; color: var(--muted); }
.scene-preview p { white-space: pre-wrap; }
.scene-preview p + p { margin-top: .65rem; }
#book-dialog p { margin-bottom: .8rem; color: var(--muted); }
.book-list { display: grid; gap: .45rem; margin-top: .75rem; }
.book-list .book-option { display: flex; align-items: center; gap: .6rem; min-width: 0; margin: 0; padding: .56rem .68rem; border: 1px solid var(--line); border-radius: 8px; }
.book-option input { flex: 0 0 auto; accent-color: var(--pink); }
.book-option span { overflow-wrap: anywhere; }
.book-option small { display: block; color: var(--muted); }
.book-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.book-actions .import { flex: 1 1 13rem; width: auto; }
.book-actions #create-lorebook { flex: 0 0 auto; }
#book-result:empty { display: none; }
.book-row { display: flex; align-items: stretch; gap: .4rem; min-width: 0; }
.book-row .book-option { flex: 1; }
.book-edit { flex: 0 0 auto; margin-inline-start: auto; color: var(--pink); font-size: .83rem; }

#lorebook-editor-dialog { width: min(calc(100% - 1.5rem), 970px); }
#lorebook-editor-dialog .dialog-head h2 { overflow-wrap: anywhere; }
.lorebook-editor-layout { display: grid; grid-template-columns: minmax(13rem, .72fr) minmax(0, 1.5fr); gap: 1rem; align-items: start; }
.lorebook-entry-sidebar { min-width: 0; padding: .75rem; border: 1px solid var(--line); border-radius: 9px; background: #1b141e; }
.lorebook-entry-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .65rem; }
.lorebook-entry-toolbar h3 { margin: 0; font-size: 1rem; font-weight: 650; }
.lorebook-entry-toolbar button { font-size: .85rem; }
#lorebook-entry-list { display: grid; gap: .32rem; max-height: min(50dvh, 29rem); overflow: auto; overscroll-behavior: contain; padding: .25rem .2rem; scrollbar-color: #67475d #19141d; }
#lorebook-entry-list:empty { display: none; }
.lorebook-entry-option { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .15rem .6rem; width: 100%; min-height: 2.45rem; text-align: left; overflow-wrap: anywhere; }
.lorebook-entry-option small { color: var(--pink); }
.lorebook-entry-option[aria-pressed="true"] { background: #3b263a; border-color: #956682; color: var(--pink); }
#lorebook-entry-fields { min-width: 0; margin: 0; }
#lorebook-entry-fields > label, .lorebook-entry-terms > label { display: grid; align-items: stretch; gap: .25rem; margin: .25rem 0 .65rem; }
.lorebook-entry-terms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.lorebook-entry-terms label { margin-bottom: .35rem; }
.lorebook-entry-options { display: flex; flex-wrap: wrap; gap: .25rem .85rem; }
.lorebook-entry-options input { accent-color: var(--pink); }
.lorebook-entry-actions { display: flex; justify-content: flex-end; margin: .65rem 0 .2rem; }
#lorebook-entry-remove { color: var(--pink); font-size: .85rem; }
#lorebook-editor-status { margin: .6rem 0 0; color: var(--pink); }
#lorebook-editor-status:empty { display: none; }
#lorebook-editor-dialog .dialog-foot { position: sticky; bottom: 0; padding-block: .55rem .2rem; background: #211823; }

.connection-grid, .connection-select { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .75rem; }
.connection-select { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.connection-select button { margin-bottom: .65rem; }
.load-models { font-size: .85rem; margin-bottom: .7rem; }
#custom-base { grid-column: 1 / -1; }
.connection-help, #connection-result { color: var(--muted); font-size: .88rem; margin-bottom: .6rem; }
#import-persona { margin-bottom: .7rem; }
#persona-result:not(:empty) { margin-top: .65rem; color: var(--pink); }
#connection-result:not(:empty) { color: var(--pink); }
.advanced-connection { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: .75rem; padding: .55rem 0; }
.advanced-connection summary { cursor: pointer; }
.advanced-connection[open] .connection-grid { margin-top: .6rem; }
.advanced-connection[open] > label:first-of-type { margin-top: .6rem; }
.memory-toggle { display: flex; align-items: center; gap: .4rem; }
.photo-choice { display: flex; gap: .65rem; align-items: center; margin-bottom: .65rem; }
.photo-choice label { flex: 1; min-width: 0; margin: 0; }
.photo-choice input { max-width: 100%; }
.photo-feedback:empty { display: none; }
#memory-coverage:empty, #memory-feedback:empty, #transfer-feedback:empty, #continuation-feedback:empty { display: none; }
#memory-feedback { color: var(--pink); }
.connection-actions { flex-wrap: wrap; gap: .55rem; }
#chat-tools-character { overflow-wrap: anywhere; }
#chat-tools .scene-list { margin-bottom: .65rem; }
.chat-tool-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.chat-tool-list button { min-height: 42px; text-align: left; }
.chat-portrait-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr)); gap: .55rem; }
.chat-portrait-choice { display: grid; align-content: start; gap: .45rem; padding: .45rem; min-width: 0; }
.chat-portrait-choice[aria-pressed="true"] { border-color: #d5a1bf; color: var(--pink); background: #422a3e; }
.chat-portrait-choice .portrait { width: 100%; height: auto; aspect-ratio: 1; border-radius: 7px; }
.chat-portrait-choice img { grid-area: 1 / 1; }
#chat-portrait-status { margin: .75rem 0 0; }
#chat-portrait-status:empty { display: none; }
.family-editor { margin: .8rem 0; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 8px; }
.family-editor summary { cursor: pointer; }
.family-editor[open] summary { margin-bottom: .6rem; }
#family-count { margin-left: .35rem; color: var(--muted); font-size: .82rem; }
.family-member { margin-bottom: .65rem; padding: .55rem .65rem; background: #19141d; border: 1px solid var(--line); border-radius: 8px; }
.family-member-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; overflow-wrap: anywhere; }
.family-member-head button { font-size: .83rem; }
.family-member-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 .7rem; }
.family-wide { grid-column: 1 / -1; }
.phone-repair { margin: 0 0 .75rem; padding: .65rem; border: 1px solid var(--line); border-radius: 8px; }
#repair-result { margin: .4rem 0 0; }
#repair-result:empty { display: none; }
.toast { position: fixed; pointer-events: none; bottom: 1rem; right: 1rem; max-width: calc(100vw - 2rem); padding: .65rem .9rem; background: #3c2639; color: #f2ddec; border: 1px solid #795569; border-radius: 9px; z-index: 3; }
@media (max-width: 760px) {
  .top { padding-block: max(.23rem, env(safe-area-inset-top)) .23rem; }
  .chat-page[data-has-character="true"] .top .brand { display: none; }
  .top .app-link, .top button { min-height: 42px; padding: .2rem .52rem; }
  .top-controls { flex: 1 1 auto; justify-content: start; }
  .top-controls .provider { flex: 1 1 100%; text-align: left; }
  .library-head button, .library-bottom button, #import-card, .character-row { min-height: 42px; }
  .character-head { gap: .4rem; }
  .character-summary { gap: .52rem; }
  .character-summary .portrait { flex-basis: 34px; height: 34px; }
  .character-summary h1 { font-size: 1.12rem; }
  .character-summary p { display: none; }
  .chat-controls { gap: .25rem; }
  .chat-controls button { min-width: 44px; min-height: 44px; padding-inline: .4rem; }
  .messages { padding-block: .62rem; scrollbar-gutter: auto; }
  .message { margin-bottom: 1.25rem; padding: .65rem .8rem .8rem; }
  .message-meta .message-portrait { flex-basis: 30px; width: 30px; height: 30px; border-radius: 7px; font-size: .94rem; }
  .message-menu-toggle { min-width: 42px; min-height: 40px; }
  .message-actions button { min-height: 36px; }
  .reply-actions button { min-height: 38px; }
  .composer { padding-top: .35rem; padding-bottom: max(.48rem, env(safe-area-inset-bottom)); }
  .scene-settings { display: flex; flex-wrap: wrap; align-items: center; gap: .32rem .5rem; width: 100%; }
  .persona-control { display: flex; align-items: center; gap: .35rem; }
  .scene-settings .player-picker, .scene-settings .intimacy-control { gap: .25rem; font-size: .74rem; }
  .scene-settings .player-avatar { flex-basis: 22px; height: 22px; }
  .scene-settings .player-picker select { padding: .12rem .3rem; }
  .memory-count { min-height: 2.25rem; }
  #player-persona { max-width: min(25vw, 8rem); }
  #intimacy-mode { max-width: min(29vw, 8rem); }
  dialog { max-height: calc(var(--phone-height, 100dvh) - 1.5rem); }
  .lorebook-editor-layout { grid-template-columns: 1fr; gap: .75rem; }
  #lorebook-entry-list { max-height: min(25dvh, 8.5rem); }
  #lorebook-editor-dialog { padding: .85rem; }
  #lorebook-entry-content { min-height: 9rem; }
  .lorebook-entry-option, .lorebook-entry-toolbar button, .book-edit { min-height: 42px; }
  #connection-dialog .connection-actions { position: sticky; bottom: 0; background: #211823; padding-top: .55rem; }
  #reply, .player-picker select { font-size: 16px; }
}
@media (max-width: 400px) {
  .lorebook-entry-terms { grid-template-columns: 1fr; gap: 0; }
  .connection-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 430px) {
  dialog.library { overflow-y: auto; }
  .library .characters { flex: none; overflow: visible; }
}

#access-settings {
  color: inherit;
  text-decoration: none;
  padding: .6rem .75rem;
  border-radius: .5rem;
  border: 1px solid #4c3649;
  white-space: nowrap;
}
#access-settings:hover { background: #302032; }

html.session-closed { visibility: hidden; }
