:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-synthesis: none;
  background: #f8f5ed;
  color: #211f19;
  --blue: #263caf;
  --work-ink: #263caf;
  --paper: #f7f1dc;
  --border: #dfd9c7;
  --quiet: #5e5a4d;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid #3f54c9; outline-offset: 4px; }

.shell { width: min(100% - 64px, 1280px); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--border); }
.masthead-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; color: inherit; text-decoration: none; font-size: 21px; letter-spacing: -.055em; font-weight: 800; }
.brand-mark { width: 20px; aspect-ratio: 1; margin-right: 9px; background: var(--blue); border-radius: 50% 50% 50% 4px; transform: rotate(-12deg); }
.brand-period { color: var(--blue); }
.masthead-divider { width: 1px; height: 16px; background: var(--border); }
.section-name { color: var(--quiet); font-size: 14px; }

main { padding-block: 34px 30px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 25px; }
h1 { margin: 0; font-size: clamp(2.15rem, 4.5vw, 3.7rem); line-height: 1.02; letter-spacing: -.082em; }
.intro p { margin: 12px 0 0; color: var(--quiet); font-size: 16px; line-height: 1.5; }
.save { min-height: 46px; padding-inline: 17px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; white-space: nowrap; font-weight: 750; color: #fff; background: var(--blue); border: 1px solid var(--blue); border-radius: 7px; }
.save:not(:disabled):hover { background: #1d2f8d; }
.save svg { width: 19px; height: 19px; }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 310px); overflow: hidden; background: #fffdf6; border: 1px solid var(--border); border-radius: 12px; }
.viewer { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #eae4d1; }
.viewer-header, .compare-controls { display: flex; align-items: center; min-height: 54px; padding-inline: 19px; background: #f5f0e0; }
.viewer-header { gap: 12px; justify-content: space-between; border-bottom: 1px solid var(--border); }
.viewer-header h2, .setting h2 { margin: 0; font-size: 15px; font-weight: 780; letter-spacing: -.025em; }
.dimensions { color: var(--quiet); font: 12px ui-monospace, Consolas, monospace; white-space: nowrap; }

.stage { min-width: 0; display: grid; place-items: center; min-height: 220px; padding: clamp(12px, 3vw, 32px); background-image: radial-gradient(#83775455 .7px, transparent .7px); background-size: 14px 14px; }
.comparison { --split: 45%; position: relative; width: min(100%, var(--preview-width, 670px)); aspect-ratio: var(--aspect, 4 / 3); overflow: hidden; background: var(--paper); box-shadow: 0 10px 26px #40362938, 0 1px 4px #4036294f; cursor: ew-resize; touch-action: pan-y; }
.comparison[data-loading=true] { cursor: default; }
.comparison[data-loading=true] > :not(canvas) { visibility: hidden; }
.comparison canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
#original { clip-path: inset(0 calc(100% - var(--split)) 0 0); }
.tag { pointer-events: none; position: absolute; top: 10px; padding: 5px 8px; border-radius: 4px; background: #211f19dc; color: white; font-size: 12px; font-weight: 720; }
.tag-original { left: 10px; }
.tag-print { right: 10px; }
.comparison[data-original=false] .tag-original, .comparison[data-print=false] .tag-print { display: none; }
.divider { position: absolute; top: 0; left: clamp(0px, var(--split), calc(100% - 2px)); height: 100%; width: 2px; pointer-events: none; background: #fffdf5; box-shadow: 0 0 4px #211f1966; }
.divider span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; height: 30px; width: 34px; color: #202221; white-space: nowrap; border-radius: 50%; background: #fffdf5; box-shadow: 0 2px 8px #211f1944; font-size: 15px; font-weight: 700; }
.comparison[data-original=false] .divider span { left: 9px; }
.comparison[data-print=false] .divider span { left: -8px; }

.compare-controls { gap: 14px; border-top: 1px solid var(--border); }
.compare-controls label { color: var(--quiet); font-size: 13px; font-weight: 680; white-space: nowrap; }
.compare-controls input { flex: 1; min-width: 40px; accent-color: var(--blue); }

.settings { min-width: 0; padding: 22px; border-left: 1px solid var(--border); }
.setting + .setting { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 18px; }
.setting-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 11px; }
.sample { padding: 0; background: transparent; border: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--quiet); font-size: 13px; }
.sample:not(:disabled):hover { color: var(--blue); }
.upload { width: 100%; display: flex; align-items: center; gap: 11px; text-align: left; padding: 11px; border: 1px dashed #a59c83; border-radius: 7px; background: #faf6e8; }
.upload:hover, .upload.is-dragging { background: #f0ead7; border-color: var(--blue); }
.upload svg { flex: 0 0 26px; width: 26px; color: var(--blue); }
.upload strong, .upload small, .effect strong, .effect small { display: block; }
.upload strong, .effect strong { font-size: 14px; }
.upload small, .effect small, .photo-name { color: var(--quiet); font-size: 12px; }
.upload small, .effect small { margin-top: 3px; }
.photo-name { margin: 8px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.effects { display: grid; gap: 7px; margin-top: 10px; }
.effect { display: flex; align-items: center; text-align: left; gap: 10px; padding: 8px; min-height: 54px; background: #fffdf7; border: 1px solid var(--border); border-radius: 7px; }
.effect:hover { border-color: #8a8067; }
.effect[aria-pressed=true] { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); background: #f0f1fe; }
.effect-sample { flex: 0 0 39px; height: 35px; border-radius: 4px; background-color: #f6eed6; border: 1px solid #d8d0b5; }
.pixel-sample { background-image: conic-gradient(var(--work-ink) 0 25%, transparent 0 50%, var(--work-ink) 0 75%, transparent 0); background-size: 12px 12px; }
.dot-sample { background-image: radial-gradient(circle, var(--work-ink) 2.8px, transparent 3.1px); background-size: 10px 10px; background-position: -1px -2px; }

#ink-name { color: var(--quiet); font-size: 13px; }
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.swatch { color: white; aspect-ratio: 1; min-height: 29px; max-height: 42px; border: 1px solid #211f1944; border-radius: 6px; background: var(--color); }
.swatch[aria-pressed=true] { outline: 1px solid #211f19; outline-offset: 2px; }
.swatch[aria-pressed=true]::after { content: '✓'; font-weight: 800; }
.swatch:focus-visible { outline: 2px solid #334dcb; outline-offset: 3px; }

.notice { margin: 10px 0 0; color: #922c20; font-size: 14px; line-height: 1.5; }

@media (max-width: 820px) {
  .shell { width: min(100% - 36px, 732px); }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .settings { border-top: 1px solid var(--border); border-left: 0; }
  .stage { min-height: 0; }
}

@media (max-width: 465px) {
  .shell { width: calc(100% - 28px); }
  .masthead-inner { min-height: 55px; gap: 12px; }
  main { padding-block: 23px; }
  .intro { align-items: flex-start; flex-wrap: wrap; gap: 13px; margin-bottom: 16px; }
  .intro p { margin-top: 7px; font-size: 14px; }
  .save { min-height: 42px; padding-inline: 13px; font-size: 14px; }
  .viewer-header, .compare-controls { min-height: 44px; padding-inline: 12px; }
  .settings { padding: 17px; }
}
