:root {
  --paper: #f7f5fb;
  --paper-strong: #ffffff;
  --ink: #23212e;
  --ink-soft: #686473;
  --ink-faint: #9893a4;
  --line: #e8e5ef;
  --line-strong: #d8d3e4;
  --violet: #6658e8;
  --violet-dark: #4a3fc2;
  --violet-soft: #edeaff;
  --coral: #ff7d66;
  --coral-soft: #fff0ec;
  --lime: #c6ed8c;
  --green: #2eb27b;
  --stage: #21212c;
  --stage-soft: #2c2c3a;
  --shadow-sm: 0 2px 8px rgba(35, 33, 46, 0.05);
  --shadow-md: 0 12px 32px rgba(44, 34, 82, 0.08);
  --shadow-lg: 0 22px 60px rgba(44, 34, 82, 0.13);
  --radius-lg: 24px;
  --radius-md: 16px;
  --ease: cubic-bezier(0.22, 0.8, 0.2, 1);
}

[data-theme="dark"] {
  --paper: #17161f;
  --paper-strong: #211f2a;
  --ink: #f8f6ff;
  --ink-soft: #b8b3c6;
  --ink-faint: #777186;
  --line: #332f3e;
  --line-strong: #484154;
  --violet-soft: #272441;
  --coral-soft: #34221f;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  transition: background 220ms ease, color 220ms ease;
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.45;
  background-image: radial-gradient(rgba(102, 88, 232, 0.11) 0.8px, transparent 0.8px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.skip-link { position: fixed; top: 12px; left: 16px; z-index: 1000; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--paper-strong); transform: translateY(-180%); transition: transform 180ms ease; }
.skip-link:focus-visible { transform: translateY(0); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(102, 88, 232, 0.35);
  outline-offset: 3px;
}

.app-shell { width: min(1440px, 100%); margin: 0 auto; padding: 0 48px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark { display: inline-grid; width: 34px; height: 34px; color: var(--ink); }
.brand-mark svg { width: 34px; height: 34px; }
.brand-copy { display: flex; flex-direction: column; gap: 0; line-height: 1.1; }
.brand-copy strong { font-size: 17px; letter-spacing: -0.04em; }
.brand-copy span { margin-top: 3px; color: var(--ink-faint); font-size: 10px; letter-spacing: 0.16em; }
.topnav { display: inline-flex; align-items: center; gap: 28px; margin-left: 100px; }
.topnav-link { position: relative; padding: 10px 0; color: var(--ink-soft); font-size: 13px; transition: color 180ms ease; }
.topnav-link::after { position: absolute; right: 0; bottom: 3px; left: 0; height: 2px; content: ""; background: var(--violet); transform: scaleX(0); transform-origin: center; transition: transform 180ms ease; }
.topnav-link:hover, .topnav-link.active { color: var(--ink); }
.topnav-link.active::after { transform: scaleX(1); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.local-badge { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(46, 178, 123, 0.13); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.tiny-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-strong); cursor: pointer; transition: border-color 180ms ease, background 180ms ease, color 180ms ease; }
.icon-button:hover { border-color: var(--violet); color: var(--violet); }
.icon-button.small { width: 44px; height: 44px; border-radius: 10px; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(310px, 0.9fr); align-items: center; gap: 80px; min-height: 470px; padding: 74px 0 60px; }
.hero-copy { max-width: 690px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; margin: 0 0 18px; color: var(--violet); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: 0.17em; }
.eyebrow-line { display: inline-block; width: 26px; height: 1px; background: currentColor; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 22px; font-size: clamp(38px, 5.2vw, 72px); font-weight: 700; letter-spacing: -0.07em; line-height: 1.08; }
h1 em, .about-card em { color: var(--violet); font-style: normal; }
.hero-subtitle { max-width: 560px; margin-bottom: 28px; color: var(--ink-soft); font-size: 16px; line-height: 1.75; }
.hero-points { display: flex; flex-wrap: wrap; gap: 16px 22px; color: var(--ink-soft); font-size: 12px; }
.hero-points span { display: inline-flex; align-items: center; gap: 7px; }
.hero-points .tiny-icon { color: var(--green); }
.hero-art { position: relative; min-height: 310px; overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: var(--paper-strong); box-shadow: var(--shadow-md); isolation: isolate; }
.hero-art::before { position: absolute; top: -80px; right: -80px; width: 260px; height: 260px; border-radius: 50%; content: ""; background: var(--violet-soft); }
.hero-art::after { position: absolute; bottom: -70px; left: -50px; width: 180px; height: 180px; border-radius: 50%; content: ""; background: var(--coral-soft); }
.art-grid { position: absolute; inset: 42px 38px; border: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 20px 20px; opacity: 0.8; transform: rotate(-8deg); }
.art-bead { position: absolute; z-index: 2; width: 48px; height: 48px; border-radius: 14px; box-shadow: inset 4px 4px 0 rgba(255,255,255,0.36), inset -4px -5px 0 rgba(24, 22, 35, 0.14), 0 9px 17px rgba(29, 25, 49, 0.15); transform: rotate(8deg); }
.art-bead-a { top: 94px; left: 28%; background: var(--coral); }
.art-bead-b { top: 145px; left: 43%; background: var(--violet); transform: rotate(-7deg); }
.art-bead-c { top: 85px; left: 58%; width: 34px; height: 34px; border-radius: 11px; background: var(--lime); transform: rotate(14deg); }
.art-bead-d { top: 186px; left: 59%; width: 34px; height: 34px; border-radius: 11px; background: #ffcf61; transform: rotate(3deg); }
.art-note { position: absolute; z-index: 3; color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: 0.12em; }
.note-top { top: 21px; left: 22px; }
.note-bottom { right: 22px; bottom: 18px; }
.art-label { position: absolute; right: 28px; bottom: 47px; z-index: 3; color: var(--ink); font-family: "DM Mono", monospace; font-size: 12px; font-weight: 500; letter-spacing: 0.12em; line-height: 1.55; text-align: right; }

.studio-wrap { padding-top: 26px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: clamp(26px, 3vw, 38px); letter-spacing: -0.06em; line-height: 1.15; }
.section-heading.centered { display: block; text-align: center; }
.section-heading.centered .eyebrow { justify-content: center; }
.text-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 0; border: 0; background: transparent; color: var(--ink-soft); font-size: 12px; cursor: pointer; transition: color 180ms ease; }
.text-button:hover { color: var(--violet); }
.studio-layout { display: grid; grid-template-columns: 276px minmax(0, 1fr) 276px; align-items: stretch; gap: 16px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--paper-strong) 94%, transparent); box-shadow: var(--shadow-sm); }
.controls-panel, .stats-panel { display: flex; flex-direction: column; padding: 24px; }
.panel-title-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.panel-kicker { display: block; margin-bottom: 5px; color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: 0.16em; }
.panel h3 { margin: 0; font-size: 18px; letter-spacing: -0.04em; }
.step-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--violet-soft); color: var(--violet); font-family: "DM Mono", monospace; font-size: 10px; }
.step-icon.coral { background: var(--coral-soft); color: var(--coral); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-height: 182px; padding: 22px 15px; border: 1px dashed color-mix(in srgb, var(--violet) 62%, var(--line)); border-radius: 17px; background: color-mix(in srgb, var(--violet-soft) 45%, var(--paper-strong)); color: var(--ink); cursor: pointer; transition: border-color 180ms ease, background 180ms ease, transform 180ms var(--ease); }
.dropzone:hover, .dropzone.dragover { border-color: var(--violet); background: var(--violet-soft); transform: translateY(-2px); }
.dropzone-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 15px; background: var(--paper-strong); color: var(--violet); box-shadow: var(--shadow-sm); }
.dropzone-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.dropzone-title { font-size: 13px; font-weight: 600; }
.dropzone-hint { margin-top: 3px; color: var(--ink-faint); font-size: 10px; }
.file-meta { display: grid; grid-template-columns: 44px minmax(0, 1fr) 30px; align-items: center; gap: 10px; margin-top: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper-strong); }
.file-meta img { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--violet-soft); }
.file-meta-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.file-meta-copy strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.file-meta-copy span { color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 9px; }
.divider { height: 1px; margin: 22px 0; background: var(--line); }
.control-section { margin-bottom: 22px; }
.control-section:last-of-type { margin-bottom: 0; }
.control-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; color: var(--ink); font-size: 12px; font-weight: 600; }
.control-label-row label { cursor: pointer; }
.control-value { color: var(--violet); font-family: "DM Mono", monospace; font-size: 10px; font-weight: 500; }
.size-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.size-options button { display: flex; min-height: 52px; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 5px 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong); color: var(--ink-soft); font-family: "DM Mono", monospace; font-size: 9px; cursor: pointer; transition: color 160ms ease, background 160ms ease, border-color 160ms ease; }
.size-options button span { color: var(--ink-faint); font-size: 8px; letter-spacing: 0.04em; }
.size-options button strong { color: inherit; font-size: 11px; font-weight: 600; }
.size-options button:hover { border-color: var(--violet); color: var(--violet); }
.size-options button.selected { border-color: var(--violet); background: var(--violet); color: #fff; }
.size-options button.selected span { color: rgba(255,255,255,0.7); }
.range-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.range-row label { color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 9px; }
.range-row input { width: 70px; min-height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper-strong); color: var(--ink); font-family: "DM Mono", monospace; font-size: 11px; text-align: center; }
.range-row input:focus { border-color: var(--violet); outline: 3px solid color-mix(in srgb, var(--violet) 18%, transparent); }
.range-row > span { color: var(--ink-faint); }
.helper-text { margin: 9px 0 0; color: var(--ink-faint); font-size: 10px; line-height: 1.5; }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; height: 44px; padding: 0 34px 0 12px; border: 1px solid var(--line); border-radius: 10px; appearance: none; background: var(--paper-strong); color: var(--ink); font-size: 11px; cursor: pointer; }
.select-wrap select:hover { border-color: var(--line-strong); }
.select-chevron { position: absolute; top: 12px; right: 10px; width: 16px; height: 16px; fill: none; stroke: var(--ink-faint); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; pointer-events: none; }
.palette-source-note { margin: 8px 0 0; color: var(--ink-faint); font-size: 9px; line-height: 1.45; }
.advanced-details { margin-top: 18px; border-top: 1px solid var(--line); }
.advanced-details summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; color: var(--ink-soft); cursor: pointer; list-style: none; }
.advanced-details summary::-webkit-details-marker { display: none; }
.advanced-details summary > span { display: flex; flex-direction: column; gap: 1px; }
.advanced-title { color: var(--ink); font-size: 12px; font-weight: 600; }
.advanced-hint { color: var(--ink-faint); font-size: 9px; }
.advanced-chevron { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transition: transform 180ms var(--ease); }
.advanced-details[open] .advanced-chevron { transform: rotate(180deg); }
.advanced-content { display: grid; gap: 12px; padding: 2px 0 13px; }
.advanced-content .switch-row { min-height: 44px; }
.advanced-range { display: grid; gap: 5px; padding: 0 2px; }
.composition-offsets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.advanced-note { margin: 0; color: var(--ink-faint); font-size: 9px; line-height: 1.55; }
input[type="range"] { width: 100%; height: 4px; accent-color: var(--violet); cursor: pointer; }
.range-input { display: block; }
.range-caption { display: flex; justify-content: space-between; margin-top: 5px; color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 9px; }
.compact-section { margin-bottom: 18px; }
.switch-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-title, .switch-hint { display: block; }
.switch-title { color: var(--ink-soft); font-size: 11px; }
.switch-hint { color: var(--ink-faint); font-size: 9px; }
.switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-ui { position: relative; flex: none; width: 31px; height: 18px; border-radius: 99px; background: var(--line-strong); transition: background 180ms ease; }
.switch-ui::after { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; content: ""; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.18); transition: transform 180ms var(--ease); }
.switch-row input:checked + .switch-ui { background: var(--violet); }
.switch-row input:checked + .switch-ui::after { transform: translateX(13px); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 15px; border: 1px solid transparent; border-radius: 11px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms var(--ease), box-shadow 180ms ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--violet); color: #fff; box-shadow: 0 7px 14px rgba(102, 88, 232, 0.22); }
.btn-primary:hover { background: var(--violet-dark); box-shadow: 0 10px 19px rgba(102, 88, 232, 0.3); }
.btn-primary[aria-busy="true"] { cursor: wait; }
.btn-primary[aria-busy="true"] .icon { animation: beadboard-spin 720ms linear infinite; }
.btn-secondary { border-color: var(--line); background: var(--paper-strong); color: var(--ink-soft); }
.btn-secondary:hover { border-color: var(--violet); color: var(--violet); }
.full-width { width: 100%; }
.privacy-note { display: flex; align-items: flex-start; gap: 6px; margin: 11px 0 0; color: var(--ink-faint); font-size: 9px; line-height: 1.45; }
.privacy-note .tiny-icon { flex: none; margin-top: 1px; color: var(--green); }

.canvas-panel { display: flex; min-height: 650px; flex-direction: column; padding: 20px; }
.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 42px; }
.canvas-title { display: flex; align-items: center; gap: 12px; }
.canvas-title .panel-kicker { margin: 0; }
.canvas-title h3 { margin: 0; }
.view-tabs { display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong); }
.view-tab { min-height: 30px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-faint); font-size: 10px; cursor: pointer; }
.view-tab:hover { color: var(--violet); }
.view-tab.active { background: var(--violet-soft); color: var(--violet); font-weight: 600; }
.canvas-actions { display: flex; align-items: center; gap: 5px; }
.zoom-value { min-width: 42px; color: var(--ink-soft); font-family: "DM Mono", monospace; font-size: 10px; text-align: center; }
.toolbar-divider { width: 1px; height: 22px; margin: 0 7px; background: var(--line); }
.compact-btn { min-height: 44px; padding: 0 11px; border-radius: 9px; font-size: 10px; }
.canvas-stage { position: relative; display: grid; flex: none; width: 100%; height: clamp(530px, 58vh, 620px); min-height: 530px; margin: 17px 0 13px; overflow: auto; place-items: center; border-radius: 17px; background: var(--stage); background-image: radial-gradient(rgba(255,255,255,0.07) 0.8px, transparent 0.8px); background-size: 16px 16px; }
.canvas-stage::before { position: absolute; inset: 0; pointer-events: none; content: ""; background: linear-gradient(135deg, rgba(255,255,255,0.055), transparent 45%); }
.view-canvas { position: relative; z-index: 1; display: none; max-width: none; border-radius: 3px; box-shadow: 0 20px 38px rgba(0,0,0,0.25); image-rendering: pixelated; }
.view-canvas.active { display: block; }
#processedCanvas, #originalCanvas { background: repeating-conic-gradient(rgba(255,255,255,0.14) 0 25%, transparent 0 50%) 50% / 16px 16px; }
.empty-canvas { position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: center; max-width: 250px; padding: 26px; border: 1px solid rgba(255,255,255,0.12); border-radius: 17px; background: rgba(33,33,44,0.86); color: #fff; text-align: center; backdrop-filter: blur(10px); }
.empty-orb { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 15px; border-radius: 16px; background: rgba(198, 237, 140, 0.16); color: var(--lime); }
.empty-orb svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.empty-canvas strong { font-size: 14px; }
.empty-canvas span { margin-top: 5px; color: rgba(255,255,255,0.62); font-size: 11px; line-height: 1.55; }
.empty-canvas .text-button { margin-top: 12px; color: var(--lime); font-size: 11px; }
.canvas-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-faint); font-size: 10px; }
.canvas-coords { color: var(--ink-soft); font-family: "DM Mono", monospace; }
.editor-toolbar { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.editor-toolbar .btn[aria-pressed="true"] { border-color: var(--violet); background: var(--violet-soft); color: var(--violet); }
.editor-hint { color: var(--ink-faint); font-size: 9px; }

.stats-hero { display: flex; align-items: baseline; gap: 7px; padding: 19px 17px; border-radius: 15px; background: linear-gradient(135deg, var(--violet-soft), color-mix(in srgb, var(--coral-soft) 55%, var(--violet-soft))); }
.stats-hero strong { color: var(--violet); font-family: "DM Mono", monospace; font-size: 32px; letter-spacing: -0.08em; line-height: 1; }
.stats-hero span { color: var(--ink-soft); font-size: 10px; }
.stats-hero .stats-label { align-self: flex-start; margin-top: 4px; margin-right: auto; font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 10px; }
.stat-grid > div { padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-strong); }
.stat-grid strong, .stat-grid span { display: block; }
.stat-grid strong { font-family: "DM Mono", monospace; font-size: 16px; }
.stat-grid span { margin-top: 1px; color: var(--ink-faint); font-size: 9px; }
.stats-panel .divider { margin: 22px 0 16px; }
.palette-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--ink-soft); font-size: 11px; font-weight: 600; }
.palette-heading span:last-child { color: var(--ink-faint); font-size: 9px; font-weight: 400; }
.palette-list { display: flex; flex-direction: column; gap: 8px; min-height: 176px; max-height: 320px; overflow-y: auto; padding-right: 3px; scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.stats-empty { display: grid; gap: 3px; margin: 2px 0 8px; padding: 12px 13px; border: 1px dashed var(--line-strong); border-radius: 12px; background: color-mix(in srgb, var(--paper-strong) 64%, transparent); }
.stats-empty strong { color: var(--ink-soft); font-size: 11px; }
.stats-empty span { color: var(--ink-faint); font-size: 9px; }
.palette-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; min-height: 48px; }
.palette-row.zero { opacity: 0.45; }
.palette-row.disabled { opacity: 0.38; }
.palette-swatch { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; box-shadow: inset 2px 2px 0 rgba(255,255,255,0.35), inset -2px -2px 0 rgba(0,0,0,0.12); cursor: pointer; transition: transform 160ms var(--ease), box-shadow 160ms ease; }
.palette-swatch:hover, .palette-swatch.selected { transform: scale(1.12); box-shadow: 0 0 0 3px var(--paper-strong), 0 0 0 5px var(--violet); }
.palette-name { overflow: hidden; color: var(--ink-soft); font-family: "DM Mono", monospace; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.palette-count { color: var(--ink); font-family: "DM Mono", monospace; font-size: 10px; font-weight: 500; }
.palette-toggle { min-height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--ink-faint); font-size: 9px; cursor: pointer; }
.palette-toggle:hover { border-color: var(--violet); color: var(--violet); }
.palette-empty { align-self: center; max-width: 170px; padding: 34px 10px; color: var(--ink-faint); font-size: 10px; line-height: 1.6; text-align: center; }
.stats-actions { min-width: 0; margin-top: auto; padding-top: 18px; }
.color-tools { display: grid; gap: 8px; margin-bottom: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: color-mix(in srgb, var(--paper-strong) 72%, transparent); }
.color-tool-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; color: var(--ink-faint); font-size: 9px; }
.color-tool-row select { min-width: 0; height: 32px; padding: 0 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper-strong); color: var(--ink-soft); font-size: 9px; }
.color-tool-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; min-width: 0; }
.color-tool-actions .compact-btn { min-height: 34px; padding: 0 6px; font-size: 9px; }
.edit-tip { display: flex; align-items: flex-start; gap: 7px; margin: 12px 0 0; color: var(--ink-faint); font-size: 9px; line-height: 1.5; }
.tip-dot { flex: none; width: 6px; height: 6px; margin-top: 4px; border-radius: 50%; background: var(--coral); }

.guide-section { padding: 128px 0 74px; }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 31px; }
.guide-card { position: relative; min-height: 223px; padding: 28px; border: 1px solid var(--line); border-radius: 19px; background: var(--paper-strong); box-shadow: var(--shadow-sm); transition: transform 180ms var(--ease), box-shadow 180ms ease; }
.guide-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.guide-number { position: absolute; top: 24px; right: 24px; color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 10px; }
.guide-icon { width: 27px; height: 27px; margin-bottom: 27px; fill: none; stroke: var(--violet); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.guide-card h3 { margin-bottom: 9px; font-size: 16px; letter-spacing: -0.03em; }
.guide-card p { max-width: 280px; margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.75; }
.about-section { padding: 22px 0 80px; }
.about-card { display: grid; grid-template-columns: 1fr minmax(250px, 0.7fr); align-items: end; gap: 50px; padding: 45px 48px; border-radius: var(--radius-lg); background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); }
.about-card .panel-kicker { color: rgba(255,255,255,0.48); }
.about-card h2 { margin: 0; font-size: clamp(26px, 4vw, 45px); letter-spacing: -0.07em; line-height: 1.16; }
.about-card em { color: var(--lime); }
.about-card p { max-width: 330px; margin: 0; color: rgba(255,255,255,0.64); font-size: 12px; line-height: 1.8; }
.footer { display: flex; justify-content: space-between; gap: 15px; padding: 25px 0 32px; border-top: 1px solid var(--line); color: var(--ink-faint); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: 0.06em; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 320px; padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--ink); color: #fff; font-size: 11px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 180ms var(--ease); }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1220px) {
  .app-shell { padding: 0 28px; }
  .hero { gap: 45px; }
  .studio-layout { grid-template-columns: 248px minmax(0, 1fr); }
  .stats-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 190px 1fr 1fr; align-items: start; gap: 14px 24px; }
  .stats-panel .panel-title-row { grid-column: 1; margin-bottom: 0; }
  .stats-hero { grid-column: 2; margin: 0; }
  .stat-grid { grid-column: 3; margin: 0; }
  .stats-panel .divider, .stats-panel .palette-heading, .stats-panel .stats-empty, .stats-panel .palette-list, .stats-panel .stats-actions { grid-column: 1 / -1; }
  .stats-panel .divider { margin: 6px 0 0; }
  .stats-panel .palette-list { min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
  .stats-panel .stats-actions { margin: 0; display: flex; align-items: center; gap: 20px; }
  .stats-panel .stats-actions .btn { width: auto; min-width: 190px; }
  .stats-panel .edit-tip { margin: 0; }
}
@media (max-width: 860px) {
  .app-shell { padding: 0 20px; }
  .topbar { min-height: 70px; }
  .topnav { gap: 17px; margin-left: 20px; }
  .hero { grid-template-columns: 1fr; gap: 32px; padding: 60px 0 40px; }
  .hero-art { min-height: 250px; }
  .studio-layout { grid-template-columns: 1fr; }
  .stats-panel { grid-column: auto; display: flex; }
  .stats-panel .panel-title-row { margin-bottom: 22px; }
  .stats-hero { margin: 0; }
  .stat-grid { margin-top: 10px; }
  .stats-panel .divider { margin: 22px 0 16px; }
  .stats-panel .palette-list { display: flex; min-height: 176px; }
  .stats-panel .stats-actions { display: block; }
  .stats-panel .stats-actions .btn { width: 100%; }
  .stats-panel .edit-tip { margin-top: 12px; }
  .canvas-panel { min-height: 580px; }
  .canvas-stage { min-height: 460px; }
  .view-tabs { order: 3; }
  .canvas-toolbar { flex-wrap: wrap; }
  .guide-section { padding-top: 84px; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide-card { min-height: 0; }
  .about-card { grid-template-columns: 1fr; gap: 22px; padding: 34px 28px; }
}
@media (max-width: 560px) {
  .app-shell { padding: 0 14px; }
  .topnav { display: none; }
  .local-badge { display: none; }
  .hero { min-height: auto; gap: 18px; padding: 28px 0 20px; }
  h1 { margin-bottom: 14px; font-size: clamp(32px, 10.5vw, 48px); }
  .hero-subtitle { font-size: 14px; }
  .hero-points { gap: 10px 15px; font-size: 10px; }
  .hero-art { min-height: 165px; }
  .art-grid { inset: 31px 25px; background-size: 16px 16px; }
  .art-bead { width: 38px; height: 38px; border-radius: 11px; }
  .art-bead-a { top: 70px; }
  .art-bead-b { top: 111px; }
  .art-bead-c { top: 63px; width: 28px; height: 28px; }
  .art-bead-d { top: 143px; width: 28px; height: 28px; }
  .art-label { right: 20px; bottom: 33px; font-size: 10px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading h2 { font-size: 29px; }
  .section-heading .text-button { padding-top: 0; }
  .controls-panel, .stats-panel { padding: 20px; }
  .canvas-panel { min-height: 540px; padding: 14px; }
  .canvas-toolbar { align-items: flex-start; flex-direction: column; }
  .view-tabs { width: 100%; }
  .view-tab { flex: 1; }
  .canvas-actions { width: 100%; flex-wrap: wrap; }
  .canvas-actions .compact-btn { margin-left: auto; }
  .canvas-stage { height: min(58vh, 520px); min-height: 400px; max-height: 520px; margin-top: 13px; }
  .canvas-footer { align-items: flex-start; flex-direction: column; }
  .editor-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .editor-hint { width: 100%; }
  .composition-offsets { grid-template-columns: 1fr; }
  .color-tool-row { grid-template-columns: auto minmax(0, 1fr); }
  .color-tool-row > span { display: none; }
  .stats-panel .stats-actions .btn { min-width: 0; }
  .guide-section { padding-bottom: 48px; }
  .about-section { padding-bottom: 50px; }
  .about-card h2 { font-size: 31px; }
  .footer { align-items: flex-start; flex-direction: column; font-size: 8px; }
  .toast { right: 14px; bottom: 14px; left: 14px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@keyframes beadboard-spin { to { transform: rotate(360deg); } }

/* Mosaic Glass direction: pixel texture + Apple-like translucent materials. */
:root {
  --paper: #edf1ff;
  --paper-strong: rgba(255, 255, 255, 0.58);
  --ink: #18203b;
  --ink-soft: #53607f;
  --ink-faint: #7c88a7;
  --line: rgba(83, 102, 153, 0.18);
  --line-strong: rgba(83, 102, 153, 0.3);
  --violet: #675cf6;
  --violet-dark: #4940c7;
  --violet-soft: rgba(103, 92, 246, 0.13);
  --coral: #ff806f;
  --coral-soft: rgba(255, 128, 111, 0.14);
  --lime: #b7e86e;
  --green: #32bb91;
  --stage: #11182f;
  --stage-soft: #1b2546;
  --shadow-sm: 0 12px 30px rgba(43, 52, 102, 0.08);
  --shadow-md: 0 24px 58px rgba(45, 50, 113, 0.14);
  --shadow-lg: 0 32px 90px rgba(31, 37, 90, 0.2);
  --radius-lg: 28px;
  --radius-md: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --paper: #0b1021;
  --paper-strong: rgba(24, 32, 60, 0.68);
  --ink: #f7f8ff;
  --ink-soft: #b6c0dd;
  --ink-faint: #7e8aaa;
  --line: rgba(196, 208, 255, 0.15);
  --line-strong: rgba(196, 208, 255, 0.27);
  --violet-soft: rgba(118, 104, 255, 0.18);
  --coral-soft: rgba(255, 128, 111, 0.16);
  --shadow-sm: 0 16px 36px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 26px 62px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 38px 100px rgba(0, 0, 0, 0.38);
}

html { background: var(--paper); }
body {
  isolation: isolate;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% -10%, rgba(113, 97, 255, 0.2), transparent 34%),
    radial-gradient(circle at 94% 13%, rgba(69, 208, 207, 0.12), transparent 27%),
    linear-gradient(145deg, var(--paper) 0%, color-mix(in srgb, var(--paper) 74%, #dfe8ff) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Noto Sans SC", "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}
body::before {
  z-index: -1;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(109, 104, 232, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109, 104, 232, 0.12) 1px, transparent 1px);
  background-size: 20px 20px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 78%);
}
body::after {
  position: fixed;
  inset: -20%;
  z-index: -2;
  pointer-events: none;
  content: "";
  opacity: 0.52;
  background:
    radial-gradient(circle at 30% 25%, rgba(121, 103, 255, 0.16), transparent 19%),
    radial-gradient(circle at 72% 54%, rgba(68, 205, 202, 0.1), transparent 17%),
    radial-gradient(circle at 44% 88%, rgba(255, 128, 111, 0.1), transparent 14%);
  filter: blur(50px);
}

.app-shell { width: min(1480px, 100%); padding: 0 36px; }
.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  min-height: 68px;
  margin-top: 14px;
  padding: 10px 16px 10px 18px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 75%, white 25%);
  border-radius: 22px;
  background: color-mix(in srgb, var(--paper-strong) 82%, transparent);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
}
.brand { gap: 10px; }
.brand-mark { filter: drop-shadow(0 7px 12px rgba(103, 92, 246, 0.24)); }
.brand-mark svg rect { rx: 8; }
.brand-copy strong { font-size: 16px; letter-spacing: -0.05em; }
.brand-copy span { color: var(--ink-faint); font-size: 9px; letter-spacing: 0.13em; }
.topnav { gap: 24px; margin-left: 60px; }
.topnav-link { color: var(--ink-soft); font-size: 12px; }
.topnav-link::after { bottom: 1px; height: 3px; border-radius: 99px; background: linear-gradient(90deg, #6b5cff, #43c9ca); }
.topnav-link:hover, .topnav-link.active { color: var(--ink); }
.local-badge { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--paper-strong) 68%, transparent); }
.icon-button {
  border-color: var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--paper-strong) 80%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}
.icon-button:hover { border-color: color-mix(in srgb, var(--violet) 70%, white); background: var(--violet-soft); color: var(--violet); }

.hero { gap: 64px; min-height: 500px; padding: 78px 0 66px; }
.eyebrow { color: var(--violet); font-size: 9px; letter-spacing: 0.2em; }
.eyebrow-line { width: 32px; height: 2px; border-radius: 99px; background: linear-gradient(90deg, var(--violet), #54caca); }
h1 { max-width: 760px; margin-bottom: 20px; font-size: clamp(42px, 5.5vw, 78px); font-weight: 750; letter-spacing: -0.075em; line-height: 1.03; }
h1 em { color: transparent; background: linear-gradient(110deg, #6558f4 12%, #3bbdbf 92%); -webkit-background-clip: text; background-clip: text; }
.hero-subtitle { max-width: 580px; color: var(--ink-soft); font-size: 16px; line-height: 1.7; }
.hero-points { gap: 12px 18px; }
.hero-points span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--paper-strong) 56%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.hero-art {
  min-height: 330px;
  border-color: rgba(255, 255, 255, 0.24);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(18, 26, 58, 0.94), rgba(25, 33, 72, 0.74));
  box-shadow: 0 30px 80px rgba(28, 34, 88, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}
.hero-art::before { background: radial-gradient(circle, rgba(116, 104, 255, 0.3), transparent 68%); }
.hero-art::after { background: radial-gradient(circle, rgba(63, 207, 203, 0.2), transparent 68%); }
.art-grid { inset: 38px 34px; border-color: rgba(214, 225, 255, 0.2); background-image: linear-gradient(rgba(214, 225, 255, 0.14) 1px, transparent 1px), linear-gradient(90deg, rgba(214, 225, 255, 0.14) 1px, transparent 1px); background-size: 18px 18px; transform: rotate(-5deg); }
.art-bead { border-radius: 8px; box-shadow: inset 4px 4px 0 rgba(255, 255, 255, 0.34), inset -4px -5px 0 rgba(9, 14, 35, 0.22), 0 12px 22px rgba(4, 7, 22, 0.28); }
.art-note, .art-label { color: rgba(230, 237, 255, 0.62); }
.art-label { font-size: 11px; }

.studio-wrap { padding-top: 22px; }
.section-heading { margin-bottom: 24px; }
.section-heading h2 { font-size: clamp(28px, 3.2vw, 42px); letter-spacing: -0.075em; }
.studio-layout { grid-template-columns: 292px minmax(0, 1fr) 304px; gap: 18px; }
.panel {
  border: 1px solid color-mix(in srgb, var(--line-strong) 76%, white 24%);
  border-radius: 28px;
  background: color-mix(in srgb, var(--paper-strong) 78%, transparent);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.56);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
}
.controls-panel, .stats-panel { padding: 26px; }
.panel-title-row { margin-bottom: 24px; }
.panel-kicker { color: var(--violet); font-size: 8px; letter-spacing: 0.2em; }
.panel h3 { font-size: 19px; letter-spacing: -0.055em; }
.step-icon { border: 1px solid rgba(103, 92, 246, 0.2); border-radius: 11px; background: var(--violet-soft); }
.dropzone { min-height: 188px; border: 1px dashed color-mix(in srgb, var(--violet) 58%, var(--line)); border-radius: 20px; background: linear-gradient(145deg, color-mix(in srgb, var(--violet-soft) 75%, transparent), color-mix(in srgb, var(--paper-strong) 54%, transparent)); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.dropzone:hover, .dropzone.dragover { border-color: var(--violet); background: linear-gradient(145deg, rgba(103, 92, 246, 0.22), rgba(67, 201, 202, 0.12)); transform: translateY(-2px); }
.dropzone-icon { border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 14px; background: color-mix(in srgb, var(--paper-strong) 80%, transparent); box-shadow: 0 12px 24px rgba(68, 78, 146, 0.12); }
.file-meta, .color-tools, .stats-empty, .stat-grid > div { border-color: var(--line); background: color-mix(in srgb, var(--paper-strong) 60%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.divider, .switch-row + .switch-row { background: var(--line); border-color: var(--line); }
.size-options { gap: 7px; }
.size-options button { min-height: 56px; border-color: var(--line); border-radius: 13px; background: color-mix(in srgb, var(--paper-strong) 66%, transparent); }
.size-options button:hover { border-color: var(--violet); background: var(--violet-soft); }
.size-options button.selected { border-color: transparent; background: linear-gradient(135deg, #6e61ff, #4a45cf); box-shadow: 0 10px 20px rgba(89, 78, 221, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.select-wrap select, .range-row input, .color-tool-row select { border-color: var(--line); background: color-mix(in srgb, var(--paper-strong) 72%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.select-wrap select:focus, .range-row input:focus, .color-tool-row select:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(103, 92, 246, 0.14); }
.palette-source-note { color: var(--ink-faint); }
.advanced-details { border-color: var(--line); }
.switch-ui { background: color-mix(in srgb, var(--line-strong) 80%, #8a96b6); box-shadow: inset 0 1px 2px rgba(18, 25, 56, 0.14); }
.switch-row input:checked + .switch-ui { background: linear-gradient(90deg, #6b5df5, #4bc5c1); }
.btn { min-height: 48px; border-radius: 15px; transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms ease, border-color 180ms ease; touch-action: manipulation; }
.btn:active, .icon-button:active, .size-options button:active { transform: scale(0.97); }
.btn-primary { border: 0; background: linear-gradient(135deg, #7568ff, #4d48d3 72%, #3dbfc0); box-shadow: 0 14px 28px rgba(80, 71, 207, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.btn-primary:hover { background: linear-gradient(135deg, #8277ff, #574fdc 72%, #4acdcc); box-shadow: 0 18px 34px rgba(80, 71, 207, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.24); }
.btn-secondary { border-color: var(--line); background: color-mix(in srgb, var(--paper-strong) 64%, transparent); color: var(--ink-soft); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.btn-secondary:hover { border-color: color-mix(in srgb, var(--violet) 66%, white); background: var(--violet-soft); color: var(--violet); }

.canvas-panel {
  --ink: #f7f8ff;
  --ink-soft: #b7c3e2;
  --ink-faint: #8390b2;
  --line: rgba(202, 216, 255, 0.15);
  --line-strong: rgba(202, 216, 255, 0.28);
  min-height: 690px;
  padding: 22px;
  border-color: rgba(214, 225, 255, 0.2);
  background: linear-gradient(145deg, rgba(17, 25, 55, 0.82), rgba(21, 29, 64, 0.65));
  box-shadow: 0 32px 86px rgba(22, 28, 75, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.canvas-panel .panel-kicker { color: #8e83ff; }
.view-tabs { border-color: rgba(207, 218, 255, 0.16); background: rgba(255, 255, 255, 0.07); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.view-tab { color: rgba(215, 224, 255, 0.58); }
.view-tab:hover { color: #fff; }
.view-tab.active { background: rgba(117, 105, 255, 0.35); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.canvas-stage { height: clamp(560px, 62vh, 680px); margin: 18px 0 14px; border: 1px solid rgba(210, 224, 255, 0.12); border-radius: 22px; background-color: #0d1530; background-image: linear-gradient(rgba(154, 171, 224, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(154, 171, 224, 0.08) 1px, transparent 1px), radial-gradient(circle at 18% 14%, rgba(112, 97, 255, 0.16), transparent 30%); background-size: 18px 18px, 18px 18px, auto; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -24px 60px rgba(3, 7, 21, 0.28); }
.canvas-stage::before { background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 38%, rgba(80, 200, 200, 0.04)); }
.view-canvas { box-shadow: 0 28px 54px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08); }
.empty-canvas { border-color: rgba(214, 225, 255, 0.18); border-radius: 20px; background: rgba(21, 30, 63, 0.7); box-shadow: 0 20px 45px rgba(2, 6, 20, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12); -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%); }
.empty-orb { border: 1px solid rgba(181, 231, 110, 0.2); border-radius: 13px; background: rgba(181, 231, 110, 0.14); }
.canvas-footer { color: var(--ink-faint); }
.canvas-coords { color: var(--ink-soft); }
.editor-toolbar .btn[aria-pressed="true"] { border-color: rgba(126, 113, 255, 0.7); background: rgba(103, 92, 246, 0.2); color: #d5d2ff; }

.stats-hero { border: 1px solid rgba(103, 92, 246, 0.2); background: linear-gradient(135deg, rgba(103, 92, 246, 0.16), rgba(67, 201, 202, 0.12)); }
.stats-hero strong { color: var(--violet); }
.palette-list { scrollbar-color: var(--line-strong) transparent; }
.palette-swatch { border-radius: 8px; box-shadow: inset 2px 2px 0 rgba(255,255,255,0.38), inset -2px -2px 0 rgba(9, 14, 35, 0.2), 0 5px 12px rgba(28, 39, 89, 0.12); }
.palette-swatch:hover, .palette-swatch.selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--paper-strong) 90%, transparent), 0 0 0 5px var(--violet), 0 10px 20px rgba(103, 92, 246, 0.2); }
.palette-toggle { border-color: var(--line); background: color-mix(in srgb, var(--paper-strong) 50%, transparent); }
.guide-section { padding: 112px 0 72px; }
.guide-card { border-color: var(--line); border-radius: 22px; background: color-mix(in srgb, var(--paper-strong) 66%, transparent); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.44); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.guide-card::before { position: absolute; inset: 0; z-index: -1; border-radius: inherit; content: ""; opacity: 0.35; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 16px 16px; mask-image: linear-gradient(135deg, black, transparent 62%); }
.guide-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.5); }
.guide-icon { color: var(--violet); }
.about-card { border: 1px solid rgba(207, 220, 255, 0.15); border-radius: 28px; background: linear-gradient(145deg, rgba(17, 25, 55, 0.93), rgba(25, 34, 73, 0.75)); box-shadow: var(--shadow-lg); -webkit-backdrop-filter: blur(24px) saturate(150%); backdrop-filter: blur(24px) saturate(150%); }
.about-card em { color: #b7e86e; }
.footer { border-color: var(--line); }
.toast { border-color: rgba(214, 225, 255, 0.2); border-radius: 16px; background: rgba(22, 31, 65, 0.78); box-shadow: 0 22px 50px rgba(2, 6, 20, 0.3); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .topbar, .panel, .icon-button, .btn-secondary, .dropzone, .empty-canvas, .guide-card, .about-card, .toast { background: var(--paper-strong); }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar, .panel, .icon-button, .btn-secondary, .dropzone, .empty-canvas, .guide-card, .about-card, .toast { -webkit-backdrop-filter: none; backdrop-filter: none; background: color-mix(in srgb, var(--paper-strong) 94%, transparent); }
}

@media (max-width: 1220px) {
  .studio-layout { grid-template-columns: 276px minmax(0, 1fr); gap: 16px; }
  .canvas-panel { grid-column: 2; grid-row: 1; }
  .stats-panel { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .app-shell { padding: 0 20px; }
  .topbar { top: 8px; margin-top: 8px; }
  .hero { gap: 32px; padding: 60px 0 42px; }
  .studio-layout { grid-template-columns: 1fr; }
  .canvas-panel { grid-column: auto; grid-row: auto; min-height: 620px; }
  .canvas-stage { min-height: 480px; }
}

@media (max-width: 560px) {
  .app-shell { padding: 0 14px; }
  .topbar { min-height: 62px; padding-inline: 12px; border-radius: 18px; }
  .topbar-actions { gap: 8px; }
  .hero, .hero-copy, .hero-art { width: 100%; min-width: 0; max-width: 100%; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 38px 0 30px; }
  .hero-copy { overflow: hidden; }
  h1 { max-width: 100%; font-size: clamp(30px, 7.8vw, 44px); letter-spacing: -0.06em; overflow-wrap: anywhere; word-break: break-word; }
  .hero-subtitle { max-width: 100%; font-size: 14px; overflow-wrap: anywhere; word-break: break-word; }
  .hero-points span { padding: 6px 8px; }
  .hero-art { width: 100%; max-width: 100%; min-height: 220px; border-radius: 24px; }
  .studio-wrap { padding-top: 12px; }
  .controls-panel, .stats-panel { padding: 20px; }
  .canvas-panel { min-height: 565px; padding: 14px; border-radius: 24px; }
  .canvas-stage { height: min(60vh, 520px); min-height: 410px; border-radius: 18px; }
  .guide-section { padding-top: 78px; }
}

/* Recent-inspired refinement: editorial grid, dark media surfaces, floating glass controls. */
:root {
  --paper: #f3f4f2;
  --paper-strong: rgba(255, 255, 255, 0.72);
  --ink: #11131a;
  --ink-soft: #555c6c;
  --ink-faint: #8b919d;
  --line: rgba(16, 20, 31, 0.09);
  --line-strong: rgba(16, 20, 31, 0.16);
  --violet: #5f5be8;
  --violet-dark: #4945c7;
  --violet-soft: rgba(95, 91, 232, 0.1);
  --shadow-sm: 0 7px 24px rgba(18, 22, 35, 0.045);
  --shadow-md: 0 18px 46px rgba(18, 22, 35, 0.075);
  --shadow-lg: 0 28px 76px rgba(18, 22, 35, 0.12);
  --radius-lg: 20px;
  --radius-md: 15px;
}

[data-theme="dark"] {
  --paper: #0e1015;
  --paper-strong: rgba(26, 29, 38, 0.76);
  --ink: #f5f6f8;
  --ink-soft: #b0b5c0;
  --ink-faint: #747b88;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --violet-soft: rgba(118, 113, 255, 0.14);
}

body {
  background:
    radial-gradient(circle at 8% 2%, rgba(98, 93, 232, 0.07), transparent 27%),
    linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--paper) 97%, #e9edf5));
}
body::before {
  opacity: 0.24;
  background-image: linear-gradient(rgba(80, 85, 110, 0.1) 1px, transparent 1px), linear-gradient(90deg, rgba(80, 85, 110, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, black 0, rgba(0,0,0,0.45) 42%, transparent 76%);
}
body::after { opacity: 0.18; filter: blur(70px); }

.topbar {
  min-height: 64px;
  border-color: var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper-strong) 88%, transparent);
  box-shadow: 0 8px 32px rgba(16, 20, 31, 0.06), inset 0 1px 0 rgba(255,255,255,0.72);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  backdrop-filter: blur(20px) saturate(145%);
}
.brand-mark { filter: none; }
.brand-copy strong { color: var(--ink); }
.topnav { padding: 4px; gap: 4px; margin-left: 40px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--paper-strong) 54%, transparent); }
.topnav-link { padding: 7px 13px; border-radius: 999px; font-size: 11px; }
.topnav-link::after { display: none; }
.topnav-link:hover { background: color-mix(in srgb, var(--paper-strong) 88%, transparent); }
.topnav-link.active { background: var(--ink); color: color-mix(in srgb, var(--paper) 95%, white); }
.local-badge { padding: 7px 10px; border-color: var(--line); background: color-mix(in srgb, var(--paper-strong) 62%, transparent); }
.icon-button { border-radius: 50%; background: color-mix(in srgb, var(--paper-strong) 72%, transparent); }
.icon-button.small { border-radius: 50%; }

.hero { min-height: 405px; gap: 54px; padding: 48px 0 42px; }
h1 { max-width: 690px; margin-bottom: 16px; font-size: clamp(40px, 4.8vw, 68px); letter-spacing: -0.073em; }
h1 em { background: linear-gradient(100deg, #5d59e6 8%, #399ea7 92%); -webkit-background-clip: text; background-clip: text; }
.hero-subtitle { max-width: 540px; margin-bottom: 22px; font-size: 15px; }
.hero-points { gap: 8px; }
.hero-points span { padding: 6px 10px; border-color: var(--line); background: rgba(255, 255, 255, 0.44); font-size: 10px; }
[data-theme="dark"] .hero-points span { background: rgba(255, 255, 255, 0.05); }
.hero-art { min-height: 270px; border-color: rgba(255,255,255,0.1); border-radius: 17px; background: linear-gradient(145deg, #12141a, #1b2030); box-shadow: 0 24px 58px rgba(15, 18, 30, 0.2), inset 0 1px 0 rgba(255,255,255,0.08); }
.hero-art::before, .hero-art::after { opacity: 0.5; }
.art-grid { inset: 32px 30px; background-size: 16px 16px; transform: rotate(-4deg); }
.art-bead { width: 44px; height: 44px; border-radius: 7px; }
.art-bead-a { top: 70px; }
.art-bead-b { top: 116px; }
.art-bead-c { top: 66px; }
.art-bead-d { top: 156px; }

.studio-wrap { padding-top: 12px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { font-size: clamp(27px, 3vw, 38px); }
.studio-layout { gap: 12px; }
.panel {
  border-color: var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper-strong) 88%, transparent);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.64);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  backdrop-filter: blur(20px) saturate(135%);
}
.controls-panel, .stats-panel { padding: 22px; }
.panel-title-row { margin-bottom: 20px; }
.panel-kicker { color: var(--ink-faint); }
.step-icon { border: 0; border-radius: 50%; background: var(--ink); color: color-mix(in srgb, var(--paper) 92%, white); }
.step-icon.coral { background: var(--coral); color: #fff; }
.dropzone { min-height: 170px; border-color: rgba(95,91,232,0.42); border-radius: 14px; background: color-mix(in srgb, var(--paper-strong) 82%, var(--violet-soft)); }
.dropzone:hover, .dropzone.dragover { background: color-mix(in srgb, var(--paper-strong) 65%, var(--violet-soft)); }
.dropzone-icon { border-radius: 12px; box-shadow: 0 8px 20px rgba(26, 31, 48, 0.08); }
.size-options button { min-height: 52px; border-radius: 10px; }
.size-options button.selected { background: var(--ink); box-shadow: 0 9px 22px rgba(17, 19, 26, 0.18); }
.select-wrap select, .range-row input, .color-tool-row select { background: color-mix(in srgb, var(--paper-strong) 88%, transparent); }
.btn { min-height: 46px; border-radius: 12px; }
.btn-primary { background: var(--ink); box-shadow: 0 12px 26px rgba(17, 19, 26, 0.18), inset 0 1px 0 rgba(255,255,255,0.18); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--violet)); box-shadow: 0 16px 30px rgba(17, 19, 26, 0.24); }
.btn-secondary { background: color-mix(in srgb, var(--paper-strong) 74%, transparent); }

.canvas-panel {
  min-height: 660px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(18, 20, 28, 0.96), rgba(22, 27, 40, 0.93));
  box-shadow: 0 24px 64px rgba(13, 16, 28, 0.18), inset 0 1px 0 rgba(255,255,255,0.08);
}
.view-tabs { padding: 2px; border-radius: 999px; }
.view-tab { min-height: 31px; padding: 0 12px; border-radius: 999px; }
.canvas-actions .icon-button { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.1); color: #f4f6ff; }
.canvas-actions .btn-secondary { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.1); color: #f4f6ff; }
.canvas-stage { height: clamp(545px, 60vh, 650px); min-height: 545px; border-radius: 14px; background-color: #0c1020; background-size: 16px 16px, 16px 16px, auto; }
.empty-canvas { border-radius: 16px; }
.editor-toolbar .btn-secondary { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.08); color: #c7cede; }

.stats-hero { border-color: var(--line); border-radius: 13px; background: linear-gradient(135deg, rgba(95,91,232,0.1), rgba(60,168,177,0.07)); }
.stat-grid > div, .stats-empty, .color-tools { border-radius: 10px; }
.palette-swatch { border-radius: 6px; }
.palette-toggle { border-radius: 999px; }
.guide-section { padding-top: 94px; }
.guide-grid { gap: 12px; }
.guide-card { min-height: 205px; border-radius: 15px; background: color-mix(in srgb, var(--paper-strong) 88%, transparent); }
.guide-card::before { border-radius: inherit; background-size: 18px 18px; }
.about-card { border-radius: 17px; background: linear-gradient(145deg, #111318, #1b202c); }
.toast { border-radius: 13px; }

.hero-art, .panel, .guide-card {
  animation: mosaic-materialize 420ms var(--ease) backwards;
}
.controls-panel { animation-delay: 40ms; }
.canvas-panel { animation-delay: 90ms; }
.stats-panel { animation-delay: 140ms; }
.guide-card:nth-child(2) { animation-delay: 50ms; }
.guide-card:nth-child(3) { animation-delay: 100ms; }

@keyframes mosaic-materialize {
  from { opacity: 0; filter: blur(4px); transform: translateY(10px) scale(0.985); }
  to { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}

@media (max-width: 860px) {
  .hero { min-height: auto; padding-top: 42px; }
  .canvas-panel { min-height: 600px; }
}

@media (max-width: 560px) {
  .topbar { border-radius: 15px; }
  .hero { padding: 32px 0 28px; }
  h1 { font-size: clamp(30px, 7.7vw, 43px); }
  .hero-art { min-height: 210px; border-radius: 15px; }
  .panel, .canvas-panel { border-radius: 15px; }
  .canvas-stage { min-height: 400px; border-radius: 12px; }
}
