/* Scrawl. Ink on paper: warm neutrals, dark ink for anything active, serif for titles, sans for controls. */
:root {
  --bg: #ececec;
  --panel: #f7f7f7;
  --surface: #ffffff;
  --soft: #ededed;
  --line: #dcdcdc;
  --line-strong: #b8b8b8;
  --text: #000000;
  --muted: #6b6b6b;
  --ink: #000000;
  --ink-text: #ffffff;
  --sample: #fcfcfa;
  --shadow: rgba(0, 0, 0, 0.18);
  --focus: rgba(0, 0, 0, 0.2);
  --r: 6px;
}
[data-theme="dark"] {
  --bg: #000000; --panel: #0c0c0c; --surface: #161616; --soft: #1d1d1d; --line: #262626; --line-strong: #3d3d3d;
  --text: #f5f5f5; --muted: #8a8a8a; --ink: #ffffff; --ink-text: #000000; --sample: #f4f2ec;
  --shadow: rgba(0, 0, 0, 0.7); --focus: rgba(255, 255, 255, 0.28);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --panel: #0c0c0c; --surface: #161616; --soft: #1d1d1d; --line: #262626; --line-strong: #3d3d3d;
    --text: #f5f5f5; --muted: #8a8a8a; --ink: #ffffff; --ink-text: #000000; --sample: #f4f2ec;
    --shadow: rgba(0, 0, 0, 0.7); --focus: rgba(255, 255, 255, 0.28);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--text); }
#app { display: grid; grid-template-columns: 360px minmax(0, 1fr) 328px; grid-template-rows: auto minmax(0, 1fr); height: 100%; }

/* ---------- top bar ---------- */
.topbar { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 16px; height: 50px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tb-left { display: flex; align-items: center; gap: 12px; }
.tb-mid { display: flex; align-items: center; gap: 6px; justify-self: center; }
.tb-right { display: flex; align-items: center; gap: 8px; justify-self: end; }
.tb-right .btn { display: inline-flex; align-items: center; gap: 6px; }
.wordmark { font-weight: 600; font-size: 17px; line-height: 1; color: var(--text); letter-spacing: -0.02em; padding-left: 4px; }
#pageinfo { color: var(--muted); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; font-size: 12.5px; }
#status { color: var(--muted); font-size: 12px; margin-left: 8px; }
.theme { background: none; border: 0; border-radius: var(--r); width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); cursor: pointer; margin-left: 4px; }
.theme:hover { color: var(--text); background: var(--soft); }
.theme .moon { display: none; }
[data-theme="dark"] .theme .sun { display: none; }
[data-theme="dark"] .theme .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { display: none; }
  :root:not([data-theme="light"]) .theme .moon { display: block; }
}

/* ---------- panes ---------- */
.pane { background: var(--panel); overflow-y: auto; min-height: 0; padding: 16px 20px 20px; }
#editor { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#editor .textbox { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 240px; }
#editor textarea { flex: 1 1 auto; min-height: 0; resize: none; }
#inspector { border-left: 1px solid var(--line); }
.pane-head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 10px; }
.sect { border-bottom: 1px solid var(--line); padding: 0 0 6px; margin: 0; }
.sect:not([open]) { padding-bottom: 0; }
.sect-head { list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 10px; padding: 14px 0; font-size: 13px; font-weight: 600; }
.sect-head::-webkit-details-marker { display: none; }
.sect-head::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin-left: auto; margin-right: 4px; transition: transform .15s; flex: none; }
.sect[open] > .sect-head::after { transform: rotate(-135deg); margin-top: 4px; }
.sect-sum { color: var(--muted); font-weight: 400; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; }
.sect[open] > .sect-head .sect-sum { display: none; }
.sect > :not(summary) { }
.sect[open] { padding-bottom: 16px; }
.links.tight { margin: 8px 0 12px; text-align: center; }
.pane-foot p { margin: 4px 0; }
.pane-foot .muted { color: var(--muted); }
.pane-foot { font-size: 12px; color: var(--muted); }
.pane-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.pane-foot .dot { margin: 0 4px; }
.pane-foot .link { color: var(--muted); }
.subhead { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 14px 0 8px; }

/* text */
.textbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.textbox:focus-within { border-color: var(--line-strong); }
textarea { display: block; width: 100%; min-height: 220px; resize: vertical; border: 0; background: transparent; color: var(--text); padding: 11px 13px; font: 13px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; outline: none; }
.drop { display: flex; align-items: center; gap: 8px; padding: 8px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; cursor: pointer; }
.drop:hover, .drop.over { color: var(--text); background: var(--soft); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
input[type=text], input[type=number] { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; font: inherit; }
input[type=text]:focus, input[type=number]:focus { outline: none; border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder { color: var(--muted); opacity: .9; }
.tips { font-size: 12.5px; }
.tips ul { margin: 0; padding: 8px 10px 10px 26px; line-height: 1.6; color: var(--muted); }
.tips code { font: 11.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); padding: 2px 5px; border-radius: 4px; }

/* handwriting */
.current { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sample); }
.current canvas { display: block; width: 100%; height: auto; }
.current-meta { display: flex; align-items: baseline; gap: 8px; padding: 7px 11px; font-size: 12.5px; font-weight: 500; color: #000; background: var(--sample); border-top: 1px solid rgba(0,0,0,.07); }
.current-meta .muted { color: #7a776f; font-weight: 400; font-size: 12px; }
.twoup { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 12px; }
.links { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.links .dot { margin: 0 6px; }
.saverow { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.saverow input { flex: 1; min-width: 0; }
#tune > summary { display: none; }
#tune:not([open]) { display: none; }
#tune { margin-top: 8px; }
#tune > .row:first-of-type { margin-top: 10px; }
#tune > .row:last-of-type, #tune > div:last-child { margin-bottom: 4px; }
.tune h4 { margin: 14px 10px 4px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }

/* rows and sliders */
.sliders { display: grid; gap: 0; }
.row { display: grid; grid-template-columns: 126px 1fr 38px; align-items: center; gap: 10px; min-height: 30px; }
.row label { font-size: 13px; color: var(--text); line-height: 1.25; }
.row output { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.row input[type=text], .row .fontpick, .row .swatches, .row .segmented, .row .link.left { grid-column: 2 / 4; }
.link.left { justify-self: start; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: none; margin: 0; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: linear-gradient(to right, var(--ink) 0 var(--p), var(--line-strong) var(--p) 100%); }
input[type=range]::-moz-range-track { height: 2px; background: var(--line-strong); }
input[type=range]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--ink); border: 0; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 0; }
input[type=range]:focus { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--focus); }

.fontpick { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 10px; font-size: 17px; line-height: 1.3; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fontpick:hover { border-color: var(--line-strong); }
.fontmenu { position: fixed; z-index: 50; max-height: 360px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 4px; }
.fontmenu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 12px; font-size: 18px; border-radius: 4px; cursor: pointer; }
.fontmenu button:hover { background: var(--soft); }
.fontmenu button.active { background: var(--ink); color: var(--ink-text); }

.swatches { display: flex; gap: 8px; align-items: center; }
.swatches button, .swatches .custom { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatches button.active { border-color: var(--panel); box-shadow: 0 0 0 1.5px var(--ink); }
.swatches .custom { position: relative; background: conic-gradient(#e33, #ec3, #3c6, #39e, #a3e, #e33); }
.swatches .custom::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--c); }
.swatches .custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.link { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text); }

/* paper */
.paperstyles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ps { background: none; border: 0; padding: 0; cursor: pointer; text-align: center; }
.ps i { display: block; height: 52px; border-radius: 4px; background: #fbfaf7; border: 1px solid #dcd9d0; position: relative; overflow: hidden; }
.ps:hover i { border-color: #b9b5aa; }
.ps.active i { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.ps.ruled i { background-image: repeating-linear-gradient(to bottom, transparent 0 9px, #c5d3e8 9px 10px); }
.ps.margin i::after { content: ''; position: absolute; left: 12px; top: 0; bottom: 0; width: 1px; background: #e8a0a0; }
.ps.squared i { background-image: linear-gradient(to right, #d3ddec 1px, transparent 1px), linear-gradient(to bottom, #d3ddec 1px, transparent 1px); background-size: 7px 7px; }
.ps span { display: block; font-size: 11.5px; margin-top: 5px; color: var(--muted); }
.ps.active span { color: var(--text); }

.switches { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 6px; }
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 28px; height: 16px; border-radius: 8px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--ink); }
.switch input:checked + i::after { transform: translateX(12px); background: var(--ink-text); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--focus); }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); padding: 2px; margin-bottom: 6px; background: var(--surface); }
.segmented button { background: none; border: 0; padding: 4px 11px; border-radius: 4px; cursor: pointer; color: var(--muted); font-weight: 500; }
.segmented button.active { background: var(--ink); color: var(--ink-text); }
.segmented.tight { margin: 0; justify-self: start; }
.segmented.tight button { padding: 3px 9px; font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips button { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px; font-size: 12.5px; cursor: pointer; color: var(--text); }
.chips button:hover { border-color: var(--line-strong); }
.chips button.active { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.bg { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 12.5px; }
.bg img { width: 44px; height: 33px; object-fit: cover; border-radius: 4px; }
.bg span { color: var(--muted); }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.tune { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tune + .tune { margin-top: 6px; }
.tune > summary { list-style: none; cursor: pointer; user-select: none; padding: 8px 10px; font-size: 12.5px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; border-radius: var(--r); }
.tune > summary::-webkit-details-marker { display: none; }
.tune > summary::before { display: none; }
.tune > summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin-left: auto; margin-right: 3px; transition: transform .15s; flex: none; }
.tune[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.tune > summary:hover { background: var(--soft); }
.tune[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; }
.tune > div { padding: 6px 10px 8px; }
.tune > .row, .tune > h4 { margin-left: 10px; margin-right: 10px; }
.tune > h4:first-of-type { margin-top: 10px; }
.tune > div.sliders { padding: 4px 10px 8px; }

/* buttons */
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 12px; font-weight: 500; cursor: pointer; white-space: nowrap; color: var(--text); transition: border-color .12s, background .12s; }
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.wide { width: 100%; padding: 10px 14px; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.icon { padding: 4px 9px; font-size: 16px; line-height: 1; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- stage ---------- */
#stage { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; background: var(--bg); }
.desk { position: relative; overflow: auto; display: flex; justify-content: center; align-items: safe center; padding: 24px; min-height: 0; }
#view { max-width: 100%; max-height: 100%; width: auto; height: auto; cursor: zoom-in; box-shadow: 0 24px 50px var(--shadow), 0 1px 4px var(--shadow); border-radius: 2px; background: #fff; }
.desk.actual #view { max-width: none; max-height: none; cursor: zoom-out; }
.filmstrip { display: flex; gap: 10px; padding: 10px 20px 14px; overflow-x: auto; }
.filmstrip canvas { width: 62px; height: 88px; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.3); cursor: pointer; opacity: .7; }
.filmstrip canvas:hover { opacity: 1; }
.filmstrip canvas.active { opacity: 1; outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- tip ---------- */
.tip { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 14px; padding: 9px 10px 9px 14px; border-radius: 8px; background: var(--ink); color: var(--ink-text); font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.tip .btn { background: transparent; color: inherit; border-color: rgba(255,255,255,.25); }
[data-theme="dark"] .tip .btn { border-color: rgba(0,0,0,.25); }

/* ---------- dialogs ---------- */
.wizard { position: fixed; inset: 0; z-index: 60; background: rgba(20, 18, 14, .45); display: grid; place-items: center; padding: 16px; }
.wizcard { width: min(960px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: hidden; }
.wizcard.narrow { width: min(640px, 100%); }
.wizcard header { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.wizstep { color: var(--muted); font-size: 12px; white-space: nowrap; }
.wiztitle { font-weight: 600; font-size: 14px; flex: 1; }
.wizbody { display: grid; grid-template-columns: 1fr 220px; min-height: 0; overflow: auto; }
.wizcontent { padding: 18px 20px; overflow: auto; }
.wizref { border-left: 1px solid var(--line); padding: 16px; background: var(--bg); }
.wizref-head { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.wizref img { display: block; width: 100%; border-radius: 4px; margin-bottom: 8px; }
.wizcard footer { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.wizcard footer .spacer { flex: 1; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hands { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hand { display: block; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--sample); overflow: hidden; cursor: pointer; text-align: left; }
.hand:hover { border-color: var(--line-strong); }
.hand.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.hand canvas { display: block; width: 100%; height: auto; }
.hand span { display: block; padding: 6px 10px 7px; font-size: 12.5px; font-weight: 500; color: #000; background: var(--sample); border-top: 1px solid rgba(0,0,0,.07); }
.hand.mine span::after { content: ' · yours'; color: #7a776f; font-weight: 400; }
.wizgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.wizab { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wizab .opt { display: block; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--sample); overflow: hidden; cursor: pointer; text-align: left; }
.wizab .opt canvas { display: block; width: 100%; height: auto; }
.wizab .opt span { display: block; padding: 8px 12px; font-weight: 500; color: #000; border-top: 1px solid rgba(0,0,0,.07); }
.wizab .opt:hover { border-color: var(--line-strong); }
.wizab .opt.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.wizmid { margin-top: 10px; text-align: center; }
.wizmid .btn.active { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.letters { display: grid; gap: 14px; }
.letterrow { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 12px; }
.letterrow .lab { font-size: 20px; font-weight: 600; text-align: center; color: var(--muted); }
.letterrow .opts { display: flex; gap: 8px; flex-wrap: wrap; }
.letterrow .opts button { width: 58px; height: 58px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sample); padding: 0; cursor: pointer; }
.letterrow .opts button canvas { display: block; width: 56px; height: 56px; }
.letterrow .opts button.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.wizdone { max-width: 420px; }
.wizdone input { margin: 10px 0; }
.lead.small { font-size: 12.5px; color: var(--muted); margin: 8px 0; }

/* ---------- privacy page ---------- */
body.doc { height: auto; }
.docwrap { max-width: 640px; margin: 0 auto; padding: 40px 24px 80px; font-size: 15px; line-height: 1.6; }
.docwrap h1 { font-weight: 600; font-size: 26px; margin: 12px 0 4px; letter-spacing: -0.02em; }
.docwrap h2 { font-weight: 600; font-size: 15px; margin: 28px 0 6px; }
.docwrap p { margin: 0 0 12px; }
.docwrap .updated { color: var(--muted); font-size: 13px; }
.docwrap .back { text-decoration: none; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 1080px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; height: auto; min-height: 100%; }
  .topbar { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; padding: 8px 10px; height: auto; gap: 6px 8px; }
  .tb-left { order: 1; }
  .tb-right { order: 2; margin-left: auto; justify-self: auto; gap: 6px; }
  .tb-mid { order: 3; flex-basis: 100%; justify-self: auto; }
  #status, #zoom, #shareUrl, #dlpage { display: none; }
  .tb-right .btn { padding: 5px 9px; font-size: 12.5px; }
  body { overflow-x: hidden; }
  #stage { order: 1; }
  #editor { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  #inspector { order: 3; border-left: 0; border-top: 1px solid var(--line); }
  #editor .textbox { min-height: 180px; }
  #editor textarea { min-height: 160px; resize: vertical; }
  .pane { overflow: visible; }
  .desk { padding: 12px; }
  #view { max-height: 70vh; }
  .row { grid-template-columns: 116px 1fr 36px; }
  .wizard { padding: 0; }
  .wizcard { border-radius: 0; height: 100%; }
  .wizbody { grid-template-columns: 1fr; }
  .wizref { border-left: 0; border-top: 1px solid var(--line); }
  .wizab { grid-template-columns: 1fr; }
  .tip { left: 10px; right: 10px; transform: none; flex-wrap: wrap; }
}

.pager { display: flex; align-items: center; gap: 6px; }
.tb-right .link { color: var(--muted); font-size: 12.5px; }
.current-meta .right { margin-left: auto; color: #000; font-weight: 500; }
.links.end { text-align: right; margin-top: 4px; }
.links.end .link { color: var(--muted); }

.refai { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.refresult { margin: 8px 0 0; font-size: 12.5px; color: var(--text); }

/* matcher: choice screen and result */
.choice { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.choice-card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--surface); }
.choice-card.quiet { background: transparent; }
.choice-card h3 { margin: 0 0 6px; font-size: 14px; }
.choice-card p { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.choice-photo img { display: block; max-width: 100%; max-height: 220px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 8px; }
.choice-card .hint a { color: var(--muted); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare figure { margin: 0; }
.compare img, .compare canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.compare figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.result input { margin-top: 10px; max-width: 320px; }
.result .btnrow { margin-top: 12px; }
@media (max-width: 760px) { .choice, .compare { grid-template-columns: 1fr; } }

.coderow { margin: 8px 0; }
.coderow input { max-width: 220px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- tool switcher ---------- */
.switcher { position: relative; }
.switcher .wordmark { background: none; border: 0; padding: 6px 8px 6px 4px; border-radius: var(--r); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.switcher .wordmark svg { color: var(--muted); }
.switcher .wordmark:hover { background: var(--soft); }
.switchmenu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 55; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 6px; }
.sm-head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 10px 4px; }
.sm-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.sm-item span { font-weight: 500; }
.sm-item small { color: var(--muted); font-size: 12px; }
a.sm-item:hover { background: var(--soft); }
.sm-item.current { background: var(--soft); }
.sm-item.muted span { color: var(--muted); font-weight: 400; }
.sm-foot { border-top: 1px solid var(--line); margin-top: 4px; padding: 8px 10px 4px; font-size: 12px; }
.sm-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* Camera controls stay close to the photograph, including on narrow screens. */
#view.camera-view { cursor: crosshair; }
.photo-dock { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 20px 14px; font-size: 12px; color: var(--muted); }
.photo-dock .btnrow { margin: 0; }
.focus-ring { position: absolute; width: 38px; height: 38px; border: 1.5px solid #ffd76a; border-radius: 5px; box-shadow: 0 0 0 1px #0005; pointer-events: none; opacity: 0; }
.shot-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.shot-presets button { padding: 10px; text-align: left; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); cursor: pointer; }
.shot-presets button:hover, .shot-presets button.active { border-color: var(--ink); }
.shot-presets button.active { box-shadow: inset 0 0 0 1px var(--ink); }
.shot-presets strong { display: block; font-size: 12px; font-weight: 600; }
.shot-presets span { display: block; font-size: 10px; line-height: 1.5; color: var(--muted); margin-top: 3px; }

.sheet-form { display: flex; flex-wrap: wrap; margin-bottom: 8px; }
.sheet-form button { flex: 1 1 auto; font-size: 11px; padding: 6px 7px; }
.switch:has(input:disabled) { opacity: .5; }

.surface-select { width: 100%; padding: 10px 34px 10px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.surface-select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
label.subhead { display: block; margin-top: 16px; }
.render-progress { position: absolute; bottom: 35px; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 40px)); display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 15px 17px 12px; border: 1px solid #ffffff30; border-radius: 12px; background: #1e2429eb; color: #faf8ef; box-shadow: 0 8px 35px #0003; backdrop-filter: blur(12px); }
.render-copy strong { display: block; font-size: 12px; font-weight: 500; }
.render-copy span { display: block; font-size: 10px; opacity: .6; margin-top: 3px; }
.render-percent { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .75; }
.render-progress progress { grid-column: 1 / -1; width: 100%; height: 3px; border: 0; border-radius: 5px; overflow: hidden; accent-color: #d9c69b; background: #ffffff20; }
.render-progress progress::-webkit-progress-bar { background: #ffffff20; }
.render-progress progress::-webkit-progress-value { background: #d9c69b; transition: width .2s; }
.render-progress .link { grid-column: 1 / -1; justify-self: center; font-size: 10px; color: #f5eddc; opacity: .7; }
.aperture { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #ffffff35; border-top-color: #e3d0a7; border-right-color: #e3d0a7; animation: aperture-turn 1.8s linear infinite; }
@keyframes aperture-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .aperture { animation: none; } .render-progress progress::-webkit-progress-value { transition: none; } }
