@font-face {
  font-family: 'Pretendard Variable';
  src: url('assets/pretendard-variable.woff2') format('woff2');
  font-weight: 45 930;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --text: #e3ebf2;
  --muted: #b0bcc9;
  --paper: #1b212a;
  --surface: #252d38;
  --recess: #1d252f;
  --line: #3c4958;
  --track: #424f5d;
  --streetlight-gradient: linear-gradient(112deg, #ff9750 4%, #ffbf62 46%, #ffe8a2 96%);
  --accent: #ffcf83;
  --accent-ink: #2a180e;
  --selected-border: #bc854e;
  --hover: #334150;
  --header-surface: #222a34;
  --foil-cycle: 15.444s;
  --ui-font: 'Pretendard Variable', system-ui, 'Malgun Gothic', sans-serif;
  font-family: var(--ui-font);
  color: var(--text);
  background: var(--paper);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
.studio-page, .studio-page body { overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
}
h1, h2, p, figure { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.site-header { flex: none; border-bottom: 1px solid #34404c; background: var(--header-surface); }
.header-inner {
  width: calc(100% - 48px); min-height: 48px; margin-inline: auto;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center;
}
.wordmark { display: flex; align-items: center; gap: 9px; font-weight: 760; font-size: 1.1rem; letter-spacing: -.03em; white-space: nowrap; }
.studio-navigation { justify-self: start; display: flex; align-items: center; gap: 8px; }
.studio-home { text-decoration: none; }
.header-action {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 37px; padding: 5px 13px; border: 1px solid transparent; border-radius: 8px;
  background: linear-gradient(var(--header-surface), var(--header-surface)) padding-box, var(--streetlight-gradient) border-box;
  color: var(--accent); font-size: .9rem; font-weight: 670; white-space: nowrap;
}
.header-action:hover:not(:disabled) { filter: brightness(1.1); }
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .header-action-label {
    background: var(--streetlight-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
  }
}
.mark { display: block; width: 32px; height: 32px; flex: none; }
h1 { font: 740 1.38rem/1.25 var(--ui-font); letter-spacing: -.036em; text-align: center; }
.source-button { justify-self: end; display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; min-height: 40px; padding: 0 0 0 8px; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.source-button:hover { color: var(--accent); }
.info-icon { display: grid; place-content: center; width: 15px; height: 15px; border: 1px solid currentColor; border-radius: 50%; font: 700 .67rem Georgia, serif; }
.studio-page .header-inner { min-height: 54px; }

.workspace {
  --work-side: clamp(14px, 2.1vw, 36px);
  --work-top: 67px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --work-bottom: calc(44px + var(--safe-bottom));
  position: relative;
  isolation: isolate;
  flex: 1;
  min-height: 0;
}
.sheet, .board { position: absolute; inset: 0; }
.board {
  --foil-travel: 1;
  isolation: isolate; overflow: hidden;
  touch-action: none; -webkit-touch-callout: none;
  user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle, #91a8ba20 .8px, transparent 1.2px) center / 22px 22px var(--paper);
}
.board .page-ornaments { --ornament-size: clamp(13px, 1.6vw, 23px); }
.workspace > .page-ornament--sudali { z-index: 1; left: 87%; }
.board .page-ornament--moon { left: 9%; }
.board .page-ornament--star { left: 3px; }
.board .page-ornament--leaf { right: 3px; }
.board .page-ornament--shell { right: 5px; }
.board .page-ornament--gem { top: auto; left: 38%; bottom: calc(var(--safe-bottom) + 10px); }
.fit-area {
  position: absolute; inset: var(--work-top) var(--work-side) var(--work-bottom);
  pointer-events: none;
}
.artwork-frame {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%;
  width: var(--artwork-width); height: var(--artwork-height);
  opacity: 0;
}
.board-content {
  pointer-events: auto;
  isolation: isolate;
  overflow: hidden;
  border-radius: 4px;
  background: #0b0b0d;
  box-shadow: 0 0 0 1px #43515e, 0 12px 42px #0a10154d;
}
.board-content, .scratch-view, .completed-lines-view { position: absolute; inset: 0; }
.board.is-ready .artwork-frame { opacity: 1; animation: artwork-arrival .82s cubic-bezier(.22, .7, .26, 1); }
@keyframes artwork-arrival {
  from { opacity: .12; transform: translateY(18px) scale(.955); }
  to { opacity: 1; transform: none; }
}
.scratch-view[inert] { visibility: hidden; }
.completed-lines-view { background: #0b0b0d; }
.completed-lines-view canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.foil, .foil-colors { position: absolute; z-index: 0; inset: 0; pointer-events: none; }
.foil { overflow: hidden; }
.foil-colors {
  background-color: #0b0b0d;
  background-image: var(--rainbow, linear-gradient(119deg, #ff8b2b, #ff3973, #bc59ff, #24a6fd, #3cffbf, #e9fc33));
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: var(--foil-filter, saturate(1.14) brightness(1.16));
}
.board.has-revealed .foil-colors { animation: foil-tones var(--foil-cycle) ease-in-out calc(var(--foil-cycle) / -4) infinite; }
.board.has-revealed .neon-shades { animation: neon-breathe var(--foil-cycle) ease-in-out -2s infinite; }
.board:is(.is-scratching, .is-panning) :is(.foil-colors, .neon-shades),
.board.has-revealed .scratch-view[inert] :is(.foil-colors, .neon-shades) { animation-play-state: paused; }
@keyframes foil-tones {
  0%, 100% {
    transform: translate(calc(1.65% * var(--foil-travel)), calc(-1% * var(--foil-travel))) scale(calc(1 + .05 * var(--foil-travel)));
    filter: var(--foil-filter-high);
  }
  50% {
    transform: translate(calc(-1.65% * var(--foil-travel)), calc(1% * var(--foil-travel))) scale(calc(1 + .05 * var(--foil-travel)));
    filter: var(--foil-filter-low);
  }
}
@property --neon-radius { syntax: '<number>'; inherits: true; initial-value: 1.5; }
@keyframes neon-breathe {
  0%, 100% { --neon-radius: 0; }
  50% { --neon-radius: 3; }
}
#surface, .neon-shades, .neon-shade { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.neon-shades, .sheen { pointer-events: none; user-select: none; }
#surface { z-index: 2; cursor: crosshair; -webkit-user-drag: none; }
.neon-shades { z-index: 2; --neon-radius: 1.5; }
.neon-shade { opacity: clamp(0, var(--neon-width) - var(--neon-radius), 1); }
.artwork-atmosphere {
  position: absolute; z-index: 3; inset: 0; pointer-events: none;
  background: var(--scene-atmosphere, none) center / 100% 100% no-repeat;
  opacity: 0; mix-blend-mode: screen;
}
.sheen { z-index: 3; position: absolute; inset: 0 auto auto 0; will-change: transform; }
#surface { will-change: transform; }
.board:not(.is-ready) #surface { background: #0b0b0d; }
#surface:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: inherit; }
.board.pointer-input #surface:focus-visible { outline: none; }
.board.has-cursor #surface { cursor: none; }
.board.is-panning, .board.is-panning #surface { cursor: grabbing; }
.brush-cursor {
  z-index: 5; display: none; position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  border: 1px solid #fff2daee; box-shadow: 0 0 0 1px #1a141099; border-radius: 50%;
  width: var(--cursor-size); aspect-ratio: 1; left: var(--cursor-x); top: var(--cursor-y);
}
.board.has-cursor .brush-cursor { display: block; }
.brush-cursor::before { content: ''; position: absolute; inset: 0; margin: auto; width: 3px; height: 3px; border-radius: 50%; background: #fff2da; }
.board[data-tool='free'] .brush-cursor { border-color: var(--accent); }
.board-hint {
  z-index: 6; display: flex; align-items: center; gap: 8px; pointer-events: none; position: absolute; bottom: calc(var(--work-bottom) + 13px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; border-radius: 100px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 7px 12px; font-size: .875rem; letter-spacing: -.015em;
}
.touch-hint { display: none; }
.workspace-status {
  position: absolute; inset: auto var(--work-side) calc(9px + var(--safe-bottom));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px;
  color: var(--muted); font-size: .8125rem; word-break: keep-all; pointer-events: none;
}
.sheet-meta, .view-controls { display: flex; align-items: center; gap: 10px; }
.view-controls { margin-inline-start: auto; }
.workspace-status button { pointer-events: auto; }
.workspace-status .source-button { min-height: 32px; padding: 0 3px; }
.artwork-size { white-space: nowrap; font-variant-numeric: tabular-nums; }
.export-status { margin-top: 8px; }
.wallpaper-setup { display: grid; gap: 12px; margin: 15px 0 0; padding: 0; list-style: none; font-size: .875rem; color: var(--muted); }
.wallpaper-setup li { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; word-break: keep-all; }
.wallpaper-setup a { width: fit-content; color: var(--accent); text-underline-offset: 3px; }
.wheel-help { padding-left: 5px; }
.zoom-reset { min-width: 53px; min-height: 32px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-variant-numeric: tabular-nums; }
.zoom-reset:disabled { opacity: 1; color: var(--muted); }
.zoom-reset:hover:not(:disabled) { background: var(--hover); }

.tool-strip {
  position: absolute; z-index: 2; top: 10px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - var(--work-side) * 2); min-height: 46px; padding: 5px 6px;
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  box-shadow: 0 8px 26px #0a10156b, inset 0 1px #ffffff06;
  font-size: .875rem;
  animation: controls-arrival .42s ease-out;
}
@keyframes controls-arrival {
  from { opacity: .35; translate: 0 -5px; }
  to { opacity: 1; translate: 0 0; }
}
.tool-modes { display: flex; gap: 3px; align-items: center; width: max-content; }
.tool-modes button { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 9px; background: transparent; border: 1px solid transparent; border-radius: 7px; white-space: nowrap; color: var(--muted); }
.tool-modes button:hover { background: var(--hover); color: var(--text); }
.tool-modes button[aria-pressed='true'] { background: var(--streetlight-gradient); border-color: var(--selected-border); color: var(--accent-ink); font-weight: 650; }
.brush-control { display: grid; grid-template-columns: auto clamp(105px, 13vw, 184px) 51px; gap: 7px; align-items: center; min-width: 0; }
.brush-control label { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-weight: 650; }
.pen-icon, .free-icon { display: inline-grid; place-items: center; width: 17px; height: 17px; }
.pen-icon::before { content: ''; width: 15px; height: 5px; background: currentColor; transform: rotate(-43deg); border-radius: 2px; clip-path: polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%); }
.free-icon::before { content: ''; width: 14px; height: 7px; border-block: 1px solid currentColor; border-radius: 45%; transform: rotate(-35deg); }
#brush-size { appearance: none; width: 100%; min-width: 0; height: 34px; margin: 0; border-radius: 4px; background: transparent; cursor: ew-resize; }
#brush-size::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--streetlight-gradient) left center / var(--track-fill, 68%) 100% no-repeat var(--track); }
#brush-size::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -6px; border: 1px solid var(--selected-border); border-radius: 50%; background: var(--accent); }
#brush-size::-moz-range-track { height: 4px; border-radius: 4px; background: var(--track); }
#brush-size::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--streetlight-gradient); }
#brush-size::-moz-range-thumb { width: 14px; height: 14px; border: 1px solid var(--selected-border); border-radius: 50%; background: var(--accent); }
#brush-value, #progress-text { color: var(--accent); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#brush-value { padding: 4px 5px; border-radius: 5px; background: var(--recess); font-weight: 650; }
#brush-value span, #progress-text span { font-size: .75rem; margin-left: 2px; }
.palette-control { position: relative; display: flex; align-items: center; min-height: 34px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); }
.palette-swatch { position: absolute; width: 12px; height: 12px; inset-inline-start: 8px; border-radius: 50%; background: var(--palette-chip, #db945d); pointer-events: none; }
.palette-control::after { position: absolute; inset-inline-end: 8px; width: 5px; height: 5px; border-inline-end: 1px solid; border-block-end: 1px solid; transform: translateY(-1px) rotate(45deg); content: ''; pointer-events: none; }
#palette-select { appearance: none; min-height: 32px; width: 139px; max-width: 100%; padding: 0 20px 0 26px; border: 0; border-radius: 6px; color: inherit; background: transparent; font: inherit; cursor: pointer; text-overflow: ellipsis; }
#palette-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.progress-panel { display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); white-space: nowrap; }
#progress-text { min-width: 54px; font-weight: 650; }
progress { appearance: none; display: block; width: clamp(27px, 6vw, 75px); height: 4px; overflow: hidden; border: 0; border-radius: 99px; background: var(--track); }
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { border-radius: 99px; background: var(--streetlight-gradient); }
progress::-moz-progress-bar { border-radius: 99px; background: var(--streetlight-gradient); }
.tool-actions { display: flex; gap: 3px; padding-left: 8px; border-left: 1px solid var(--line); }
.tool-actions button { position: relative; display: flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 7px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); white-space: nowrap; }
.action-icon { display: inline-grid; place-items: center; width: 15px; font-family: system-ui, sans-serif; font-size: 1.04rem; line-height: 1; }
.tool-actions button:hover:not(:disabled) { background: var(--hover); border-color: var(--selected-border); color: var(--text); }
button.preview-button[aria-pressed='true']:not(:disabled) { background: var(--streetlight-gradient); border-color: var(--selected-border); color: var(--accent-ink); }

dialog { width: min(calc(100% - 32px), 430px); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 23px; box-shadow: 0 14px 50px #0a101580; }
.wallpaper-dialog { width: min(calc(100% - 32px), 490px); }
dialog::backdrop { background: #090e1690; }
dialog h2 { font-size: 1.5rem; font-weight: 740; letter-spacing: -.03em; margin-bottom: 10px; }
dialog p { color: var(--muted); line-height: 1.6; word-break: keep-all; }
.finish-dialog { width: min(calc(100% - 32px), 380px); padding: 28px 23px 24px; text-align: center; }
.finish-star { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%; background: var(--streetlight-gradient); color: var(--accent-ink); font: 1.45rem/1 system-ui, sans-serif; }
.finish-dialog h2 {
  width: max-content; margin: 0 auto 8px; padding: 0 3px;
  color: var(--accent); letter-spacing: -.04em;
  font: 760 clamp(1.75rem, 7vw, 2.2rem)/1.25 var(--ui-font);
}
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .finish-dialog h2 {
    background-image:
      linear-gradient(113deg, transparent 38%, #fff6caa0 46%, #fffbea 50%, #fff6ca80 54%, transparent 62%),
      repeating-linear-gradient(164deg, transparent 0 2px, #3c24176b 2.2px 2.7px, transparent 3px 5px),
      var(--streetlight-gradient);
    background-repeat: no-repeat;
    background-size: 290% 100%, 100% 100%, 100% 100%;
    background-position: 100% 0, 0 0, 0 0;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: finish-glint 3s linear infinite;
  }
}
@keyframes finish-glint {
  0%, 7% { background-position: 100% 0, 0 0, 0 0; }
  30%, 100% { background-position: 0 0, 0 0, 0 0; }
}
.finish-dialog .dialog-actions { justify-content: center; }
.finish-dialog .primary-button { min-width: 112px; }
.source-links, .dialog-actions { display: flex; gap: 9px 14px; flex-wrap: wrap; margin-top: 17px; }
.source-links a { color: var(--accent); font-size: .875rem; text-underline-offset: 3px; }
.dialog-actions { justify-content: end; }
.primary-button, .secondary-button { min-height: 42px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: transparent; font-size: .875rem; }
.primary-button { background: var(--streetlight-gradient); border-color: var(--selected-border); color: var(--accent-ink); }
.primary-button:hover:not(:disabled) { filter: brightness(1.1); }
.secondary-button:hover { background: var(--hover); }
.wallpaper-button {
  justify-self: end; min-height: 42px; padding-inline: 16px;
}

@media (max-width: 1320px) {
  .workspace > .page-ornament--sudali { top: calc(var(--work-top) - 6px); left: auto; right: 7px; }
  .board .page-ornament--moon { top: calc(var(--work-top) + 3px); left: 17%; }
  .board .page-ornament--gem { left: 9%; bottom: calc(var(--work-bottom) + 7px); }
}

@media (max-width: 870px) {
  .workspace { --work-top: 107px; }
  .workspace > .page-ornament--sudali { left: 76%; right: auto; }
  .tool-strip { width: min(100%, 460px); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; }
  .brush-control { grid-row: 2; grid-template-columns: auto minmax(0, 1fr) 43px; }
  .palette-control { grid-row: 1; grid-column: 2; justify-self: end; }
  .tool-actions { grid-row: 2; grid-column: 2; }
  .tool-actions button { min-width: 34px; justify-content: center; }
  .action-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

@media (max-width: 560px) {
  .header-inner { width: calc(100% - 28px); min-height: 51px; grid-template-columns: 1fr auto 1fr; gap: 5px; }
  .studio-page .header-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; }
  .studio-navigation { gap: 5px; }
  .studio-navigation .mark { width: 27px; height: 27px; }
  .brush-control label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  h1 { font-size: clamp(1.045rem, 5vw, 1.25rem); }
  .studio-page h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-action { padding-inline: 8px; font-size: .8rem; }
  .source-button { gap: 4px; padding-left: 0; font-size: .8125rem; }
  .workspace-status .source-button { min-width: 28px; justify-content: center; }
  .source-label { display: none; }
  .info-icon { width: 13px; height: 13px; }
  .brush-control { grid-template-columns: minmax(0, 1fr) 43px; }
  #palette-select { width: 116px; }
  .wheel-help { display: none; }
}

@media (any-pointer: coarse) {
  .wheel-help, .mouse-hint { display: none; }
  .board-hint { width: max-content; max-width: calc(100% - var(--work-side) * 2); white-space: normal; word-break: keep-all; text-align: center; font-size: .8125rem; }
  .touch-hint { display: inline; }
}

@media (max-width: 360px) {
  .workspace { --work-bottom: calc(78px + var(--safe-bottom)); }
  .tool-modes button { gap: 4px; padding-inline: 7px; font-size: .8125rem; }
  .tool-modes :is(.pen-icon, .free-icon) { display: none; }
  #palette-select { width: 108px; }
  .view-controls { gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .board.has-revealed .foil-colors, .board.has-revealed .neon-shades, .finish-dialog h2,
  .board.is-ready .artwork-frame, .tool-strip { animation: none; }
}
