:root {
  color-scheme: light;
  --paper: #f9f0f2;
  --sheet: #fffafb;
  --ink: #33213c;
  --muted: #68576d;
  --line: #dfcdd8;
  --accent: #804376;
  --select: #eacfe3;
  --body: 'Yu Gothic UI', 'Hiragino Kaku Gothic ProN', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 var(--body); }
button, input, select { font: inherit; }
button, select, .manual-link { border: 1px solid var(--line); border-radius: 7px; background: var(--sheet); color: var(--ink); cursor: pointer; padding: .58em .85em; font-weight: 650; }
button:hover:not(:disabled), select:hover, .manual-link:hover { border-color: var(--accent); }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type='range'], input[type='checkbox'] { accent-color: var(--accent); }
.topbar { min-height: 66px; padding: 12px clamp(16px, 4vw, 64px); display: flex; flex-wrap: wrap; align-items: center; gap: 9px clamp(12px, 1.6vw, 24px); border-bottom: 1px solid var(--line); background: var(--sheet); }
.brand, .toolbar, .headline, .stage-tools, .timeline { display: flex; align-items: center; }
.brand { min-width: 0; gap: 10px; font-size: 18px; letter-spacing: .045em; }
.brand strong { overflow-wrap: anywhere; }
.brand .mark, .brand .version { flex: none; }
.mark { display: grid; grid-template-columns: repeat(2, 8px); gap: 2px; transform: rotate(-12deg); }
.mark i { height: 8px; border-radius: 1px; background: var(--ink); }
.mark i:nth-child(2) { background: #cb7990; }
.mark i:nth-child(3) { background: #8a758f; }
.mark i:nth-child(4) { background: #edbb88; }
.version { font: 10px/1.5 'Cascadia Mono', monospace; letter-spacing: .09em; color: var(--muted); }
.toolbar, .undo-tools { display: flex; gap: 7px; flex-wrap: wrap; }
.toolbar { justify-content: flex-end; margin-inline-start: auto; max-width: 100%; min-width: 0; }
.toolbar :is(button, .manual-link) { flex: none; white-space: nowrap; }
.manual-link { display: inline-flex; align-items: center; gap: .45em; white-space: nowrap; text-decoration: none; }
.manual-link span { color: var(--muted); font-size: .77em; letter-spacing: .04em; }
#project-saves { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; color: var(--muted); font-size: 11px; }
@media (min-width: 1280px) { #project-saves { position: static; width: auto; height: auto; overflow: visible; clip-path: none; } }
.ink-button, .play-button { background: var(--ink); color: white; border-color: var(--ink); }
.play-button { padding: .8em 1.23em; border-radius: 30px; white-space: nowrap; background: var(--accent); border-color: var(--accent); }
main { display: grid; grid-template-columns: minmax(0, 1fr) 282px; max-width: 1540px; margin: auto; gap: clamp(18px, 3vw, 44px); padding: 36px clamp(16px, 4vw, 64px) 24px; align-items: start; }
main.single-screen { grid-template-columns: minmax(0, 1fr); }
.stage { min-width: 0; }
.headline { justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.project-label { color: var(--accent); font-size: 12px; font-weight: 750; margin: 0 0 7px; overflow-wrap: anywhere; }
h1 { margin: 0; font: 750 clamp(23px, 3.2vw, 52px)/1.15 'Yu Mincho', 'Hiragino Mincho ProN', Georgia, serif; letter-spacing: -.045em; }
h2 { font-size: 23px; margin: 0; }
.stage-tools { justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.screen-nav { flex-shrink: 0; font-size: 13px; }
.gallery-hint { margin: 0 0 16px; color: var(--muted); }
.source-menu { position: relative; }
.source-menu summary { list-style: none; cursor: pointer; border: 1px solid var(--line); background: var(--sheet); border-radius: 7px; padding: .58em .85em; font-weight: 650; }
.source-menu summary::-webkit-details-marker { display: none; }
.source-menu summary::after { content: ' ▾'; }
.source-menu > div { position: absolute; inset: auto 0 auto auto; z-index: 1; display: grid; gap: 6px; padding: 7px; margin-top: 4px; background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #33213c20; white-space: nowrap; }
.source-menu button { text-align: left; }
#import { flex: none; margin-inline: auto; min-height: 46px; white-space: nowrap; padding: .65em 1.2em; font-size: 16px; font-weight: 800; }
.import-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 12px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--sheet); }
.import-feedback progress { width: min(100%, 130px); accent-color: var(--accent); }
.import-feedback[data-state='error'] { color: #8b2437; background: #f8e2e4; }
.trace-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 13px; margin: -3px 0 13px; font-size: 12px; }
#trace { min-width: 148px; min-height: 46px; padding: .58em 1.35em; border-color: #801f55; background: #a12e6a; color: white; font-size: 16px; font-weight: 800; box-shadow: 0 2px 0 #801f55; }
#trace:hover:not(:disabled) { border-color: #691944; background: #862458; }
#trace:active:not(:disabled) { box-shadow: none; }
.trace-row small { color: var(--muted); }
.current-source { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 7px; min-width: 0; overflow-wrap: anywhere; }
.trace-row .play-button { margin-inline-start: auto; }
.speed-control { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.speed-control output { min-width: 31px; }
.trace-row .speed-control input, .timeline .speed-control input { width: 70px; min-width: 47px; margin: 0; }
.switch { display: flex; gap: 3px; background: #f1e2ec; border-radius: 8px; padding: 4px; }
#work-views { flex-wrap: wrap; }
.switch button { border-color: transparent; background: transparent; }
button[aria-pressed='true'] { background: var(--sheet); border-color: var(--line); }
.views { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(9px, 1.5vw, 20px); }
.views:has(> .art:only-child) { grid-template-columns: minmax(0, 1fr); }
.views > .art:only-child { width: min(100%, 650px); justify-self: center; }
.views.work-grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 12px; }
.work-card { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; text-align: left; padding: 12px; background: var(--sheet); border: 1px solid var(--line); border-radius: 11px; }
.work-card h2 { font-size: 14px; overflow-wrap: anywhere; }
.work-previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.work-preview { min-width: 0; display: grid; gap: 4px; align-content: start; padding: 6px; text-align: left; font-size: 12px; }
.work-preview img, .work-preview-empty { width: 100%; aspect-ratio: 1 / 1.08; border-radius: 4px; background: #f0e9ef; }
.work-preview img { display: block; object-fit: contain; }
.work-preview-empty { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.work-card span { overflow-wrap: anywhere; line-height: 1.25; }
.work-card small { color: var(--muted); font-size: 10px; }
.work-edit { justify-self: start; font-size: 12px; }
.art { background: var(--sheet); border: 1px solid var(--line); border-radius: 11px; margin: 0; padding: 8px; min-width: 0; overflow: hidden; }
.art figcaption { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; padding: 0 5px 8px; font-weight: 700; overflow-wrap: anywhere; }
.art figcaption small { color: var(--muted); font-size: 11px; text-align: right; }
.art figcaption small:empty { display: none; }
.art[data-variant='source'] .pending-trace { padding: 2px 6px; border-radius: 4px; background: #efe2ec; font-weight: 700; }
.art-save { margin-inline-start: auto; padding: .25em .6em; font-size: 12px; }
.art canvas, #movie { display: block; width: 100%; height: auto; max-height: 600px; object-fit: contain; background: white; border-radius: 6px; }
.art[data-variant='a'] { border-top: 3px solid #aa7565; }
.art[data-variant='b'] { border-top: 3px solid #8f68a3; }
.inspector { min-width: 0; background: var(--sheet); border: 1px solid var(--line); border-radius: 13px; padding: 16px; }
.inspector h2 { font-size: 17px; }
.ink-settings > h2 { margin-bottom: 10px; }
#palette-settings { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
#palette-settings summary { cursor: pointer; font-weight: 700; }
.palette-purpose { margin: 7px 0; font-size: 12px; color: var(--muted); }
#color-view { margin-bottom: 10px; font-size: 12px; }
.pen-setting { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; font-weight: 650; }
.pen-setting select { flex: 0 1 58%; min-width: 0; }
.pen-strength { display: grid; grid-template-columns: 1fr auto; gap: 3px 6px; font-size: 12px; color: var(--muted); margin-bottom: 9px; }
.pen-strength input { grid-column: span 2; width: 100%; margin: 0; }
.roles-label, .role-row { display: grid; grid-template-columns: minmax(0, 1fr) 36px 36px 24px; gap: 6px; align-items: center; }
.role-row input[type='checkbox'] { justify-self: center; }
.role-row:not([data-used]) { color: var(--muted); }
.roles { max-height: 345px; overflow: auto; }
.roles-label { font-size: 10px; color: var(--muted); padding: 0 6px 5px; }
.role-row { border-top: 1px solid #f0e3ec; padding: 4px 6px; }
.role-row:has(button[aria-pressed='true']) { background: #f4e5ee; }
.role-row button { padding: 3px 4px; background: transparent; border-color: transparent; text-align: left; overflow-wrap: anywhere; }
.role-row .layer-color { width: 100%; min-height: 27px; padding: 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--sheet); }
.layer-color span { display: block; height: 19px; border: 1px solid #33213c32; border-radius: 2px; }
#color-dialog { width: min(380px, calc(100% - 28px)); max-height: calc(100% - 28px); color: var(--ink); background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; padding: 19px; box-shadow: 0 14px 42px #33213c35; }
#color-dialog::backdrop { background: #33213c68; }
#color-heading { font-size: 21px; }
#color-target { color: var(--muted); margin: 3px 0 13px; overflow-wrap: anywhere; }
.color-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 13px; font-size: 12px; }
.color-chip { display: block; height: 42px; margin-top: 3px; border: 1px solid var(--line); border-radius: 6px; }
.color-code, .color-sliders label { display: grid; grid-template-columns: 7em minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; }
#color-hex { width: 100%; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); background: white; border-radius: 6px; color: var(--ink); font-family: 'Cascadia Mono', monospace; }
.color-sliders { display: grid; gap: 6px; margin-top: 10px; }
.color-sliders label { grid-template-columns: 2em minmax(0, 1fr); }
.color-sliders input { width: 100%; margin: 0; }
#color-red { accent-color: #aa3044; }
#color-green { accent-color: #357a4d; }
#color-blue { accent-color: #3a62a1; }
.color-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.quick-row, .quick-colors { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.quick-row { margin-top: 9px; font-size: 11px; }
.quick-row button { padding: 1px 7px; }
.quick-colors { margin-top: 5px; }
.quick-colors button { padding: 3px; width: 25px; height: 23px; border-radius: 4px; }
.quick-colors button[aria-pressed='true'] { outline: 1px solid var(--accent); outline-offset: 1px; }
.quick-colors span { display: block; height: 100%; border-radius: 2px; }
.preview-heading, .export-controls { display: flex; gap: 12px; align-items: center; }
.preview-heading { flex-wrap: wrap; margin-bottom: 14px; }
.preview-heading h2 { font-size: 19px; }
.preview-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 322px); gap: clamp(12px, 2vw, 24px); align-items: start; max-width: 1070px; }
#export-image canvas { max-height: min(64vh, 640px); }
.export-panel { padding: 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: 11px; }
.export-panel h2 { font-size: 17px; margin-bottom: 10px; }
#export-target { margin: 0 0 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.export-controls { align-items: end; }
.export-controls > div { flex: 1; min-width: 0; }
.export-controls label { display: block; margin-bottom: 4px; font-size: 12px; }
#export-type { width: 100%; }
.export-size { margin-top: 12px; }
.export-size label { display: block; margin-bottom: 4px; font-size: 12px; }
#export-size { width: 100%; }
#export { min-width: 78px; }
#export-status { overflow-wrap: anywhere; }
#export-help:empty, #export-status:empty, #export-size-note:empty { display: none; }
.highlight { display: block; font-size: 12px; margin-top: 12px; }
.hint, .settings p { font-size: 12px; color: var(--muted); margin: 7px 0 0; }
.settings { margin-top: 10px; }
.settings summary { cursor: pointer; font-weight: 650; }
.settings label { display: block; margin: 5px 0; font-size: 12px; }
.settings input { width: 100%; }
.replay { background: #f0dfe8; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; padding: 8px; }
#movie { width: min(100%, 495px); margin: 0 auto; }
.timeline { gap: 9px; padding-top: 8px; font-size: 12px; flex-wrap: wrap; }
#scrub { flex: 1; min-width: 70px; }
#phase { min-width: 56px; }
#trace-monitor {
  --monitor-bg: #33263c;
  --monitor-text: #fff5fb;
  --monitor-muted: #dec9df;
  --monitor-line: #635269;
  min-width: 0; margin-top: 8px; padding: 12px; border-radius: 8px;
  background: var(--monitor-bg); color: var(--monitor-text); font-size: 12px;
}
.trace-monitor-header { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; margin-bottom: 8px; }
.trace-monitor-header h2 { margin: 0; font-size: 14px; }
#trace-monitor-state { flex: none; color: var(--monitor-muted); font-weight: 700; letter-spacing: .07em; }
#trace-monitor[data-live] #trace-monitor-state { color: #ffc3ad; animation: trace-signal 1.35s steps(1) infinite; }
#trace-monitor[data-painting] [data-monitor-trace], #trace-monitor:not([data-painting]) [data-monitor-paint] { display: none; }
@keyframes trace-signal { 50% { color: #fff5fb; } }
.trace-scope { position: relative; overflow: hidden; border-radius: 4px; background: #fbf6fa; color: var(--ink); }
#trace-zoom { display: block; width: 100%; height: auto; }
.trace-scope:has(#trace-zoom-hint[hidden])::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(#8043764a, #8043764a) center / 1px 100% no-repeat,
    linear-gradient(#8043764a, #8043764a) center / 100% 1px no-repeat;
}
#trace-zoom-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.trace-zoom-label { position: absolute; left: 6px; top: 6px; padding: 1px 5px; border-radius: 3px; background: var(--monitor-bg); color: var(--monitor-text); font-size: 10px; }
.trace-readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 10px; margin: 8px 0; }
.trace-readout > div { padding: 4px 0; border-bottom: 1px solid var(--monitor-line); }
.trace-readout dt, .trace-progress label { color: var(--monitor-muted); font-size: 11px; }
.trace-readout dd, .trace-progress > span { margin: 0; font: 600 12px/1.5 ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.trace-readout > div:nth-child(-n+4) dd { font-size: 14px; }
.trace-readout dd small { display: block; color: var(--monitor-muted); font-size: 10px; }
.trace-color { display: flex; align-items: center; gap: 6px; }
#trace-color-chip { width: 13px; height: 13px; flex: none; border: 1px solid var(--monitor-muted); border-radius: 3px; }
.trace-progress { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 8px; }
.trace-progress progress { grid-column: 1 / -1; width: 100%; height: 5px; accent-color: #f2a78e; }
.trace-method { margin: 10px 0 0; font-size: 11px; color: var(--monitor-muted); }
.trace-method strong { color: var(--monitor-text); }
@media (min-width: 1120px) {
  .replay:has(#trace-monitor:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1fr) 254px; gap: 8px; align-items: start; }
  #trace-monitor { margin-top: 0; }
}
@media (max-width: 740px) {
  .replay:has(#trace-monitor:not([hidden])) #movie { max-height: min(42svh, 420px); }
}
footer { border-top: 1px solid var(--line); color: var(--muted); padding: 12px clamp(16px, 4vw, 64px); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; font-size: 12px; }
#status { color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 740px) { .toolbar { flex-basis: 100%; } #import { margin-inline: auto 0; } }
@media (max-width: 900px) { main { grid-template-columns: minmax(0, 1fr) 244px; gap: 14px; padding-top: 24px; } .inspector { padding: 12px; } }
@media (max-width: 740px) { main, .preview-layout { grid-template-columns: minmax(0, 1fr); } .inspector { width: 100%; } .headline { margin-bottom: 16px; flex-wrap: wrap; } .source-menu > div { position: static; white-space: normal; } #export-image canvas { max-height: 51vh; } }
@media (max-width: 540px) { .brand { font-size: 14px; gap: 7px; } #import { padding-inline: .7em; font-size: 14px; } .toolbar { justify-content: flex-start; font-size: 12px; } .toolbar :is(button, .manual-link) { padding-inline: .62em; } }
@media (max-width: 400px) { .stage-tools { font-size: 12px; } .play-button { padding: .65em .8em; font-size: 12px; } .art { padding: 4px; } .art figcaption { font-size: 11px; } .art figcaption small { font-size: 9px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  #trace-monitor[data-live] #trace-monitor-state { animation: none; }
}
