:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f8eef4;
  background: #100e10;
  --panel: #1b171b;
  --studio: #151215;
  --line: #392b35;
  --muted: #c0adb8;
  --accent: #f38dbb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button, select, input { color: inherit; border: 1px solid var(--line); border-radius: 8px; background: #251e25; }
button, a, select, input[type=color], input[type=checkbox] { cursor: pointer; }
button { padding: 9px 12px; font-size: .86rem; font-weight: 600; }
button:hover:not(:disabled) { background: #382632; }
button:disabled { opacity: .43; cursor: default; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.04rem; letter-spacing: -.025em; }
h2 { font-size: .84rem; font-weight: 650; }
h3 { font-size: 1.12rem; margin-bottom: 16px; letter-spacing: -.03em; }

.topbar { border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px max(20px, calc((100% - 1340px) / 2)); }
.brand, .actions { display: flex; gap: 10px; align-items: center; }
.brand img { border-radius: 10px; }
.brand span { display: block; font-size: .75rem; color: var(--muted); margin-top: 3px; }
.primary { background: var(--accent); border-color: transparent; color: #281120; }
.primary:hover:not(:disabled) { background: #ffabd0; }
#export-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px max(15px, calc((100% - 1300px) / 2)); border-bottom: 1px solid #854258; background: #30202a; color: #ffb7d2; font-size: .86rem; }
.primary span { margin-left: 3px; }
.workbench { width: min(1340px, calc(100% - 40px)); margin: 24px auto; display: grid; grid-template-columns: minmax(170px, 230px) minmax(300px, 1fr) minmax(190px, 242px); gap: 16px; align-items: start; }
.sidebar { display: grid; gap: 16px; }
.panel { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin-bottom: 14px; min-height: 27px; }
.compact { font-size: .75rem; padding: 5px 8px; }
.delete-project { margin-top: 9px; color: #ffb6c8; background: transparent; }
label { display: block; font-size: .77rem; color: var(--muted); }
.panel select, input[type=text], input[type=number] { width: 100%; margin: 5px 0 12px; padding: 8px; background: #151116; font-size: .85rem; }
.muted { color: var(--muted); }
.small { font-size: .75rem; line-height: 1.5; }

.layers ul { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 5px; }
.layer { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; gap: 6px; background: transparent; }
.layer[aria-pressed=true] { border-color: #a65482; background: #3b2334; color: #ffcae3; }
.layer small { font-size: .65rem; font-weight: 500; color: var(--muted); }
.layer-actions, .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.layer-actions button { font-size: .75rem; padding: 6px 3px; }

.workspace { min-width: 0; background: var(--studio); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.mode-switch { display: flex; justify-content: center; gap: 5px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.mode-switch button { border-color: transparent; background: transparent; color: var(--muted); }
.mode-switch button[aria-pressed=true] { color: var(--accent); background: #3b2334; border-color: #70425e; }
.canvas-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; padding: 8px; border-bottom: 1px solid var(--line); }
.canvas-tools button[aria-pressed=true] { color: #ffcae3; background: #3b2334; border-color: #a65482; }
.stage { display: grid; place-items: center; min-height: 492px; padding: 26px 22px; background-image: radial-gradient(#41313d 1px, transparent 1px); background-size: 18px 18px; }
.bezel, .screen { border-radius: 22.05% / 19.11%; }
.bezel { width: min(100%, 360px); box-shadow: 0 18px 42px #0008, 0 0 0 1px #695462, 0 0 0 4px #241c22; }
.screen { position: relative; overflow: hidden; isolation: isolate; background: #0b141a; }
#canvas { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }
#canvas.move-photo { cursor: grab; }
#canvas.move-photo.dragging-photo { cursor: grabbing; }
#canvas.clean-preview { cursor: default; touch-action: auto; }
#canvas:focus-visible { outline-offset: -4px; }
.canvas-guide { position: absolute; pointer-events: none; border: 0 dashed var(--accent); filter: drop-shadow(0 0 1px #100e10); }
#guide-x { inset: 0 auto 0 50%; border-left-width: 1px; }
#guide-y { inset: 50% 0 auto 0; border-top-width: 1px; }
.canvas-guide.snapped { border-style: solid; border-color: #ffd0e7; }
#outline { position: absolute; pointer-events: none; border: 1px solid var(--accent); border-radius: 3px; box-shadow: 0 0 0 1px #111a; }
#mark-highlight { position: absolute; pointer-events: none; width: 22px; height: 22px; border: 1px solid var(--accent); border-radius: 100%; box-shadow: 0 0 0 1px #111b; transform: translate(-50%, -50%); }
.stage-footer { display: flex; justify-content: space-between; padding: 11px 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: .74rem; }
.fields input { margin-bottom: 6px; }
#alignment { display: grid; gap: 4px; margin-top: 9px; }
.alignment-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.alignment-row button { font-size: .69rem; padding: 5px 1px; min-height: 30px; }
.check, .color-field { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.color-field input { padding: 1px; width: 31px; height: 26px; }
.background-controls { display: grid; gap: 8px; }
.copy-actions { display: grid; gap: 6px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.background-controls .color-field { margin-top: 0; justify-content: space-between; }
.layer-style { display: grid; gap: 9px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.layer-style button { justify-self: start; }
.analog-marks { margin-top: 0; }
.dial-editor { border: 1px solid var(--line); border-radius: 8px; background: #151116; }
.dial-editor summary { padding: 8px; cursor: pointer; font-size: .8rem; font-weight: 600; }
.dial-controls { display: grid; gap: 9px; padding: 4px 8px 9px; }
.dial-controls input[type=number] { margin-bottom: 0; }
.dial-controls .color-field { justify-content: space-between; }
.mark-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.mark-grid button { justify-self: stretch; min-height: 28px; padding: 5px 0; font-size: .74rem; }
.mark-grid button[aria-pressed=true] { background: #3b2334; color: #f5a2cb; border-color: #a65482; }
.hand-editor { margin-top: 0; }
.hand-editor #hand-tail { margin: 5px 0 0; }
.hand-editor .color-field { justify-content: space-between; margin-top: 0; }
#hand-file-state { margin: 6px 0 9px; }
#hand-preview { display: block; width: 100%; height: auto; margin-bottom: 4px; border-radius: 6px; background: #100d13; border: 1px solid var(--line); cursor: crosshair; }
.panel .font-field select { margin-bottom: 0; }
.range-field { display: grid; gap: 3px; }
.range-field span { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.range-field output { flex: none; font-variant-numeric: tabular-nums; color: #f8eef4; }
.range-field input { width: 100%; margin: 0; accent-color: var(--accent); }
.file-field { position: relative; display: block; padding: 7px 9px; text-align: center; color: #f8eef4; background: #251e25; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
#photo, #hand-file, #mark-file { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); }
.file-field:has(+ input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
#export-result { margin-top: 12px; }
#export-result a { display: inline-block; font-size: .83rem; margin-bottom: 8px; }
#show-qr { display: block; margin: 4px 0; }
#qr-status:empty { display: none; }
#qr-result { display: grid; gap: 8px; margin-top: 9px; }
#qr-code { display: block; width: min(100%, 250px); height: auto; image-rendering: pixelated; }

@media (max-width: 900px) {
  .workbench { width: calc(100% - 26px); gap: 10px; grid-template-columns: 160px minmax(245px, 1fr) 170px; }
  .sidebar { gap: 10px; }
  .panel { padding: 12px; }
  .stage { min-height: 390px; }
}
@media (max-width: 650px) {
  .topbar { padding: 10px; }
  .brand { gap: 4px; }
  .brand img { width: 30px; height: 30px; }
  h1 { font-size: .88rem; }
  .actions { gap: 4px; }
  .actions button { padding: 7px; font-size: .72rem; }
  .workbench { grid-template-columns: 1fr 1fr; margin: 10px auto 18px; align-items: start; }
  .workspace { grid-column: 1/-1; grid-row: 1; }
  .stage { min-height: 0; padding: 23px; }
  .bezel { width: min(100%, 300px); }
  .panel { padding: 10px; }
}

@media (max-width: 440px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .actions { flex-wrap: wrap; }
}
