:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --bg-soft: #edf2ea;
  --surface: #fffdf6;
  --surface-strong: #ffffff;
  --ink: #1d2722;
  --muted: #68736c;
  --line: #d6d4c7;
  --accent: #bf5f45;
  --accent-strong: #843d2e;
  --leaf: #477457;
  --sky: #6fa8bf;
  --gold: #d6a73d;
  --shadow: 0 18px 48px rgba(47, 49, 40, 0.13);
  --blank-region: #fbf8ef;
  --paper: #fffdf6;
  --number: #26322b;
  --focus: #1d6fb7;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151816;
  --bg-soft: #1c241f;
  --surface: #202520;
  --surface-strong: #262c27;
  --ink: #f3efe5;
  --muted: #b6b7ad;
  --line: #3a433b;
  --accent: #e28a61;
  --accent-strong: #f0b185;
  --leaf: #8abe8f;
  --sky: #8bbfd0;
  --gold: #efc96c;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.33);
  --blank-region: #2c322c;
  --paper: #222820;
  --number: #f7eedc;
  --focus: #86c5ff;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(111, 168, 191, 0.16), transparent 340px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.paint-region:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 2px solid var(--ink);
  background: linear-gradient(135deg, var(--gold), var(--accent), var(--leaf));
  color: #fffdf6;
  border-radius: 8px;
  font-family: Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
  overflow-wrap: anywhere;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 0.79rem;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.app-shell.is-paint-expanded {
  min-height: 100vh;
}

.app-shell.is-paint-expanded .workspace {
  width: 100%;
  max-width: none;
  grid-template-columns: minmax(0, 1fr);
  padding: 10px;
}

.app-shell.is-paint-expanded .park-rail,
.app-shell.is-paint-expanded .info-panel,
.app-shell.is-paint-expanded .studio-header,
.app-shell.is-paint-expanded .footer-note {
  display: none;
}

.app-shell.is-paint-expanded .tool-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
}

.app-shell.is-paint-expanded .canvas-panel {
  min-height: calc(100vh - 92px);
}

.app-shell.is-paint-expanded .art-frame {
  min-height: calc(100vh - 160px);
}

.app-shell.is-paint-expanded .paint-svg {
  min-height: calc(100vh - 190px);
}

.text-link,
.utility-button,
.ghost-button,
.segment,
.primary-link,
.park-button,
.palette-button,
.trail-card {
  border-radius: 8px;
}

.text-link,
.utility-button,
.ghost-button,
.segment,
.primary-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.text-link {
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
}

.utility-button[aria-pressed="true"],
.segment.is-active,
.primary-link {
  border-color: transparent;
  background: var(--ink);
  color: var(--surface);
}

.sound-button[aria-pressed="true"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #72d17d;
  box-shadow: 0 0 0 4px rgba(114, 209, 125, 0.18);
}

.workspace {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2vw, 28px);
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr) minmax(280px, 360px);
  gap: clamp(14px, 2vw, 24px);
  align-items: start;
  flex: 1;
}

.park-rail,
.canvas-panel,
.controls-panel,
.photo-feature,
.snapshot,
.picture-trail {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow);
}

.park-rail,
.controls-panel,
.info-panel {
  position: sticky;
  top: 84px;
}

.park-rail {
  border-radius: 8px;
  padding: 14px;
}

.rail-heading {
  padding: 4px 4px 12px;
}

.rail-heading p,
.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rail-heading span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.park-list {
  display: grid;
  gap: 8px;
}

.park-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.park-button:hover,
.park-button.is-active {
  border-color: var(--line);
  background: var(--surface-strong);
}

.rank-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.park-button.is-active .rank-badge {
  background: var(--accent);
  color: #fffdf6;
}

.park-button strong,
.park-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.park-button strong {
  font-size: 0.92rem;
}

.park-button span {
  color: var(--muted);
  font-size: 0.78rem;
}

.studio {
  min-width: 0;
}

.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 14px;
}

.studio-header h1 {
  margin: 2px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4.4vw, 4.35rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.studio-header p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}

.visit-chip {
  flex: 0 0 auto;
  max-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.visit-chip strong {
  display: block;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  gap: clamp(14px, 2vw, 20px);
  align-items: start;
}

.canvas-panel,
.controls-panel,
.photo-feature,
.snapshot,
.picture-trail {
  border-radius: 8px;
}

.canvas-panel {
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 78%, var(--bg-soft));
}

.expand-button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: #fffdf6;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.segment {
  min-height: 32px;
  border: 0;
  background: transparent;
}

.ghost-button {
  min-height: 36px;
}

.art-frame {
  padding: clamp(10px, 2vw, 18px);
  overflow: auto;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 34%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in srgb, var(--line) 34%, transparent) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

.paint-svg {
  display: block;
  width: calc(100% * var(--canvas-zoom, 1));
  min-width: 100%;
  height: auto;
  min-height: 460px;
  aspect-ratio: 90 / 62;
  border-radius: 6px;
  background: var(--paper);
  touch-action: none;
  cursor: crosshair;
}

.paint-region {
  stroke: color-mix(in srgb, var(--ink) 80%, transparent);
  stroke-width: 3.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: fill 160ms ease, filter 160ms ease;
}

.paint-region:hover {
  filter: brightness(0.96);
}

.paint-number {
  pointer-events: none;
  fill: var(--number);
  font-weight: 900;
  font-size: 18px;
}

.paint-number-badge {
  pointer-events: none;
  fill: color-mix(in srgb, var(--paper) 88%, transparent);
  stroke: color-mix(in srgb, var(--ink) 52%, transparent);
  stroke-width: 2;
}

.linework {
  pointer-events: none;
  fill: none;
  stroke: color-mix(in srgb, var(--ink) 70%, transparent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.68;
}

.texture-line {
  pointer-events: none;
  fill: none;
  stroke: color-mix(in srgb, var(--ink) 50%, transparent);
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.48;
}

.app-shell.numbers-hidden .paint-labels {
  display: none;
}

.brush-dot {
  pointer-events: none;
  mix-blend-mode: multiply;
}

[data-theme="dark"] .brush-dot {
  mix-blend-mode: screen;
}

.controls-panel {
  padding: 14px;
}

.control-group + .control-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.control-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.control-heading h2,
.photo-feature h2,
.snapshot h2,
.picture-trail h2 {
  margin: 0;
  font-size: 0.98rem;
}

.control-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

.palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.palette-button {
  position: relative;
  min-height: 50px;
  border: 2px solid color-mix(in srgb, var(--line) 90%, transparent);
  background: var(--swatch);
  color: #fff;
  cursor: pointer;
}

.palette-button::before {
  content: attr(data-number);
  position: absolute;
  left: 7px;
  top: 5px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.palette-button.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 32%, transparent);
}

.custom-color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.custom-color input {
  width: 52px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#brush-size {
  width: 100%;
  accent-color: var(--accent);
}

.point-preview {
  display: grid;
  place-items: center;
  height: 58px;
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-soft) 80%, transparent);
}

#point-preview-dot {
  display: block;
  width: var(--point-size, 18px);
  height: var(--point-size, 18px);
  border-radius: 999px;
  background: var(--selected-color, #6aa84f);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.36);
}

.guide-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.guide-list li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.guide-number {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--swatch);
  color: #fff;
  font-weight: 900;
}

.info-panel {
  display: grid;
  gap: 14px;
}

.photo-feature {
  overflow: hidden;
}

.photo-feature img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg-soft);
}

.photo-feature > div,
.snapshot,
.picture-trail {
  padding: 14px;
}

.photo-feature p,
.snapshot p {
  color: var(--muted);
}

.photo-feature .primary-link {
  margin-top: 6px;
  width: 100%;
}

.snapshot ul {
  display: grid;
  gap: 9px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.snapshot li {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.snapshot li::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--accent);
}

.picture-trail > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.trail-card {
  min-height: 94px;
  display: flex;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.58)),
    var(--image);
  background-size: cover;
  background-position: center;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
}

.trail-card span {
  font-size: 0.78rem;
  font-weight: 800;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.footer-note {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 3vw, 32px) 28px;
  color: var(--muted);
  font-size: 0.86rem;
}

.footer-note a {
  color: var(--accent-strong);
  font-weight: 800;
}

@media (max-width: 1440px) {
  .workspace {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .info-panel {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: minmax(280px, 420px) minmax(240px, 1fr);
  }

  .picture-trail {
    grid-column: 1 / -1;
  }

  .picture-trail > div {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .park-rail,
  .controls-panel {
    position: static;
  }

  .park-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-layout,
  .app-shell.is-paint-expanded .tool-layout,
  .info-panel {
    grid-template-columns: 1fr;
  }

  .studio-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .visit-chip {
    text-align: left;
  }

  .paint-svg {
    min-height: 340px;
  }

  .picture-trail > div {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .park-rail,
  .controls-panel,
  .info-panel,
  .studio-header,
  .canvas-toolbar,
  .footer-note {
    display: none !important;
  }

  .workspace,
  .tool-layout,
  .studio,
  .canvas-panel,
  .art-frame {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .paint-svg {
    width: 100% !important;
    min-height: 0 !important;
    border-radius: 0 !important;
  }
}

@media (max-width: 560px) {
  .top-actions,
  .canvas-toolbar {
    width: 100%;
  }

  .text-link,
  .utility-button,
  .ghost-button {
    flex: 1 1 auto;
  }

  .park-list,
  .palette {
    grid-template-columns: 1fr;
  }

  .canvas-toolbar .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  .paint-svg {
    min-height: 280px;
  }
}
