* { box-sizing: border-box; }
html { background: var(--bg); scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
body { margin: 0; min-width: 360px; color: var(--text); font: 14px/1.6 var(--sans); background: var(--bg); }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button, a { touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: var(--surface-soft); color: var(--text); border-radius: 8px; padding: 11px 13px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }
input:disabled, select:disabled { cursor: not-allowed; color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
button { color: inherit; }
button, .book-cover { transition: background-color .18s, border-color .18s, box-shadow .18s, transform .22s; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 500; }
[hidden] { display: none !important; }
.icon { flex: 0 0 auto; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 95px; z-index: 200; padding: 8px 14px; background: var(--surface); }
.skip-link:focus { top: 8px; }
.preview-shell { min-height: 100dvh; padding-left: var(--rail-width); }
.global-rail { position: fixed; inset: 0 auto 0 0; width: var(--rail-width); z-index: 30; display: flex; flex-direction: column; align-items: center; padding: 24px 10px 12px; border-right: 1px solid var(--line); background: var(--surface-soft); overflow-y: auto; }
.brand-mark { position: relative; display: grid; place-items: center; width: 43px; height: 43px; margin: 0 0 30px; font: 28px var(--serif); border: 1px solid var(--accent); border-radius: 10px 2px 10px 2px; }
.brand-mark span { position: absolute; width: 4px; height: 4px; background: var(--accent); right: 4px; bottom: 4px; }
.global-rail nav, .rail-bottom { display: flex; flex-direction: column; flex-shrink: 0; gap: 10px; width: 100%; align-items: center; }
.global-rail .brand-mark { flex-shrink: 0; }
.rail-bottom { margin-top: auto; padding-top: 28px; gap: 4px; }
.rail-button { border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); width: 60px; min-height: 65px; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; font-size: 11px; letter-spacing: .08em; }
.rail-button .icon { width: 21px; height: 21px; }
.rail-button:hover, .rail-button.active { color: var(--accent-strong); background: var(--accent-wash); }
.rail-button.active { border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.rail-bottom .rail-button { min-height: 54px; }
.version-mark { color: var(--faint); font-size: 9px; letter-spacing: .1em; margin-top: 18px; }
.app-frame { display: flex; min-height: 100dvh; flex-direction: column; }
.topbar { height: 74px; flex-shrink: 0; display: flex; align-items: center; gap: 32px; padding: 0 32px; border-bottom: 1px solid var(--line); background: var(--bg); }
.library-search { display: flex; flex: 1 1 420px; align-items: center; gap: 10px; min-width: 180px; max-width: 460px; height: 48px; padding: 0 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.library-search .icon { color: var(--faint); width: 20px; height: 20px; }
.library-search input { padding: 0; min-width: 0; height: 44px; border: 0; background: transparent; font-size: 15px; }
.library-search input:focus { box-shadow: none; }.library-search:focus-within { border-color: var(--accent); }
.library-topbar .breadcrumb { flex-shrink: 0; }
.brand-word { font: 21px var(--serif); letter-spacing: .12em; white-space: nowrap; }
.brand-word > span { display: block; font: 8px/1.7 var(--sans); letter-spacing: .24em; color: var(--faint); margin-top: 3px; }
.breadcrumb { display: flex; gap: 11px; align-items: center; min-width: 0; color: var(--muted); font-size: 12px; }
.breadcrumb > span { max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.breadcrumb .icon { width: 12px; height: 12px; color: var(--faint); }
.breadcrumb strong { color: var(--text); font-weight: 400; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.preview-badge { font-size: 11px; color: var(--accent); display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; margin-right: 8px; }
.preview-badge > span { width: 5px; height: 5px; border: 1px solid var(--accent); transform: rotate(45deg); }
.button { display: inline-flex; justify-content: center; gap: 8px; align-items: center; min-height: 38px; padding: 8px 15px; border-radius: 7px; font-size: 12px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.button .icon { width: 16px; height: 16px; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-wash); }
.button.primary { background: var(--accent); color: var(--on-accent, #121c24); border-color: var(--accent); font-weight: 600; }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); }
:root[data-theme="paper"] .button.primary { color: var(--on-accent, #fffaf0); }
.button.subtle { background: transparent; }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button.quiet.active, .button.subtle.active { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.button.large { min-height: 43px; padding: 10px 20px; }
.full-width { width: 100%; }
.icon-button { display: inline-flex; width: 34px; height: 34px; flex-shrink: 0; align-items: center; justify-content: center; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--muted); }
.icon-button .icon { width: 17px; height: 17px; }
.page-content { flex: 1; min-width: 0; outline: none; }
.preview-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 34px; border-top: 1px solid var(--line); padding: 8px 24px; font-size: 10px; color: var(--muted); }
.preview-footer > span:first-child { display: flex; align-items: center; gap: 7px; }
.preview-footer .icon { width: 12px; height: 12px; }
.footer-note { color: var(--faint); white-space: nowrap; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .15em; margin-bottom: 8px; font-weight: 500; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.section-heading h1 { font: 32px/1.35 var(--serif); letter-spacing: .05em; margin: 0 0 10px; }
.section-description { font-size: 13px; color: var(--muted); margin: 0; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.muted { color: var(--muted); font-size: 12px; }
.muted-tag { display: inline-flex; font-size: 10px; font-weight: 400; line-height: 1.5; padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.panel-header { display: flex; align-items: center; justify-content: space-between; min-height: 57px; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.panel-header > strong { font-size: 12px; font-weight: 500; }
.text-tab { display: inline-flex; align-items: center; gap: 6px; padding: 15px 6px; border: 0; border-bottom: 2px solid transparent; background: transparent; font-size: 12px; color: var(--muted); white-space: nowrap; }
.text-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.text-tab > span { font-size: 10px; color: var(--faint); margin-left: 8px; }
.text-tab:hover { color: var(--text); }
.text-tab .icon { height: 15px; width: 15px; }
.advanced-menu { position: absolute; z-index: 45; top: 64px; right: 24px; width: 235px; padding: 18px 10px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.advanced-menu .eyebrow { padding: 0 12px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; padding: 11px 12px; background: transparent; border-radius: 6px; text-align: left; font-size: 12px; }
.menu-item:hover { background: var(--surface-raised); color: var(--accent); }
.menu-item .icon { width: 17px; height: 17px; }
.menu-note { color: var(--faint); font-size: 10px; margin: 12px 12px 6px; }
.manager-orb { position: fixed; right: 24px; bottom: 53px; z-index: 42; width: 49px; height: 49px; border: 1px solid var(--accent); border-radius: 50%; background: var(--surface); color: var(--accent); box-shadow: 0 4px 22px #0004; font: 23px var(--serif); touch-action: none; user-select: none; cursor: grab; }
.manager-orb:hover { box-shadow: 0 6px 26px #0006; }
.manager-orb.is-dragging, .floating-manager.is-dragging .manager-drag-bar { cursor: grabbing; }
.manager-drag-bar { touch-action: none; user-select: none; cursor: grab; }
.manager-drag-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.manager-window-controls { display: flex; flex-shrink: 0; gap: 2px; align-items: center; }
.manager-window-controls .button { min-height: 28px; padding: 4px 6px; font-size: 12px; }
.manager-panel .panel-header { gap: 6px; }
.manager-panel .panel-header > strong { min-width: 0; }
.manager-orb i { position: absolute; right: 2px; top: 2px; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; border: 2px solid var(--surface); }
.floating-manager { position: fixed; z-index: 44; right: 22px; bottom: 52px; width: min(365px, calc(100vw - 96px)); height: min(660px, calc(100dvh - 130px)); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.manager-size-handle { position: absolute; width: 18px; height: 18px; padding: 0; border: 0; background: transparent; z-index: 5; touch-action: none; }
.manager-size-handle::after { content: ''; position: absolute; inset: 5px; border: 2px solid var(--accent); opacity: .7; }
.manager-size-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.size-nw { left: 0; top: 0; cursor: nwse-resize; }.size-ne { right: 0; top: 0; cursor: nesw-resize; }
.size-sw { left: 0; bottom: 0; cursor: nesw-resize; }.size-se { right: 0; bottom: 0; cursor: nwse-resize; }
.size-nw::after { border-right: 0; border-bottom: 0; }.size-ne::after { border-left: 0; border-bottom: 0; }
.size-sw::after { border-right: 0; border-top: 0; }.size-se::after { border-left: 0; border-top: 0; }
.preview-dialog { width: min(610px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 15px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); overflow: auto; }
.preview-dialog::backdrop { background: #01070dc2; backdrop-filter: blur(5px); }
.settings-dialog { width: min(790px, calc(100vw - 32px)); }
.dialog-header { display: flex; gap: 20px; justify-content: space-between; padding: 24px 28px 20px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font: 25px var(--serif); }
.dialog-body { padding: 24px 28px; }
.preview-form { display: flex; flex-direction: column; gap: 18px; }
.preview-form label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dialog-actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.dialog-tip { display: flex; align-items: center; gap: 9px; padding: 12px 14px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 7px; font-size: 11px; line-height: 1.7; }
.dialog-tip .icon { width: 15px; height: 15px; }
.creation-steps { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 23px; font-size: 11px; color: var(--faint); }
.creation-steps span { white-space: nowrap; }
.creation-steps span.active { color: var(--accent); }
.creation-steps b { display: inline-grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; border: 1px solid var(--line); margin-right: 7px; }
.creation-steps .active b { border-color: var(--accent); }
.creation-steps i { height: 1px; background: var(--line); flex: 1; }
.settings-layout { display: grid; grid-template-columns: 155px 1fr; min-height: 330px; gap: 26px; }
.settings-nav { display: flex; flex-direction: column; gap: 7px; border-right: 1px solid var(--line); padding-right: 16px; }
.settings-tab { display: flex; gap: 9px; align-items: center; border: 0; background: transparent; color: var(--muted); padding: 11px 10px; text-align: left; border-radius: 6px; font-size: 12px; }
.settings-tab .icon { width: 16px; height: 16px; }
.settings-tab.active { color: var(--accent); background: var(--accent-wash); }
.settings-content { min-width: 0; }
.settings-content h3 { font-size: 16px; margin: 0 0 11px; }
.theme-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 25px 0; }
.theme-choice { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 14px; text-align: left; }
.theme-choice.selected { border-color: var(--accent); }
.theme-choice strong, .theme-choice small { display: block; font-size: 12px; margin-top: 7px; font-weight: 400; }
.theme-choice small { font-size: 10px; color: var(--muted); }
.theme-swatch { height: 65px; display: flex; border-radius: 5px; overflow: hidden; border: 1px solid #8a91882b; }
.theme-swatch i:nth-child(1) { flex: 1; background: #08131e; }.theme-swatch i:nth-child(2) { flex: 2; background: #122333; }.theme-swatch i:nth-child(3) { flex: .6; background: #cba76b; }
.paper-choice .theme-swatch i:nth-child(1) { background: #f2f0ea; }.paper-choice .theme-swatch i:nth-child(2) { background: #fdfbf6; }.paper-choice .theme-swatch i:nth-child(3) { background: #89642c; }
.model-slots { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.model-slot { display: flex; align-items: center; gap: 12px; padding: 15px 12px; border: 1px solid var(--line); border-radius: 7px; }
.model-slot > .icon { color: var(--accent); }
.model-slot strong { font-size: 12px; font-weight: 400; }.model-slot small { display: block; color: var(--faint); font-size: 10px; margin-top: 3px; }.model-slot .muted-tag { margin-left: auto; }
.empty-panel, .drop-preview { text-align: center; padding: 36px 20px; }.empty-panel > .icon, .drop-preview > .icon { width: 34px; height: 34px; color: var(--accent); margin-bottom: 18px; }.empty-panel h3, .drop-preview h3 { font: 22px var(--serif); }.empty-panel p, .drop-preview p { color: var(--muted); font-size: 12px; }
.drop-preview { border: 1px dashed var(--line); border-radius: 9px; margin-bottom: 18px; }
.help-content { font-size: 13px; color: var(--muted); line-height: 1.9; }.help-content h3 { color: var(--text); font-size: 14px; margin-top: 22px; }
@media (min-width: 1700px) { .topbar { padding-inline: 44px; } }
@media (max-width: 1100px) { .breadcrumb { display: none; }.topbar { gap: 20px; }.language-button { display: none; } }
@media (max-width: 700px) {
  :root { --rail-width: 64px; }.global-rail { padding: 17px 5px 10px; }.brand-mark { width: 37px; height: 37px; margin-bottom: 18px; }.rail-button { width: 49px; min-height: 58px; }.rail-bottom { padding-top: 10px; }.version-mark { display: none; }
  .topbar { height: 64px; padding: 0 14px; gap: 12px; }.brand-word { font-size: 18px; }.brand-word > span { display: none; }.top-actions { gap: 4px; }.preview-badge { font-size: 10px; margin-right: 2px; }.top-actions .button { padding-inline: 8px; }.top-actions .button .icon { display: none; }
  .preview-footer { padding: 9px 14px; font-size: 9px; }.footer-note { display: none; }.section-heading { align-items: flex-start; flex-wrap: wrap; gap: 18px; }.section-heading h1 { font-size: 27px; }.section-description { font-size: 12px; }.heading-actions { gap: 8px; }
  .dialog-header, .dialog-body { padding: 20px; }.settings-layout { grid-template-columns: 1fr; gap: 18px; }.settings-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }.settings-tab { font-size: 11px; padding: 7px; }.settings-tab .icon { display: none; }.creation-steps { gap: 5px; font-size: 10px; }.creation-steps b { margin-right: 3px; }.manager-orb { right: 16px; }
}
@media (max-height: 820px) {
  .global-rail { padding-top: 16px; padding-bottom: 10px; }
  .global-rail .brand-mark { width: 37px; height: 37px; margin-bottom: 18px; }
  .global-rail nav { gap: 6px; }.global-rail .rail-button { min-height: 52px; }
  .rail-bottom { padding-top: 12px; gap: 2px; }.rail-bottom .rail-button { min-height: 43px; }.version-mark { display: none; }
}
@media (min-width: 901px) { .library-topbar .breadcrumb { display: flex; } }
@media (max-width: 900px) {
  .library-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: auto; min-height: 74px; gap: 12px; padding-block: 12px; }
  .library-topbar .brand-word { grid-column: 1; grid-row: 1; }
  .library-topbar .top-actions { grid-column: 2; grid-row: 1; }
  .library-search { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* Account forms stay in the existing drawer; no extra chat toolbar. */
.account-login form { display:grid; gap:14px; margin-block:16px; }
.account-login label { display:grid; gap:7px; }
.account-login textarea { width:100%; resize:vertical; font:inherit; color:var(--text); background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:10px; }
.account-login details { margin-block:14px; }
.account-login pre { white-space:pre-wrap; overflow-wrap:anywhere; max-height:280px; overflow:auto; }
