:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --sidebar: #efefec;
  --panel: #ffffff;
  --soft: #e8e9e5;
  --text: #25282d;
  --muted: #6d7179;
  --border: #d9d9d4;
  --accent: #465680;
  --accentText: #ffffff;
  --userBubble: #dfe6fb;
  --danger: #9b4b2a;
  --radius: 16px;
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
}

.thread-file-dialog { width: min(520px, calc(100vw - 24px)); max-height: 86dvh; padding: 20px; border-radius: 16px; }
.thread-file-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.thread-file-dialog .dialog-head { flex: none; align-items: center; gap: 8px; }
.thread-file-dialog .dialog-head h2 { min-width: 0; font-size: 18px; overflow-wrap: anywhere; }
.thread-file-dialog .dialog-head button { min-width: 32px; min-height: 32px; border: 0; }
.thread-file-dialog-body { min-height: 0; overflow: auto; }
.thread-file-dialog-body > input { width: 100%; }
/* Every text field in these dialogs uses the app's field style, including a bare input under the title. */
.thread-file-dialog input[type="text"], .thread-file-dialog input[type="search"] { width: 100%; min-height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 9px 12px; }
.thread-file-dialog input[type="text"]:focus-visible, .thread-file-dialog input[type="search"]:focus-visible, .thread-file-dialog textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 82%); }
.thread-file-dialog-body > select { width: 100%; margin-top: 8px; min-height: 32px; }
.file-manager-actions label { display: grid; gap: 6px; padding: 8px 12px; font-size: 13px; }
.file-manager-actions select { width: 100%; min-height: 32px; }
.thread-file-dialog .muted { font-size: 12px; }
.thread-file-dialog pre, .thread-file-message pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 13px; }
.thread-file-dialog summary, .thread-file-message summary { cursor: pointer; overflow-wrap: anywhere; }
.thread-file-dialog .dialog-actions { flex: none; margin: 0; gap: 8px; }
.material-action-dialog .thread-file-dialog-body { overflow-wrap: anywhere; }
.material-action-dialog .thread-file-dialog-body p { margin: 0; }
.material-action-dialog .dialog-actions { flex-wrap: wrap; }
.thread-file-dialog .dialog-actions button { min-height: 34px; padding: 7px 14px; border-radius: 10px; font-size: 13px; }
/* The confirming action is the filled accent button, as in 会話の設定; secondary actions stay outlined. */
.thread-file-dialog .dialog-actions button:not(.quiet) { border: 1px solid var(--accent); background: var(--accent); color: var(--accentText); font-weight: 700; }
.thread-file-dialog .dialog-actions button.quiet { border: 1px solid var(--border); background: transparent; color: var(--text); }
.thread-file-drafts { display: flex; flex-wrap: wrap; min-width: 0; gap: 6px; padding-bottom: 8px; }
.thread-file-chip { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }
.thread-file-chip button { min-height: 32px; border: 0; font-size: 12px; padding: 4px 8px; }
.thread-file-chip button:first-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-file-chip button:last-child { flex: none; }
.thread-file-message { margin-top: 8px; font-size: 13px; }
.thread-file-dialog .dialog-field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.thread-file-dialog textarea, .thread-file-dialog select { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 8px; }
.thread-file-dialog textarea { resize: vertical; min-height: 100px; max-height: 40dvh; }
.name-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.thread-file-dialog .dialog-field + .name-suggestions { margin-top: -2px; }
.name-suggestions > button { min-height: 28px; padding: 3px 12px; border: 0; border-radius: 99px; background: var(--bg); font-size: 13px; color: var(--muted); }
.name-suggestions > button:hover { background: var(--soft); color: var(--text); }
.name-entry, .name-entry-user-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.thread-file-dialog .name-entry > input[type="text"] { width: 100%; min-width: 0; font-size: 16px; }
.name-entry-user { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 16px; }
.name-entry-user-label { flex: 1 1 240px; min-width: 0; }
.thread-file-dialog .name-entry-user select { width: 100%; min-width: 0; min-height: 40px; border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 16px; color: var(--text); }
.name-entry-create { margin-top: 8px; }
.user-profile-form { display: grid; gap: 18px; }
.user-profile-list { display: flex; flex-wrap: wrap; gap: 8px; }
.user-profile-list button { min-height: 44px; max-width: 100%; overflow-wrap: anywhere; }
.user-profile-list button[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); color: var(--text); }
.user-profile-gender { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 12px; min-width: 0; }
.user-profile-gender legend { padding: 0; margin-bottom: 6px; font-size: 13px; }
.user-profile-gender label { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.user-profile-appearance { display: grid; gap: 12px; justify-items: start; }
.user-profile-appearance > div:empty, .user-profile-appearance > div:has(> .character-portrait[hidden]) { display: none; }
.user-profile-appearance p { margin: 0; font-size: 14px; line-height: 1.6; }
.user-profile-appearance .character-portrait { max-width: 160px; }
.user-profile-gender label[hidden] { display: none; }
.name-suggestions { align-items: center; }
.name-suggestions > span { font-size: 13px; color: var(--muted); }
.user-persona-choice { flex: none; display: inline-flex; min-height: 40px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.thread-file-dialog .user-persona-choice > button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 0; background: var(--panel); font-size: 13px; color: var(--muted); }
.thread-file-dialog .user-persona-choice > button + button { border-left: 1px solid var(--border); }
.thread-file-dialog .user-persona-choice > button:hover { background: var(--soft); color: var(--text); }
.thread-file-dialog .user-persona-choice > button[aria-pressed="true"] { background: var(--soft); color: var(--text); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
.name-suggestions > button[aria-pressed="true"] { background: var(--soft); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }
.thread-file-save-kind { margin-bottom: 12px; }
.thread-file-conflict { margin-bottom: 12px; }
.thread-file-conflict > p { margin: 0 0 6px; }
.thread-file-conflict > div { display: flex; flex-wrap: wrap; gap: 8px; }
.thread-file-conflict button { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.thread-file-conflict button[aria-pressed="true"] { background: var(--soft); font-weight: 700; }
.thread-file-answer-menu { font-size: 12px; }
.thread-file-answer-menu summary { cursor: pointer; padding: 6px; }
.thread-file-answer-menu > div { display: flex; align-items: center; gap: 6px; padding: 4px; }
.thread-file-action-block { margin: 8px 0; }
.thread-file-action-block [data-thread-file-action="pick"] { display: inline-flex; align-items: center; gap: 6px; }
.thread-file-action-block [data-thread-file-action="pick"] svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; }
.story-setup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.message-story-start .message-bubble { background: transparent; border: 0; box-shadow: none; padding: 0; color: var(--muted); font-size: 13px; }
.thread-file-action-block button { min-height: 32px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); font-size: 13px; }
@media (max-width:760px), (pointer:coarse) { .thread-file-action-block button { min-height: 44px; } }
@media (max-width: 760px), (pointer: coarse) {
  .thread-file-dialog { padding: 12px; }
  .thread-file-dialog .dialog-head h2 { font-size: 16px; }
  .thread-file-dialog button, .thread-file-dialog .dialog-head button, .thread-file-dialog .dialog-actions button,
  .thread-file-chip button, .story-play-search, .story-play-option { min-height: 44px; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { opacity: .52; cursor: not-allowed; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { position: relative; display: grid; grid-template-columns: var(--sidebar-width, 260px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.sidebar { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 10px 8px 8px; background: var(--sidebar); border-right: 1px solid var(--border); }
.sidebar-resizer { position: absolute; z-index: 5; top: 0; bottom: 0; left: calc(var(--sidebar-width, 260px) - 4px); width: 8px; cursor: col-resize; touch-action: none; }
.sidebar-resizer:hover, .sidebar-resizer:focus-visible, .sidebar-resizing .sidebar-resizer { background: linear-gradient(to right, transparent 3px, var(--muted) 3px, var(--muted) 5px, transparent 5px); outline: none; }
.sidebar-resizing { cursor: col-resize; user-select: none; }
.brand { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 3px 8px 5px; font-size: 14px; font-weight: 700; letter-spacing: -.015em; }
.sidebar-heading { display: flex; align-items: center; gap: 4px; }
.sidebar-heading .brand { flex: 1; min-width: 0; }
.sidebar-close { flex: 0 0 44px; width: 44px; height: 44px; border: 0; }
.brand { border: 0; background: transparent; text-align: left; }
.brand:hover { background: var(--soft); }
.brand-wordmark { display: block; width: 142px; height: auto; max-width: 100%; }
.gate-wordmark { width: 180px; margin-bottom: 20px; }
:root[data-theme="dark"] .brand-wordmark { filter: invert(1); }
.primary, .quiet, .icon { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); padding: 9px 13px; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accentText); font-weight: 700; }
.wide { width: 100%; justify-content: center; }
.quiet { background: transparent; }
.button-with-icon, .tool-button { display: inline-flex; align-items: center; gap: 8px; }
.button-with-icon svg, .tool-button svg { width: 17px; height: 17px; }
.story-navigation { flex-shrink: 0; margin-top: 8px; max-height: 65dvh; overflow-y: auto; }
.story-entry { display: flex; width: 100%; min-height: 34px; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.story-entry { align-items: center; font-weight: 600; }
.story-entry:hover { background: var(--soft); }
.story-entry svg { width: 16px; height: 16px; flex-shrink: 0; }
#story-create { margin: 6px 0 0; }
#story-edit { margin: 0 0 6px; }
#story-edit.is-current { background: var(--soft); }
#story-builder-menu { position: fixed; inset: auto; margin: 0; width: min(232px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px #0003; }
#story-builder-menu::backdrop { background: transparent; }
#story-builder-menu > button { display: flex; align-items: center; gap: 8px; width: 100%; color: var(--text); min-height: 34px; padding: 7px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 13px; }
#story-builder-menu > button:hover:not(:disabled), #story-builder-menu > button:focus-visible { background: var(--soft); }
#story-builder-menu > button:disabled { opacity: .45; cursor: default; }
#story-builder-menu > #new-thread, .thread-filter-trash { position: relative; margin-top: 9px; }
#story-builder-menu > #new-thread::before, .thread-filter-trash::before { content: ""; position: absolute; left: 4px; right: 4px; top: -5px; border-top: 1px solid var(--border); }
.thread-filter-trash svg { width: 16px; height: 16px; flex: 0 0 16px; }
#story-builder-menu svg { width: 16px; height: 16px; flex-shrink: 0; }
.story-kinds { display: flex; flex-wrap: wrap; gap: 2px; width: fit-content; max-width: 100%; padding: 2px; border-radius: 18px; background: var(--bg); }
.story-kinds > button { min-height: 32px; padding: 4px 12px; border: 0; border-radius: 99px; background: transparent; color: var(--muted); font-size: 13px; }
.story-kinds > button:hover { background: var(--soft); color: var(--text); }
.story-kinds > button[aria-pressed="true"] { background: var(--soft); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }
.thread-file-dialog-body > .story-play-search { margin-top: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 8px; }
.story-play-options { display: grid; gap: 2px; margin-top: 12px; }
.story-play-options > p { margin: 8px 0; }
.play-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 16px; }
.play-preparing .thread-header, .play-preparing .composer-wrap, .play-preparing .character-portrait-intro { display: none; }
.play-preparing .messages { min-height: 0; padding: 0 24px 24px; scroll-padding-top: 16px; }
@media (max-width: 760px) {
  .play-opening .play-library { padding-top: 48px; }
}
.play-preparing .message { width: 100%; max-width: none; margin: 0; }
.play-preparing .message-bubble { padding: 0; }
.play-own-section { position: sticky; top: 0; z-index: 2; padding-bottom: 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.play-section-label { margin: 0; padding: 16px 0 10px; font-size: 12px; color: var(--muted); }
.play-own-carousel.has-overflow { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 8px; }
.play-row-arrow { width: 32px; min-height: 44px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 22px; }
.play-row-arrow:hover:not(:disabled), .play-row-arrow:focus-visible { background: var(--soft); }
.play-row-arrow:disabled { opacity: .25; }
@media (max-width: 760px), (pointer: coarse) {
  .play-own-carousel.has-overflow { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .play-row-arrow { width: 44px; }
}
.play-own-row { display: grid; grid-auto-flow: column; grid-auto-columns: 180px; gap: 16px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; padding: 3px; margin: -3px; }
.play-own-row::-webkit-scrollbar { display: none; }
.play-own-row .play-card { scroll-snap-align: start; }
.play-load-sentinel { height: 1px; }
@media (max-width: 480px) {
  .play-preparing .messages { padding: 0 12px 16px; }
  .play-own-row { grid-auto-columns: max(144px, calc((100% - 20px) / 2.2)); gap: 10px; }
}
@media (max-width: 800px) {
  .play-own-section { padding-top: 44px; }
  .play-own-section[hidden] + .play-section-label { padding-top: 60px; }
}
.play-card { display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); text-align: left; line-height: 1.5; }
.play-card:hover { border-color: var(--accent); }
.play-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.play-card-cover { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; background: linear-gradient(145deg, var(--soft), var(--bg)); color: var(--muted); font-size: 36px; }
.play-card:nth-child(3n + 2) .play-card-cover { background: linear-gradient(35deg, var(--soft), var(--userBubble)); }
.play-card:nth-child(3n + 3) .play-card-cover { background: linear-gradient(160deg, var(--bg), var(--soft)); }
.play-card-cover img { display: block; width: 100%; height: 100%; min-width: 0; object-fit: cover; }
.play-card-cast img { flex: 1 1 0; width: 0; object-position: center 25%; }
.play-card-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; padding: 0 12px; margin: 11px 0 12px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.play-library-status:empty { display: none; }
.play-library-status { margin-top: 16px; font-size: 13px; }
.play-library-status button { margin-top: 8px; }
@media (max-width: 480px) {
  .play-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .play-card-title { padding: 0 9px; font-size: 13px; }
}
.story-play-options > button.quiet:not(.story-play-option) { justify-self: start; }
.story-play-option { display: grid; gap: 2px; min-width: 0; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.story-play-option:hover, .story-play-option:focus-visible { background: var(--soft); }
.story-play-option[aria-pressed="true"] { position: relative; padding-right: 34px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--border); }
.story-play-option[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 50%; right: 12px; transform: translateY(-50%); font-weight: 700; }
.story-play-option > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-play-option > span:first-child { font-size: 14px; font-weight: 600; }
.story-play-option.file-create-option { display: flex; align-items: center; gap: 8px; }
.file-create-option > svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.story-play-option.file-create-option > .file-title { font-size: 14px; font-weight: 600; }
.story-play-selected { margin: 0 0 12px; font-size: 15px; overflow-wrap: anywhere; }
.story-play-dialog { height: min(560px, 86dvh); }
.quest-start-name { margin: 0 0 12px; font-weight: 700; overflow-wrap: anywhere; }
.quest-start-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; }
.quest-start-row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.quest-start-row > button { flex: none; padding: 6px 12px; }
.story-play-dialog .thread-file-dialog-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.story-play-dialog .thread-file-dialog-body > * { flex: none; }
.story-play-dialog .thread-file-dialog-body > .story-play-options { flex: 1; min-height: 0; overflow-y: auto; align-content: start; }
.story-play-dialog .dialog-actions:empty { display: none; }
.prompt-files { margin: 8px 0; }
#prompt-fixed-files { display:flex; flex-wrap:wrap; gap:6px; }
.prompt-fixed-file { display: flex; align-items: center; gap: 2px; min-width: 0; max-width:100%; border:1px solid var(--border); border-radius:8px; }
.prompt-fixed-file > button { padding: 6px; font-size: 12px; white-space: nowrap; flex-shrink: 0; border:0; background:transparent; }
.prompt-fixed-file .prompt-fixed-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: left; }
@media (max-width: 760px), (pointer: coarse) { .prompt-files button { min-height: 44px; } }
#story-entry-error { margin: 8px; font-size: 12px; }
@media (max-width: 760px), (pointer: coarse) { .story-entry, #story-builder-menu > button { min-height: 44px; } }
.thread-area { position: relative; flex: 1; min-height: 0; }
.thread-scroll { height: 100%; overflow: auto; overscroll-behavior: contain; }
.thread-list { display: flex; flex-direction: column; gap: 1px; padding-top: 3px; }
.thread-list-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 0 8px; color: var(--muted); font-size: 11px; }
.thread-list-header > h2, .thread-section-heading { margin: 0; min-width: 0; color: var(--muted); font-size: 11px; line-height: 20px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-section-heading { padding: 14px 8px 6px; }
.thread-section-start { flex-shrink: 0; min-width: 0; }
#thread-filter-toggle { position: relative; display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
#thread-filter-toggle svg { width: 16px; height: 16px; }
#thread-filter-toggle:hover { background: var(--soft); }
#thread-filter-toggle.is-filtered::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
#thread-filter-menu { position: fixed; inset: auto; margin: 0; width: 216px; max-height: calc(100dvh - 140px); overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px #0003; font-size: 12px; }
#thread-filter-menu label { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
#thread-filter-brand { min-width: 0; flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px; }
#thread-filter-reset { border: 0; background: transparent; color: var(--muted); padding: 5px 0; font-size: 12px; }
.thread-filter-option { display: flex; align-items: center; gap: 7px; width: 100%; padding: 8px 5px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 12px; }
.thread-filter-option:hover, .thread-filter-option[aria-pressed=true] { background: var(--soft); }
.thread-filter-option img { flex: 0 0 16px; object-fit: contain; }
.thread-filter-check { margin-left: auto; }
.thread-filter-divider { margin: 4px; border: 0; border-top: 1px solid var(--border); }
.thread-filter-empty { color: var(--muted); font-size: 11px; padding: 8px; line-height: 1.6; }
.thread-actions { position: absolute; right: 2px; display: flex; visibility: hidden; opacity: 0; border-radius: 6px; background: var(--soft); }
.thread-item:hover .thread-actions, .thread-item:focus-within .thread-actions { visibility: visible; opacity: 1; }
.thread-item:hover .thread-button, .thread-item:focus-within .thread-button { padding-right: 62px; }
.thread-action { display: grid; place-items: center; width: 26px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.thread-action svg { width: 14px; height: 14px; }
.thread-action:hover { background: var(--panel); color: var(--text); }
.thread-trash:hover { color: var(--danger); }
.thread-pin[aria-pressed=true] { color: var(--accent); }

.thread-actions .thread-more { position: static; opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .thread-actions { visibility: visible; opacity: 1; background: transparent; }
  .thread-item .thread-button { padding-right: 62px; }
}
.thread-item { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 8px; }
.thread-item:hover, .thread-item:focus-within, .thread-item:has(.thread-button[aria-current=true]) { background: var(--soft); }
.thread-button { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; min-height: 32px; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; line-height: 1.35; text-align: left; }
.thread-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-name-numbered { display: flex; }
.thread-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.thread-name-number { flex: 0 0 auto; white-space: pre; }
.thread-lines { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.thread-participant { display: flex; align-items: center; gap: 5px; min-width: 0; }
.thread-group { margin-block: 4px; }
.thread-group .thread-lines { border-left: 2px solid var(--muted); padding-left: 8px; }
.thread-group .thread-participant { min-height: 18px; }
.thread-model-marks { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; color: var(--muted); }
.thread-model-logo { width: 12px; height: 12px; object-fit: contain; opacity: .72; filter: saturate(.65); }
.thread-more, .thread-restore { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.thread-more { position: absolute; right: 2px; opacity: 0; }
.thread-item:hover .thread-more, .thread-item:focus-within .thread-more, .thread-more[aria-expanded=true] { opacity: 1; }
.thread-more:hover, .thread-restore:hover { background: color-mix(in srgb, var(--text), transparent 91%); color: var(--text); }
.thread-more svg, .thread-restore svg { width: 15px; height: 15px; }
.thread-list > .thread-item { flex-shrink: 0; }
.list-more { flex-shrink: 0; min-height: 44px; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; }
.list-more:hover { background: var(--soft); color: var(--text); }
.sidebar-footer-button { flex-shrink: 0; min-height: 44px; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; text-align: left; }
.sidebar-footer-button:hover { background: var(--soft); color: var(--text); }
.sidebar-footer { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.sidebar-footer:has(> #sidebar-registration:not([hidden])) {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}
#sidebar-registration { grid-column: 2; }
.sidebar-footer:has(> #sidebar-registration:not([hidden])) > #settings-open { grid-column: 3; justify-self: end; }
.sidebar #account-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; overflow: hidden; font-weight: 400; line-height: 20px; }
.sidebar #account-open .account-avatar { width: 18px; height: 18px; font-size: 9px; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
#trash-dialog { width: min(520px, calc(100vw - 28px)); padding: 20px; }
.folder-screen.material-trash-pane { padding: 0; margin-top: 12px; max-height: 55dvh; overflow: auto; }
.material-trash-pane .folder-heading { justify-content: flex-end; margin-bottom: 8px; }
.material-trash-pane .folder-heading:has(.folder-search-toggle[hidden]) { display: none; }
.trash-list { display: grid; gap: 1px; max-height: 55dvh; overflow: auto; overscroll-behavior: contain; }
.trash-list .thread-restore { flex-shrink: 0; width: 44px; height: 44px; }
.trash-item { display: flex; align-items: center; gap: 2px; min-width: 0; padding-left: 8px; }
.trash-title { flex: 1; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.main { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.menu-toggle.icon { position: absolute; z-index: 9; top: 2px; left: 6px; width: 44px; height: 44px; padding: 0; place-items: center; border: 0; border-radius: 8px; background: transparent; }
.menu-toggle:hover { background: var(--soft); }
.gate, .welcome { flex: 1; overflow: auto; }
.gate { display: grid; place-items: center; padding: 28px; }
.gate-card { width: min(580px, 100%); padding: 48px; border: 1px solid var(--border); border-radius: 22px; background: var(--panel); }
.eyebrow { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.gate h1, .welcome h1 { margin: 0 0 12px; font-size: clamp(30px, 5vw, 52px); line-height: 1.1; letter-spacing: -.045em; }
.gate p, .welcome p, .dialog-intro { color: var(--muted); line-height: 1.7; }
.gate .primary { margin-top: 16px; }
.welcome { padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 64px); }
.welcome-copy, .welcome .model-grid, .welcome .empty-state { width: min(100%, 820px); margin-left: auto; margin-right: auto; }
.welcome h1 { margin: 8px 0; font-size: 26px; line-height: 1.4; letter-spacing: -.02em; }
.welcome-copy > p { margin: 0; font-size: 13px; }
.welcome .eyebrow { font-size: 10px; letter-spacing: .14em; }
.model-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 26px; }
.model-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; min-height: 96px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); text-align: left; }
.model-card:hover { border-color: var(--accent); background: var(--soft); }
.model-card-copy { min-width: 0; }
.model-card-arrow { flex: 0 0 auto; color: var(--muted); font-size: 22px; }
.model-card h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.model-card h2 span { min-width: 0; }
.model-card-logo { flex: 0 0 20px; width: 20px; height: 20px; object-fit: contain; }
.model-card p { margin: 0; font-size: 12px; line-height: 1.6; }
.model-card .model-restriction { margin-top: 8px; color: var(--muted); font-size: 12px; }
.model-meta { display: flex; gap: 7px; color: var(--muted); font-size: 12px; }
.model-capabilities { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.pill { padding: 4px 8px; border-radius: 99px; background: var(--soft); font-size: 11px; }
.empty-state { margin-top: 38px; padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }

.conversation { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.workspace-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-height: 44px; gap: 4px 8px; padding: 4px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
#pane-add { grid-column: 2; grid-row: 1; margin-left: auto; flex-shrink: 0; }
#pane-tabs { display: none; min-width: 0; gap: 4px; }
#pane-tabs button { min-width: 0; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 8px; }
#pane-tabs button[aria-selected="true"] { color: var(--text); background: var(--panel); box-shadow: inset 0 -2px var(--text); }
.pane-grid { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; min-height: 0; min-width: 0; }
.pane-grid.split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pane-grid .conversation { position: relative; min-width: 0; overflow: hidden; }
.pane-grid.split .conversation + .conversation { border-left: 1px solid var(--border); }
.pane-close { margin-left: auto; flex: 0 0 auto; }
.pane-missing { margin: 24px; color: var(--muted); }
.workspace-status { padding: 8px 16px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.chat-modes { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; grid-column: 1; grid-row: 1; }
.chat-modes button { background: transparent; border: 0; border-radius: 6px; padding: 6px 12px; font-size: 12px; }
.chat-modes button[aria-pressed="true"] { background: var(--soft); color: var(--text); }
#mode-note { color: var(--muted); font-size: 11px; }
.shared-composer-wrap { flex-shrink: 0; padding: 4px max(12px, calc((100% - 920px) / 2)) 12px; max-height: 45%; overflow-y: auto; }
#batch-results { display: flex; gap: 8px 20px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
#batch-results > div { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#batch-results button { font-size: 12px; padding: 5px 8px; }
.batch-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
#batch-limit { font-size: 11px; color: var(--muted); }
#batch-send { flex-shrink: 0; padding: 7px 12px; font-size: 12px; }
:is(.batch-mode, .dialogue-mode) .pane-grid .composer { border-radius: 12px; box-shadow: none; }
@media (max-width: 760px), (pointer: coarse) {
  .chat-modes button, #batch-send, #batch-results button { min-height: 44px; }
  .shared-composer-wrap { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (max-width: 1000px) {
  .pane-grid.split { grid-template-columns: minmax(0, 1fr); }
  .pane-grid .conversation:not(.is-selected) { display: none; }
  .pane-grid.split .conversation + .conversation { border-left: 0; }
  #pane-tabs { display: flex; grid-column: 1; grid-row: 1; }
  .chat-modes { grid-column: 1 / -1; grid-row: 2; }
  #pane-tabs button { flex: 1; min-height: 44px; padding: 8px; }
}
@media (max-width: 760px) {
  .workspace-bar { padding-left: 54px; }
  .pane-grid .thread-header { padding-left: 14px; }
  .workspace .icon { min-width: 44px; min-height: 44px; }
}
.thread-header { display: flex; align-items: center; gap: 7px; min-height: 42px; padding: 0 max(18px, calc((100% - 920px) / 2)); border-bottom: 1px solid color-mix(in srgb, var(--border), transparent 28%); color: var(--muted); font-size: 12px; white-space: nowrap; }
.thread-header strong { min-width: 0; overflow: hidden; color: var(--text); font-weight: 650; text-overflow: ellipsis; }
.thread-header-separator { color: color-mix(in srgb, var(--muted), transparent 35%); }
[data-pane-element="thread-header-model"] { flex: 0 0 auto; }
[data-pane-element="thread-header-files"] { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow: auto; overflow-anchor: none; padding: 38px max(24px, calc((100% - 920px) / 2)) 190px; }
.messages-latest { position: absolute; right: 0; left: 0; margin-inline: auto; bottom: calc(100% + 8px); pointer-events: auto; background: var(--panel); box-shadow: 0 2px 10px #0002; }
.latest-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 50%; }
.latest-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 760px), (pointer: coarse) { .latest-button { width: 44px; height: 44px; } }
.dialogue-mode .messages-latest { display: none; }
@media (max-width: 760px), (pointer: coarse) { .messages-latest { min-height: 44px; } }
.message { width: min(82%, 720px); margin: 0 0 26px; }
.messages > .message:last-child { margin-bottom: 0; }
.message-user { margin-left: auto; }
.message-content { min-width: 0; }
.message-user .message-content { display: grid; justify-items: end; }
.generation-state { display: flex; align-items: center; justify-content: flex-end; gap: 8px; max-width: 560px; padding: 5px 4px 0; color: var(--muted); font-size: 11px; text-align: right; }
.generation-retry { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; border: 0; border-radius: 7px; background: transparent; color: var(--muted); padding: 5px 7px; font-size: 11px; }
.generation-retry:hover { background: var(--soft); color: var(--text); }
.generation-retry svg { width: 14px; height: 14px; }
@media (max-width: 760px), (pointer: coarse) { .generation-retry { min-height: 44px; } }
.message-bubble { min-width: 0; max-width: 100%; line-height: 1.72; overflow-wrap: anywhere; }
.message-bubble p { margin: 0; white-space: pre-wrap; }
.message-bubble p + p, .message-bubble p + ul, .message-bubble p + ol, .message-bubble ul + p, .message-bubble ol + p, .message-bubble pre + p { margin-top: .85em; }
.message-bubble ul, .message-bubble ol { margin: .55em 0; padding-left: 1.45em; }
.message-bubble li + li { margin-top: .28em; }
.message-bubble li > ul, .message-bubble li > ol { margin: .28em 0 0; }
.message-bubble .message-heading { margin: 1.1em 0 .45em; line-height: 1.45; font-weight: 650; }
.message-bubble h3.message-heading { font-size: 1.14em; }
.message-bubble h4.message-heading { font-size: 1.06em; }
.message-bubble h5.message-heading { font-size: 1em; }
.message-bubble hr { margin: 1em 0; border: 0; border-top: 1px solid var(--border); }
.message-bubble blockquote { margin: .75em 0; padding-left: .9em; border-left: 3px solid var(--border); color: var(--muted); }
.message-table { max-width: 100%; margin: .75em 0; overflow-x: auto; }
.message-table table { border-collapse: collapse; font-size: .95em; }
.message-table th, .message-table td { padding: .4em .75em; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.message-table th { font-weight: 650; }
.message-bubble > .message-heading:first-child, .message-bubble > hr:first-child, .message-bubble > blockquote:first-child, .message-bubble > .message-table:first-child { margin-top: 0; }
.message-bubble code { padding: .12em .35em; border-radius: 5px; background: var(--soft); font-family: "Cascadia Code", Consolas, monospace; font-size: .92em; }
.message-bubble pre { max-width: 100%; overflow: auto; margin: .75em 0 0; padding: 12px; border-radius: 10px; background: var(--soft); }
.message-bubble pre code { padding: 0; background: transparent; }
.message-code-block { min-width: 0; max-width: 100%; margin-top: .75em; border-radius: 10px; background: var(--soft); overflow: hidden; }
.code-block-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; padding: 2px 6px; border-top: 1px solid var(--border); }
.code-block-copy { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 76px; min-height: 36px; border: 0; border-radius: 6px; padding: 6px 8px; background: transparent; color: var(--muted); font-size: 12px; }
.code-block-copy:hover { color: var(--text); background: var(--panel); }
.code-block-copy svg { width: 16px; height: 16px; }
.message-code-block pre { margin: 0; border-radius: 0; }
.message-code-block.creation-draft pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.message-code-block.creation-draft code { white-space: inherit; }
.character-draft-result { overflow-wrap: anywhere; }
.character-draft-overview > p { margin: 0 0 12px; }
.character-draft-details { margin: 16px 0; }
.character-draft-details > summary { width: fit-content; min-height: 32px; padding: 4px 0; cursor: pointer; color: var(--muted); }
.character-draft-details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
@media (max-width: 640px), (pointer: coarse) { .character-draft-details > summary { min-height: 44px; padding: 9px 0; } }
.message-code-block + p { margin-top: .85em; }
.message-code-block .inline-operation-error { padding: 0 12px 10px; }
@media (max-width: 760px) { .code-block-copy { min-height: 44px; } }
.message-user .message-bubble { padding: 12px 15px; border: 1px solid color-mix(in srgb, var(--accent), transparent 72%); border-radius: 18px 18px 5px 18px; background: var(--userBubble); box-shadow: 0 1px 2px color-mix(in srgb, var(--text), transparent 94%); }
.message-assistant .message-bubble { padding: 4px; }
.message-footer { display: flex; align-items: center; gap: 4px; min-height: 30px; padding: 4px 4px 0; }
.message-status { color: var(--muted); font-size: 11px; }
.message-actions { display: flex; gap: 4px; }
.message-action { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.message-action:hover { background: var(--soft); color: var(--text); }
.message-action svg { width: 17px; height: 17px; }

.composer-wrap { position: absolute; right: 0; bottom: 0; left: 0; padding: 28px max(20px, calc((100% - 820px) / 2)) 16px; background: linear-gradient(transparent, var(--bg) 28%); }
.composer-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.composer-tools { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.composer-model { display:inline-flex; align-items:center; justify-content:center; flex:none; width:36px; height:36px; padding:7px; border:0; border-radius:50%; color:var(--muted); background:transparent; }
.composer-model:hover,.composer-model[aria-expanded="true"] { background:var(--soft); }
.composer-model img,.composer-model svg { width:20px; height:20px; }
.composer-model-menu { position:fixed; inset:auto; margin:0; padding:4px; border:1px solid var(--border); border-radius:10px; background:var(--panel); color:var(--text); box-shadow:0 8px 28px #0003; overflow-y:auto; }
.composer-model-menu::backdrop { background:transparent; }
.composer-model-menu .model-option { min-height:32px; padding:6px 8px; margin:0; border-radius:6px; font-size:13px; line-height:18px; }
.composer-model-menu .model-option[aria-checked="true"] { background:var(--soft); }
.composer-model-menu p { margin:12px; font-size:13px; color:var(--muted); }
@media (max-width:760px), (pointer:coarse) { .composer-model { width:44px; height:44px; }.composer-model-menu .model-option { min-height:44px; } }
.composer-settings { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.composer-recovery { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.composer-recovery > span { flex: 1 1 180px; }
.composer-recovery > button { flex: 0 0 auto; font-size: 12px; padding: 6px 9px; }
.tool-button { padding: 7px 10px; border-radius: 99px; color: var(--muted); font-size: 13px; }
.tool-button:hover { background: var(--soft); color: var(--text); }
.state-toggle { font-weight: 600; }
.state-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accentText); }
.state-toggle:disabled { cursor: default; }
.model-output-settings { border-top: 0; margin-top: 0; padding-top: 10px; }
.output-setting-fields { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: center; gap: 5px 12px; margin-top: 0; }
.output-setting-fields label { grid-column: 1 / -1; font-size: 13px; }
.output-setting-fields input { display: block; min-width: 0; width: 100%; margin: 0; }
#prompt-dialog #answer-characters { height: 30px; min-height: 30px; padding: 4px 7px; border-radius: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.answer-length-control { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--muted); font-size: 12px; }
.answer-length-control > span { flex: 0 0 auto; }
.answer-length-control #answer-length { flex: 1; min-width: 0; width: 0; height: 32px; margin: 0; padding: 0; border: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }
.answer-length-control #answer-length.unspecified { opacity: .5; }
.model-output-settings .field-note { font-size: 12px; line-height: 1.6; margin: 6px 0; }
@media (max-width: 480px) { .output-setting-fields { gap: 6px 10px; } .answer-length-control { gap: 6px; } }
.model-family h3 { color: var(--muted); font-size: 11px; margin: 7px 12px; }
.model-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px; margin-top: 5px; border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left; }
.model-option:hover, .model-option[aria-current=true] { background: var(--soft); }
.model-option strong { font-size: 14px; }
.model-option-detail, .model-option-reason { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.model-option .pill { flex: 0 0 auto; }
.switch { width: 34px; height: 20px; border-radius: 99px; background: var(--border); padding: 3px; }
.switch:after { content: ""; display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); transition: transform .15s; }
.composer-limit { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 9px 9px 9px 13px; border: 1px solid var(--border); border-radius: 24px; background: var(--panel); box-shadow: 0 8px 32px color-mix(in srgb, var(--text), transparent 90%); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent), transparent 45%); }
.composer textarea { flex: 1; resize: none; min-height: calc(1.5em + 16px); max-height: 180px; border: 0; outline: 0; background: transparent; padding: 8px 5px; line-height: 1.5; }
.guest-chat-input { min-height: 44px; border: 0; background: transparent; padding: 8px 5px; color: var(--muted); font: inherit; text-align: start; }
.guest-chat-input:hover { color: var(--text); }
.send { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: var(--accent); color: var(--accentText); }
.send svg { width: 21px; height: 21px; }
.send:disabled { opacity: .45; cursor: default; }
.mobile-only { display: none !important; }
dialog { width: min(620px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow: auto; border: 1px solid var(--border); border-radius: 20px; background: var(--panel); color: var(--text); padding: 24px; box-shadow: 0 24px 80px #0004; }
dialog::backdrop { background: #1118; backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-head h2 { margin: 0; font-size: 28px; }
.icon { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0; background: transparent; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; margin-top: 24px; }
.dialog-actions-split { justify-content: space-between; align-items: center; }
.dialog-field { display: grid; gap: 7px; margin-top: 22px; font-size: 13px; font-weight: 700; }
.dialog-field input { width: 100%; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); padding: 10px; font-weight: 400; }
.danger-button { border: 1px solid color-mix(in srgb, var(--danger), transparent 40%); border-radius: 10px; background: transparent; color: var(--danger); padding: 9px 13px; font-weight: 700; }
.danger-button:hover { background: color-mix(in srgb, var(--danger), transparent 90%); }
#prompt-form { display: grid; gap: 15px; }
#prompt-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
#prompt-form input, #prompt-form textarea { width: 100%; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); padding: 10px; font-weight: 400; }
.prompt-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.prompt-tab { border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); padding: 8px 11px; font-size: 12px; }
.prompt-tab[aria-selected=true] { background: var(--soft); color: var(--text); font-weight: 700; }
.prompt-fields { display: grid; gap: 15px; }
.prompt-raw-fields { display: grid; gap: 8px; }
.raw-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#prompt-form .raw-editor { min-height: 230px; resize: vertical; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; line-height: 1.6; }
.field-note { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent), transparent 55%); outline-offset: 2px; }

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #17181b;
    --sidebar: #111215;
    --panel: #222429;
    --soft: #2b2e35;
    --text: #f1f2f3;
    --muted: #aeb2bc;
    --border: #373a43;
    --accent: #b7c5f4;
    --accentText: #17181b;
    --userBubble: #303b5a;
    --danger: #efb58f;
}

#sidebar-backdrop { display: none; }
@media (max-width: 760px) {
  .sidebar.open ~ #sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 9; border: 0; padding: 0; background: transparent; cursor: default; }
  .app-shell { display: block; }
  .sidebar-resizer { display: none; }
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: min(280px, 88vw); padding-bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-105%); transition: transform .18s; box-shadow: 20px 0 60px #0004; }
  .sidebar.open { transform: none; }
  .thread-more { opacity: .78; }
  .mobile-only { display: grid !important; }
  .welcome { padding: 62px 18px 28px; }
  .thread-header { height: 48px; min-height: 48px; flex-shrink: 0; padding: 0 14px 0 58px; }
  [data-pane-element="thread-header-model"] { max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
  .gate { padding: 18px; }
  .gate-card { padding: 30px 22px; }
  .messages { padding: 26px 12px 184px; }
  .message { width: 92%; margin-bottom: 22px; }
  .message-user .message-bubble { padding: 11px 13px; }
  .composer-wrap { padding-right: 10px; padding-left: 10px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .composer textarea { max-height: min(180px, 30dvh); font-size: 16px; }
  .composer .send { width: 44px; height: 44px; }
  .composer .tool-button, .composer .thinking-option { min-height: 44px; }
  .composer-tools { padding-left: 2px; }
  .model-grid { grid-template-columns: 1fr; }
}

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

.model-group-title { grid-column: 1 / -1; margin: 12px 0 0; font-size: 13px; color: var(--muted); }

.thinking-control { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.thinking-segments { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 99px; background: var(--bg); }
.thinking-control > span { padding-left: 6px; color: var(--muted); }
.thinking-option { min-height: 32px; padding: 4px 9px; border: 0; border-radius: 99px; background: transparent; color: var(--muted); }
.thinking-option:hover { background: var(--soft); color: var(--text); }
.thinking-option[aria-pressed="true"] { background: var(--soft); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }

.settings-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 7px; }

.prompt-tag-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
#prompt-help { position: fixed; inset: auto; margin: 0; width: min(380px, calc(100vw - 16px)); max-height: min(300px, calc(100dvh - 16px)); overflow-y: auto; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--muted); font-size: 13px; box-shadow: 0 8px 28px #0005; }
#prompt-help::backdrop { background: transparent; }
#prompt-help > .icon { float: right; }
#prompt-help pre { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }

.prompt-count { text-align: right; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
#free-prompt-panel > .raw-heading { justify-content: flex-end; }

.settings-heading-actions { margin-left: auto; }
#free-prompt-panel .prompt-tag-buttons { margin-top: 0; }

#prompt-tags button { font-family: ui-monospace, Consolas, monospace; }
#prompt-tags .tag-group { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }
#prompt-help h3 { font-size: 13px; color: var(--text); }

/* Compact custom-instruction editor. */
#named-prompt-dialog { width: min(520px, calc(100vw - 24px)); padding: 20px; border-radius: 16px; }
#named-prompt-dialog h2 { font-size: 18px; margin: 0 0 12px; }
#named-prompt-name { font-weight: 600; overflow-wrap: anywhere; }
#named-prompt-description { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
#named-prompt-dialog .dialog-actions button { border-radius: 8px; padding: 7px 10px; min-height: 32px; font-size: 13px; }
@media (max-width:760px), (pointer:coarse) { #named-prompt-dialog .dialog-actions button { min-height: 44px; } }
#prompt-dialog { width: min(520px, calc(100vw - 24px)); padding: 20px; border-radius: 16px; }
.prompt-text-editor { position: relative; min-height: 0; }
.prompt-edit-heading { display: flex; align-items: center; gap: 12px; }
.prompt-edit-heading .prompt-name-row { flex: 1; min-width: 0; }
#prompt-dialog #prompt-expand { position: absolute; top: 5px; right: 18px; width: 30px; height: 30px; min-height: 30px; padding: 5px; border-radius: 6px; background: var(--panel); }
#prompt-dialog .prompt-text-editor #free-prompt { padding-right: 52px; }
#prompt-form { gap: 8px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
#prompt-dialog .dialog-head { gap: 8px; margin-bottom: 12px; }
#prompt-dialog h2 { margin: 0; font-size: 18px; line-height: 1.4; font-weight: 600; }
#prompt-dialog .dialog-head .icon { width: 30px; height: 30px; min-height: 0; padding: 4px; border: 0; border-radius: 8px; background: transparent; }
#prompt-dialog .prompt-tag-buttons { gap: 5px; margin: 0 0 8px; }
#prompt-dialog .prompt-tag-buttons button { padding: 4px 7px; font-size: 12px; border-radius: 6px; }
#prompt-dialog #free-prompt { height: 180px; min-height: 120px; padding: 10px; font-size: 13px; line-height: 1.6; border-radius: 8px; }
#prompt-dialog .prompt-count { font-size: 11px; text-align: left; margin-top: 14px; }
#prompt-dialog .form-error:empty { display: none; }
#prompt-dialog .dialog-actions { margin-top: 0; padding-top: 0; }

#prompt-dialog .dialog-actions .primary { min-height: 32px; padding: 6px 12px; font-size: 13px; border-radius: 8px; }
#prompt-dialog:has(.form-error:not(:empty)) .dialog-actions { margin-top: 8px; }

.tag-pair { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; }
#prompt-dialog .tag-pair > button { border: 0; background: transparent; }
#prompt-dialog .tag-pair .tag-info { padding: 4px 6px; border-left: 1px solid var(--border); color: var(--muted); font-family: inherit; }

#prompt-tags.hide-tag-help .tag-info { display: none; }
#tag-help-switch { font-size: 11px; padding: 4px 7px; border: 0; color: var(--muted); }
#tag-help-switch[aria-pressed="true"] { color: var(--text); }

.template-panel { margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.template-panel summary { cursor: pointer; width: fit-content; }
.template-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.template-tools input, .template-tools select { min-width: 0; max-width: 100%; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; padding: 6px; font-size: 12px; }
#template-status { flex-basis: 100%; }

.template-toolbar { display: flex; gap: 4px; margin-bottom: 10px; }
.template-toolbar button { font-size: 12px; padding: 4px 8px; }
#instruction-library { max-height: 150px; overflow: auto; background: var(--bg); border-radius: 8px; margin-bottom: 10px; padding: 6px; font-size: 12px; }
.instruction-row { display: flex; align-items: center; gap: 4px; }
.instruction-row > :first-child { flex: 1; min-width: 0; text-align: left; }
.instruction-row input { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px; }


.settings-heading-actions { display: flex; align-items: center; gap: 4px; }
#prompt-dialog .template-toolbar { margin: 8px 0 0; display: inline-flex; }

#prompt-dialog .dialog-head > div:first-child { min-width: 0; flex: 1; }
#prompt-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.instruction-menu, #instruction-library { position: fixed; inset: auto; margin: 0; width: 240px; max-width: calc(100vw - 16px); max-height: 220px; overflow: auto; padding: 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 24px #0004; }
.instruction-menu button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; text-align: left; font-size: 13px; overflow-wrap: anywhere; }
.instruction-menu button:hover, .instruction-menu button:focus-visible { background: var(--soft); }
.instruction-menu p { margin: 8px; font-size: 12px; }
.settings-heading-actions .icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#tag-help-switch[aria-pressed="true"] { color: var(--accent); background: var(--soft); }
.thread-rename-input { min-width: 0; width: 100%; padding: 7px 8px; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--accent); border-radius: 6px; }

.inline-operation-error { margin: 6px 0 0; color: var(--danger); font-size: 12px; }
.inline-operation-error:empty { display: none; }
.assistant-waiting { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 4px; color: var(--text); }
.waiting-dot { display: block; width: 10px; height: 10px; border-radius: 50%; background: currentColor; animation: waiting-pulse 1.2s ease-in-out infinite; }
.thinking-label { color: var(--muted); font-size: 14px; }
.generation-elapsed { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes waiting-pulse { 50% { opacity: .4; transform: scale(.8); } }
@media (prefers-reduced-motion: reduce) { .waiting-dot { animation: none; } }

#total-cost { padding: 10px 8px; border: 0; border-top: 1px solid var(--border); background: transparent; text-align: left; color: var(--muted); font-size: 11px; }
#total-cost:hover { color: var(--text); background: var(--soft); }
.composer-settings .thread-settings { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 38%; padding: 6px 8px; border: 0; border-radius: 7px; color: var(--text); font-size: 13px; font-weight: 600; }
.thread-settings:hover { background: var(--soft); color: var(--text); }

.thread-settings svg { flex: 0 0 18px; width: 18px; height: 18px; }
#usage-dialog { width: min(900px, calc(100vw - 28px)); padding: 20px; }
.usage-note, #usage-empty { color: var(--muted); font-size: 12px; line-height: 1.7; }
.usage-table-wrap { overflow: auto; max-height: 60dvh; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.usage-table th, .usage-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.usage-table th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.usage-table td { overflow-wrap: anywhere; min-width: 100px; max-width: 250px; }
.usage-table td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media(max-width: 760px) {
  .thread-header { flex-wrap: wrap; height: auto; padding-top: 6px; padding-bottom: 6px; }
  .composer-settings .thread-settings { max-width: 100%; }
}
.history-entry { border-top: 1px solid var(--border); padding: 14px 0; }
.history-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.history-controls label { display: flex; align-items: center; gap: 8px; }
.history-entry p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 14px; }
.history-excluded { color: var(--muted); }
#history-dialog { width: min(640px, calc(100vw - 32px)); max-height: 85dvh; overflow-y: auto; }
#history-dialog[open] { display: flex; flex-direction: column; }
#history-dialog > :not(#history-items) { flex-shrink: 0; }
#history-items { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#history-dialog .dialog-actions { margin-top: 12px; }
.history-preview { font-size: 11px; color: var(--muted); }
.history-control { display: inline-flex; align-items: center; gap: 0; padding: 2px; border-radius: 99px; background: var(--bg); white-space: nowrap; }
.history-control .history-preview { min-height: 32px; padding: 4px 9px 4px 2px; border: 0; border-radius: 99px; font-size: 12px; }
.history-control[data-enabled="true"] .history-preview { color: var(--text); }
.history-control[data-enabled="false"] .history-preview { opacity: 1; cursor: default; background: transparent; }
.history-switch { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 32px; padding: 6px 5px; border: 0; border-radius: 99px; background: transparent; }
.history-switch:hover { background: var(--soft); }
.history-switch .switch { display: block; flex-shrink: 0; background: var(--soft); box-shadow: inset 0 0 0 1px var(--border); }
.history-switch .switch:after { background: var(--muted); }
.history-switch[aria-checked="true"] .switch:after { transform: translateX(14px); background: var(--text); }
@media (max-width: 760px), (pointer: coarse) { .history-control .history-preview, .history-switch { min-height: 44px; } .history-switch { min-width: 44px; } }

#instruction-save-menu-toggle { width: 22px; min-width: 22px; margin-left: -8px; }
#instruction-save-menu { position: fixed; margin: 0; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); }
#instruction-save-menu button { border: 0; background: transparent; color: inherit; padding: 8px 12px; }
#file-manager { width: min(600px, calc(100vw - 32px)); max-height: 85dvh; overflow-y: auto; }
.file-manager-row { display:flex; align-items:center; gap:4px; min-width:0; }
.file-manager-actions { position:fixed; inset:auto; margin:0; padding:4px; width:170px; border:1px solid var(--border); border-radius:8px; background:var(--panel); color:var(--text); box-shadow:0 8px 24px #0003; }
.file-manager-actions button { font-size: 12px; }
#instruction-save-menu button { display: block; width: 100%; text-align: left; }

#file-manager-title { font-size: 18px; }
#file-manager-status, #file-rename-error, #instruction-save-error { font-size: 13px; }
.history-entry summary { cursor: pointer; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; }
#history-summary { font-size: 12px; color: var(--muted); }
#history-dialog > .history-controls { flex-wrap: wrap; }
#prompt-title[role="button"] { cursor: text; }
#prompt-title input { width: 100%; min-width: 0; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }
.model-ratings { display: grid; grid-template-columns: 1fr auto; gap: 5px 16px; margin: 14px 0 0; font-size: 12px; }
.model-ratings dt { color: var(--muted); }
.model-ratings dd { margin: 0; letter-spacing: 2px; }
.model-review-legend, .model-card .model-review-note { font-size: 11px; line-height: 1.6; color: var(--muted); }
.model-review-legend { max-width: 820px; }

/* Home: plain feature descriptions with expandable usage guides. */
.welcome { padding: 40px 32px; }
.home-columns { max-width: 960px; margin: 0 auto; }
.home-column { min-width: 0; }
.home-scenarios { margin-top: 36px; }
.home-scenarios > h2 { margin: 0; font-size: 20px; }
.home-scenarios .publication-grid:empty { display: none; }
.home-scenarios .home-empty:empty { display: none; }
.home-scenarios > button { min-height: 44px; }
.welcome .home-heading { margin: 0 0 10px; font-size: 28px; line-height: 1.5; font-weight: 700; letter-spacing: -.025em; }
.home-intro { max-width: 720px; margin: 0 0 18px; font-size: 14px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.home-actions > button, .guest-registration-button { min-height: 44px; padding: 8px 16px; font-size: 13px; }
.home-library { margin-top: 24px; }
.home-features { display: grid; grid-template-columns: 1fr; gap: 28px; max-width: 720px; }
.home-features > section { min-width: 0; }
.home-features h2 { text-wrap: balance; margin: 0 0 6px; font-size: 18px; font-weight: 650; line-height: 1.6; }
.home-features p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.9; }
.home-story-types { display: grid; grid-template-columns: 8em minmax(0, 1fr); gap: 8px 20px; margin: 14px 0; font-size: 13px; line-height: 1.9; }
.home-story-types dt { font-weight: 600; }
.home-story-types dd { margin: 0; color: var(--muted); }
.home-model-summary { margin-top: 12px; }
.welcome .model-grid { display: flex; flex-wrap: wrap; align-items: center; width: auto; margin: 0; gap: 8px 14px; }
.home-brand-name { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 24px; font-weight: 500; white-space: nowrap; }
.home-brand-name img { flex: 0 0 18px; object-fit: contain; }
.home-text-button { margin: 0; min-height: 34px; padding: 4px 0; border: 0; background: transparent; color: var(--accent); font-size: 13px; }
.home-text-button:hover { text-decoration: underline; }
.home-more { margin-top: 8px; font-size: 13px; }
.home-more > summary { display: flex; align-items: center; gap: 8px; width: fit-content; min-height: 34px; cursor: pointer; color: var(--accent); list-style: none; }
.home-more > summary::-webkit-details-marker { display: none; }
.home-more > summary::after { content: ''; width: 6px; height: 6px; border-right: 1px solid; border-bottom: 1px solid; transform: translateY(-2px) rotate(45deg); }
.home-more[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.home-more > summary:hover { text-decoration: underline; }
.home-more-close, .home-more[open] .home-more-open { display: none; }
.home-more[open] .home-more-close { display: inline; }
.home-feature-detail { padding-top: 8px; overflow-wrap: anywhere; }
.home-feature-detail p + p { margin-top: 10px; }
.home-feature-detail dl { margin: 12px 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; line-height: 1.8; }
.home-feature-detail dt { font-weight: 600; }
.home-feature-detail dd { margin: 0; color: var(--muted); }
.home-column .empty-state { margin-top: 0; padding: 16px 0; }
.home-column .empty-state h3 { font-size: 14px; }

@media (max-width: 760px) {
  .home-columns { max-width: 520px; }
  .home-features { grid-template-columns: 1fr; }
}
#home-reviews-dialog { width: min(740px, calc(100vw - 28px)); }
#home-reviews-dialog .dialog-head { align-items: center; }
#home-reviews-dialog .dialog-head h2 { font-size: 18px; }
#home-reviews-close { min-width: 44px; min-height: 44px; }
.home-model-evaluations { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 32px; margin: 24px 0 0; }
.home-model-evaluations h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 600; }
.home-model-evaluations .model-card-logo { width: 20px; height: 20px; flex: 0 0 20px; }
.home-model-description { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
#home-reviews-dialog .model-review-legend { margin: 28px 0 0; }
@media (max-width: 1000px) {
  .welcome { padding: 62px 20px 28px; }
  .home-features { gap: 28px; }
}
@media (max-width: 480px) {
  .welcome .home-heading { font-size: 24px; }
  .home-story-types { grid-template-columns: 1fr; gap: 4px; }
  .home-story-types dd + dt { margin-top: 8px; }
  .home-model-evaluations { grid-template-columns: 1fr; }
}
@media (pointer: coarse), (max-width: 760px) {
  .home-text-button, .home-more > summary { min-height: 44px; }
}
.model-reference-ratings { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

.theme-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; font-size: 12px; color: var(--muted); }
.theme-control select { font: inherit; color: var(--text); background: var(--sidebar); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; }
#settings-open { width: 44px; justify-content: center; margin-left: auto; flex-shrink: 0; min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); padding: 8px; font-size: 13px; text-align: left; }
#settings-open:hover { background: var(--soft); color: var(--text); }
#settings-open svg { width: 16px; height: 16px; }
@media (min-width: 761px) and (pointer: fine) {
  .sidebar #account-open, #settings-open { min-height: 32px; padding: 6px 8px; }
  #settings-open { width: 32px; }
}
#settings-dialog { width: min(360px, calc(100vw - 28px)); padding: 14px; border-radius: 14px; }
#settings-dialog .dialog-head { align-items: center; gap: 8px; margin-bottom: 8px; }
#settings-dialog .dialog-head h2 { font-size: 16px; line-height: 24px; }
#settings-close { width: 28px; height: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; border-radius: 6px; }
#settings-controls { display: flex; flex-direction: column; gap: 4px; }
#settings-registration { align-self: center; }
#settings-controls .theme-control { min-height: 34px; padding: 0 6px; font-size: 13px; color: var(--text); }
#settings-controls .theme-control select { min-height: 28px; background: var(--panel); }
#settings-controls .settings-row, #settings-controls .member-logout { min-height: 34px; border: 0; background: transparent; color: var(--text); font-size: 13px; padding: 6px; border-radius: 6px; text-align: left; }
#settings-controls .settings-row:hover, #settings-controls .member-logout:not(:disabled):hover { background: var(--soft); }
#settings-controls .member-logout { border-top: 1px solid var(--border); border-radius: 0; margin-top: 4px; }
#settings-usage { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 8px; font-size: 14px; }
#settings-usage:has(#total-cost[hidden]) { display: none; }
#settings-usage #total-cost { min-height: 44px; border: 0; border-radius: 8px; font-size: 12px; text-align: right; }

.prompt-presets { margin-bottom: 6px; }
.prompt-presets h3 { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.5; }
.prompt-preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; }
#prompt-preset-options { display: flex; flex-wrap: wrap; gap: 4px; }
#prompt-preset-options button { min-height: 28px; padding: 3px 10px; border-radius: 5px; font-size: 12px; line-height: 20px; }
#prompt-dialog .prompt-tags-toggle { display: flex; align-items: center; gap: 5px; width: auto; min-height: 30px; margin: 0; padding: 5px 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 12px; text-align: left; }
#prompt-dialog .prompt-tags-toggle:hover { color: var(--text); background: transparent; }
.prompt-tags-toggle svg { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.prompt-tags-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
#prompt-dialog .prompt-tags-toggle[aria-expanded="true"] { color: var(--text); }
#prompt-tags:not(.is-expanded) { display: none; }
#prompt-dialog #prompt-tags { max-height: min(240px, 30dvh); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 760px), (max-height: 500px) {
  #prompt-dialog #free-prompt { height: clamp(120px, 28dvh, 220px); }
}
@media (max-width: 760px) {
  #prompt-preset-options button { min-height: 44px; padding: 8px 12px; }
  #prompt-dialog .prompt-tags-toggle { min-height: 44px; padding: 10px 0; }
  #prompt-dialog { width: min(520px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 12px; }
  #prompt-dialog .dialog-head { flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
  #prompt-dialog .dialog-head > div:first-child { flex-basis: auto; }
  #prompt-dialog #prompt-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #prompt-dialog .settings-heading-actions { margin-right: auto; }
  #prompt-dialog .dialog-head .icon, #prompt-dialog .message-action { width: 44px; min-width: 44px; height: 44px; }
  #prompt-dialog .prompt-tag-buttons button { min-height: 44px; }
  #prompt-dialog .tag-pair .tag-info { min-width: 44px; }
  #prompt-dialog #free-prompt { font-size: 16px; }
  #prompt-dialog #answer-characters, #prompt-title input { font-size: 16px; }
}
/* Account details share the existing dialog and theme controls. */
#account-dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 24px; }
#account-dialog p { overflow-wrap: anywhere; }
#account-dialog[data-local-auth] #account-title { font-size: 18px; overflow-wrap: anywhere; }
#account-products { display: grid; gap: 8px; }
#account-dialog .dialog-actions { flex-wrap: wrap; gap: 8px; }
#account-dialog button { min-height: 44px; }

.prompt-tags-heading { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; border-top: 0; }
.sync-setting { padding: 0 6px 4px; }
.sync-setting label { display: flex; align-items: center; gap: 8px; min-height: 34px; font-size: 13px; }
.sync-setting label > span:first-child { flex-shrink: 0; }
#sync-status { margin-left: auto; max-width: 170px; font-size: 11px; font-weight: 400; line-height: 1.5; text-align: right; overflow-wrap: anywhere; color: var(--muted); }
.sync-setting input { appearance: none; flex: 0 0 30px; width: 30px; height: 18px; min-height: 0; margin: 0; padding: 2px; border: 1px solid var(--border); border-radius: 12px; background: var(--soft); cursor: pointer; }
.sync-setting input::before { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .12s; }
.sync-setting input:checked { background: var(--accent); }
.sync-setting input:checked::before { transform: translateX(12px); background: var(--bg); }
.sync-setting input:disabled { opacity: .5; cursor: default; }
.sync-setting p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
@media (max-width: 760px), (pointer: coarse) {
  .sync-setting label, #settings-controls .theme-control, #settings-controls .theme-control select,
  #settings-controls .settings-row, #settings-controls .member-logout { min-height: 44px; }
  #settings-close { width: 44px; height: 44px; }
}
#prompt-dialog #tag-help-switch { width: 28px; height: 28px; padding: 5px; border-radius: 5px; }
@media (max-width: 760px) { #prompt-dialog #tag-help-switch { width: 44px; height: 44px; padding: 12px; } }

.prompt-model-row { display: flex; align-items: center; gap: 12px; margin: 0 0 2px; padding-bottom: 0; border-bottom: 0; }
#prompt-model-help { position: fixed; inset: auto; box-sizing: border-box; margin: 0; padding: 4px; width: min(400px, calc(100vw - 16px)); border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); overflow-y: auto; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.model-help-option { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 12px; border: 0; border-radius: 6px; background: transparent; text-align: left; font: inherit; color: inherit; white-space: normal; }
.model-help-option:hover, .model-help-option[aria-pressed="true"] { background: var(--soft); }
.model-help-name { display: flex; justify-content: space-between; gap: 12px; width: 100%; font-weight: 600; }
.model-help-description { color: var(--muted); }
.model-help-label { display: flex; align-items: center; gap: 7px; min-width: 0; }
.model-help-logo { width: 16px; height: 16px; object-fit: contain; flex: 0 0 16px; }
.composer-model-menu { font-size: 12px; line-height: 1.55; }
.composer-model-menu .model-help-option { padding: 8px 10px; gap: 2px; }
.composer-model-menu .model-help-option[aria-checked="true"] { background: var(--soft); }
@media (max-width:760px), (pointer:coarse) { .composer-model-menu .model-help-option { min-height: 44px; } }
.prompt-model-question { flex: 0 0 auto; font-size: 14px; font-weight: 400; }
@media (max-width: 760px), (pointer: coarse) { .prompt-model-row { gap: 8px; } }
.prompt-model-row > span { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
#prompt-model { flex: 1; min-width: 0; width: 0; min-height: 32px; height: 32px; padding: 4px 8px; font-size: 13px; border-radius: 6px; }
@media (max-width: 760px), (pointer: coarse) { #prompt-model { min-height: 44px; height: 44px; font-size: 16px; } }

#prompt-model { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; background: transparent; border: 1px solid var(--border); color: var(--text); }
#prompt-model:hover, #prompt-model[aria-expanded="true"] { background: var(--soft); }
#prompt-model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#prompt-model svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.composer .state-toggle, .composer-settings .thread-settings { width: auto; height: 32px; min-height: 32px; min-width: 0; max-width: none; justify-content: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.composer .state-toggle svg, .composer-settings .thread-settings svg { flex: 0 0 17px; width: 17px; height: 17px; }
.composer .state-toggle { padding: 4px 9px; border: 0; background: transparent; font-size: 12px; font-weight: 400; }
.composer .state-toggle svg { flex-basis: 14px; width: 14px; height: 14px; }
.composer .state-toggle[aria-pressed="true"] { background: var(--soft); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }
.composer .state-toggle:hover, .composer-settings .thread-settings:hover { color: var(--text); }
.composer .state-toggle[aria-pressed="true"]:hover { color: var(--text); background: var(--soft); }
.conversation-settings-heading { display: flex; align-items: center; gap: 8px; }
.conversation-settings-mark { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.5; color: var(--muted); }
.conversation-settings-heading #prompt-title { min-width: 0; flex: 1; }
@media (max-width: 760px), (pointer: coarse) { .composer .state-toggle, .composer-settings .thread-settings { height: 44px; min-height: 44px; } }
.composer-settings .thread-settings { height: 36px; min-height: 36px; padding: 6px 11px; border: 0; background: var(--bg); font-size: 12px; font-weight: 400; }
.composer-settings .thread-settings svg { flex-basis: 14px; width: 14px; height: 14px; }
.composer-settings .thread-settings:hover { background: var(--soft); }
@media (max-width: 760px), (pointer: coarse) { .composer-settings .thread-settings { height: 48px; min-height: 48px; } }

@media (max-width: 760px), (pointer: coarse) { #prompt-dialog #answer-characters { height: 44px; min-height: 44px; font-size: 16px; } }


/* Conversation settings: one editor with secondary actions grouped beside it. */
.custom-prompt-heading, .custom-prompt-actions, .prompt-editor-tools { display:flex; align-items:center; gap:8px; }
.custom-prompt-heading { justify-content:space-between; margin:12px 0 8px; flex-wrap:wrap; }
.custom-prompt-heading h3 { display:flex; align-items:center; gap:7px; font-size:13px; margin:0; font-weight:600; }
.custom-prompt-heading h3 svg, .custom-prompt-actions svg { width:16px; height:16px; flex:0 0 16px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
.custom-prompt-actions .tool-button, .prompt-editor-tools .tool-button { min-height:30px; padding:4px 7px; font-size:12px; }
#prompt-form .prompt-name-row { display:grid; grid-template-columns:48px minmax(0,1fr); align-items:center; margin-bottom:8px; color:var(--muted); font-weight:400; }
#prompt-form #prompt-name { height:32px; padding:5px 8px; font-size:13px; border-radius:6px; color:var(--text); }
.prompt-editor-tools { justify-content:space-between; margin:4px 0 8px; flex-wrap:wrap; }
#prompt-dialog .prompt-editor-tools .template-toolbar, .prompt-editor-tools .prompt-tags-heading { margin:0; }
#prompt-preset-menu { position:fixed; inset:auto; margin:0; padding:12px; border:1px solid var(--border); border-radius:8px; background:var(--panel); color:var(--text); box-shadow:0 8px 24px #0003; }
#prompt-dialog .dialog-actions { margin-top:6px; }
@media (min-width:761px) { .output-setting-fields { grid-template-columns:84px 80px minmax(0,1fr); } .output-setting-fields label { grid-column:auto; } }
@media (max-width:760px), (pointer:coarse) { #prompt-form #prompt-name { height:44px; font-size:16px; } .custom-prompt-actions .tool-button, .prompt-editor-tools .tool-button, #prompt-preset-options button, #prompt-dialog .dialog-actions .primary { min-height:44px; } }

#file-manager { overflow:hidden; padding:20px; }
#file-manager-list { max-height:60dvh; overflow-y:auto; }
#file-search { width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:7px; background:var(--bg); color:var(--text); }
.file-name { flex:1; min-width:0; text-align:left; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.file-name, .file-more { background:transparent; border:0; border-radius:6px; padding:8px; min-height:38px; }
.file-more { flex:0 0 36px; font-size:22px; }
.file-name:hover, .file-more:hover, .file-manager-actions button:hover { background:var(--soft); }
.file-manager-actions button { display:block; width:100%; min-height:34px; border:0; border-radius:4px; padding:6px 10px; text-align:left; background:transparent; color:inherit; }
@media(max-width:760px),(pointer:coarse) { .file-name,.file-more,.file-manager-actions button,#file-search { min-height:44px; } #file-search { font-size:16px; } }
.dialogue-panel { min-height: 0; }
.dialogue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.dialogue-panel p { margin: 6px 0; font-size: 12px; }
#dialogue-state { display: block; margin-bottom: 8px; font-size: 14px; }
#dialogue-guidance { color: var(--muted); }
.dialogue-actions { margin-top: 4px; justify-content: flex-end; gap: 6px; }
.dialogue-actions button { min-height: 32px; padding: 7px 12px; font-size: 12px; }
#dialogue-setup { padding: 0 5px; }
#dialogue-composer > .inline-operation-error:empty { display: none; }
.dialogue-panel textarea { display: block; width: 100%; }
#dialogue-theme, #dialogue-instruction-list { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 100px; overflow-y: auto; }
.dialogue-panel details { font-size: 12px; margin-top: 6px; }
/* Keep the original pane composers and their settings below the shared transcript. */
.dialogue-mode .workspace-bar { display: none !important; }
.dialogue-mode #pane-grid { order: 1; flex: 0 0 auto; max-height: 35%; overflow-y: auto; }
.dialogue-mode #dialogue-panel { order: 2; }
.dialogue-mode #pane-grid .messages, .dialogue-mode #pane-grid .thread-header { display: none; }
.dialogue-mode #pane-grid .composer-wrap { position: static; padding-top: 8px; background: none; }
.dialogue-input-hint { display: none; }
.dialogue-mode #dialogue-input { grid-area: 1 / 1; }
.dialogue-mode #dialogue-input:disabled { color: transparent; }
.dialogue-mode #dialogue-input:disabled::placeholder { color: transparent; }
.dialogue-mode #dialogue-input:disabled + .dialogue-input-hint { display: block; grid-area: 1 / 1; align-self: start; padding: 8px 5px; color: var(--muted); line-height: 1.5; pointer-events: none; }
@media (max-width: 1000px) {
  .dialogue-mode #pane-grid.split { grid-template-columns: minmax(0, 1fr); }
  .dialogue-mode #pane-grid .conversation { display: flex; }
}
#dialogue-conversation { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
#dialogue-conversation[hidden] { display: none; }
.dialogue-participants { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); flex-shrink: 0; min-width: 0; }
.dialogue-participants .thread-header { min-width: 0; }
.dialogue-participants .thread-header + .thread-header { border-left: 1px solid var(--border); }
@media (max-width: 640px) { .dialogue-participants { grid-template-columns: minmax(0, 1fr); } .dialogue-participants .thread-header + .thread-header { border-left: 0; } }
#dialogue-transcript { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 24px max(18px, calc((100% - 820px) / 2)) 36px; }
.dialogue-transcript-theme { margin: 0 auto 28px; padding: 10px 16px; max-width: 90%; text-align: center; }
.dialogue-transcript-theme h3 { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.dialogue-transcript-theme p { margin: 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialogue-transcript-answer { display: flex; flex-direction: column; align-items: flex-start; width: fit-content; max-width: 86%; margin: 0 auto 24px 0; min-width: 0; }
.dialogue-transcript-answer[data-speaker="1"] { align-items: flex-end; margin-left: auto; margin-right: 0; }
.dialogue-transcript-answer > header { display: flex; flex-direction: column; gap: 3px; margin: 0 4px 7px; max-width: 100%; overflow-wrap: anywhere; }
.dialogue-transcript-answer > header strong { font-size: 13px; }
.dialogue-transcript-answer[data-speaker="1"] > header { text-align: right; }
.dialogue-transcript-answer > header span { color: var(--muted); font-size: 11px; }
.dialogue-transcript-answer > .message-body { min-width: 0; max-width: 100%; padding: 14px 18px; border: 1px solid var(--border); border-radius: 4px 18px 18px 18px; background: var(--panel); overflow-wrap: anywhere; }
.dialogue-transcript-answer[data-speaker="1"] > .message-body { background: var(--userBubble); border-radius: 18px 4px 18px 18px; }
.dialogue-transcript-answer > .message-body > :first-child { margin-top: 0; }
.dialogue-transcript-answer > .message-body > :last-child { margin-bottom: 0; }
.dialogue-answer-copy { margin-top: 4px; font-size: 11px; padding: 4px 6px; border: 0; color: var(--muted); }
.dialogue-transcript-notice, .dialogue-transcript-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
#dialogue-latest { position: absolute; bottom: 10px; right: 0; left: 0; margin-inline: auto; background: var(--panel); box-shadow: 0 2px 10px #0002; }
@media (max-width: 760px), (pointer: coarse) {

  #dialogue-transcript { padding: 18px 12px 44px; }
  .dialogue-transcript-answer { max-width: 92%; }
  .dialogue-transcript-answer > .message-body { padding: 12px 14px; }
  .dialogue-actions button { min-height: 44px; }
  .dialogue-answer-copy, #dialogue-latest { min-height: 44px; }
}
@media (max-width: 640px) {
  .dialogue-panel { max-height: 55%; }
  .dialogue-actions button { min-height: 44px; }
  .dialogue-panel textarea { font-size: 16px; }

}

/* A single conversation has one header row, with its action on the right. */
.workspace.single-conversation { position: relative; }
.single-conversation .workspace-bar { position: absolute; top: 0; right: 20px; z-index: 2; display: flex; min-height: 52px; padding: 0; border: 0; }
.single-conversation #pane-tabs { display: none; }
.single-conversation .thread-header { height: 52px; min-height: 52px; flex-shrink: 0; flex-wrap: nowrap; padding: 0 144px 0 24px; gap: 8px; }
.single-conversation .thread-header strong { flex: 0 1 auto; }
.single-conversation [data-pane-element="thread-header-model"] { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.single-conversation #pane-add { min-height: 32px; padding: 5px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.single-conversation #pane-add:hover:not(:disabled) { background: var(--soft); color: var(--text); }
@media (max-width: 760px), (pointer: coarse) {
  .single-conversation #pane-add { min-height: 44px; }
}
@media (max-width: 760px) {
  .single-conversation .workspace-bar { right: 10px; }
  .single-conversation .thread-header { padding-left: 58px; padding-right: 112px; }
}

/* Shared modes stay centered above the conversation headers. */
.workspace:not(.single-conversation) { position: relative; }
.workspace:not(.single-conversation) .workspace-bar { display: contents; }
.workspace:not(.single-conversation) .chat-modes { flex: 0 0 auto; flex-wrap: nowrap; gap: 2px; }
.batch-actions { flex-wrap: wrap; }
.batch-actions #batch-limit { margin-left: auto; }
.workspace:not(.single-conversation) .chat-modes button { min-height: 32px; padding: 5px 9px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.workspace:not(.single-conversation) .chat-modes button[aria-pressed="true"] { color: var(--text); }
.workspace:not(.single-conversation) .thread-header { min-height: 52px; height: 52px; flex-shrink: 0; flex-wrap: nowrap; padding: 0 18px; }
.workspace:not(.single-conversation) [data-pane-element="thread-header-model"] { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) {
  .workspace:not(.single-conversation) #pane-tabs { display: flex; flex-shrink: 0; height: 44px; padding: 0 12px; border-bottom: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .workspace:not(.single-conversation) #pane-tabs { padding-left: 54px; }
  .workspace:not(.single-conversation) .conversation .thread-header { padding-left: 14px; padding-right: 14px; }
  .workspace:not(.single-conversation) .chat-modes button { padding: 5px 6px; }
}
@media (max-width: 760px), (pointer: coarse) {
  .workspace:not(.single-conversation) .chat-modes button { min-height: 44px; }
}

#ai-add-menu { position: fixed; inset: auto; margin: 0; width: min(264px, calc(100vw - 16px)); padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px #0003; }
#ai-add-menu::backdrop { background: transparent; }
#ai-add-menu button { display: block; width: 100%; min-height: 36px; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 13px; }
#ai-add-menu button:hover, #ai-add-menu button:focus-visible { background: var(--soft); }
@media (max-width: 760px), (pointer: coarse) { #ai-add-menu button { min-height: 44px; } }


.workspace > .chat-modes { justify-content: center; min-height: 44px; padding: 6px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
@media (max-width: 760px), (pointer: coarse) { .workspace > .chat-modes { min-height: 52px; padding: 4px 54px; } }

/* Diagnostics stay in the sidebar log, outside the chat layout. */
.central-error-log #workspace .inline-operation-error:not(#dialogue-error),
.central-error-log #workspace-error,
.central-error-log .generation-error-detail,
.central-error-log [data-pane-element="recovery-note"] { display: none !important; }
.central-error-log #workspace .generation-error-detail[data-error-code="account_reconciliation_pending"] { display: block !important; }
/* usage_v2 stops and waits are actionable: the user sees why nothing was sent (no amounts). */
.central-error-log #workspace .generation-error-detail:is([data-error-code="usage_limit_reached"], [data-error-code="video_limit_reached"],
  [data-error-code="usage_insufficient_for_request"], [data-error-code="out_of_contract"], [data-error-code="account_suspended"],
  [data-error-code="commercial_admission_paused"], [data-error-code="accounting_hold"], [data-error-code="usage_pending_wait"],
  [data-error-code="admission_rate_limited"]) { display: block !important; }
.central-error-log #dialogue-status, .central-error-log #dialogue-inspection { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#error-log-dialog { width: min(760px, calc(100vw - 24px)); max-height: 85dvh; overflow-y: auto; }
.error-log-toolbar, .error-log-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.error-log-toolbar label { margin-right: auto; }
#error-log-filter { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
#error-log-note { color: var(--muted); font-size: 12px; }
.error-log-entry { padding: 14px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.error-log-entry p { margin: 6px 0; font-size: 13px; }
.error-log-entry p:first-of-type { font-size: 11px; color: var(--muted); }
.error-log-actions button { font-size: 12px; min-height: 32px; padding: 5px 9px; }
@media (max-width: 760px), (pointer: coarse) { .error-log-actions button, .error-log-toolbar button, #error-log-filter { min-height: 44px; } }

#error-log-title { font-size: 18px; margin: 0; }
/* Expanded prompt editing keeps the same input, selection and autosave handlers. */
#prompt-dialog.prompt-expanded { width: min(1100px, calc(100vw - 32px)); height: calc(100dvh - 40px); max-height: calc(100dvh - 40px); overflow: hidden; }
#prompt-dialog.prompt-expanded #prompt-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#prompt-dialog.prompt-expanded #prompt-form > :not(#free-prompt-panel):not(#prompt-error):not(#instruction-retry) { display: none; }
#prompt-dialog.prompt-expanded #free-prompt-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#prompt-dialog.prompt-expanded #free-prompt-panel > :not(.prompt-edit-heading):not(.prompt-text-editor):not(.prompt-editor-tools):not(#prompt-tags):not(#prompt-help):not(#template-status) { display: none; }
#prompt-dialog.prompt-expanded .prompt-editor-tools { flex-shrink: 0; }
#prompt-dialog.prompt-expanded .prompt-editor-tools .template-toolbar { display: none; }
#prompt-dialog.prompt-expanded #prompt-tags { flex-shrink: 0; max-height: min(180px, 25dvh); }
#prompt-dialog.prompt-expanded #prompt-help { top: auto !important; bottom: 24px; max-height: min(280px, 45dvh) !important; }
#prompt-dialog.prompt-expanded #template-status:empty { display: none; }
#prompt-dialog.prompt-expanded .prompt-text-editor { flex: 1; min-height: 0; display: flex; }
#prompt-dialog.prompt-expanded #free-prompt { height: 100%; min-height: 0; resize: none; padding: 14px; font-size: 15px; line-height: 1.7; }
#prompt-dialog.prompt-expanded #prompt-expand { display: none; }
#prompt-dialog.prompt-expanded #prompt-name { height: 36px; font-size: 15px; }
#prompt-edit-back { flex: none; min-height: 36px; padding: 6px 14px; border-radius: 8px; }
#prompt-dialog.prompt-expanded .prompt-name-row { margin: 0; }
#prompt-dialog.prompt-expanded .prompt-edit-heading { margin-bottom: 12px; }
@media (max-width: 760px), (pointer: coarse) {
  #prompt-dialog #prompt-expand { width: 44px; height: 44px; }
  #prompt-dialog .prompt-text-editor #free-prompt { padding-right: 64px; }
  #prompt-dialog.prompt-expanded { width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); padding: 12px; }
  #prompt-dialog.prompt-expanded #free-prompt { padding: 12px; font-size: 16px; }
  #prompt-dialog.prompt-expanded #prompt-name, #prompt-edit-back { min-height: 44px; font-size: 16px; }
  #prompt-dialog.prompt-expanded .prompt-edit-heading { gap: 8px; }
}


/* Participant actions share one small menu; closing never deletes a conversation. */
.thread-header { position: relative; }
.workspace:not(.single-conversation) .thread-header { padding-right: 56px; }
.pane-menu-button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; }
.pane-menu-button:hover, .pane-menu-button[aria-expanded="true"] { background: var(--soft); color: var(--text); }
#pane-actions-menu { position: fixed; inset: auto; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px #0003; }
#pane-actions-menu button { display: block; width: 100%; min-height: 36px; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 13px; }
#pane-actions-menu button:hover:not(:disabled), #pane-actions-menu button:focus-visible { background: var(--soft); }
#pane-actions-note, .pane-action-note { margin: 4px 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
#pane-undo { position: fixed; z-index: 30; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 24px); padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: 0 4px 18px #0003; font-size: 13px; }
#pane-undo button { flex-shrink: 0; padding: 6px 8px; border: 0; background: transparent; color: var(--accent); }
@media (max-width: 760px), (pointer: coarse) { .pane-menu-button { width: 44px; height: 44px; right: 4px; } #pane-actions-menu button, #pane-undo button { min-height: 44px; } }

/* Public conversations share the same preview and reader. */
.publication-page { display: block; height: auto; min-height: 100vh; overflow: auto; }
#public-page { width: min(100% - 32px, 968px); margin: 20px auto 64px; }
.publication-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.publication-actions a, .publication-dialog a.primary { text-decoration: none; display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 6px; font-size: 13px; min-height: 32px; }
.publication-content { min-width: 0; width: 100%; max-width: 968px; margin-inline: auto; overflow-wrap: anywhere; }
.publication-content h1 { font-size: 18px; line-height: 1.4; margin: 16px 0 12px; }
.publication-identity { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 10px; }
.publication-content h2 { font-size: 16px; margin: 18px 0 6px; }
.publication-content h3 { font-size: 13px; margin: 14px 0 4px; color: var(--muted); }
.publication-content details { padding: 0; font-size: 13px; }
.publication-content summary { cursor: pointer; width: fit-content; padding: 6px 0; color: var(--muted); }
.publication-content summary::marker { content:''; }
.publication-content summary { display:inline-flex; align-items:center; gap:7px; }
.publication-settings-mark { width:16px; height:16px; flex:0 0 16px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; }
.publication-settings-body { max-height: min(320px, 45dvh); overflow: auto; overscroll-behavior: contain; margin-top: 4px; padding: 10px 12px; border-radius: 6px; background: var(--soft); }
:root[data-theme="dark"] .publication-settings-body { background: var(--soft); }
.publication-settings-body > section:first-child > h2 { margin-top: 0; }
.publication-content details p { color: var(--muted); }
.publication-rows { padding: 38px max(24px, calc((100% - 920px) / 2)) 24px; }
.publication-row { max-width: 100%; }
.publication-theme, .publication-instruction { border-left: 2px solid var(--border); padding-left: 16px; }
.publication-speaker { color: var(--muted); font-size: 12px; line-height: 1.5; margin-bottom: 5px; }
.publication-text { white-space: pre-wrap; line-height: 1.65; font-size: 15px; }
.publication-dialog { width: min(520px, calc(100% - 24px)); max-height: 88dvh; overflow: auto; padding: 20px; border-radius: 16px; }
.publication-dialog > input { width: 100%; margin: 14px 0; }
.publication-dialog > .primary { margin: 10px 8px 0 0; }
.publication-dialog > p { line-height: 1.6; color: var(--muted); }
.publication-dialog > details { margin: 12px 0; }
.publication-dialog.publication-import[open] { display: flex; flex-direction: column; overflow: hidden; }
.publication-import > .dialog-head, .publication-import > p, .publication-import-actions { flex-shrink: 0; }
.publication-import-body { min-height: 0; overflow: auto; }
.publication-import .publication-settings-body { max-height: none; overflow: visible; }
.publication-import-actions { padding-top: 12px; }
.publication-import-actions > p:empty { display: none; }
.publication-import-actions > p { color: var(--danger, var(--text)); }
.publication-dialog > details button { display: block; margin: 6px 0; }
.publication-feed { width: min(100%, 820px); margin: 42px auto 20px; }
.publication-feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.publication-feed h2 { font-size: 20px; }
.publication-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 16px 0; }
.publication-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--panel); min-width: 0; }
.publication-card:hover { border-color: var(--accent); }
.publication-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.publication-card p { font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.publication-models { display: flex; gap: 8px; }.publication-models img { width: 20px; height: 20px; }
.publication-owned { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0; }.publication-owned a { overflow-wrap: anywhere; }
.publication-menu-group { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 0; margin: 4px 0; }
.publication-menu-group:first-child { border-top: 0; margin-top: 0; }
.single-conversation .thread-header { padding-right: 60px; }
.single-conversation .workspace-bar { display: none; }
#chat-modes { position: relative; }
#conversation-menu { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 16px; }
.gate:has(.publication-feed:not([hidden])) { display: block; padding: 48px 24px; }
.gate:has(.publication-feed:not([hidden])) .gate-card { margin: 0 auto; }
@media (max-width: 760px) { .publication-grid { grid-template-columns: 1fr; }.publication-dialog { padding: 16px; }.single-conversation .thread-header { padding-right: 56px; }.publication-actions > * { min-height: 44px; }.publication-owned { flex-wrap: wrap; } }
.publication-dialog > input { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); padding: 10px 12px; font-size: 16px; }
.publication-preview[open] { width: min(600px, calc(100% - 24px)); max-width: calc(100% - 24px); margin-inline: auto; display: flex; flex-direction: column; overflow: hidden; padding: 16px 0; background: var(--bg); }
.publication-preview .dialog-head { flex: none; align-items: center; gap: 10px; margin-bottom: 8px; }
.publication-preview .dialog-head h2 { margin: 0; margin-right: auto; }
.publication-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.publication-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.publication-action svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#pane-actions-menu .publication-action { display: flex; justify-content: flex-start; }
@media (max-width: 760px), (pointer: coarse) { .publication-dialog .publication-action { min-height: 44px; } }
.publication-preview-actions > .primary { padding: 6px 10px; border-radius: 6px; min-height: 32px; font-size: 13px; }
.publication-preview-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 0 8px; }
.publication-preview-body > input { width: 100%; margin: 4px 0; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); padding: 6px 8px; font-size: 15px; }
.publication-preview-body .publication-content > h1 { display: none; }
.publication-preview-body > p { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 6px 0 10px; }
.publication-preview > [role="alert"]:empty { display: none; }
.publication-preview > [role="alert"] { flex: none; margin: 4px 0 12px; }
.publication-to-top, .publication-dialog button.publication-to-top { position: fixed; left: auto; right: 40px; bottom: 20px; z-index: 3; width: 32px; min-width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--panel); color: var(--text); box-shadow: 0 2px 10px #0002; }
.publication-dialog button.publication-to-top { position: absolute; }
@media (max-width: 520px) { .publication-preview .dialog-head { flex-wrap: wrap; } .publication-preview .dialog-head h2 { flex: 1; font-size: 16px; } .publication-preview-actions { order: 3; flex-basis: 100%; } }
.publication-dialog .dialog-head h2 { font-size: 15px; font-weight: 600; }
.publication-dialog .dialog-head > .icon { width: 32px; min-width: 32px; height: 32px; border: 0; border-radius: 6px; }
.publication-actions button:not(.primary), .publication-dialog button:not(.primary):not(.icon), .publication-owned button { border: 1px solid var(--border); background: transparent; border-radius: 6px; padding: 6px 10px; font-size: 13px; min-height: 32px; color: var(--text); }
.publication-actions button:hover, .publication-dialog button:not(:disabled):hover { background: var(--soft); }
#public-page > .brand { color: var(--text); text-decoration: none; padding-left: 0; }

@media (max-width: 760px), (pointer: coarse) { .publication-preview-actions > .primary, .publication-actions > *, .publication-dialog .dialog-head > .icon, .publication-to-top, .publication-dialog button.publication-to-top { min-width: 44px; min-height: 44px; } .publication-content summary { min-height: 44px; display: flex; align-items: center; gap: 6px; } .publication-content summary::before { content: "▸"; } .publication-content details[open] > summary::before { content: "▾"; } .publication-preview-body > input { font-size: 16px; } }

@media (max-width: 760px), (pointer: coarse) { .publication-rows { padding: 26px 12px 24px; } }

.publication-preview > .dialog-head, .publication-preview > [role="alert"] { margin-inline: 16px; }
.publication-preview-body > input { width: calc(100% - 32px); margin-inline: 16px; }
.publication-preview-body > p, .publication-preview-body .publication-content > details, .publication-preview-body .publication-identity { margin-inline: 16px; }
.publication-preview .publication-content { max-width: none; }

/* One reader for cards, owner previews and shared URLs. */
.publication-card { gap: 8px; padding: 12px 14px; border-radius: 8px; }
.publication-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.publication-card strong { font-size: 14px; }
.publication-card .publication-models { flex-shrink: 0; gap: 4px; }
.publication-card .publication-models img { width: 16px; height: 16px; }
.publication-card p { -webkit-line-clamp: 2; line-height: 1.65; color: var(--muted); }
.publication-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.publication-preview.publication-reading[open] { padding: 0; }
.publication-reader { position: relative; display: flex; flex-direction: column; min-height: 0; height: min(780px, 86dvh); width: 100%; overflow: hidden; background: var(--bg); }
.publication-reader-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.publication-reader-title { flex: 1 1 220px; min-width: 0; font-size: 15px; line-height: 1.5; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.publication-reader-head > .icon { flex-shrink: 0; width: 32px; min-width: 32px; height: 32px; border: 0; }
.publication-reader .publication-preview-actions { order: 0; }
.publication-reader .publication-action { text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 13px; min-height: 32px; }
.publication-reader button.publication-action:not(.primary) { color: var(--text); background: transparent; border: 1px solid var(--border); }
.publication-reader-body { overflow: auto; overscroll-behavior: contain; min-height: 0; flex: 1; padding: 12px 16px 24px; }
.publication-reader .publication-content { max-width: 760px; }
.publication-reader .publication-rows { padding: 18px 0 0; }
.publication-reader .publication-row { margin-bottom: 16px; width: 88%; }
.publication-reader .message-user .message-bubble { padding: 9px 12px; }
.publication-reader-error:empty { display: none; }
.publication-reader-error { margin: 8px 16px; flex-shrink: 0; }
.publication-reader .publication-to-top { position: absolute; right: 32px; bottom: 16px; }
.publication-page { height: 100dvh; min-height: 0; overflow: hidden; }
#public-page { width: min(100% - 24px, 1000px); height: calc(100dvh - 24px); margin: 12px auto; }
#public-content, #public-content > .publication-reader { height: 100%; }
.publication-exit { font-size: 13px; color: var(--text); text-decoration: none; white-space: nowrap; }
@media (max-width: 760px), (pointer: coarse) {
  .publication-reader .publication-action, .publication-reader-head > .icon, .publication-exit { min-height: 44px; }
  .publication-exit { display: inline-flex; align-items: center; }
  .publication-reader-head { gap: 8px; padding: 8px 12px; }
  .publication-reader-title { flex-basis: 140px; }
  .publication-reader .publication-preview-actions { order: 2; flex-basis: 100%; gap: 6px; }
  .publication-reader-body { padding: 8px 12px 24px; }
  .publication-reader .publication-row { width: 94%; }
}

@media (max-width: 760px), (pointer: coarse) { .publication-reader .publication-action { height: 44px; } }

.publication-selection[open] { display: flex; flex-direction: column; width: min(520px, calc(100% - 24px)); max-width: calc(100% - 24px); max-height: 88dvh; overflow: hidden; margin-inline: auto; }
.publication-selection > :not(.publication-selection-list) { flex-shrink: 0; }
.publication-selection-list { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.publication-selection .history-controls { flex-wrap: wrap; }
.publication-files-option { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; }
.publication-files-option input { width: 18px; height: 18px; flex: none; }
.range-selection-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.range-sort-control { display: inline-flex; }
.range-sort-toggle { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.range-sort-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.range-sort-menu { position: fixed; inset: auto; margin: 0; padding: 5px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); box-shadow: 0 8px 24px #0003; }
.range-sort-menu button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px; border: 0; border-radius: 6px; background: transparent; color: inherit; text-align: left; font-size: 12px; }
.range-sort-menu button:hover, .range-sort-menu button:focus-visible { background: var(--soft); }
.range-sort-menu button[aria-checked="false"] .range-sort-check { visibility: hidden; }
.publication-selection .history-entry > .history-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.publication-selection .history-controls label { min-width: 0; overflow-wrap: anywhere; }
.publication-selection details { overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.publication-selection .history-entry > p { font-size: 13px; line-height: 1.6; }
.publication-selection details p { white-space: pre-wrap; }
.publication-selection button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.publication-selection > .history-controls:last-child { margin-top: 10px; }
.publication-selection > .history-controls:last-child .primary { margin-left: auto; }
@media (max-width: 760px), (pointer: coarse) { .publication-selection button, .publication-selection .history-controls label { min-height: 44px; } }

/* Public preview: one row, with URL beside the title. */
.publication-preview .dialog-head,.publication-preview .publication-reader-head {display:flex;flex-wrap:nowrap;gap:8px;align-items:center;}
.publication-preview .dialog-head > h2,.publication-preview .publication-reader-title {flex:1 1 auto;min-width:0;max-width:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;}
.publication-preview .publication-preview-actions {display:flex;flex:0 0 auto;flex-wrap:nowrap;gap:6px;align-items:center;order:0;margin-left:auto;}
.publication-start-action {margin-left:0;}
.publication-preview .publication-range-action {margin-left:auto;}
.publication-dialog.publication-preview .publication-preview-actions > button.publication-action {min-height:28px;height:28px;padding:3px 8px;font-size:12px;white-space:nowrap;flex-shrink:0;}
@media (max-width:760px), (pointer:coarse) {
.publication-dialog.publication-preview .publication-preview-actions > button.publication-action {min-height:44px;height:44px;}
}
@media (max-width:480px) {
.publication-preview .publication-preview-actions {gap:4px;}
.publication-preview .publication-preview-actions > .publication-action:not([aria-label="公開URLをコピー"]) svg {display:none;}
.publication-preview .dialog-head,.publication-preview .publication-reader-head {gap:4px;}
}

.publication-preview .publication-user { padding-block: 8px; }

.publication-preview input.publication-title-input {width:40%;height:32px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--text);font-size:15px;font-weight:600;}
.publication-preview input.publication-title-input:hover {border-color:var(--border);}
.publication-preview input.publication-title-input:focus {border-color:var(--accent);outline:1px solid var(--accent);}
@media (max-width:760px), (pointer:coarse) {.publication-preview input.publication-title-input {height:44px;font-size:16px;}}
/* Shared application font; explicit conversation text sizing. */
.message-bubble, .composer textarea, .dialogue-panel textarea {
  font-family: inherit;
  font-size: 16px;
  line-height: 26px;
  font-weight: 400;
  letter-spacing: normal;
}
/* History uses the publication range editor's layout and shared controls. */
#history-dialog.publication-selection { width: min(520px, calc(100% - 24px)); height: auto; max-height: 88dvh; overflow: hidden; }
#history-status:empty, #history-limit:empty { display: none; }
#history-limit { margin: 6px 0; font-size: 12px; color: var(--danger); }

/* Modal density follows the conversation editor; shared URL readers stay full-page. */
.publication-dialog .dialog-head { gap: 8px; margin-bottom: 12px; }
.publication-dialog .dialog-head h2 { font-size: 18px; line-height: 1.4; }
.publication-dialog .dialog-head > .icon,
.publication-preview .publication-reader-head > .icon { width: 30px; min-width: 30px; height: 30px; min-height: 30px; padding: 4px; border-radius: 8px; }
.publication-preview .publication-reader { height: auto; max-height: min(780px, 86dvh); }
.publication-preview .publication-reader-head { padding: 20px 20px 12px; border-bottom: 0; }
.publication-preview .publication-reader-title,
.publication-preview input.publication-title-input { font-size: 18px; line-height: 1.4; }
.publication-preview .publication-reader-body { flex: 0 1 auto; padding: 0 20px 20px; }
@media (max-width: 760px) {
  .publication-dialog { padding: 12px; }
  .publication-dialog .dialog-head h2,
  .publication-preview .publication-reader-title,
  .publication-preview input.publication-title-input { font-size: 16px; }
  .publication-preview .publication-reader-head { padding: 12px 12px 8px; }
  .publication-preview .publication-reader-body { padding: 0 12px 12px; }
}
@media (max-width: 760px), (pointer: coarse) {
  .publication-dialog .dialog-head > .icon,
  .publication-preview .publication-reader-head > .icon { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
}

@media (max-width: 480px) {
  .publication-preview .publication-reader-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .publication-preview .publication-reader-title,
  .publication-preview input.publication-title-input { grid-column: 1; grid-row: 1; max-width: 100%; width: 100%; min-width: 0; }
  .publication-preview .publication-reader-head > .icon { grid-column: 2; grid-row: 1; }
  .publication-preview .publication-preview-actions { grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; flex-wrap: wrap; min-width: 0; }
}
@media (max-width: 760px), (pointer: coarse) {
  .publication-selection.publication-dialog button:not(.primary):not(.icon) { min-height: 44px; }
}

#account-dialog.automatic-backup { width: min(360px, calc(100vw - 24px)); padding: 16px; }
#account-status:empty { display: none; }

.account-avatar { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: var(--soft); color: var(--text); font-size: 14px; font-weight: 600; }
.account-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
#avatar-dialog, #guest-tapfun-dialog { width: min(340px, calc(100vw - 24px)); padding: 16px; }
#avatar-dialog h2, #guest-tapfun-dialog h2 { font-size: 16px; }
#guest-tapfun-note { margin-top: 8px; font-size: 13px; }
#guest-tapfun-dialog form { display: grid; gap: 10px; margin-top: 12px; }
#guest-tapfun-dialog label { display: grid; gap: 4px; font-size: 13px; }
#guest-tapfun-dialog input { width: 100%; box-sizing: border-box; min-height: 36px; }
#guest-tapfun-dialog button[type="submit"] { min-height: 36px; }
#guest-tapfun-dialog .dialog-actions { margin-top: 12px; justify-content: flex-start; }
@media (max-width: 760px), (pointer: coarse) {
  #guest-tapfun-close { min-width: 44px; min-height: 44px; }
}
.avatar-upload-row { display: flex; align-items: center; gap: 16px; margin: 16px 0; }
#avatar-preview { width: 64px; height: 64px; font-size: 28px; }
#avatar-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.avatar-option { border: 2px solid transparent; border-radius: 12px; background: transparent; min-height: 56px; padding: 6px; }
.avatar-option:hover { background: var(--soft); }
.avatar-option[aria-pressed="true"] { border-color: var(--accent); }
.avatar-option .account-avatar { width: 44px; height: 44px; font-size: 20px; }
#avatar-error:empty { display: none; }

/* Account display name */
#avatar-dialog form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 16px; }
#avatar-dialog form label { grid-column: 1 / -1; font-size: 13px; }
#profile-name { min-width: 0; width: 100%; }
#profile-name:read-only { grid-column: 1 / -1; }

.thread-file-action-block .story-start { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: auto; height: 38px; padding: 0 12px; border: 0; border-radius: 19px; background: var(--accent); color: var(--accentText); }
@media (max-width:760px), (pointer:coarse) { .thread-file-action-block .story-start { height: 44px; border-radius: 22px; } }

/* Quest preparation stays in the opening message and reveals one action at a time. */
.quest-builder-opening{max-width:640px;}
.quest-builder-opening .quest-material-row{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px;margin:0 0 12px;}
.quest-material-label{color:var(--muted);font-size:13px;min-width:6em;}
.quest-material-names{overflow-wrap:anywhere;flex:1;min-width:100px;}
.quest-opening-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:10px;}
.quest-builder-opening p{margin:12px 0 0;}
.quest-builder-opening .quest-opening-guide{margin:4px 0 12px;color:var(--muted);font-size:14px;}
.quest-builder-opening .quest-material-row .code-block-copy{font-size:12px;}
@media(max-width:760px){.quest-opening-controls button,.quest-material-row button{min-height:44px;}}

.quest-adult-option{display:flex;align-items:center;gap:8px;min-height:44px;font-size:13px;}
.quest-adult-option input{width:18px;height:18px;flex:none;margin:0;}
.quest-opening-controls .quest-skip{border:0;background:transparent;color:var(--muted);}

/* The first questions of the user and character builders: a card right above the composer (builder-first-choice.ts). */
.builder-question{margin:0 0 10px;padding:12px 14px 14px;border:1px solid var(--border);border-radius:14px;background:var(--panel);box-shadow:0 4px 18px color-mix(in srgb, var(--text), transparent 92%);}
.builder-question[hidden]{display:none;}
.builder-question-head{display:flex;align-items:center;justify-content:space-between;font-size:12px;color:var(--muted);}
.builder-question-close{border:0;background:transparent;font-size:18px;line-height:1;padding:2px 6px;color:var(--muted);}
.builder-question-text{margin:2px 0 0;font-size:15px;line-height:1.6;}
.builder-question-note{margin:2px 0 0;font-size:12px;color:var(--muted);}
.builder-question-choices{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:12px;}
.reply-choice-buttons{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0;}
.reply-choice-buttons button{min-height:36px;max-width:100%;}
@media(max-width:760px),(pointer:coarse){.reply-choice-buttons button{min-height:44px;}}
.builder-question-chip{min-height:34px;padding:0 14px;border:1px solid var(--border);border-radius:10px;background:var(--soft);color:var(--text);font-size:13px;}
.builder-question-chip:hover:not(:disabled){border-color:var(--muted);}
.builder-question-chip.is-primary{background:var(--text);border-color:var(--text);color:var(--panel);font-weight:700;}
.builder-question-choices input{flex:1 1 220px;min-width:0;min-height:34px;box-sizing:border-box;padding:0 10px;border:1px solid var(--border);border-radius:10px;background:var(--panel);color:var(--text);font:inherit;font-size:13px;}
@media(max-width:760px){.builder-question-chip,.builder-question-choices input{min-height:44px;}}

/* Keep the existing thinking control available before scenario generation. */
.scenario-preparing:has(.scenario-create-view) .composer{display:grid;padding:0;border:0;background:none;box-shadow:none;}
.scenario-preparing:has(.scenario-create-view) .composer > :not(.composer-bar):not(.inline-operation-error),
.scenario-preparing:has(.scenario-create-view) .composer .composer-settings,
.scenario-preparing:has(.scenario-create-view) .composer .composer-limit,
.scenario-preparing:has(.scenario-create-view) .composer .send{display:none;}
.scenario-create-about > p, .quest-builder-opening .scenario-create-about > p { margin: 0 0 4px; }
.scenario-create-about > p:first-child, .quest-builder-opening .scenario-create-about > p:first-child { margin-bottom: 12px; }
.scenario-create-about > p > strong { font-size: 13px; }
.scenario-create-about > ul { margin: 0 0 10px; padding-left: 1.4em; color: var(--muted); font-size: 14px; }
.character-image-dialog{width:min(720px,calc(100vw - 24px));max-height:90dvh;overflow:auto;padding:20px}
.character-image-heading,.character-image-controls{display:flex;align-items:center;justify-content:space-between;gap:12px}
.character-image-heading h2{font-size:18px;overflow-wrap:anywhere;margin:0}
.character-image-heading>button{flex-shrink:0;white-space:nowrap}
.character-image-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:16px 0}
.character-image-grid button{padding:4px;display:flex;flex-direction:column;align-items:center;gap:4px;min-width:0}
.character-image-grid button[aria-pressed=true]{outline:3px solid var(--accent,#3e4d78);outline-offset:1px}
.character-image-grid img{width:100%;aspect-ratio:1;object-fit:contain;border-radius:6px}
.character-image-preferences{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0}
.character-image-preferences label{min-width:0;font-size:13px}
.character-image-preferences select,.character-image-preferences input{display:block;box-sizing:border-box;width:100%;min-width:0;min-height:36px;margin-top:4px}
.character-image-preview img{display:block;width:min(100%,400px);aspect-ratio:1;object-fit:contain;margin:16px auto;border-radius:6px}
.character-image-dialog details{margin-top:16px}
.character-image-dialog summary{cursor:pointer;padding:8px 0}
.character-image-style-tools{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:12px 0}
.character-image-tags{display:flex;flex-wrap:wrap;gap:6px}
.character-image-tag{border-radius:999px;padding:4px 10px;font-size:12px}
.character-image-history-item{display:flex;flex-direction:column;gap:6px;min-width:0}
.character-image-tag-dialog{width:min(560px,calc(100vw - 32px));max-height:85dvh;overflow:auto;box-sizing:border-box}
.character-image-tag-dialog fieldset{border:0;padding:0;margin:18px 0}
.character-image-tag-dialog legend{font-size:13px;color:var(--muted);margin-bottom:8px}
.character-image-tag-options{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.character-image-tag-options button{min-width:0;min-height:44px;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:8px 4px}
.character-image-tag-options button[aria-pressed=true]{outline:2px solid var(--accent,#3e4d78);outline-offset:1px}
.character-image-tag-options small{font-size:10px;overflow-wrap:anywhere;color:var(--muted)}
.character-image-tag-dialog>a{display:block;font-size:12px;margin-top:16px}
@media(max-width:600px){.character-image-tag-options{grid-template-columns:repeat(2,minmax(0,1fr))}.character-image-tag-dialog{padding:12px}}
.character-image-adopted{display:block;width:100px;height:100px;object-fit:contain;margin-top:12px}
.character-image-dialog small{display:block;margin:10px 0;color:var(--muted,#6d7179)}
.character-image-dialog textarea{display:block;box-sizing:border-box;width:100%;margin:12px 0;resize:vertical}
.character-image-dialog button{min-height:36px}.character-image-dialog a{display:block;margin:12px 0}
.character-image-dialog [hidden]{display:none!important}
.character-appearance-dialog{box-sizing:border-box;width:min(880px,calc(100vw - 32px));max-height:calc(100dvh - 32px);padding:20px;display:flex;flex-direction:column;gap:18px}
.character-appearance-dialog:not([open]){display:none}
.character-appearance-dialog .character-image-heading{margin:0;gap:16px}
.character-image-workspace{display:grid;grid-template-columns:minmax(0,1fr);gap:24px;min-width:0}
.character-image-workspace.has-image{grid-template-columns:minmax(200px,.85fr) minmax(0,1.15fr)}
.character-appearance-dialog.character-image-initial{width:min(560px,calc(100vw - 24px))}
.character-image-initial .character-image-generation{gap:12px}
.character-image-initial .character-image-appearance-field textarea{height:180px;min-height:120px}
.character-image-initial .character-appearance-generate{margin-top:4px}
.character-image-result,.character-image-generation{min-width:0}
.character-image-result{display:flex;flex-direction:column;gap:12px}
.character-appearance-dialog .character-image-preview img{width:100%;height:auto;aspect-ratio:auto;max-width:300px;max-height:30dvh;margin:0;object-fit:contain}
.character-appearance-dialog .character-image-enlarge{width:100%;max-width:300px}
.character-image-actions{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px 12px}
.character-image-actions button{padding:8px 16px}
.character-image-confirm,.character-image-retry{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-width:108px}
.character-image-confirm svg,.character-image-retry svg{width:17px;height:17px;flex-shrink:0}
.character-image-retry{background:transparent;border:1px solid var(--border);font-weight:500}
.character-image-retry:hover:not(:disabled){background:var(--soft);border-color:var(--muted)}
.character-appearance-dialog .character-image-result>small{font-size:12px;line-height:1.5;margin:0}
.character-appearance-dialog h3{font-size:14px;font-weight:600;margin:0 0 10px}
.character-appearance-dialog .character-image-grid{position:relative;display:flex;gap:8px;overflow-x:auto;margin:0;padding:3px 3px 7px;scroll-padding:3px}
.character-appearance-dialog .character-image-grid button{flex:0 0 62px;padding:3px;gap:2px;font-size:11px;border-radius:6px}
.character-appearance-dialog .character-image-grid img{width:54px;height:54px;border-radius:3px}
.character-appearance-dialog .character-image-grid button[aria-pressed=true]{outline-width:2px}
.character-image-history-heading{display:flex;align-items:center;flex-wrap:wrap;gap:4px 12px;margin-bottom:10px}
.character-appearance-dialog .character-image-history-heading h3{margin:0}
.character-appearance-dialog .character-image-upload{font-size:12px;padding:4px 8px}
.character-appearance-dialog .character-image-grid .character-image-history-item{flex:0 0 62px;gap:2px}
.character-appearance-dialog .character-image-grid [data-candidate-index]{flex:0 0 auto;width:100%}
.character-appearance-dialog .character-image-grid .character-image-history-more{flex:0 0 auto;justify-content:center;width:100%;min-height:30px;font-size:20px;line-height:1;padding:0;border:0;background:transparent;color:var(--muted)}
.character-image-history-menu{position:fixed;inset:auto;margin:0;width:160px}
.character-appearance-dialog .character-image-generation-info{margin:0;font-size:12px;color:var(--muted)}
.character-image-generation-info label{display:block;color:var(--text)}
.character-appearance-dialog .character-image-generation-info textarea{height:140px;font-size:12px}
@media(pointer:coarse),(max-width:640px){.character-appearance-dialog .character-image-grid .character-image-history-more,.character-appearance-dialog .character-image-generation-info summary{min-height:44px;box-sizing:border-box}}
.character-image-generation{display:flex;flex-direction:column;gap:12px}
.character-appearance-dialog .character-image-preferences{grid-template-columns:minmax(0,1fr);gap:12px;margin:0}
.character-image-preferences>div{min-width:0;font-size:13px}
.character-image-model-choices{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:4px}
.character-image-model-choices label{position:relative;display:flex;min-width:0;cursor:pointer}
.character-image-model-choices input[type=radio]{position:absolute;opacity:0;width:1px;height:1px;min-height:0;margin:0}
.character-image-model-choices span{box-sizing:border-box;display:flex;align-items:center;justify-content:center;min-height:36px;width:100%;padding:8px;border:1px solid var(--border);border-radius:6px;text-align:center;line-height:1.4}
.character-image-model-choices input:checked+span{border-color:var(--accent);background:var(--accent);color:var(--bg);font-weight:600}
.character-image-model-choices input:focus-visible+span{outline:2px solid var(--accent);outline-offset:3px}
.character-image-model-choices input:disabled+span{opacity:.5;cursor:default}
@media(pointer:coarse),(max-width:640px){.character-image-model-choices span{min-height:44px}}
.character-image-style-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:13px}
.character-image-dialog .character-image-style-heading .character-image-tag-add{margin-top:0}
.character-image-dialog .character-image-tag-add{margin-top:6px;min-height:28px;padding:2px 8px;font-size:12px;border-radius:5px}
.character-image-appearance-field{display:block;font-size:13px}
.character-appearance-dialog textarea{box-sizing:border-box;margin:6px 0 0;height:clamp(100px,21dvh,170px);min-height:84px;line-height:1.55;padding:9px 10px;font-size:14px}
.character-appearance-dialog .character-image-ai{margin-top:6px;padding:3px 0;font-size:12px;border:0;background:transparent;color:var(--muted)}
.character-appearance-dialog .character-appearance-generate{position:static;display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap;padding:0;margin:0}
.character-image-generation>p:empty{display:none}
.character-image-generation>p{margin:0;font-size:13px}
.character-image-ai-dialog{box-sizing:border-box;width:min(560px,calc(100vw - 32px))}
.character-image-ai-dialog>label{display:block;margin-top:16px}
.character-image-ai-dialog>section{margin-top:20px}
.character-appearance-cleanup p{font-size:13px;overflow-wrap:anywhere}
.character-appearance-cleanup del{color:var(--muted)}
.character-appearance-cleanup ins{text-decoration:none}
.character-image-enlarge{display:block;max-width:100%;margin:auto;padding:0;border:0;background:transparent;cursor:zoom-in}
.character-image-viewer{width:min(1200px,calc(100vw - 24px));height:calc(100dvh - 24px);max-width:none;max-height:none;padding:12px;box-sizing:border-box}
.character-image-viewer[open]{display:flex;flex-direction:column;gap:12px}
.character-image-viewer .character-image-heading{margin:0;flex-shrink:0;gap:8px;flex-wrap:wrap}
.character-image-viewer h2{flex:1;margin:0;font-size:16px}
.character-image-viewer button{min-height:44px}
.character-image-viewer .character-image-download{box-sizing:border-box;display:inline-flex;align-items:center;min-height:44px;text-decoration:none;font-size:13px;padding:8px 12px}
.character-image-viewer-viewport{position:relative;flex:1;min-height:0;overflow:auto}
.character-image-viewer-viewport img{position:absolute;inset:0;display:block;width:100%;height:100%;object-fit:contain}
.character-image-viewer-viewport.actual-size img{position:static;width:auto;height:auto;max-width:none;max-height:none;margin:auto}
@media(max-width:600px){.character-image-dialog{padding:12px}.character-image-dialog button{min-height:44px}.character-image-dialog textarea{font-size:16px}.character-image-preferences{grid-template-columns:1fr}.character-image-preferences select,.character-image-preferences input{min-height:44px;font-size:16px}.character-image-controls{flex-wrap:wrap}}
@media(max-width:639px){
  .character-image-viewer .character-image-heading{display:grid;grid-template-columns:minmax(0,1fr) auto}
  .character-image-viewer .character-image-heading>h2{grid-column:1;grid-row:1}
  .character-image-viewer .character-image-heading>button:last-of-type{grid-column:2;grid-row:1;justify-self:end}
  .character-image-viewer .character-image-download{grid-column:1;grid-row:2;justify-self:start;max-width:100%;white-space:normal}
  .character-image-viewer .character-image-heading>button:first-of-type{grid-column:2;grid-row:2;justify-self:end}
  .character-appearance-dialog{width:calc(100vw - 24px);max-height:calc(100dvh - 24px);gap:14px;padding:14px}
  .character-image-heading h2{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:16px}
  .character-image-workspace.has-image{grid-template-columns:minmax(0,1fr);gap:18px}
  .character-appearance-dialog .character-image-preview img{max-height:24dvh;max-width:200px;margin:auto}
  .character-appearance-dialog .character-image-enlarge{max-width:200px}
  .character-image-result{gap:8px}
  .character-appearance-dialog textarea{height:112px;font-size:16px}
}

/* Adopted portraits share the existing thread header/sidebar positions. */
.character-portrait { display: inline-flex; flex: 0 0 auto; }
.character-portrait[hidden] { display: none; }
.character-portrait img { display: block; object-fit: cover; border-radius: 6px; }
.character-portrait-icon img { width: 20px; height: 20px; }
.character-portrait-header img { width: 28px; height: 28px; }
.character-portrait-result img { width: min(240px, 100%); height: auto; aspect-ratio: auto; object-fit: contain; }
.character-portrait-result, .character-portrait-intro { display: block; max-width: 100%; }
.character-portrait-intro { box-sizing: border-box; width: min(100%, 640px, 80svh); aspect-ratio: 4 / 3; padding: clamp(12px, 2vw, 24px); margin: 24px auto 32px; }
.character-portrait-intro img { width: 100%; height: 100%; object-fit: contain; }
.character-portrait-enlarge { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.character-image-step { margin: 16px 0; }
.character-image-step p { margin: 0 0 10px; }
.character-image-step .character-portrait { margin-bottom: 10px; }

/* Creation and character identity share the existing menu icon vocabulary. */
.thread-identity-icon { display:inline-flex; flex:none; align-items:center; justify-content:center; }
.thread-identity-icon[hidden] { display:none; }
.thread-identity-icon svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.thread-identity-header svg { width:24px; height:24px; }
.character-image-header-button { display:inline-flex; flex:none; align-items:center; justify-content:center; gap:6px; min-width:36px; height:36px; padding:3px; border:1px solid transparent; border-radius:8px; background:transparent; color:inherit; cursor:pointer; }
.character-image-header-button:hover { border-color:var(--border); background:var(--panel); }
.character-image-header-button:focus-visible { outline:2px solid var(--text); outline-offset:2px; }
@media (pointer:coarse), (max-width:640px) { .character-image-header-button { min-width:44px; height:44px; } }
.character-builder-step { margin:12px 0; }
.character-builder-step p { margin:8px 0; }
.character-builder-actions { display:grid; gap:16px; }
.character-builder-image-action { margin-top:24px; }

/* Thread identity spans the title and the compact applied-file row. */
.workspace.single-conversation .thread-header, .workspace:not(.single-conversation) .thread-header { height:auto; min-height:52px; align-items:center; padding-top:6px; padding-bottom:6px; }
.thread-header-text { display:flex; flex:1; flex-direction:column; justify-content:center; min-width:0; min-height:36px; gap:1px; padding:0; border:0; border-radius:3px; background:transparent; color:inherit; font:inherit; text-align:left; cursor:pointer; }
.thread-header-text:disabled { opacity:1; cursor:default; }
.thread-header-text:focus-visible { outline:2px solid var(--text); outline-offset:2px; }
.thread-header-text > strong { display:block; line-height:18px; white-space:nowrap; }
.thread-header .thread-header-files { display:flex; flex-wrap:wrap; align-items:center; min-width:0; overflow:visible; white-space:normal; font-size:11px; line-height:16px; color:var(--text); }
.thread-header-file { display:block; max-width:100%; min-width:0; line-height:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.thread-header-file svg { display:inline-block; width:11px; height:11px; margin-right:3px; vertical-align:-2px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.thread-header .thread-header-files[hidden] { display:none; }
.thread-header-file + .thread-header-file::before { content:'｜'; padding:0 5px; color:var(--muted); }
.thread-header-text:not(:disabled):hover .thread-header-file { text-decoration:underline; }
.thread-header > .thread-identity-icon, .thread-header > .character-portrait { align-self:center; }
@media (pointer:coarse), (max-width:640px) { .thread-header-text { min-height:44px; } }

.publication-artwork {display:block;width:min(240px,100%);height:auto;border-radius:8px;margin:12px 0;}
.publication-models .publication-card-artwork {width:40px;height:40px;object-fit:cover;border-radius:6px;}

.thread-header-file .character-portrait-file {display:inline-flex;width:18px;height:18px;flex:0 0 18px;vertical-align:middle;}
.thread-header-file .character-portrait-file img {width:18px;height:18px;object-fit:cover;border-radius:3px;}
.thread-header-file .character-portrait-file[hidden], .thread-header-file svg[hidden] {display:none;}
.thread-reference-portraits {display:flex;align-items:center;gap:4px;flex-shrink:0;}
.thread-reference-portraits > button {display:flex;align-items:center;justify-content:center;min-width:34px;min-height:34px;padding:3px;border:0;border-radius:6px;background:transparent;color:inherit;}
.thread-reference-portraits > button:hover {background:var(--panel);}
.thread-reference-portraits .character-portrait-file img {width:28px;height:28px;object-fit:cover;border-radius:3px;}
.thread-reference-portraits svg {width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.thread-reference-portraits [hidden] {display:none;}
.character-detail-tabs {display:flex;gap:4px;flex:none;border-bottom:1px solid var(--border);}
.character-detail-tabs [role=tab] {min-height:40px;padding:8px 20px;border:0;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--muted);}
.character-detail-tabs [aria-selected=true] {border-bottom-color:var(--accent);color:var(--text);font-weight:600;}
.character-detail-settings {min-height:0;overflow:auto;}
.character-detail-settings pre {margin:0;line-height:1.65;}
.character-detail-settings > details {margin-top:20px;}
.character-detail-images {min-width:0;min-height:0;overflow:auto;}
.character-detail-images > p {margin:0 0 16px;font-size:12px;color:var(--muted);}
.character-appearance-dialog.character-detail-reading {width:min(560px,calc(100vw - 24px));}
.character-appearance-dialog [role=tabpanel][hidden] {display:none;}
.thread-header-file-choices {display:flex;flex-direction:column;gap:8px;}
.thread-header-file-choices button {text-align:left;white-space:normal;overflow-wrap:anywhere;}
@media(pointer:coarse),(max-width:640px){.character-detail-tabs [role=tab],.thread-reference-portraits > button {min-width:44px;min-height:44px;}}
.image-references {margin:0;min-width:0;}
.image-reference-heading {font-size:12px;}
.image-reference-list {display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 0;}
.image-reference-list[hidden] {display:none;}
.image-reference-add {box-sizing:border-box;width:88px;height:88px;flex:0 0 88px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:8px;border:1px dashed var(--border);border-radius:6px;background:transparent;color:var(--muted);font-size:12px;}
.image-reference-add > span:first-child {font-size:24px;line-height:1;}
.image-reference-add:hover {color:var(--text);border-color:var(--accent);background:var(--surface);}
.image-reference-sources {display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;padding:10px;border:1px solid var(--border);border-radius:6px;}
.image-reference-sources > button {font-size:12px;}
.image-reference-sources .image-reference-list {flex-basis:100%;}
.image-reference-card {position:relative;width:88px;min-width:0;}
.image-reference-card > span {display:block;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:4px;}
.image-reference-thumb {display:block;padding:0;width:88px;height:88px;overflow:hidden;border:1px solid var(--border);border-radius:6px;background:var(--surface);}
.image-reference-thumb img {width:100%;height:100%;object-fit:contain;}
.image-reference-remove {position:absolute;right:-4px;top:-4px;min-width:24px;min-height:24px;padding:0;background:var(--bg);border:1px solid var(--border);border-radius:50%;}
.image-reference-choice {display:flex;align-items:center;gap:6px;max-width:100%;font-size:12px;}
.image-reference-choice img {width:40px;height:40px;object-fit:cover;border-radius:4px;}
@media (pointer:coarse), (max-width:640px) {.image-reference-remove {min-width:44px;min-height:44px;right:-6px;top:-6px;}.character-image-dialog .character-image-tag-add {min-height:44px;}}

.character-image-preferences>.character-image-quality{display:flex;flex-wrap:wrap;gap:8px;grid-column:1/-1}
.character-image-quality>label{display:flex;flex:1 1 140px;min-width:0;flex-direction:column;gap:4px}
.character-image-quality select{width:100%;min-width:0}

/* Image-first hides presentation only; the complete answer is still saved. */
.illustration-hold > .message-body, .illustration-hold > .speech-controls, .illustration-hold > .message-footer { display: none; }
.speech-player audio {display:block;width:min(100%,420px);margin:8px 0;}
.speech-controls {max-width:100%;margin-top:0;}
.speech-generate + .illustration-camera {margin-inline-start:0;}
.voice-editor textarea {width:100%;box-sizing:border-box;}
.voice-editor button {margin:4px 6px 4px 0;}
.composer-icon, .composer-settings .thread-settings.composer-icon, .composer-history .history-preview { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 34px; min-width: 34px; height: 34px; min-height: 34px; padding: 7px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.composer-icon svg, .composer-settings .thread-settings.composer-icon svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.composer-icon:not(:disabled):hover, .composer-icon:focus-visible { background: var(--soft); color: var(--text); }
.composer-model-control, .composer-history, .illustration-control { padding: 0; border-radius: 8px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.composer-tools, .composer-settings { gap: 6px; }
.composer-history .composer-switch, .illustration-control .composer-switch { min-width: 34px; padding-inline: 3px; border-radius: 8px; }
.composer-switch { min-height: 34px; }
.composer-switch .switch { display: block; flex-shrink: 0; box-sizing: content-box; width: 24px; height: 12px; padding: 2px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--border); }
.composer-switch .switch:after { width: 12px; height: 12px; background: var(--muted); }
.composer-switch[aria-checked="true"] .switch { background: var(--accent); box-shadow: none; }
.composer-switch[aria-checked="true"] .switch:after { transform: translateX(12px); background: var(--accentText); }
.thinking-control .thinking-select { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; width: auto; min-width: 66px; min-height: 34px; border: 0; border-radius: 8px; padding: 6px 8px; background: transparent; color: var(--text); font-size: 12px; font-weight: 400; cursor: pointer; }
.thinking-control .thinking-select:hover { background-color: var(--soft); }
.thinking-select svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.thinking-menu { position: fixed; inset: auto; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px #0003; overflow-y: auto; }
.thinking-menu::backdrop { background: transparent; }
.thinking-menu > button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 32px; margin: 0; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; font-weight: 400; text-align: left; }
.thinking-menu > button:hover, .thinking-menu > button[aria-checked="true"] { background: var(--soft); }
@media (max-width: 760px), (pointer: coarse) { .thinking-menu > button { min-height: 44px; } }
.composer-model-control { display: inline-flex; flex-wrap: wrap; align-items: center; flex: 0 1 auto; gap: 0; min-width: 0; max-width: 100%; }
.composer-model-control > .composer-settings { gap: 0; }
.composer-model-control .composer-history { background: transparent; }
.composer-model-control .composer-history::after { display: none; }
.composer-model-control .composer-model { justify-content: center; flex: 0 0 auto; width: 40px; min-width: 40px; height: 34px; padding: 6px; gap: 6px; border-radius: 8px; color: var(--muted); }
.composer-model-control .composer-model::after { content: ""; flex: 0 0 5px; width: 5px; height: 5px; border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.composer-model-control .composer-model img, .composer-model-control .composer-model svg { width: 14px; height: 14px; flex: 0 0 14px; }
.composer-model-control .thinking-control { flex: 0 0 auto; gap: 0; }
.composer-model-control .thinking-control::before,
.composer-model-control .composer-settings::before,
.composer-model-control .composer-history::before { content: ""; flex: 0 0 1px; width: 1px; height: 14px; margin-inline: 2px; background: color-mix(in srgb, var(--muted) 15%, transparent); }
.composer-model-control .thinking-select { min-width: 54px; padding-inline: 6px; gap: 4px; color: var(--muted); border-radius: 8px; }
.composer-model-control .composer-model:hover, .composer-model-control .composer-model[aria-expanded="true"], .composer-model-control .thinking-select:hover, .composer-model-control .thinking-select[aria-expanded="true"] { background: var(--soft); }
@media (max-width: 760px), (pointer: coarse) {
  .composer-model-control .composer-model { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .composer-model-control, .composer-history, .illustration-control { position: relative; isolation: isolate; background: transparent; }
  .composer-model-control::after, .composer-history::after, .illustration-control::after { content: ""; position: absolute; inset: 5px 0; z-index: -1; border-radius: 8px; background: color-mix(in srgb, var(--text) 6%, transparent); pointer-events: none; }
}
@media (max-width: 760px), (pointer: coarse) { .composer-history .composer-switch, .illustration-control .composer-switch { min-width: 44px; } }
@media (max-width: 760px), (pointer: coarse) { .composer-icon, .composer-settings .thread-settings.composer-icon, .composer-history .history-preview { width: 44px; min-width: 44px; height: 44px; min-height: 44px; } .thinking-control .thinking-select { min-height: 44px; font-size: 16px; } }
.illustration-settings-dialog { width: min(440px, calc(100vw - 24px)); max-width: calc(100vw - 24px); }
.illustration-settings-dialog .dialog-head h2 { flex: 1; }
.illustration-settings-dialog select { width: 100%; min-width: 0; min-height: 36px; }
.illustration-settings-group { min-width: 0; border: 0; margin: 0; padding: 0; }
.illustration-settings-group + .illustration-settings-group { margin-top: 24px; }
.illustration-settings-group > legend { margin-bottom: 12px; padding: 0; font-size: 14px; font-weight: 600; }
.illustration-prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.illustration-prompt-head h3 { margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; }
.illustration-enhancement { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; white-space: nowrap; }
.illustration-settings-dialog .illustration-enhancement select { width: auto; min-width: 68px; max-width: 110px; padding: 6px; }
.illustration-ratio-select { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 36px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--panel); font: inherit; font-size: 13px; text-align: left; }
.illustration-ratio-select::after { content: ''; width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); margin: -3px 3px 0 auto; }
.illustration-ratio-icon { display: inline-flex; flex: 0 0 28px; height: 24px; align-items: center; justify-content: center; }
.illustration-ratio-shape { display: block; box-sizing: border-box; border: 1px solid currentColor; border-radius: 2px; }
.illustration-ratio-select > span:last-of-type { white-space: nowrap; }
.illustration-ratio-menu { box-sizing: border-box; max-height: calc(100dvh - 16px); }
.illustration-ratio-menu button { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.illustration-ratio-menu button[aria-checked="true"] { background: var(--userBubble); }
.illustration-ratio-menu button:disabled { opacity: .45; cursor: default; }
.illustration-settings-dialog .illustration-setting-row { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 12px; align-items: center; margin: 0 0 10px; font-weight: 400; }
.illustration-settings-dialog .illustration-setting-row:last-child { margin-bottom: 0; }
.illustration-instruction-field { margin-bottom: 0; text-align: right; }
.illustration-instruction-field textarea { display: block; width: 100%; box-sizing: border-box; resize: vertical; min-height: 104px; margin-bottom: 6px; text-align: left; }
.illustration-instruction-field > button { min-height: 34px; }
.illustration-instruction-menu { max-height: min(420px, calc(100dvh - 16px)); text-align: left; }
.illustration-instruction-menu button { min-height: 34px; }
.illustration-instruction-recovery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.illustration-instruction-recovery[hidden] { display: none; }
@media (pointer: coarse), (max-width: 760px) { .illustration-instruction-field textarea { font-size: 16px; } .illustration-instruction-field > button, .illustration-instruction-menu button, .illustration-instruction-recovery button { min-height: 44px; } }
.illustration-settings-dialog .muted { margin: 8px 0 0; line-height: 1.6; }
.illustration-settings-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
@media (max-width: 480px) { .illustration-settings-dialog { padding: 12px; } .illustration-settings-dialog .illustration-setting-row { grid-template-columns: 96px minmax(0,1fr); gap: 8px; } .illustration-settings-dialog .illustration-enhancement select { max-width: 96px; } }
@media (pointer: coarse), (max-width: 760px) { .illustration-settings-dialog select, .illustration-settings-dialog .dialog-head button, .illustration-ratio-select, .illustration-ratio-menu button { min-height: 44px; } }
.auto-illustration, .manual-illustration { display: flow-root; margin: 10px 0 0; overflow-anchor: none; }
.illustration-camera, .speech-generate, .video-generate-button, .image-plan-button, .illustration-remake-button { flex: 0 0 auto; }
.illustration-camera { margin-inline-start: auto; }
.illustration-camera:focus-visible, .video-generate-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.illustration-camera[aria-busy="true"], .video-generate-button[aria-busy="true"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
.illustration-candidates > div { display: flex; gap: 12px; overflow-x: auto; padding: 4px 0 12px; }
.illustration-candidate { flex: 0 0 160px; min-width: 0; display: flex; flex-wrap: wrap; align-content: start; gap: 6px; }
.illustration-candidate .illustration-enlarge { width: 100%; margin: 0; padding: 0; }
.illustration-candidate img { max-height: 160px; object-fit: contain; }
.illustration-candidate [role=status] { flex-basis: 100%; overflow-wrap: anywhere; }
.illustration-candidates [role=alert]:empty { display: none; }
@media (pointer: coarse), (max-width: 760px) { .illustration-candidates button, .illustration-settings-dialog .primary { min-height: 44px; }  }
.illustration-enlarge { display: block; box-sizing: border-box; width: min(100%, 640px, calc(76svh * var(--illustration-ratio, 1.333333))); padding: clamp(12px, 2vw, 24px); margin: 24px auto 32px; border: 0; background: transparent; cursor: zoom-in; }
.illustration-enlarge img { display: block; width: 100%; height: auto; object-fit: contain; border-radius: 8px; }
.video-source { display:grid;grid-template-columns:minmax(0,1fr);width: min(100%, 640px, calc(76svh * var(--illustration-ratio, 1.333333))); margin: 24px auto 32px; }
.video-source > .illustration-enlarge { grid-area:1/1;width: 100%; margin: 0; padding-bottom: 8px; }
.video-source > .video-controls { display:contents; }
.video-source > .video-controls > .video-actions { grid-area:2/1;justify-self:end;margin-inline:clamp(12px,2vw,24px); }
.video-source > .video-controls > .video-results { grid-area:3/1;padding-inline:clamp(12px,2vw,24px); }
.video-source > .video-controls > .video-status { grid-area:4/1;padding-inline:clamp(12px,2vw,24px); }
.video-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.image-plan-button svg, .illustration-remake-button svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.image-plan-dialog { width: min(720px, calc(100vw - 24px)); }
.image-plan-body { min-height: 0; overflow-y: auto; display: grid; gap: 16px; }
.image-plan-body h3 { margin: 0 0 4px; font-size: 14px; }
.image-plan-body p { margin: 0 0 6px; }
.image-plan-body details { border-top: 1px solid var(--border); padding: 8px 0; }
.image-plan-body pre { margin: 8px 0 0; }
.video-confirm-dialog { width:min(480px,calc(100vw - 32px)); }
.video-confirm-preview { display:block;max-width:100%;max-height:200px;object-fit:contain;margin:0 auto 16px;border-radius:8px; }
.video-confirm-summary { display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px 16px;font-size:13px; }
.video-confirm-summary dt { color:var(--muted); }
.video-confirm-summary dd { margin:0;overflow-wrap:anywhere; }
.video-confirm-instruction { white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;max-height:100px;overflow:auto; }
.video-confirm-dialog .dialog-actions { display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:20px; }
.video-status { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.video-toggle-row { display: flex; align-items: center; gap: 10px; min-height: 38px; font-size: 13px; }
.video-toggle-row > span:first-child { flex: 1; }
.video-audio-children { min-width: 0; margin: 0; padding: 0 0 0 18px; border: 0; }
.video-audio-children:disabled { opacity: .5; }
.video-toggle-row input:disabled { cursor: default; }
.video-toggle-row > span:nth-child(2) { color: var(--muted); font-size: 11px; }
.video-toggle-row input { appearance: none; flex: 0 0 32px; width: 32px; height: 20px; margin: 0; padding: 2px; border: 1px solid var(--border); border-radius: 12px; background: var(--soft); cursor: pointer; }
.video-toggle-row input::before { content: ''; display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .1s; }
.video-toggle-row input:checked { background: var(--accent); }
.video-toggle-row input:checked::before { transform: translateX(12px); background: #fff; }
.video-instruction { margin: 16px 0 0; }
.video-instruction textarea { width: 100%; resize: vertical; min-height: 80px; }
.video-results video { display: block; width: 100%; max-height: 70svh; border-radius: 8px; margin-top: 12px; }
.video-result { margin-top: 12px; }
.video-results:not(:empty) { margin-bottom: 8px; }
@media (pointer: coarse), (max-width: 760px) { .video-toggle-row { min-height: 44px; } .video-settings-dialog textarea, .video-settings-dialog select { font-size: 16px; } }
.illustration-status { display: block; color: var(--muted); font-size: 12px; }
.illustration-retry { font-size: 12px; min-height: 32px; }
@media (max-width: 760px), (pointer: coarse) { .illustration-retry { min-height: 44px; } .composer-switch { min-height: 44px; } }

.illustration-control { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; }

.composer-tools > .composer-settings { flex: 0 0 auto; flex-wrap: nowrap; }
.composer-tools > .illustration-control { margin-left: auto; }
.illustration-control { max-width: 100%; }

.character-image-quality>label.character-image-resolution{display:grid;flex-basis:100%;grid-template-columns:96px minmax(0,1fr);gap:12px;align-items:center;font-weight:400}
.character-image-resolution select{min-height:36px}
@media(max-width:480px){.character-image-quality>label.character-image-resolution{gap:8px}}
@media(pointer:coarse),(max-width:760px){.character-image-resolution select{min-height:44px}}

.character-image-quality>.character-image-ratio{display:grid;flex:1 1 100%;min-width:0;grid-template-columns:96px minmax(0,1fr);gap:12px;align-items:center;font-weight:400}
@media(max-width:480px){.character-image-quality>.character-image-ratio{gap:8px}}
@media(pointer:coarse),(max-width:760px){.illustration-ratio-select,.illustration-ratio-menu button{min-height:44px}}

/* Character completion: vertical prose and equally prominent primary actions. */
.character-builder-step { margin: 12px 0; }
.character-builder-step .character-image-step { margin: 28px 0 0; }
.character-builder-step .character-builder-image-action { margin: 0 0 28px; }
.character-builder-step .character-builder-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.character-builder-step .character-completion-expansion { margin-top: 12px; }
.character-builder-step .character-completion-action p,
.character-builder-step .character-builder-image-action p { margin: 0 0 12px; font: inherit; color: inherit; }
.character-builder-step button.button-with-icon { min-height: 34px; max-width: 100%; gap: 8px; padding: 7px 12px; text-align: left; }
.character-builder-step button.button-with-icon svg { flex-shrink: 0; }
.character-builder-step button.character-completion-primary { background: var(--accent); border-color: var(--accent); color: var(--accentText); font-weight: 700; }
.creation-next-step button.creation-start-primary { background: var(--accent); border-color: var(--accent); color: var(--accentText); font-weight: 700; }
.creation-next-step .character-builder-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.creation-next-step .character-builder-actions > div > p { margin: 0 0 12px; }
.creation-next-step button.button-with-icon { min-height: 34px; max-width: 100%; gap: 8px; padding: 7px 12px; text-align: left; }
.creation-next-step button.button-with-icon svg { flex-shrink: 0; }
@media (pointer: coarse), (max-width: 760px) { .creation-next-step button.button-with-icon { min-height: 44px; } }
.character-builder-step button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.character-builder-step .character-completion-reuse { margin: -16px 0 0; font-size: 12px; color: var(--muted); }
@media (pointer: coarse), (max-width: 760px) { .character-builder-step button.button-with-icon { min-height: 44px; } }

/* Character completion scenario guide; icons stay on buttons. */
.character-builder-step .character-completion-scenario { margin-top: 12px; }
.character-builder-step .character-completion-scenario p { margin: 0 0 12px; }
.character-builder-step .character-completion-scenario > p:last-child { margin-bottom: 0; }
.character-builder-step .character-completion-examples { list-style: none; margin: 16px 0; padding: 0; }
.character-builder-step .character-completion-examples > li { margin: 0 0 10px; padding: 0; }
.character-builder-step .character-completion-examples > li:last-child { margin-bottom: 0; }

.speech-generate { margin-left: auto; }
.message-footer .message-action svg, .video-generate-button svg, .image-plan-button svg, .illustration-remake-button svg { width: 16px; height: 16px; }
@media (pointer: coarse), (max-width: 760px) {
  .message-footer .message-action, .video-generate-button, .image-plan-button, .illustration-remake-button { width: 44px; height: 44px; }
}

/* Keep the visual surface proportional even when the touch target is larger. */
:where(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open) {
  position: relative;
  isolation: isolate;
  --icon-surface-size: 30px;
}
:where(.composer-icon) { --icon-surface-size: 32px; }
:where(.icon) { --icon-surface-size: 34px; }
:is(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open),
:is(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open):is(:hover, :focus-visible, [aria-expanded="true"], [aria-pressed="true"]) {
  background: transparent;
  border-color: transparent;
}
:where(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open)::before {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: min(100%, var(--icon-surface-size));
  height: min(100%, var(--icon-surface-size));
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 6px;
}
:where(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open):not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"], [aria-pressed="true"])::before {
  background: var(--soft);
}
:is(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open):focus-visible {
  outline: none;
}
:where(.message-action, .composer-icon, .icon, .pane-menu-button, #settings-open):focus-visible::before {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.message-action[aria-busy="true"] { box-shadow: none; }
.message-action[aria-busy="true"]::before { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent); }

/* Composer actions and anchored settings menu, shared by desktop and mobile. */
.composer-model-control { flex-wrap: nowrap; background: transparent; }
.composer-model-control::after, .composer-model-control > .composer-settings,
.composer-model-control .thinking-control::before { display: none; }
.mobile-composer-settings { display: inline-flex; }
.composer-tools > .illustration-control { flex: 0 0 auto; margin-left: auto; background: transparent; }
.composer-tools > .illustration-control::after, .composer-tools .illustration-label, .speech-settings-source { display: none; }
.composer-tools .mobile-state-button { width: 34px; min-width: 34px; height: 34px; padding: 8px; background: transparent; }
.mobile-state-slash { display: none; }
.mobile-state-button[aria-checked="false"] .mobile-state-slash { display: initial; }
.composer-settings-menu { position: fixed; inset: auto; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 8px 28px #0003; overflow-y: auto; }
.composer-settings-menu::backdrop { background: transparent; }
.composer-settings-menu-row { display: flex; align-items: center; }
.composer-settings-menu-row[hidden] { display: none; }
.composer-settings-menu button { display: flex; align-items: center; gap: 10px; min-height: 32px; margin: 0; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; line-height: 18px; font-weight: 400; text-align: left; }
.composer-settings-menu button:hover { background: var(--soft); }
.composer-settings-menu-item { flex: 1; min-width: 0; }
.composer-settings-menu svg { flex: 0 0 18px; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.composer-settings-menu .composer-menu-state { justify-content: center; flex: 0 0 44px; padding-inline: 8px; }
@media (max-width: 760px), (pointer: coarse) {
  .composer-settings-menu button { min-height: 44px; }
  .composer-tools .mobile-state-button { width: 44px; min-width: 44px; height: 44px; padding: 13px; }
}
@media (max-width: 760px) {
  .composer-bar { position: relative; flex-wrap: nowrap; align-items: center; gap: 2px; }
  .composer-tools { flex-wrap: nowrap; gap: 2px; padding-left: 0; }
  .composer-model-control { flex: 0 0 auto; max-width: none; }
  .composer-model-control .composer-model { flex: 0 0 auto; width: 44px; min-width: 44px; padding: 8px; border-radius: 8px; }
  .composer-model-control .thinking-select { width: 44px; min-width: 44px; padding: 4px; gap: 2px; font-size: 12px; }
  .composer-model-control .thinking-select svg { width: 10px; height: 10px; }
  .composer-bar:has(> .composer-limit:not([hidden])) { padding-top: 16px; }
  .composer-limit { position: absolute; top: 0; right: 0; margin: 0; max-width: none; white-space: nowrap; }
  .composer-bar > .send { flex-shrink: 0; }
}
/* Conversation settings: material controls first, body editors in their own dialog. */
#prompt-fixed-files { display:flex; flex-direction:column; gap:14px; }
.conversation-file-row { display:flex; align-items:center; gap:8px; min-width:0; }
.conversation-file-label { flex:1; min-width:0; display:grid; grid-template-columns:1fr; gap:3px; }
.conversation-file-label > span:not(.character-portrait) { overflow:hidden; text-overflow:ellipsis; }
.conversation-file-label .muted { font-size:12px; }
.conversation-file-label .character-portrait { grid-column:1; grid-row:1 / 3; width:40px; margin-right:8px; }
.conversation-file-label .character-portrait img { width:40px; height:40px; }
.conversation-file-label:has(.character-portrait:not([hidden])) { grid-template-columns:48px 1fr; }
.conversation-file-label:has(.character-portrait:not([hidden])) > span:not(.character-portrait) { grid-column:2; }
.conversation-file-row > button { flex-shrink:0; }
.conversation-scenario-items { list-style:none; margin:-4px 0 4px; padding:0 0 0 12px; border-left:2px solid var(--border); display:grid; gap:2px; min-width:0; }
.conversation-scenario-items li { display:grid; grid-template-columns:auto 1fr; gap:8px; align-items:baseline; min-width:0; font-size:13px; }
.conversation-scenario-items li > span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conversation-scenario-items .muted { font-size:12px; }
.conversation-file-actions { display:flex; justify-content:flex-end; gap:8px; margin-bottom:12px; }
.scenario-image-choices > button { display:inline-flex; align-items:center; gap:6px; }
.scenario-image-choices > button[aria-pressed="true"] { background: var(--soft); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--border); }
.adopted-file-conflict pre { white-space:pre-wrap; max-height:180px; overflow:auto; font-size:12px; }
.adopted-file-conflict:empty { display:none; }
.thread-file-dialog .dialog-actions .file-history-open { margin-right:auto; }
.file-history-list { display:flex; flex-direction:column; gap:2px; max-height:180px; overflow:auto; border:1px solid var(--border); border-radius:8px; padding:4px; margin-bottom:12px; }
.adopted-file-choice { margin:0 0 8px; }
.adopted-file-choice summary { margin-top:4px; font-size:13px; color: var(--muted); cursor:pointer; }
.file-history-item { display:flex; flex-shrink:0; align-items:center; justify-content:space-between; gap:12px; text-align:left; width:100%; min-height:32px; }
.file-history-item > span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.file-history-item[aria-selected="true"] { background: var(--soft); color: var(--text); font-weight:700; }
.file-history-time { font-weight:700; margin:0 0 6px; }
.file-history-detail pre { white-space:pre-wrap; max-height:220px; overflow:auto; font-size:12px; }
.file-history-diff { max-height:260px; overflow:auto; border:1px solid var(--border); border-radius:8px; padding:6px 0; margin-bottom:8px; font-family:"Cascadia Code", Consolas, monospace; font-size:12px; line-height:1.6; }
.file-history-line, .file-history-gap { white-space:pre-wrap; overflow-wrap:anywhere; padding:0 8px; }
.file-history-line.remove { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.file-history-line.add { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.file-history-gap { color: var(--muted); }
#free-prompt-panel > [hidden] { display:none!important; }

/* Multi-character replies: one message, visually separate narration and speech. */
.message-body.character-reply { display:flex; flex-direction:column; gap:18px; }
.character-reply-narration { color:var(--text); margin:0; }
.character-reply-speech { display:flex; align-items:flex-start; gap:10px; min-width:0; }
.character-reply-avatar { flex:0 0 32px; width:32px; height:32px; border-radius:50%; overflow:hidden; background:var(--soft); color:var(--text); display:grid; place-items:center; font-size:11px; line-height:1; }
.character-reply-avatar img { width:100%; height:100%; object-fit:cover; }
.character-reply-bubble { min-width:0; max-width:calc(100% - 42px); padding:11px 15px; border-radius:4px 17px 17px 17px; background:var(--soft); color:var(--text); overflow-wrap:anywhere; }
.character-reply-bubble > :first-child,.character-reply-narration > :first-child { margin-top:0; }
.character-reply-bubble > :last-child,.character-reply-narration > :last-child { margin-bottom:0; }
.character-model-recommendation { font-size:11px; color:var(--muted); margin-left:auto; }
@media(max-width:600px) { .character-reply-speech { gap:8px; } .character-reply-bubble { padding:10px 12px; max-width:calc(100% - 40px); } }

.material-browser-row { display:flex; align-items:center; gap:4px; min-width:0; }
.material-browser-row > .story-play-option { flex:1; min-width:0; }
.material-row-actions { flex:none; }
.material-row-actions .file-more { width:36px; height:36px; }
#material-action-form .dialog-field { display:flex; flex-direction:column; gap:8px; }
@media (max-width:640px), (pointer:coarse) {
  .material-row-actions .file-more { width:44px; height:44px; }
}

/* Public conversations are separate from the scenario galleries. */
.public-threads { padding: 32px; overflow-y: auto; min-height: 0; }
.public-threads-content { max-width: 960px; margin: 0 auto; }
.public-threads h1 { margin: 0; font-size: 24px; }
.public-threads .publication-card { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 6px 12px; align-content: start; }
.public-threads .publication-card-head { display: contents; }
.public-threads .publication-models { grid-column: 1; grid-row: 1 / span 2; align-self: start; justify-content: flex-start; }
.public-threads .publication-card strong { grid-column: 2; white-space: normal; overflow-wrap: anywhere; }
.public-threads .publication-card p { grid-column: 2; display: -webkit-box; -webkit-line-clamp: 2; }
.public-threads .publication-models .publication-card-artwork { width: 48px; height: 48px; flex-shrink: 0; }
.public-threads .home-empty:empty { display: none; }
.public-threads-content > button { min-height: 44px; }
.public-threads-sentinel { height: 1px; }
.public-threads-content:has(.public-thread-card) { max-width: 720px; }
.public-threads .publication-grid:has(.public-thread-card) { grid-template-columns: minmax(0, 1fr); }
.public-threads .public-thread-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.public-threads .public-thread-card .publication-card-head { display: flex; align-items: center; gap: 10px; }
.public-threads .public-thread-card .publication-models { align-self: center; }
.public-threads .public-thread-card .publication-models .publication-card-artwork { width: 40px; height: 40px; border-radius: 50%; }
.public-thread-talk { display: flex; flex-direction: column; gap: 6px; }
.public-thread-talk > span { max-width: 85%; padding: 8px 12px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.public-thread-talk > span > span { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.public-thread-user { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: var(--userBubble); }
.public-thread-user > span { -webkit-line-clamp: 2; }
.public-thread-reply { align-self: flex-start; border-radius: 14px 14px 14px 4px; background: var(--soft); }
.public-thread-reply > span { -webkit-line-clamp: 3; }
.public-thread-meta { font-size: 12px; color: var(--muted); }
.public-thread-main { min-height:0;min-width:0;height:100%;overflow:hidden; }
.public-thread-mark { width:16px;height:16px;flex:0 0 16px;fill:none;stroke:currentColor;stroke-width:1.5; }
.public-thread-main > .publication-reader { height:100%;width:100%;max-width:1100px;margin:auto; }
.public-thread-main > button, .public-thread-main > p { margin:16px; }
.public-thread-main .publication-reader-head { padding:16px 24px; }
.public-thread-main .publication-reader-body { padding:16px 24px; }
@media (max-width:760px) { .public-thread-main .publication-reader-head { padding-top:52px; } .public-thread-main > button:first-child { margin-top:52px; } }
.public-thread-undo { position:fixed;bottom:24px;left:50%;transform:translateX(-50%);z-index:90;display:flex;align-items:center;gap:12px;padding:8px 16px;border:1px solid var(--border);border-radius:8px;background:var(--surface);font-size:13px; }
@media (max-width: 640px) { .public-threads { padding: 24px 16px; } }
/* Cast media: person and speaker confirmation (shown only when people cannot be fixed automatically). */
.cast-media-dialog .cast-media-people { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.cast-media-dialog .cast-media-people label { display: flex; align-items: center; gap: 10px; min-height: 40px; overflow-wrap: anywhere; }
.cast-media-dialog .cast-media-person { display: flex; align-items: center; gap: 8px; }
.cast-media-dialog .cast-media-person label { flex: 1; min-width: 0; }
.cast-media-dialog .cast-media-person button { flex: none; font-size: 12px; min-height: 32px; white-space: nowrap; }
.cast-media-dialog .cast-speech-line { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px 10px; margin: 6px 0; }
.cast-media-dialog .cast-speech-line select { min-height: 36px; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: inherit; padding: 4px 8px; }
.cast-media-dialog .cast-speech-line textarea { grid-column: 1 / -1; width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: inherit; padding: 8px 10px; }
@media (max-width: 480px), (pointer: coarse) { .cast-media-dialog .cast-media-people label, .cast-media-dialog .cast-speech-line select, .cast-media-dialog .cast-media-person button { min-height: 44px; } }
/* The ambiguous-speech text label ("セリフを確認") uses the icon slot; size it to its text on one line. */
.message-footer .speech-generate.quiet { width: auto; padding: 0 10px; white-space: nowrap; font-size: 12px; }
.cast-media-dialog .cast-media-face { width: 32px; height: 32px; flex: none; border-radius: 50%; object-fit: cover; }

.story-entry .create-chevron { width: 14px; height: 14px; margin-left: auto; color: var(--muted); stroke-width: 2; }
.story-entry[aria-expanded="true"] .create-chevron { transform: rotate(90deg); }
#story-create .create-chevron { transform: none; }
#story-create[data-menu-placement="bottom"] .create-chevron { transform: rotate(90deg); }
.folder-screen { display: flex; flex: 1; min-height: 0; flex-direction: column; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px; overflow: hidden; }
.folder-screen.story-play-dialog { height: auto; }
.folder-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; margin-bottom: 16px; }
.folder-heading h1 { flex: 1; font-size: 18px; margin: 0; }
.folder-back { width: 36px; height: 36px; margin-left: -8px; padding: 8px; border: 0; background: transparent; }
.folder-back:hover { background: var(--soft); }
.folder-back svg { width: 18px; height: 18px; }
.folder-screen.folder-top .thread-file-dialog-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.folder-top-section { margin-bottom: 28px; }
.folder-kind-description { margin: 0 0 12px; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.6; overflow-wrap: anywhere; }
.folder-top-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin-bottom: 10px; }
.folder-top-head h2 { margin: 0; font-size: 15px; }
.folder-profile { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; }
.folder-profile-avatar { display: block; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--soft); }
.folder-profile-avatar .library-thumbnail { width: 100%; height: 100%; border-radius: inherit; }
.folder-profile-avatar .character-portrait img { object-position: center top; }
.folder-profile-open { position: relative; display: flex; width: 100%; padding: 0; border: 0; border-radius: 10px; background: transparent; }
.folder-profile-line { display: flex; align-items: flex-start; width: 100%; gap: 0; }
.folder-profile-name { flex: 1; min-width: 0; min-height: 44px; padding: 11px 2px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.folder-profile-open:hover, .folder-profile-name:hover { background: var(--soft); }
.folder-profile-open:focus-visible, .folder-profile-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.folder-profile-picture { position: relative; }
.file-card-grid .material-row-actions.person-card-menu { position: absolute; top: 0; right: 0; bottom: auto; width: 100%; aspect-ratio: 1; display: flex; justify-content: flex-end; align-items: flex-end; pointer-events: none; }
.person-card-menu .file-more { position: relative; display: grid; place-items: center; flex: none; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 10px; color: #303238; background: transparent; isolation: isolate; pointer-events: auto; }
.person-card-menu .file-more::before { content: ''; position: absolute; width: 28px; height: 28px; border-radius: 50%; background: #ffffffe0; z-index: -1; }
.person-card-menu .file-more svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.person-card-menu .file-more:hover::before { background: #fff; }
.person-card-menu .file-more:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.person-card-menu .file-manager-actions { pointer-events: auto; max-height: calc(100dvh - 16px); overflow-y: auto; }
.file-card-grid > .material-browser-row:has(> .person-card-menu) .file-title { padding-right: 2px; }
.file-manager-actions button.material-menu-group { margin-top: 10px; }
.folder-shelf-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.folder-shelf-pages { display: inline-flex; gap: 4px; }
.folder-top-head .folder-shelf-icon { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 50%; color: var(--text); }
.folder-top-head .folder-shelf-icon svg { width: 16px; height: 16px; }
.folder-top-head .folder-shelf-icon:disabled { opacity: .35; cursor: default; background: transparent; }
.folder-top-head .folder-shelf-controls > button:not(.folder-shelf-icon) { min-height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 16px; color: var(--text); font-size: 13px; }
/* A shelf: one horizontal row per kind, swiped or paged with ‹ ›. Card widths keep the scenario > people > parts order. */
.folder-screen .folder-top-section { --shelf-card: 144px; }
.folder-screen .folder-top-scenario { --shelf-card: 220px; }
.folder-screen .folder-top-setting, .folder-screen .folder-top-quest, .folder-screen .folder-top-generic { --shelf-card: 176px; }
.folder-screen .folder-top-section .story-play-options { display: grid; grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: var(--shelf-card); align-items: start; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: 3px; scrollbar-width: none; }
.folder-screen .folder-top-section .story-play-options::-webkit-scrollbar { display: none; }
.folder-screen .folder-top-section .story-play-options > * { scroll-snap-align: start; }
.folder-screen .folder-top-section .file-card-grid .story-play-option > .file-title { font-size: 14px; }
.folder-screen .folder-top-scenario .file-card-grid .story-play-option > .file-title { -webkit-line-clamp: 1; height: 1.5em; }
.folder-top-head > button { min-height: 32px; padding: 6px 10px; border: 0; border-radius: 8px; color: var(--muted); font-size: 13px; }
.folder-top-head > button:hover { background: var(--soft); color: var(--text); }
.folder-create-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; aspect-ratio: 1; padding: 12px; border: 1px dashed var(--border); border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; }
.folder-create-tile:hover, .folder-create-tile:focus-visible { background: var(--soft); color: var(--text); }
.folder-create-tile svg { width: 24px; height: 24px; }
.folder-create-scenario { aspect-ratio: 4 / 3; }
.folder-create-setting, .folder-create-quest { aspect-ratio: auto; min-height: 84px; }
/* Folder top hierarchy: the scenario large, people as now, settings and quests as small parts. */
.folder-top-scenario .library-thumbnail-scenario, .folder-top-scenario .folder-create-scenario { aspect-ratio: 16 / 9; }
.folder-screen .folder-top-setting .file-text-card, .folder-screen .folder-top-quest .file-text-card { padding: 10px; gap: 4px; }
.folder-screen .folder-top-setting .file-text-card > .document-thumbnail-excerpt, .folder-screen .folder-top-quest .file-text-card > .document-thumbnail-excerpt { -webkit-line-clamp: 2; font-size: 12px; }
.folder-screen .folder-top-setting .file-text-card > .file-title, .folder-screen .folder-top-quest .file-text-card > .file-title { height: auto; min-height: 0; -webkit-line-clamp: 1; }
.scenario-parts { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 0 40px 0 2px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.scenario-part { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.scenario-part > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-part svg { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.folder-search-toggle { width: 36px; height: 36px; padding: 8px; border: 0; background: transparent; }
.folder-search-toggle:hover, .folder-search-toggle[aria-expanded="true"] { background: var(--soft); }
.folder-screen .file-card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 20px 16px; margin-top: 0; padding: 3px; }
.file-card-grid > p { grid-column: 1 / -1; }
.file-card-grid > .material-browser-row { position: relative; display: block; align-self: start; }
.file-card-grid .story-play-option { position: relative; display: flex; flex-direction: column; gap: 0; width: 100%; padding: 0; }
.file-card-grid .story-play-option > .file-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; height: 3em; overflow: hidden; margin: 8px 0 5px; padding: 0 40px 0 2px; white-space: normal; overflow-wrap: anywhere; font-size: 13px; font-weight: 500; line-height: 1.5; }
.file-card-grid .material-row-actions { position: absolute; right: 0; bottom: 0; }
.library-thumbnail { display: grid; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--soft); }
.library-thumbnail-scenario { aspect-ratio: 4 / 3; }
.library-thumbnail-character { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.library-thumbnail > * { grid-area: 1 / 1; }
.library-thumbnail > .chat-start-placeholder { display: grid; place-items: center; color: var(--muted); }
.library-thumbnail > .chat-start-placeholder[hidden] { display: none; }
.library-thumbnail > .chat-start-placeholder svg { width: 38%; height: 38%; fill: none; stroke: currentColor; stroke-width: 1.4; }
.library-thumbnail .character-portrait, .library-thumbnail .character-portrait img { width: 100%; height: 100%; max-height: none; border-radius: 0; object-fit: cover; }
.folder-screen .file-text-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); scrollbar-gutter: stable; }
.file-card-grid .story-play-option.file-text-card { padding: 12px; gap: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.file-card-grid .file-text-card:hover { background: var(--soft); }
.file-card-grid .story-play-option.file-text-card > .file-title { width: 100%; height: auto; min-height: 0; margin: 0; padding: 0 58px 0 0; font-weight: 600; }
.file-card-grid .file-text-card > .document-thumbnail-excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; white-space: normal; overflow-wrap: anywhere; text-align: left; font-size: 12px; font-weight: 400; line-height: 1.6; color: var(--muted); }
.file-card-grid > .material-browser-row:has(.file-text-card) > .material-row-actions { top: 4px; right: 4px; bottom: auto; }
.file-card-grid .file-text-card > .file-pin { top: 10px; right: 42px; }
.file-pin { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--panel); color: var(--accent); }
.file-pin svg { width: 16px; height: 16px; }
@media (max-width: 760px), (pointer: coarse) { .folder-search-toggle { width: 44px; height: 44px; } .file-card-grid .story-play-option > .file-title { padding-right: 46px; } }
.folder-screen > .thread-file-dialog-body { flex: 1; min-height: 0; overflow: auto; }
.folder-screen .file-card-grid .story-play-option > .file-title,
.folder-screen .folder-top-section .file-card-grid .story-play-option > .file-title { display: block; height: auto; min-height: 1.5em; overflow: visible; -webkit-line-clamp: unset; }
.folder-screen .story-play-option { min-height: 44px; }
.folder-top-head .folder-shelf-controls button { min-height: 44px; }
@media (max-width: 760px) {
  .folder-top-head { flex-wrap: wrap; }
  .folder-shelf-controls { flex-wrap: wrap; justify-content: flex-end; }
}
.folder-screen .dialog-actions { flex-wrap: wrap; }
.chat-start-model-name { display: none; }
.prompt-lab-intro { max-width: 640px; margin: clamp(16px, 8dvh, 64px) auto 24px; text-align: center; }
.prompt-lab-intro h2 { margin: 0 0 12px; font-size: 20px; font-weight: 600; }
.prompt-lab-intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.chat-starting .composer-model { width: auto; max-width: min(320px, 65vw); padding-inline: 8px; gap: 6px; }
.chat-starting .chat-start-model-name { display: inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
@media (max-width: 760px) { .folder-screen { padding: 60px 16px 16px; } }

/* Character settings: one dialog, 設定／画像／声 (docs/afterlm-character-settings-unification.md). */
.thread-file-dialog.character-settings-dialog { width: min(880px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 32px)); max-height: none; }
.character-settings-dialog .character-settings-scope { flex: none; margin: -6px 0 0; }
.character-settings-dialog .character-detail-tabs { margin-top: -4px; }
.character-settings-dialog .thread-file-dialog-body { flex: 1; }
.character-settings-panel[hidden] { display: none; }
.character-settings-panel { min-width: 0; padding: 4px 2px 2px; }
.character-settings-dialog .raw-editor { min-height: 240px; max-height: none; }
.character-settings-dialog .dialog-actions[hidden] { display: none; }
.character-appearance-dialog.character-settings-image { width: auto; max-height: none; padding: 0; overflow: visible; }
.character-appearance-dialog.character-settings-image:not([open]) { display: flex; }
.character-settings-image > p { margin: 0; font-size: 12px; color: var(--muted); }
.thread-file-dialog.character-settings-dialog.character-image-tab-active:not(.person-original-dialog) { height: auto; max-height: calc(100dvh - 32px); }
.person-original-dialog > .character-detail-tabs { flex: none; }
.person-original-dialog > .thread-file-dialog-body { scrollbar-gutter: stable; }
.person-original-dialog > .dialog-actions { flex-wrap: wrap; }
.character-image-preview.is-empty { display: grid; place-items: center; min-height: 150px; padding: 16px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 13px; }
.character-image-preview.is-empty p { margin: 0; }
.character-image-model-picker { min-width: 0; margin-top: 6px; }
.character-image-model-picker > summary { box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; overflow-wrap: anywhere; }
.character-image-model-picker > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.character-image-model-picker .model-examples-button { margin-top: 8px; }
.character-image-generation > .character-image-upload { align-self: flex-start; margin: 0; }
.character-appearance-dialog .character-image-generation textarea:not([readonly]) { height: 104px; }
.character-image-instruction-heading { display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px; }
.character-image-dialog .character-image-instruction-heading .character-image-tag-add { margin-top:0; }
.character-image-generation > .character-image-quality { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; font-size: 13px; }
.character-image-quality > .character-image-enhancement,.character-image-quality > .character-image-mode { grid-column: 1/-1; min-width: 0; }
.character-image-quality > .character-image-enhancement { order: 0; }
.character-image-quality > .character-image-mode { order: 1; }
.character-image-generation > .character-image-quality > .character-image-ratio,.character-image-generation > .character-image-quality > .character-image-resolution { display: flex; flex-direction: column; align-items: stretch; gap: 4px; order: 2; }
.image-option-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.image-option-buttons label { position: relative; display: flex; cursor: pointer; }
.image-option-buttons input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.image-option-buttons span { display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; }
.image-option-buttons input:checked + span { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.image-option-buttons input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.image-option-buttons input:disabled + span { opacity: .5; cursor: default; }
@media(pointer:coarse),(max-width:640px) { .image-option-buttons span,.character-image-model-picker > summary { min-height: 44px; } .character-image-preview.is-empty { min-height: 80px; } }
@media(max-width:360px) { .character-image-generation > .character-image-quality { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 640px) { .thread-file-dialog.character-settings-dialog { width: calc(100vw - 24px); height: calc(100dvh - 24px); } }
.character-settings-inline > .character-settings-scope { margin: 0 0 6px; }
.character-settings-inline > .character-detail-tabs { margin: 0 0 12px; }
.character-settings-panel > .scenario-image-field { margin-bottom: 16px; }
.character-settings-inline > .character-detail-tabs { position: sticky; top: 0; z-index: 2; background: var(--panel); }
.character-settings-panel [hidden] { display: none !important; }
/* A scenario without a saved file: the picture this conversation holds, read-only (docs/afterlm-material-settings-unification.md §6). */
.scenario-held-image { display: block; max-width: min(320px, 100%); margin: 0 0 10px; border-radius: 8px; }

/* Completion actions stay before expandable content; only starting is primary. */
.creation-fields { margin: 12px 0; }
.creation-fields dt { margin-top: 16px; font-weight: 600; }
.creation-fields dd { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.creation-original { margin-top: 20px; }
.creation-original > summary { cursor: pointer; padding: 10px 0; }
.character-draft-result > .thread-file-action-block { margin: 12px 0 20px; }
.character-draft-result .character-image-step { margin: 0; }
.character-draft-result .character-builder-actions { gap: 16px; }
.character-draft-result .character-builder-image-action { margin: 0; }
.creation-file-action { margin-top: 16px; }
.creation-save-notice, .creation-voice-notice { overflow-wrap: anywhere; }
[data-creation-save="failed"] > .creation-save-notice, .creation-voice-notice { color: var(--danger); }
.central-error-log #workspace .thread-file-action-block .inline-operation-error:not(#dialogue-error) { display: block !important; }
.central-error-log #workspace .thread-file-action-block .inline-operation-error:not(#dialogue-error):empty { display: none !important; }
@media (max-width:760px), (pointer:coarse) { .creation-original > summary { min-height:44px; } }

.character-draft-result .code-block-toolbar [data-voice-missing] { display: none; }
[data-creation-start="failed"]:has(.inline-operation-error:not(:empty)) > .creation-save-notice { display: none; }
/* Character item fields (docs/afterlm-character-item-structure-design.md §1.5): the text below stays the record. */
.character-body-fields { margin: 4px 0 14px; }
.character-body-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.character-body-set { display: flex; flex-wrap: wrap; gap: 6px 14px; font-weight: 400; }
.character-body-set label { display: inline-flex; align-items: center; gap: 5px; }
.character-body-head .character-body-analyze { margin-left: auto; font-weight: 400; }
.character-body-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
.character-body-grid .dialog-field, .character-body-fields > .dialog-field { margin: 0 0 10px; font-weight: 400; }
.character-body-fields > .dialog-field textarea { min-height: 0; }
.character-body-fields details { margin-top: 2px; }
.character-body-fields summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.character-body-fields > p { margin: 0 0 8px; font-size: 12px; }

/* Image model examples (docs/afterlm-model-examples-plan.md) */
.model-examples-button { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.image-model-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.illustration-settings-group > .model-examples-button { display: block; margin: -4px 0 8px auto; }
.model-examples-dialog { width: min(1180px, calc(100vw - 24px)); max-width: none; }
.model-examples-dialog .thread-file-dialog-body > p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
/* One scroll area for both directions, so the model names stay above the pictures. */
.model-examples-dialog .thread-file-dialog-body { display: flex; flex-direction: column; overflow: hidden; }
.model-examples-scroll { flex: 1; min-height: 0; overflow: auto; container-type: inline-size; }
/* The message stays readable in full while the pictures scroll sideways. */
.model-examples-message span { position: sticky; left: 0; display: inline-block; max-width: calc(100cqw - 12px); }
.model-examples-dialog table { border-collapse: separate; border-spacing: 6px 4px; width: 100%; min-width: 760px; table-layout: fixed; }
.model-examples-dialog thead th { position: sticky; top: 0; z-index: 1; padding: 6px 2px; background: var(--panel); font-size: 13px; font-weight: 600; text-align: center; }
.model-examples-message { padding: 10px 2px 2px; font-size: 14px; font-weight: 400; text-align: left; overflow-wrap: anywhere; }
.model-examples-dialog td { padding: 0; vertical-align: top; font-size: 12px; color: var(--muted); }
.model-examples-dialog td button { display: block; width: 100%; min-height: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: zoom-in; overflow: hidden; }
.model-examples-dialog td img { display: block; width: 100%; height: auto; }
@media (pointer: coarse), (max-width: 640px) { .model-examples-button { min-height: 44px; } }

/* Image selection, adoption and generation each stay beside their content. */
.character-appearance-dialog .character-image-preview { position:relative; }
.character-image-preview .character-image-info-button { position:absolute;top:4px;right:4px;min-width:36px;padding:4px;font-size:19px;background:var(--panel); }
.character-image-adopted-badge { position:absolute;left:8px;bottom:8px;padding:3px 7px;border-radius:5px;background:var(--panel);font-size:12px;pointer-events:none; }
.character-image-actions .character-image-confirm { min-width:0;padding:6px 12px;font-size:13px;font-weight:400; }
.character-appearance-dialog .character-image-grid { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));overflow-x:hidden;overflow-y:auto;box-sizing:border-box;grid-auto-rows:110px;max-height:234px;align-content:start;padding:3px; }
.character-appearance-dialog .character-image-grid [data-candidate-index] { position:relative;min-height:68px; }
.character-appearance-dialog .character-image-grid img { width:100%;height:60px;object-fit:contain; }
.character-image-history-adopted { position:absolute;right:3px;bottom:3px;background:var(--panel);border-radius:50%;padding:1px 4px; }
.character-image-info-dialog { box-sizing:border-box;width:min(640px,calc(100vw - 32px));max-height:85dvh;overflow:auto; }
.character-image-info-dialog .character-image-generation-info textarea { box-sizing:border-box;width:100%;height:220px;resize:vertical; }
.character-image-info-dialog .character-image-generation-info small { display:block;margin-top:12px; }
@media(pointer:coarse),(max-width:640px){.character-image-preview .character-image-info-button { min-width:44px;min-height:44px; }.character-appearance-dialog .character-image-grid { grid-auto-rows:122px;max-height:258px; }}

/* Character creation has one next step: image, then chat. */
.character-builder-step .character-image-step-linear { display:flex;flex-direction:column;align-items:flex-start;gap:12px;margin-top:16px; }
.character-builder-step .character-image-step-linear > [hidden] { display:none; }
.character-builder-step .character-image-step-linear .character-builder-image-action { margin:0;max-width:100%;min-width:0; }
.character-builder-step .character-image-step-linear .character-builder-actions { gap:8px;margin:0;max-width:100%; }
.character-builder-step .character-completion-secondary button { background:transparent;border-color:transparent;color:var(--muted);font-size:13px;font-weight:400;padding-left:0; }
.character-builder-step .character-completion-secondary button:hover:not(:disabled) { color:var(--text);text-decoration:underline; }
/* A saved character is one result. Its full answer remains available inside キャラ設定.
   Unsaved, failed and older drafts keep their original content and recovery controls. */
.message-body:has(> .character-completion-card > .character-builder-step[data-creation-save="saved"]) > .character-completion-context,
.character-completion-card:has(> .character-builder-step[data-creation-save="saved"]) > .character-draft-details,
.character-completion-card:has(> .character-builder-step[data-creation-save="saved"]) > .character-draft-overview > .character-draft-status { display:none; }
.message-content:has(> .message-body > .character-completion-card > .character-builder-step[data-creation-save="saved"]) > .message-footer .message-actions:not(:has(.thread-file-answer-menu)),
.message-content:has(> .message-body > .character-completion-card > .character-builder-step[data-creation-save="saved"]) > .message-footer .illustration-camera[aria-label="挿絵を生成"] { display:none; }
.message-content:has(> .message-body > .character-completion-card > .character-builder-step[data-creation-save="saved"]) > .message-footer { min-height:0;padding-top:0; }
.character-builder-step .character-completion-secondary { display:flex;flex-wrap:wrap;align-items:center;gap:4px 16px; }
.character-builder-step .character-completion-tools { display:flex;flex-wrap:wrap;align-items:center;gap:4px 20px;max-width:100%; }
.character-builder-step .character-completion-tools .creation-file-action { margin:0; }
.character-builder-step .character-completion-tools .creation-file-action button { background:transparent;border-color:transparent;color:var(--muted);font-size:13px; }
.character-builder-step .character-completion-tools .creation-file-action button:hover:not(:disabled) { color:var(--text);text-decoration:underline; }
.character-builder-step .character-completion-secondary button,
.character-builder-step .character-completion-tools .creation-file-action button { min-height:34px;padding:7px 0; }
.character-builder-step .character-completion-secondary { margin-top:8px; }
.character-builder-step .character-setting-description,
.character-builder-step .character-image-description { margin:0;font-size:13px;color:var(--muted);line-height:1.7; }
.character-builder-step .character-setting-description { margin-bottom:4px; }
.character-builder-step:not([data-creation-save="saved"]) .character-image-description { display:none; }
.character-appearance-edit-hint { display:block; }
.character-completion-card:has([data-voice-missing]) .character-appearance-edit-hint { display:none; }
.character-builder-step .character-portrait-result { width:min(320px,100%);margin-bottom:0; }
.character-builder-step .character-portrait-result img { width:100%;max-height:420px;object-position:left center; }
.character-builder-step button.character-portrait-enlarge { padding:0;border:0;background:transparent;height:auto; }
.character-builder-step .character-image-change button { background:transparent;border-color:transparent;color:var(--muted);font-size:13px;padding:0; }
.character-builder-step .character-image-change button:hover:not(:disabled) { color:var(--text);text-decoration:underline; }
.character-builder-step button.character-completion-primary { width:320px;max-width:100%;justify-content:center; }
@media (pointer:coarse),(max-width:760px) { .character-builder-step .character-completion-secondary button,.character-builder-step .character-completion-tools .creation-file-action button { min-height:44px; } }

.character-appearance-dialog textarea.character-image-style-text{height:auto;min-height:52px;margin:6px 0 0}

/* One current-tab action row; short viewports scroll the heading with the editor. */
.character-settings-scroll { display: contents; }
.character-settings-dialog .dialog-head h2 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.character-settings-dialog .dialog-head button { flex: none; min-width: 44px; min-height: 44px; }
.character-settings-dialog .thread-file-dialog-body { scrollbar-gutter: stable; }
.character-settings-dialog .character-settings-panel { overflow: visible; }
.character-settings-dialog .character-tab-actions { flex: none; display: flex; justify-content: flex-end; gap: 8px; }
.character-settings-dialog .character-tab-actions[hidden],.character-settings-dialog .character-tab-actions:empty { display: none; }
.character-tab-actions .character-image-controls { margin: 0; padding: 0; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.character-settings-dialog > .dialog-actions button,.character-tab-actions button { min-height: 44px; }
.character-settings-menu { margin: 0; width: 240px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; }
.character-settings-menu button { min-height: 44px; }
.character-settings-menu .file-history-open { margin-top: 4px; }
.character-settings-image .character-image-workspace { display: grid; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); grid-template-areas: 'preview settings' 'history settings'; align-items: start; gap: 16px 24px; }
.character-settings-image .character-image-result { grid-area: preview; }
.character-settings-image .character-image-generation { grid-area: settings; }
.character-settings-image .character-image-history { grid-area: history; }
@media (max-width: 640px) {
  .thread-file-dialog.character-settings-dialog,.thread-file-dialog.character-settings-dialog.character-image-tab-active { box-sizing: border-box; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 10px 12px; border: 0; border-radius: 0; gap: 8px; }
  .character-settings-dialog .dialog-head h2 { font-size: 16px; }
  .character-settings-dialog .raw-editor { min-height: 160px; }
  .character-settings-dialog input,.character-settings-dialog textarea { font-size: 16px; }
  .character-settings-image .character-image-workspace { grid-template-columns: minmax(0,1fr); grid-template-areas: 'preview' 'settings' 'history'; gap: 16px; }
  .character-settings-image .character-image-preview img { max-height: 140px; width: auto; max-width: 100%; margin: auto; }
  .character-settings-image .character-image-preview.is-empty { min-height: 64px; }
  .character-settings-image .character-image-result { align-items: center; }
  .character-settings-image .character-image-preview { width: 100%; }
}
@media (max-height: 500px) {
  .thread-file-dialog.character-settings-dialog,.thread-file-dialog.character-settings-dialog.character-image-tab-active { height: 100dvh; max-height: 100dvh; margin-block: 0; padding-block: 8px; gap: 8px; }
  .character-settings-scroll { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: auto; gap: 8px; }
  .character-settings-scroll > .thread-file-dialog-body { flex: none; overflow: visible; min-height: 120px; }
  .character-settings-scroll .character-detail-tabs { position: static; }
  .character-settings-dialog .raw-editor { min-height: 160px; }
}
.debug-membership:popover-open {
  position: fixed; inset: auto; margin: 0; padding: 0; width: 60px; height: 60px;
  overflow: visible; border: 0; background: transparent; color: inherit;
}
.debug-membership .debug-membership-fab,
.debug-membership .debug-membership-fab:is(:hover,:active,:focus) {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px;
  box-sizing: border-box; width: 60px; height: 60px; padding: 0; margin: 0;
  background: transparent; color: #4ade80; opacity: .55; border: 0; box-shadow: none;
  font-size: 12px; line-height: 1.25; touch-action: none; user-select: none; cursor: grab;
}
.debug-membership-fab svg { width: 23px; height: 23px; pointer-events: none; }
.debug-membership-fab:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
#debug-membership-panel {
  position: fixed; width: min(180px,100vw); max-height: 100dvh; overflow: auto; box-sizing: border-box;
  padding: 6px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--panel);
}
#debug-membership-panel button {
  display: block; width: 100%; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 4px;
  text-align: left; font: inherit; color: inherit; background: transparent;
}
#debug-membership-panel button:hover { background: var(--soft); }
#debug-membership-panel button[aria-pressed="true"] { font-weight: bold; background: var(--soft); }
#debug-membership-panel [role="status"]:not(:empty) { padding: 6px; font-size: 13px; }

#membership-dialog { width: min(420px, calc(100vw - 24px)); padding: 20px; }
#membership-dialog .dialog-actions, #preview-id-list { display: flex; flex-wrap: wrap; gap: 8px; }
#membership-detail { margin: 16px 0; line-height: 1.6; }
#preview-id-list { margin-top: 6px; }

#settings-controls.preview-settings #settings-usage { padding: 0; }
#settings-controls.preview-settings #total-cost { flex: 1; text-align: left; font-size: 13px; padding: 6px; }
.preview-settings #error-log-open { display:none; }
#account-dialog .settings-row { display: block; margin-top: 8px; }

#usage-dialog.preview-allowance, .account-subdialog { width:min(440px, calc(100vw - 28px)); padding:20px; font-variant-numeric:tabular-nums; }
#allowance-panel { margin-block:16px; }
.allowance-line { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
#allowance-panel h3, .allowance-line strong { margin:0; font-size:1rem; }
.allowance-meter { appearance:none; display:block; width:100%; height:12px; overflow:hidden; border:0; border-radius:8px; background:var(--border); color:var(--fill); }
.allowance-meter[data-level=green] { --fill:#379467; }
.allowance-meter[data-level=orange] { --fill:#c46f19; }
.allowance-meter[data-level=red] { --fill:#c44b50; }
.allowance-meter::-webkit-progress-bar { background:var(--border); border-radius:8px; }
.allowance-meter::-webkit-progress-value { background:var(--fill); border-radius:8px; }
.allowance-meter::-moz-progress-bar { background:var(--fill); border-radius:8px; }
#allowance-monthly-meter { margin-top:10px; }
#allowance-renewal { margin:6px 0 20px; }
#allowance-units > div { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:10px; margin-top:8px; }
#allowance-units span { font-size:.875rem; }
.allowance-action:not([hidden]) { display:block; margin:18px auto 0; }
#usage-records summary { cursor:pointer; padding-block:8px; }
#usage-records:not([open]) { margin-bottom:12px; }
#allowance-items { padding:0; margin:0; list-style:none; }
#allowance-items li { display:grid; gap:4px; padding:12px 0; border-bottom:1px solid var(--border); }
#allowance-items time { color:var(--muted); font-size:.85rem; }
#allowance-status:empty, #allowance-shop-status:empty, #purchase-history-status:empty { display:none; }
body:has(#usage-dialog.preview-allowance[open], .account-subdialog[open], #account-dialog[open]) #settings-dialog[open],
body:has(#allowance-shop[open]) #usage-dialog[open] { visibility:hidden; }
body:has(#usage-dialog.preview-allowance[open], .account-subdialog[open], #account-dialog[open]) #settings-dialog::backdrop,
body:has(#allowance-shop[open]) #usage-dialog::backdrop { background:transparent; backdrop-filter:none; }
#allowance-offers:not([hidden]) { display:grid; margin-top:12px; }
#allowance-offers button { display:grid; grid-template-columns:1fr auto; gap:3px 12px; align-items:center; padding:12px 10px; text-align:left; background:transparent; color:var(--text); border:0; border-bottom:1px solid var(--border); }
#allowance-offers button:hover, #allowance-offers button:focus-visible { background:var(--soft); }
#allowance-offers button span { grid-column:1; font-size:.875rem; color:var(--muted); }
#allowance-offers button::after { content:'›'; grid-column:2; grid-row:1 / 3; font-size:1.25rem; color:var(--muted); }
#allowance-selection { font-weight:600; }
#allowance-terms, #cancel-plan-detail { line-height:1.6; }
#allowance-back { margin-top:8px; border:0; }
.preview-allowance #usage-summary,.preview-allowance .usage-note,.preview-allowance .usage-table :is(td,th):last-child,.preview-allowance #usage-video-budget { display:none; }

#free-limit { width:min(27rem,calc(100% - 2rem)); }
#free-limit .dialog-head {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:start;
  gap:.75rem;
  font-size:1.1875rem;
  line-height:1.45;
}
#free-limit-title {
  font-size:inherit;
  line-height:inherit;
  text-wrap:balance;
  word-break:auto-phrase;
}
#free-limit-close {
  width:40px;
  height:40px;
  margin-block-start:calc((1.45em - 40px) / 2);
  font-size:inherit;
  line-height:1;
}
#free-limit-recovery { font-size:14px; color:var(--muted,#666); }
#free-limit .free-limit-action { text-align:center; margin-top:1.25rem; }
#free-limit-price { margin:.4rem 0 0; font-size:14px; }
#free-quota-meters { padding-bottom:1rem; }
