:root {
  color-scheme: light;
  --bg: #efeeeb; --paper: #fffefd; --ink: #25242f; --muted: #666573; --muted-light: #7a7884;
  --border: #e7e4e8; --purple: #6645cc; --purple-dark: #5134b0; --lavender: #f0ebff;
  --rust: #a54d36; --sidebar: #252333; --sidebar-light: #343142; --on-dark: #e9e6f3;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px; font-weight: 400; background: #f8f7f5; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; cursor: pointer; background: transparent; color: inherit; padding: 0; border: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .36; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #8968ef; outline-offset: 3px; }
input, textarea { accent-color: var(--purple); }
a { color: var(--purple-dark); }
h1, h2, p { margin: 0; }
i[data-icon] { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; background: currentColor; mask: var(--icon) center / contain no-repeat; -webkit-mask: var(--icon) center / contain no-repeat; }
.icon-button { width: 36px; height: 36px; border-radius: 8px; flex: none; color: var(--muted); }
.icon-button:not(:disabled):hover, .subtle:hover { background: #efedf1; color: var(--ink); }
.button, button.primary, a.primary { border: 1px solid var(--border); min-height: 38px; padding: 0 12px; border-radius: 9px; white-space: nowrap; font-size: .875rem; }
.primary, button.primary, a.primary { background: var(--purple); border-color: var(--purple); color: white; font-weight: 650; }
.primary:hover, button.primary:hover, a.primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.gate { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: #eeebf3; }
.gate-card { width: min(100%, 410px); border: 1px solid #e1dce7; box-shadow: 0 22px 60px #27233814; min-height: 380px; padding: 41px; border-radius: 20px; background: #fff; }
.logo-frame img { display: block; border-radius: 12px; margin-bottom: 28px; }
.gate h1 { margin: 5px 0 29px; font-size: clamp(1.5rem, 6vw, 2rem); letter-spacing: .015em; overflow-wrap: anywhere; }
#install-form { display: grid; gap: 10px; }
#install-form label { font-weight: 650; font-size: .875rem; }
#install-password { width: 100%; padding: 11px 12px; border: 1px solid #d8d5dd; border-radius: 8px; font: inherit; }
#gate-status { color: var(--muted); font-size: .875rem; line-height: 1.5; margin-top: 12px; }
.workspace { height: 100dvh; height: 100svh; display: grid; grid-template-columns: 242px minmax(0, 1fr) 285px; overflow: hidden; }
.workspace.no-inspector { grid-template-columns: 242px minmax(0,1fr); }
.workspace.no-inspector .inspector { display: none; }
.library { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--sidebar); color: var(--on-dark); border-right: 1px solid #22202e; }
.identity { height: 76px; display: flex; align-items: center; gap: 12px; padding: 0 20px; flex: none; }
.identity img { border-radius: 9px; }
.identity > div { min-width: 0; }
.identity strong { display: block; font-size: .95rem; font-weight: 670; line-height: 1.22; overflow-wrap: anywhere; }
.identity .mobile-only { margin-left: auto; }
.library-actions { display: flex; gap: 8px; padding: 5px 15px 17px; }
.import-button { flex: 1; min-height: 40px; background: #f1edff; color: #3e2a7e; border-radius: 8px; font-size: .875rem; font-weight: 680; }
.import-button:hover { background: #fff; }
.library .icon-button { color: #e8e1fa; }
.library .icon-button:not(:disabled):hover { background: #4a445d; color: white; }
.new-button { height: 40px; width: 40px; background: var(--sidebar-light); border: 1px solid #494459; }
.search { display: flex; gap: 8px; height: 37px; align-items: center; margin: 0 15px; padding: 0 10px; border: 1px solid #474254; color: #bdb9ce; border-radius: 7px; }
.search i { width: 15px; height: 15px; }
.search input { background: transparent; border: 0; color: white; min-width: 0; width: 100%; font-size: .84rem; }
.search input::placeholder { color: #bbb7ca; }
.filters { display: flex; gap: 5px; margin: 19px 15px 8px; }
.filters button { min-height: 30px; padding: 0 10px; border-radius: 6px; font-size: .83rem; color: #c4c0d3; }
.filters button.active { color: #f5f0ff; background: #3b354e; font-weight: 650; }
.filters button:hover { color: white; }
.library-heading { padding: 12px 18px 8px; display: flex; justify-content: space-between; color: #bdb8ce; font-size: .77rem; font-weight: 650; }
.files { min-height: 0; overflow: auto; flex: 1; padding: 0 10px 12px; }
.file-entry { display: flex; align-items: center; padding-right: 4px; border-radius: 8px; }
.file-entry.active { background: #413853; }
.file-entry:hover, .file-entry:focus-within { background: #363144; }
.file-entry.active:hover, .file-entry.active:focus-within { background: #493e5e; }
.file-row { display: flex; flex: 1; min-width: 0; justify-content: flex-start; text-align: left; min-height: 63px; padding: 6px 7px; border-radius: 8px; gap: 9px; }
.file-delete { flex: none; width: 42px; height: 44px; border-radius: 6px; color: #d0c8df; font-size: .8rem; }
.file-delete:hover, .file-delete:focus-visible { color: #ffd4c6; background: #573b50; }
.file-icon { display: flex; flex: 0 0 36px; height: 42px; justify-content: center; align-items: center; border-radius: 5px; background: #dcd1f2; color: #583b9b; }
.file-icon.tone-pdf { background: #f2d9ce; color: #983f28; }
.file-icon.tone-text { background: #d4e4dd; color: #3f6856; }
.file-icon i { width: 17px; height: 17px; }
.file-name { min-width: 0; flex: 1; }
.file-name strong, .file-name span { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; display: block; }
.file-name strong { color: #f4f1fa; font-size: .875rem; line-height: 1.55; font-weight: 610; }
.file-name span { color: #c0bbd0; font-size: .75rem; line-height: 1.55; }
.file-empty { color: #c0bbd0; font-size: .875rem; padding: 12px 9px; }
.library-footer { border-top: 1px solid #413d50; padding: 12px 15px max(13px, env(safe-area-inset-bottom)); }
.settings-button { color: #e5e0f1; font-size: .875rem; justify-content: flex-start; min-height: 28px; }
.settings-button:hover { color: white; }
.local-badge { display: block; color: #b3adc6; margin: 4px 0 0 26px; font-size: .74rem; }
.local-badge button { color: inherit; background: none; padding: 0; text-align: left; text-decoration: underline; }
.mobile-only, .scrim { display: none; }
.editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.topbar { display: flex; flex: 0 0 66px; min-width: 0; justify-content: space-between; align-items: center; gap: 9px; padding: 0 19px; border-bottom: 1px solid var(--border); background: #fcfbfa; }
.current, .header-actions { min-width: 0; display: flex; align-items: center; gap: 9px; }
.crumb { font-size: .875rem; color: var(--muted); flex: none; }
.divider { color: #a8a4b0; }
.title-button { font-size: 1rem; font-weight: 670; min-width: 0; min-height: 38px; }
.title-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-button i { color: var(--muted); width: 13px; height: 13px; }
.sync-status { color: #45695c; display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; white-space: nowrap; margin-right: 4px; }
.sync-status.offline, .sync-status.locked, .sync-status.error { color: var(--rust); }
.sync-status i { width: 15px; height: 15px; }
.header-actions { flex: 0 0 auto; }
.night-icon { width: 17px; height: 17px; border-radius: 50%; box-shadow: inset -5px -3px 0 currentColor; transform: rotate(-12deg); }
.toolbar { display: flex; align-items: center; min-height: 50px; gap: 9px; padding: 0 14px; background: #faf9f8; border-bottom: 1px solid var(--border); flex: none; overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.import-notice { flex: none; background: #f7f3ff; color: #4e4654; border-bottom: 1px solid var(--border); padding: 7px 12px; font-size: .8rem; line-height: 1.45; }
.tools, .ink-controls, .history, .palette { display: flex; align-items: center; flex: none; gap: 4px; }
.tool { color: #615e6a; height: 35px; min-width: 34px; padding: 0 7px; gap: 5px; font-size: .82rem; border-radius: 7px; }
.tool i { width: 17px; height: 17px; }
.tool:hover { background: #eeecf1; }
.tool.active { background: var(--lavender); color: var(--purple-dark); font-weight: 680; }
.tool.voice-tool i { color: var(--rust); }
.tool.voice-tool.active { color: var(--rust); background: #f8e8e2; }
.rule { display: inline-block; height: 19px; width: 1px; background: var(--border); margin: 0 4px; flex: none; }
.swatch { display: inline-grid; place-items: center; background: transparent; width: 23px; height: 25px; border-radius: 50%; border: 1px solid transparent; }
.swatch::before { content: ""; width: 13px; height: 13px; border-radius: 50%; background: var(--swatch); }
.swatch.active { border-color: var(--swatch); }
.palette-more { width: 28px; height: 31px; }
.color-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; font-size: .9rem; }
.color-field input[type="color"] { width: 38px; height: 32px; padding: 2px; border: 1px solid var(--border); background: white; border-radius: 5px; }
.color-options { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(33px, 1fr)); gap: 2px; }
.color-options .swatch { width: 33px; height: 33px; }
.color-options .swatch::before { width: 22px; height: 22px; border: 1px solid #2d24361d; }
.brush-preview { height: 78px; display: grid; place-items: center; background: #f6f4f8; border-radius: 8px; }
.brush-preview span { display: block; width: min(70%, 200px); height: 4px; border-radius: 100px; }
.brush-slider span { display: flex; justify-content: space-between; }
.brush-slider output { color: var(--muted); }
.brush-slider input[type="range"] { width: 100%; margin: 0; padding: 0; border: 0; }
.weight { width: 28px; }
.history .icon-button { width: 29px; }
.inspector-toggle { margin-left: auto; font-size: .74rem; }
.editing-area { position: relative; flex: 1; min-height: 0; background: var(--bg); }
.page-viewport { position: absolute; inset: 0; overflow: auto; scrollbar-gutter: stable; overscroll-behavior: contain; overflow-anchor: none; touch-action: pan-x pan-y; }
.page-viewport[data-view-locked] { overflow: hidden; touch-action: none; }
.paper-stage { display: flex; flex-direction: column; align-items: center; min-width: max-content; padding: 20px 32px 84px; gap: 22px; }
.page-frame { display: grid; justify-items: center; gap: 8px; flex: none; }
.page-label { width: 100%; color: var(--muted); text-align: center; font-size: .78rem; letter-spacing: .045em; }
.paper { width: var(--paper-size); background: var(--paper); overflow: hidden; position: relative; box-shadow: 0 1px 2px #332c3020, 0 7px 30px #372b3015; border-radius: 3px; flex: none; isolation: isolate; }
.page-image { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
.pdf-detail { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.pdf-detail canvas { display: block; position: absolute; }
.page-attachment-status { position: absolute; top: 24px; left: 0; right: 0; text-align: center; font-size: .85rem; color: var(--muted); }
.page-content { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.paper-grid .page-content { background-image: linear-gradient(#e9e4ee 1px, transparent 1px), linear-gradient(90deg, #e9e4ee 1px, transparent 1px); background-size: var(--grid, 24px) var(--grid, 24px); }
.paper-ruled .page-content { background-image: linear-gradient(transparent calc(100% - 1px), #e9e4ee 1px); background-size: 100% var(--grid, 24px); }
.paper-script .page-content, .paper-blank .page-content, .paper-ruled .page-content, .paper-grid .page-content { padding: 7.5% 9.4%; }
.sheet-head { position: relative; padding-bottom: 3.5%; margin-bottom: 4%; border-bottom: 1px solid #ded8d5; }
.sheet-kicker { color: var(--rust); font-weight: 700; letter-spacing: .15em; font-size: calc(var(--paper-size) * .0175); line-height: 1.4; }
.sheet-title { margin: 2% 0 1%; color: #28242a; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: calc(var(--paper-size) * .063); line-height: 1.25; font-weight: 750; letter-spacing: .06em; overflow-wrap: anywhere; }
.sheet-sub { color: #6c6670; font-size: calc(var(--paper-size) * .0175); letter-spacing: .07em; }
.sheet-pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; color: var(--text-color, #353039); font-weight: 500; font-size: calc(var(--paper-size) * .0208); line-height: 1.78; letter-spacing: .052em; }
.sheet-pre .scene-line { display: block; margin: 0 0 .65em; padding: .44em .76em; background: #f5eff6; color: var(--text-color, #4e3d63); font-weight: 700; letter-spacing: .07em; font-family: "PingFang SC", sans-serif; }
.sheet-pre .dialogue { color: var(--text-color, #472c50); font-weight: 650; }
.sheet-pre .script-line { display: block; min-height: 1.46em; }
.sheet-footer { position: absolute; bottom: 4.6%; right: 9.4%; font-size: calc(var(--paper-size) * .0175); color: #736b74; }
.ink { width: 100%; height: 100%; position: absolute; inset: 0; display: block; touch-action: pan-x pan-y; }
/* Keep native selection and iPad long-press image callouts out of ink input.
   Browse mode and editors outside the paper remain selectable. */
.page-viewport:is([data-tool="pen"], [data-tool="marker"], [data-tool="eraser"]) .paper {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.page-viewport:is([data-tool="pen"], [data-tool="marker"], [data-tool="eraser"]) .page-image {
  -webkit-user-drag: none;
}
.page-viewport:is([data-tool="pen"], [data-tool="marker"], [data-tool="eraser"]) .ink { cursor: crosshair; }
.page-viewport:not([data-finger-scroll="true"]):is([data-tool="pen"], [data-tool="marker"], [data-tool="eraser"]) .ink { touch-action: none; }
.page-viewport:is([data-tool="text"], [data-tool="voice"]) .ink { cursor: crosshair; }
.pins { position: absolute; inset: 0; pointer-events: none; }
.pin { pointer-events: auto; position: absolute; width: 29px; height: 29px; border-radius: 50%; transform: translate(-50%, -50%); color: white; background: var(--pin-color, var(--purple)); box-shadow: 0 0 0 2px white, 0 2px 5px #29233752; }
.pin.type-voice { background: var(--pin-color, var(--rust)); }
.pin.active { box-shadow: 0 0 0 2px white, 0 0 0 5px #b7a4f3; }
.pin i { width: 14px; height: 14px; }
.page-nav { display: flex; align-items: center; position: absolute; bottom: max(13px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #fcfbfa; border: 1px solid var(--border); box-shadow: 0 4px 20px #30273814; padding: 3px 4px; gap: 1px; white-space: nowrap; border-radius: 10px; z-index: 2; }
.page-nav .icon-button { width: 32px; height: 32px; }
#page-picker, #zoom-fit { min-width: 44px; padding: 0 4px; min-height: 32px; color: var(--ink); font-size: .82rem; font-variant-numeric: tabular-nums; }
#page-picker { gap: 4px; }
#page-total { color: var(--muted); }
#view-lock { width: 73px; gap: 6px; font-size: .78rem; }
#view-lock[aria-pressed="true"] { background: var(--lavender); color: var(--purple-dark); font-weight: 680; }
.view-lock-icon { position: relative; width: 13px; height: 9px; margin-top: 5px; border: 1.5px solid currentColor; border-radius: 2px; }
.view-lock-icon::before { content: ""; position: absolute; width: 5px; height: 5px; bottom: 100%; left: 3px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }
#view-lock[aria-pressed="true"] .view-lock-icon::before { left: 1px; }
.tool-hint { position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 3px 16px #2a243425; color: #4e4654; padding: 8px 11px; font-size: .83rem; white-space: nowrap; }
.recording { flex: none; border-bottom: 1px solid var(--border); padding: 7px 12px; background: #fcfbfa; color: #4e4654; font-size: .83rem; }
.recording-header { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.recording-limit { color: var(--muted); }
.recording-detail { height: clamp(65px, 13dvh, 105px); padding-top: 5px; display: flex; flex-direction: column; }
.recording #transcription-status { color: var(--muted); line-height: 1.45; }
.live-transcript { min-height: 0; overflow-y: auto; margin-top: 8px; padding: 8px; background: #f7f4fa; border-radius: 6px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
#transcript-interim { color: var(--muted); }
#transcript-confirmed:not(:empty) + #transcript-interim:not(:empty)::before { content: "\a"; white-space: pre; }
.recording-dot { flex: none; border-radius: 50%; width: 9px; height: 9px; background: #b34635; }
.recording-actions { display: flex; gap: 5px; margin-left: auto; }
.recording button { padding: 6px 8px; border-radius: 5px; background: #f8e9e3; color: #873b27; font-size: .82rem; }
.recording #toggle-transcript { background: #eeebf2; color: #514661; }
.empty { min-height: 70vh; display: grid; justify-items: center; align-content: center; gap: 13px; padding: 22px; text-align: center; }
.empty p { color: var(--muted); }
.empty-icon { width: 56px; height: 56px; display: grid; place-items: center; background: var(--lavender); color: var(--purple); border-radius: 14px; }
.empty-icon i { width: 25px; height: 25px; }
.inspector { display: flex; flex-direction: column; min-height: 0; background: #fcfbfa; border-left: 1px solid var(--border); }
.inspector-head { display: flex; justify-content: space-between; align-items: center; padding: 23px 16px 14px; }
.inspector-head p { color: var(--purple-dark); font-size: .78rem; font-weight: 650; margin-bottom: 5px; }
.inspector-head h2 { font-size: 1.13rem; letter-spacing: .04em; }
.annotation-filters { display: flex; margin: 0 15px; padding: 3px; border-radius: 8px; background: #eeecef; }
.annotation-filters button { flex: 1; min-height: 30px; border-radius: 6px; color: var(--muted); font-size: .84rem; }
.annotation-filters button.active { background: white; box-shadow: 0 1px 3px #27253413; color: #473264; font-weight: 650; }
.annotation-list { flex: 1; overflow: auto; min-height: 0; padding: 14px 15px; }
.annotation-card { background: white; border: 1px solid #e9e5ec; border-radius: 9px; padding: 10px 11px; margin-bottom: 9px; cursor: pointer; }
.annotation-card.selected { border-color: #ae98ed; }
.annotation-card:focus-within, .annotation-card:hover { border-color: #b29def; }
.annotation-head { display: flex; align-items: center; gap: 8px; }
.annotation-badge { display: grid; width: 30px; height: 30px; place-items: center; background: var(--lavender); color: var(--purple-dark); border-radius: 7px; flex: none; }
.annotation-badge.voice { color: var(--rust); background: #faede7; }
.annotation-badge i { width: 15px; height: 15px; }
.annotation-head strong { flex: 1; min-width: 0; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size: .875rem; }
.annotation-head .icon-button { width: 24px; height: 27px; }
.annotation-card p, .annotation-empty { color: var(--muted); margin: 8px 0 0; font-size: .84rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.annotation-card p { max-height: 8em; overflow: auto; }
.annotation-card p { color: var(--annotation-color, var(--muted)); }
.annotation-card audio { width: 100%; height: 37px; margin-top: 8px; }
.play-voice { min-height: 30px; margin-top: 7px; width: 100%; padding: 0 8px; color: var(--rust); border-radius: 6px; background: #faeee9; font-size: .83rem; }
.add-annotation { display: flex; gap: 6px; padding: 11px 15px max(15px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.add-annotation button { flex: 1; min-height: 36px; padding: 0 5px; font-size: .82rem; }
.add-annotation button:hover { background: white; border-color: #b8a7e5; }
#add-voice { color: #91452e; background: #fff4ef; border-color: #eed8ce; }
.review { padding: 0 15px 12px; }
.review button { width: 100%; color: var(--purple-dark); }
.toast { position: fixed; bottom: 67px; left: 50%; transform: translateX(-50%); z-index: 25; background: #2d2639; color: white; border-radius: 9px; padding: 11px 15px; max-width: min(calc(100vw - 25px), 500px); font-size: .875rem; line-height: 1.5; box-shadow: 0 6px 20px #20193035; }
.drop-hint { position: fixed; inset: 14px; display: grid; place-content: center; justify-items: center; gap: 12px; background: #f0eaffeb; color: var(--purple-dark); border: 2px dashed #8f72e4; border-radius: 14px; z-index: 30; font-size: 1.15rem; pointer-events: none; }
.drop-hint i { width: 28px; height: 28px; }
dialog { border: 1px solid var(--border); border-radius: 14px; width: min(calc(100% - 24px), 570px); max-height: 88dvh; color: var(--ink); padding: 0; overflow: auto; box-shadow: 0 25px 120px #19132047; }
dialog::backdrop { background: #20183169; }
.modal { padding: 22px; display: grid; gap: 15px; }
.modal-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-heading h2 { font-size: 1.2rem; line-height: 1.3; }
.modal p, .modal li { line-height: 1.65; font-size: .9rem; color: var(--muted); }
.modal a { text-underline-offset: .16em; }
.modal .section-label { font-size: .88rem; color: var(--ink); font-weight: 670; }
.field { display: grid; gap: 7px; font-size: .875rem; font-weight: 610; }
.field textarea { min-height: 100px; resize: vertical; line-height: 1.55; font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.modal-actions button, .modal-actions a { min-height: 40px; display: inline-flex; align-items: center; text-decoration: none; }
.modal-actions .danger { color: #963e2c; }
.choice-list { display: grid; gap: 1px; max-height: 160px; overflow: auto; background: #f8f6f8; border-radius: 8px; padding: 7px 9px; }
.choice-list label, .option-line { font-size: .875rem; display: flex; align-items: flex-start; gap: 8px; min-height: 31px; padding: 4px 0; }
.choice-list input, .option-line input { width: 17px; height: 17px; margin: 1px 0; flex: none; }
.choice-list .muted { padding: 4px; }
.modal progress { width: 100%; accent-color: var(--purple); }
.modal code { overflow-wrap: anywhere; user-select: all; }
.settings-list { display: grid; gap: 8px; }
.settings-list .button { min-height: 39px; justify-content: flex-start; text-align: left; color: var(--purple-dark); }
.response-text { white-space: pre-wrap; overflow-wrap: anywhere; background: #faf8ff; padding: 13px; border-radius: 8px; max-height: 44dvh; overflow: auto; }
@media (max-width: 1270px) {
  .workspace { grid-template-columns: 218px minmax(0, 1fr) 259px; }
  .workspace.no-inspector { grid-template-columns: 218px minmax(0,1fr); }
  .tool span { display: none; }
}
@media (max-width: 1180px) {
  .workspace, .workspace.no-inspector { grid-template-columns: 200px minmax(0, 1fr); }
  .inspector { position: absolute; inset: 116px 0 calc(45px + max(13px, env(safe-area-inset-bottom))) auto; width: min(295px, 85vw); box-shadow: -8px 0 25px #3b304127; z-index: 8; }
  .recording { position: relative; z-index: 9; }
  .paper-stage { padding: 17px 20px 76px; }
  .identity { padding-inline: 12px; }
}
@media (max-width: 900px) {
  .workspace, .workspace.no-inspector { grid-template-columns: minmax(0, 1fr); }
  .library { position: absolute; inset: 0 auto 0 0; width: min(273px, 85vw); z-index: 15; transform: translateX(-101%); transition: transform 160ms ease; }
  .workspace.library-open .library { transform: translateX(0); }
  .workspace.library-open .scrim { display: block; position: absolute; inset: 0; z-index: 14; background: #221a3970; }
  .mobile-only { display: inline-flex; }
  .topbar { flex-basis: 59px; padding: 0 9px; padding-top: env(safe-area-inset-top); }
  .inspector { top: calc(109px + env(safe-area-inset-top)); }
  .header-actions { gap: 5px; }
  .header-actions button { min-height: 35px; padding: 0 8px; }
  .header-actions #export span, .crumb, .divider, .sync-status > span { display: none; }
  .sync-status { margin: 0; }
  .current { gap: 4px; }
  .title-button { font-size: .9rem; }
  .toolbar { padding: 0 7px; gap: 4px; }
  .tool { min-width: 31px; padding: 0 4px; }
  .tools, .palette { gap: 1px; }
  .history .icon-button { width: 28px; }
  .ink-controls, .history { gap: 0; }
  .rule { margin: 0 2px; }
  .swatch { width: 19px; }
  .swatch::before { width: 11px; height: 11px; }
  .paper-stage { padding: 13px 10px 76px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 350px) {
  #view-lock { width: 34px; }
  #view-lock-label { display: none; }
}

:root[data-night] {
  color-scheme: dark;
  --bg: #17161e; --paper: #26242e; --ink: #eeeaf3; --muted: #bdb5c8; --muted-light: #aca4b9;
  --border: #42404f; --purple: #745bc3; --purple-dark: #d1c1ff; --lavender: #3b3157;
  --rust: #f1b19b; --sidebar: #1b1923; --sidebar-light: #2a2635;
  --night-surface: #211e2a; --night-raised: #2c2836; --night-hover: #393446;
  --night-voice: #422c2c; --night-rule: #443e50;
  background: #1c1a23;
}
[data-night] :is(.gate, .editing-area) { background: var(--bg); }
[data-night] :is(.topbar, .toolbar, .inspector, .page-nav, .recording, dialog, .gate-card) { background: var(--night-surface); }
[data-night] :is(.gate-card, #install-password, .annotation-card) { border-color: var(--border); }
[data-night] :is(.import-button, .import-notice, .annotation-filters button.active, #night-mode) { background: var(--lavender); color: var(--purple-dark); }
[data-night] .primary:hover { background: #6950ba; border-color: #6950ba; }
[data-night] :is(.tool, .recording, .tool-hint) { color: var(--muted); }
[data-night] :is(.tool:hover, .icon-button:not(:disabled):hover, .subtle:hover, .add-annotation button:hover, .import-button:hover) { background: var(--night-hover); color: var(--ink); }
[data-night] :is(.tool.active, #view-lock[aria-pressed="true"], .empty-icon) { color: var(--purple-dark); }
[data-night] :is(.sync-status, .sync-status.pending) { color: #a4d6be; }
[data-night] :is(.sync-status.offline, .sync-status.locked, .sync-status.error, .modal-actions .danger) { color: var(--rust); }
[data-night] :is(.brush-preview, .annotation-filters, .annotation-card, .tool-hint, .live-transcript, .choice-list,
  .response-text, .color-field input[type="color"], .recording #toggle-transcript) { background: var(--night-raised); }
[data-night] :is(.recording #toggle-transcript, .sheet-sub, .sheet-footer) { color: var(--muted); }
[data-night] :is(.annotation-card.selected, .annotation-card:focus-within, .annotation-card:hover) { border-color: #a891ea; }
[data-night] :is(.annotation-badge.voice, .play-voice, #add-voice, .tool.voice-tool.active, #stop-recording) { background: var(--night-voice); color: var(--rust); }
[data-night] #add-voice { border-color: #624245; }
[data-night] .annotation-card p { color: color-mix(in srgb, var(--annotation-color, var(--muted)) 47%, #efe9f8); }
[data-night] dialog::backdrop { background: #0f0d17b8; }
[data-night] .drop-hint { background: #252034eb; }
[data-night] .paper { box-shadow: 0 0 0 1px #383343, 0 7px 30px #0c0a155e; }
[data-night] .sheet-head { border-color: var(--night-rule); }
[data-night] .sheet-title { color: var(--ink); }
[data-night] :is(.sheet-pre, .sheet-pre .scene-line, .sheet-pre .dialogue) { color: color-mix(in srgb, var(--text-color, var(--muted)) 47%, var(--ink)); }
[data-night] .sheet-pre .scene-line { background: var(--lavender); }
[data-night] .sheet-pre .scene-line { color: var(--purple-dark); }
[data-night] .paper-grid .page-content { background-image: linear-gradient(var(--night-rule) 1px, transparent 1px), linear-gradient(90deg, var(--night-rule) 1px, transparent 1px); }
[data-night] .paper-ruled .page-content { background-image: linear-gradient(transparent calc(100% - 1px), var(--night-rule) 0); }
[data-night] :is(.page-image, .pdf-detail canvas) { filter: invert(.86) hue-rotate(180deg); }
[data-night] .image-document .page-image { filter: brightness(.78); }
[data-night] .pin { box-shadow: 0 0 0 2px var(--paper), 0 2px 5px #111018aa; }
[data-night] .pin.active { box-shadow: 0 0 0 2px var(--paper), 0 0 0 5px var(--purple-dark); }
[data-night] .swatch::before { box-shadow: 0 0 0 1px #eee4ff54; }

[data-icon="upload"] { --icon: url("./icons/upload.png"); }
[data-icon="download"] { --icon: url("./icons/download.png"); }
[data-icon="plus"] { --icon: url("./icons/plus.png"); }
[data-icon="minus"] { --icon: url("./icons/minus.png"); }
[data-icon="search"] { --icon: url("./icons/search.png"); }
[data-icon="close"] { --icon: url("./icons/close.png"); }
[data-icon="chevron"] { --icon: url("./icons/chevron.png"); }
[data-icon="left"] { --icon: url("./icons/left.png"); }
[data-icon="right"] { --icon: url("./icons/right.png"); }
[data-icon="pen"] { --icon: url("./icons/pen.png"); }
[data-icon="marker"] { --icon: url("./icons/marker.png"); }
[data-icon="eraser"] { --icon: url("./icons/eraser.png"); }
[data-icon="text"] { --icon: url("./icons/text.png"); }
[data-icon="mic"] { --icon: url("./icons/mic.png"); }
[data-icon="weight"] { --icon: url("./icons/weight.png"); }
[data-icon="undo"] { --icon: url("./icons/undo.png"); }
[data-icon="redo"] { --icon: url("./icons/redo.png"); }
[data-icon="panel"] { --icon: url("./icons/panel.png"); }
[data-icon="library"] { --icon: url("./icons/library.png"); }
[data-icon="document"] { --icon: url("./icons/document.png"); }
[data-icon="book"] { --icon: url("./icons/book.png"); }
[data-icon="settings"] { --icon: url("./icons/settings.png"); }
[data-icon="cloud"] { --icon: url("./icons/cloud.png"); }
[data-icon="sparkles"] { --icon: url("./icons/sparkles.png"); }
[data-icon="hand"] { --icon: url("./icons/hand.png"); }
[data-icon="dots"] { --icon: url("./icons/dots.png"); }
[data-icon="play"] { --icon: url("./icons/play.png"); }
[data-icon="star"] { --icon: url("./icons/star.png"); }
