:root {
  --black: #0a0a0a;
  --ink: #191919;
  --paper: #f4f0e8;
  --muted: #777269;
  --gold: #c5a15a;
  --line: #d9d2c5;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: Arial, Helvetica, sans-serif; }
body { overflow-x: hidden; }
button { font: inherit; }

.site-header {
  min-height: 96px; padding: 10px clamp(22px, 4vw, 58px); background: var(--black); color: white;
  display: flex; align-items: center; justify-content: space-between; gap: 30px; border-bottom: 1px solid #333;
}
.brand { color: white; text-decoration: none; font-size: clamp(20px, 2.2vw, 30px); font-weight: 800; letter-spacing: .07em; white-space: nowrap; display: flex; align-items: center; gap: 16px; }
.brand img { width: 76px; height: 76px; object-fit: contain; flex: 0 0 auto; }
.brand span { display: block; }
.brand em { color: var(--gold); font-style: normal; font-weight: 400; }
.site-header p { margin: 0; color: #aaa; font-size: 13px; letter-spacing: .06em; text-align: right; }

.app-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr) 290px; min-height: calc(100vh - 96px); }
.artwork-panel { background: #111; color: white; padding: 29px 16px 22px; overflow: hidden; }
.artwork-heading { padding: 0 8px 16px; }
.artwork-heading h2 { font-size: 24px; }
.artwork-heading p { margin: 8px 0 0; color: #999; font-size: 11px; }
.artwork-list { height: calc(100vh - 205px); min-height: 480px; overflow-y: auto; padding: 4px 8px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 10px; scrollbar-color: #736a5d #222; }
.artwork-choice { position: relative; width: 100%; aspect-ratio: 1; padding: 0; overflow: hidden; border: 1px solid #373737; background: #1b1b1b; color: white; cursor: pointer; text-align: left; transition: border-color .18s, transform .18s; }
.artwork-choice:hover { transform: translateY(-1px); border-color: #8c7445; }
.artwork-choice.selected { border: 3px solid var(--gold); box-shadow: 0 0 0 1px #111, 0 0 0 3px var(--gold); }
.artwork-thumb { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; background: #333; }
.artwork-choice img { position: absolute; inset: 0 auto 0 0; display: block; width: 114.3%; height: 100%; object-fit: fill; }
.artwork-choice .artwork-number { position: absolute; left: 6px; bottom: 6px; min-width: 30px; height: 24px; padding: 0 7px; display: grid; place-items: center; background: rgba(10,10,10,.9); color: #fff; border: 1px solid var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.art-panel { min-width: 0; display: flex; flex-direction: column; padding: 26px clamp(18px, 3vw, 40px) 22px; }
.art-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.eyebrow { color: #8b6c33; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2 { margin: 5px 0 0; font-family: Georgia, 'Times New Roman', serif; font-weight: 400; }
h1 { font-size: clamp(24px, 3vw, 38px); }
h2 { font-size: 26px; }
.guide-badge { display: inline-block; margin-top: 8px; padding: 5px 8px; background: #e8ddc8; color: #6e5528; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.tool-actions { display: flex; align-items: center; border: 1px solid var(--line); background: #fff; }
.tool-actions button { height: 36px; border: 0; background: white; cursor: pointer; }
.icon-button { width: 38px; font-size: 21px; }
.zoom-label { width: 58px; color: var(--muted); font-size: 11px; border-left: 1px solid var(--line) !important; border-right: 1px solid var(--line) !important; }

.canvas-scroll-shell { position: relative; flex: 1; min-height: 460px; display: flex; align-items: stretch; justify-content: center; }
.canvas-viewport { position: relative; flex: 1; height: min(68vh, 820px); min-height: 460px; overflow-x: auto; overflow-y: auto; overscroll-behavior: contain; background: #d9d5cd; border: 1px solid #c8c1b5; touch-action: pan-x pan-y; cursor: crosshair; scrollbar-width: none; }
.canvas-viewport::-webkit-scrollbar { width: 0; height: 14px; }
.canvas-viewport::-webkit-scrollbar-track { background: #eeeae2; border-left: 1px solid #c8c1b5; }
.canvas-viewport::-webkit-scrollbar-thumb { background: #655f56; border: 4px solid #eeeae2; border-radius: 999px; }
.canvas-viewport::-webkit-scrollbar-thumb:hover { background: #292724; }
.canvas-viewport::-webkit-scrollbar-corner { background: #eeeae2; }
.canvas-stage { position: relative; width: 100%; min-width: 100%; min-height: 100%; padding: 0; display: flex; align-items: flex-start; justify-content: center; }
#paintCanvas { display: block; width: 100%; height: auto; max-width: none; max-height: none; flex: 0 0 auto; background: white; box-shadow: 0 12px 36px rgba(0,0,0,.18); user-select: none; touch-action: pan-x pan-y; }
.image-scrollbar { flex: 0 0 22px; width: 22px; height: min(68vh, 820px); min-height: 460px; margin: 0; writing-mode: vertical-lr; direction: rtl; appearance: slider-vertical; accent-color: var(--gold); background: #24211e; border: 0; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: #ece8df; color: var(--muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.loading.hidden { display: none; }
.canvas-viewport.hinting #paintCanvas { animation: canvasPulse .75s ease; }
@keyframes canvasPulse { 50% { filter: brightness(1.06) drop-shadow(0 0 14px rgba(197,161,90,.75)); } }

.bottom-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 18px; }
.progress-wrap { flex: 1; max-width: 410px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 10px; letter-spacing: .12em; }
.progress-track { height: 4px; background: #d8d1c5; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s ease; }
.history-actions { display: flex; gap: 8px; }
.text-button, .primary-button, .secondary-button, .ghost-button { border: 0; cursor: pointer; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.text-button { background: transparent; padding: 11px 8px; color: var(--ink); }
.text-button:disabled { opacity: .35; cursor: default; }
.primary-button { background: var(--black); color: white; padding: 12px 18px; }

.palette-panel { background: #fff; border-left: 1px solid var(--line); padding: 29px 25px; overflow-y: auto; }
.palette-heading p { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 10px 0 20px; }
.palette-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch-button { aspect-ratio: 1; position: relative; border: 1px solid #bbb4a8; background: var(--swatch); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.swatch-button span { position: absolute; top: 5px; left: 6px; min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; background: #fff; color: #111; border: 1px solid #111; border-radius: 999px; font-size: 11px; font-weight: 900; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,.24); }
.swatch-button:hover { transform: translateY(-2px); }
.swatch-button.selected { outline: 3px solid var(--black); outline-offset: 2px; z-index: 1; }
.selected-card { display: flex; align-items: center; gap: 12px; margin: 20px 0 12px; padding: 11px; background: #f3f0ea; }
.selected-swatch { width: 34px; height: 34px; background: #f5a019; border: 1px solid #aaa; }
.selected-card small { display: block; color: var(--muted); font-size: 8px; letter-spacing: .15em; }
.selected-card strong { display: block; margin-top: 3px; font-size: 12px; }
.secondary-button, .ghost-button { width: 100%; padding: 12px; }
.secondary-button { background: var(--gold); color: #111; margin-bottom: 8px; }
.ghost-button { background: white; color: var(--ink); border: 1px solid #bdb5a9; }
.tip { margin: 18px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 20px); background: #111; color: white; padding: 11px 16px; font-size: 12px; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.site-footer { background: var(--black); color: #aaa; padding: 18px clamp(22px, 4vw, 58px); border-top: 1px solid #333; font-size: 10px; line-height: 1.6; letter-spacing: .04em; text-align: center; }

@media (max-width: 820px) {
  .site-header { position: sticky; top: 0; z-index: 30; min-height: 68px; padding: 6px 14px; }
  .brand { gap: 10px; }
  .brand img { width: 54px; height: 54px; }
  .brand span { font-size: 17px; }
  .site-header p { display: none; }
  .app-shell { display: flex; flex-direction: column; min-height: auto; }
  .artwork-panel { order: 1; padding: 14px; overflow: visible; }
  .artwork-heading { padding: 0 0 10px; }
  .artwork-heading h2 { font-size: 21px; }
  .artwork-heading p { font-size: 13px; }
  .artwork-list { height: auto; min-height: 0; overflow-x: auto; overflow-y: hidden; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 84px; gap: 9px; padding: 3px 3px 10px; scroll-snap-type: x proximity; }
  .artwork-choice { scroll-snap-align: start; }
  .palette-panel { order: 2; border-left: 0; border-top: 1px solid var(--line); padding: 16px 14px 14px; }
  .palette-heading { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 12px; }
  .palette-heading .eyebrow { grid-column: 1 / -1; }
  .palette-heading h2 { font-size: 21px; white-space: nowrap; }
  .palette-heading p { margin: 5px 0 12px; font-size: 13px; line-height: 1.4; }
  .palette-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; }
  .swatch-button { min-height: 36px; }
  .swatch-button span { top: 3px; left: 3px; min-width: 19px; height: 19px; padding: 0 4px; font-size: 10px; }
  .selected-card { margin: 13px 0 9px; }
  .secondary-button, .ghost-button { min-height: 44px; }
  .tip { font-size: 12px; margin-top: 12px; }
  .art-panel { order: 3; min-height: 0; padding: 18px 14px 20px; }
  .art-toolbar { align-items: center; margin-bottom: 12px; }
  .art-toolbar h1 { font-size: clamp(20px, 5.8vw, 27px); }
  .guide-badge { font-size: 10px; }
  .tool-actions button { min-width: 44px; height: 44px; }
  .zoom-label { width: 62px; }
  .canvas-scroll-shell { min-height: 58svh; }
  .canvas-viewport { height: 58svh; min-height: 420px; }
  .image-scrollbar { height: 58svh; min-height: 420px; flex-basis: 20px; width: 20px; }
  .bottom-bar { align-items: stretch; flex-direction: column; }
  .progress-wrap { max-width: none; }
  .history-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .history-actions button { min-height: 46px; }
}

@media (max-width: 460px) {
  .brand span { max-width: 150px; white-space: normal; line-height: 1.05; }
  .palette-heading { display: block; }
  .palette-heading h2 { white-space: normal; }
  .palette-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
  .swatch-button { min-height: 48px; }
  .swatch-button span { top: 5px; left: 5px; min-width: 22px; height: 22px; font-size: 11px; }
  .art-toolbar { align-items: flex-start; flex-direction: column; }
  .tool-actions { align-self: stretch; justify-content: space-between; }
  .tool-actions button { flex: 1; }
  .canvas-viewport { min-height: 390px; }
  .image-scrollbar { min-height: 390px; }
  .canvas-stage { padding: 0; }
  .site-footer { padding: 16px; font-size: 11px; }
}
