:root {
  color-scheme: light;
  --canvas: #f2ece1;
  --surface: #fbf7ef;
  --surface-soft: #f5efe3;
  --mat-frame: #fffdf8;
  --sage: #d8dfd0;
  --ink: #352d25;
  --secondary: #746658;
  --green: #4c6b58;
  --green-dark: #3b5645;
  --warm-gold: #c99a49;
  --selected: #dce5d4;
  --line: rgba(94, 77, 58, 0.14);
  --line-strong: rgba(94, 77, 58, 0.24);
  --radius-small: 14px;
  --radius-pill: 999px;
  --radius-sheet: 26px;
  --shadow-card: 0 2px 6px rgba(58, 43, 28, 0.08), 0 10px 24px rgba(58, 43, 28, 0.07);
  --shadow-card-hover: 0 4px 10px rgba(58, 43, 28, 0.10), 0 18px 34px rgba(58, 43, 28, 0.12);
  --shadow-btn: 0 2px 0 rgba(70, 54, 36, 0.14), 0 4px 12px rgba(58, 43, 28, 0.07);
  --shadow-sheet: 0 -10px 40px rgba(48, 36, 24, 0.14);
  --spring: cubic-bezier(0.22, 1.12, 0.36, 1);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Nunito", "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  --table-bg: radial-gradient(circle at 16% 10%, #fdf7e9 0%, #ede4d2 48%, #ded4be 100%);
  --board-mat: #faf5ea;
  --board-frame-outer: #c9b595;
  --board-frame-inner: #e6d8be;
  --board-border: #b39f7e;
  --chrome-glass: rgba(251, 247, 239, 0.86);
  --chrome-glass-hover: rgba(255, 252, 246, 0.98);
  --drawer-bg: #f8f2e6;
  --tray-well: #efe7d8;
}

body[data-theme="oak"] {
  --canvas: #eadbc6;
  --surface: #f7efe2;
  --surface-soft: #efe3cf;
  --mat-frame: #fdf9f1;
  --ink: #382a1e;
  --secondary: #755d47;
  --green: #6e5239;
  --green-dark: #573f2b;
  --selected: #e3d2bc;
  --table-bg:
    repeating-linear-gradient(
      91deg,
      rgba(105, 68, 34, 0.03) 0px,
      rgba(105, 68, 34, 0.03) 2px,
      transparent 2px,
      transparent 18px
    ),
    radial-gradient(circle at 18% 12%, #f4e2c6 0%, #dcc29c 52%, #c7a980 100%);
  --board-mat: #faf4e8;
  --board-frame-outer: #a78358;
  --board-frame-inner: #d7bc95;
  --board-border: #96744c;
  --chrome-glass: rgba(247, 239, 226, 0.88);
  --chrome-glass-hover: rgba(253, 249, 241, 0.98);
  --drawer-bg: #f4ead9;
  --tray-well: #e9dcc6;
}

body[data-theme="sage"] {
  --canvas: #eaeee5;
  --surface: #f7f8f3;
  --surface-soft: #eef2e8;
  --mat-frame: #fdfdf9;
  --ink: #2c382f;
  --secondary: #5f6f62;
  --green: #496954;
  --green-dark: #385341;
  --selected: #d3e0cf;
  --table-bg: radial-gradient(circle at 18% 12%, #e3ecdc 0%, #c8d6c0 54%, #b3c4aa 100%);
  --board-mat: #f8f7f0;
  --board-frame-outer: #8fa389;
  --board-frame-inner: #cdd9c6;
  --board-border: #7e9478;
  --chrome-glass: rgba(247, 248, 243, 0.86);
  --chrome-glass-hover: rgba(253, 253, 249, 0.98);
  --drawer-bg: #f3f5ee;
  --tray-well: #e6ebe0;
}

body[data-theme="evening"] {
  color-scheme: dark;
  background: #141714;
  --canvas: #1d211d;
  --surface: #272c27;
  --surface-soft: #212621;
  --mat-frame: #303630;
  --ink: #f0e8da;
  --secondary: #aba698;
  --green: #8eae92;
  --green-dark: #749478;
  --warm-gold: #deb86c;
  --selected: #364137;
  --line: rgba(240, 232, 218, 0.11);
  --line-strong: rgba(240, 232, 218, 0.22);
  --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.28);
  --shadow-card-hover: 0 8px 20px rgba(0, 0, 0, 0.45), 0 18px 36px rgba(0, 0, 0, 0.36);
  --shadow-btn: 0 2px 0 rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.22);
  --shadow-sheet: 0 -12px 44px rgba(0, 0, 0, 0.5);
  --table-bg: radial-gradient(circle at 20% 12%, #2c332c 0%, #1d221e 52%, #151815 100%);
  --board-mat: #262b26;
  --board-frame-outer: #4a544a;
  --board-frame-inner: #363e36;
  --board-border: #556155;
  --chrome-glass: rgba(39, 44, 39, 0.86);
  --chrome-glass-hover: rgba(52, 59, 52, 0.96);
  --drawer-bg: #252a25;
  --tray-well: #1d221d;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}
body {
  background: #ded6c7;
  color: var(--ink);
  font: 15.5px/1.5 var(--sans);
  display: grid;
  place-items: center;
  -webkit-font-smoothing: antialiased;
}
#app {
  width: min(100%, 1440px);
  height: 100dvh;
  max-height: 1120px;
  background: var(--table-bg);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
/* Soft tactile linen/paper grain across the whole tabletop */
#app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
input,
select {
  font: inherit;
}
button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
  padding: 10px 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 150ms ease,
    transform 150ms var(--spring),
    box-shadow 150ms ease,
    border-color 150ms ease;
}
button:hover {
  background: rgba(76, 107, 88, 0.09);
}
button:active {
  transform: translateY(1px) scale(0.985);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}
button[aria-pressed="true"],
button.active {
  background: var(--selected);
  border-color: var(--line-strong);
  color: var(--ink);
}
.primary {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fdfbf6;
  padding-inline: 24px;
  box-shadow: 0 2px 0 var(--green-dark), 0 6px 16px rgba(59, 86, 69, 0.22);
}
.primary:hover {
  background: var(--green-dark);
}
.primary:active {
  box-shadow: 0 1px 0 var(--green-dark);
}
body[data-theme="evening"] .primary {
  color: #161c17;
  font-weight: 600;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--chrome-glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-btn);
}
.icon-button:hover {
  background: var(--chrome-glass-hover);
}
.icon {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  background: currentColor;
  mask: var(--icon) center/contain no-repeat;
  -webkit-mask: var(--icon) center/contain no-repeat;
}
.tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Warm storybook typography — zero cold developer monospace! */
.metadata,
.eyebrow {
  font: 500 13px/1.4 var(--sans);
  color: var(--secondary);
  letter-spacing: 0.01em;
}
.eyebrow {
  font-style: italic;
  font-family: var(--serif);
  font-size: 15px;
}
.small {
  font-size: 13.5px;
  color: var(--secondary);
  line-height: 1.55;
}
h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.15;
  margin: 4px 0;
}
h2 {
  font-size: 25px;
  margin: 0;
}
p {
  line-height: 1.6;
}
a {
  color: var(--green);
  text-underline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* === Library / Keepsake Gallery === */
.library {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px clamp(20px, 4.5vw, 64px) 64px;
  scrollbar-width: none;
}
.library::-webkit-scrollbar {
  display: none;
}
.library-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-emblem {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(145deg, #63856e, #486754);
  color: #fbf7ef;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 0 #344d3e, 0 6px 14px rgba(59, 86, 69, 0.22);
  flex: none;
}
.wordmark {
  font: 600 24px/1.1 var(--serif);
  color: var(--ink);
}
.wordmark-sub {
  display: block;
  font: italic 13.5px/1.3 var(--serif);
  color: var(--secondary);
  margin-top: 2px;
}

/* Browsable cozy category shelf right in the library */
.category-shelf {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 28px 22px 2px;
  margin: 0 -2px;
  -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%);
  mask-image: linear-gradient(to right, #000 92%, transparent 100%);
}
.category-shelf::-webkit-scrollbar {
  display: none;
}
.cat-pill {
  flex: none;
  min-height: 38px;
  padding: 7px 16px;
  font-size: 13.5px;
  background: var(--chrome-glass);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 rgba(70, 54, 36, 0.09);
  color: var(--secondary);
}
.cat-pill:hover {
  background: var(--chrome-glass-hover);
  color: var(--ink);
}
.cat-pill[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fdfbf6;
  box-shadow: 0 2px 0 var(--green-dark), 0 4px 12px rgba(59, 86, 69, 0.2);
}
body[data-theme="evening"] .cat-pill[aria-pressed="true"] {
  color: #161c17;
}

.collection-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.collection-bar h1 {
  margin: 0;
  font-size: 28px;
}
.collection-bar h1 button {
  font: inherit;
  padding: 2px 6px 2px 0;
  min-height: 36px;
  border-radius: 10px;
}

/* Warm "Continue Puzzle" Wooden Keepsake Banner */
.resume-print {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 14px 20px 14px 14px;
  margin: 0 0 28px;
  gap: 20px;
  border-radius: 20px;
  background: var(--mat-frame);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}
.resume-print:hover {
  background: var(--mat-frame);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}
.resume-print > img {
  width: 118px;
  height: 86px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  flex: none;
}
.resume-print > span {
  display: grid;
  gap: 4px;
  flex: 1;
}
.resume-print small {
  font: italic 13px var(--serif);
  color: var(--warm-gold);
}
.resume-print strong {
  font: 500 21px/1.25 var(--serif);
  color: var(--ink);
}
.resume-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fdfbf6;
  background: var(--green);
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--green-dark);
  flex: none;
}
body[data-theme="evening"] .resume-cta {
  color: #161c17;
}
.resume-cta .icon {
  width: 15px;
  height: 15px;
}

/* Framed Museum Passe-Partout Puzzle Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px 24px;
}
.card {
  position: relative;
  min-width: 0;
  background: var(--mat-frame);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 10px 14px;
  box-shadow: var(--shadow-card);
  transition: transform 220ms var(--spring), box-shadow 220ms ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
}
.art {
  display: block;
  padding: 0;
  width: 100%;
  height: 210px;
  border-radius: 11px;
  overflow: hidden;
  border: 0;
  background: var(--surface-soft);
  box-shadow: inset 0 1px 4px rgba(45, 34, 22, 0.14);
}
.art:hover {
  background: var(--surface-soft);
  transform: none;
}
.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.55s var(--spring);
}
.card:hover .art img {
  transform: scale(1.03);
}
.info {
  padding: 12px 6px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.info h3 {
  font-size: 18px;
  line-height: 1.3;
  margin: 0;
  color: var(--ink);
}
.info p {
  margin: 0;
  font: italic 13.5px/1.35 var(--serif);
  color: var(--secondary);
}
.done-seal {
  position: absolute;
  top: 18px;
  left: 18px;
  background: rgba(251, 247, 239, 0.92);
  color: var(--green);
  border: 1px solid rgba(76, 107, 88, 0.25);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(40, 30, 20, 0.14);
  pointer-events: none;
}
body[data-theme="evening"] .done-seal {
  background: rgba(39, 44, 39, 0.92);
  color: #deb86c;
}
.heart {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(251, 247, 239, 0.88);
  border: 1px solid rgba(94, 77, 58, 0.16);
  color: var(--secondary);
  box-shadow: 0 2px 8px rgba(40, 30, 20, 0.14);
  backdrop-filter: blur(8px);
}
.heart:hover {
  background: #fff;
  color: #b85d52;
}
.heart[aria-pressed="true"] {
  background: #f6e1dc;
  border-color: #d9a096;
  color: #b85247;
}
body[data-theme="evening"] .heart {
  background: rgba(39, 44, 39, 0.88);
  color: #c5bdb0;
}
body[data-theme="evening"] .heart[aria-pressed="true"] {
  background: #4e312e;
  color: #f29a8f;
}

/* === Puzzle Tabletop Screen === */
.board-screen {
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--table-bg);
  transition: background 400ms ease;
}
.stage {
  position: absolute;
  inset: 0;
  background: var(--table-bg);
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline-offset: -5px;
}

.floating-title {
  position: absolute;
  left: 20px;
  top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 140px);
  pointer-events: none;
  z-index: 4;
}
.floating-title button {
  pointer-events: auto;
}
.title-pill {
  background: var(--chrome-glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 7px 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-btn);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.floating-title h2 {
  font-size: 18px;
  line-height: 1.2;
  max-width: 440px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-track {
  width: 84px;
  height: 6px;
  border-radius: 999px;
  background: rgba(94, 77, 58, 0.14);
  overflow: hidden;
  flex: none;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--warm-gold));
  transition: width 320ms var(--spring);
}
.floating-title .metadata {
  font-size: 12px;
  white-space: nowrap;
}
.floating-actions {
  position: absolute;
  right: 20px;
  top: 18px;
  display: flex;
  gap: 8px;
  z-index: 4;
}

.board-screen.opening #board {
  opacity: 0.35;
}
.board-screen.opening .floating-title,
.board-screen.opening .floating-actions {
  animation: chrome-enter 0.62s ease-out;
}
.travelling-art {
  position: fixed;
  z-index: 50;
  object-fit: fill;
  pointer-events: none;
  box-shadow: 0 18px 48px rgba(45, 34, 22, 0.22);
}

/* Cozy Recessed Sorting Drawer */
.piece-drawer {
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 238px;
  background: var(--drawer-bg);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-sheet);
  transition:
    height 440ms var(--spring),
    transform 440ms var(--spring);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 3;
}
.piece-drawer.collapsed {
  height: 60px;
}
.piece-drawer.dragging {
  transition: none;
}
.drawer-handle {
  height: 36px;
  min-height: 36px;
  width: 100%;
  padding: 8px;
  touch-action: none;
  border-radius: 26px 26px 0 0;
  flex: none;
  border: 0;
}
.drawer-handle span {
  width: 44px;
  height: 5px;
  background: var(--line-strong);
  border-radius: 999px;
}
.drawer-handle:hover {
  background: transparent;
}
.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 8px;
  height: 40px;
  flex: none;
}
.edge-control {
  height: 36px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  padding: 4px 14px;
  color: var(--ink);
  background: var(--mat-frame);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(70, 54, 36, 0.1);
}
.edge-control .icon {
  height: 16px;
  width: 16px;
  color: var(--green);
}
.edge-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.edge-control:has(input:checked) {
  background: var(--selected);
  border-color: var(--green);
}
.edge-control:has(input:focus-visible) {
  outline: 2px solid var(--green);
}

.tray {
  flex: 1;
  margin: 0 14px 12px;
  border-radius: 16px;
  background: var(--tray-well);
  box-shadow: inset 0 2px 8px rgba(58, 43, 28, 0.09);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  grid-auto-rows: 104px;
  gap: 8px;
  padding: 12px 14px 18px;
  align-content: start;
}
.tray::-webkit-scrollbar {
  display: none;
}
.tray button {
  padding: 0;
  width: 100%;
  height: 104px;
  border-radius: 14px;
  background: transparent;
  touch-action: none;
  border: 0;
  filter: drop-shadow(0 3px 4px rgba(48, 36, 24, 0.2));
  transition: transform 170ms var(--spring), background 140ms;
}
.tray button:hover {
  background: rgba(255, 252, 245, 0.55);
  transform: translateY(-3px) scale(1.03);
}
.tray button.selected {
  background: rgba(201, 154, 73, 0.2);
}
.tray canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.piece-drawer.collapsed .drawer-heading,
.piece-drawer.collapsed .tray {
  display: none;
}
.piece-drawer.collapsed .drawer-handle {
  height: 60px;
  min-height: 60px;
}
.completed .piece-drawer {
  transform: translateY(115%);
  pointer-events: none;
}
.completed .floating-title .progress-row {
  display: none;
}

.tray-empty-note {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  text-align: center;
  color: var(--secondary);
  font-size: 14px;
}

/* Completion Keepsake Dock */
.completion-dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 36px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--chrome-glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 16px 22px;
  border-radius: 22px;
  box-shadow: 0 12px 36px rgba(48, 36, 24, 0.16);
  animation: dock-rise 0.6s var(--spring);
  z-index: 4;
}
.completion-dock h2 {
  font-size: 24px;
}
.completion-dock button {
  white-space: nowrap;
}
.fav-pill {
  background: var(--mat-frame);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-btn);
  color: var(--ink);
  padding: 9px 16px;
}
.fav-pill[aria-pressed="true"] {
  background: #f6e1dc;
  border-color: #d9a096;
  color: #a64439;
}
body[data-theme="evening"] .fav-pill[aria-pressed="true"] {
  background: #4e312e;
  border-color: #8f5650;
  color: #f4a499;
}
.fav-pill.pop {
  animation: heart-pop 340ms var(--spring);
}
@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Warm Rounded Modal Sheets */
dialog {
  border: 1px solid var(--line);
  border-bottom: 0;
  margin: auto auto 0;
  padding: 26px 30px 30px;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sheet);
  width: min(560px, 100%);
  max-width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  scrollbar-width: none;
}
dialog::backdrop {
  background: rgba(42, 34, 26, 0.36);
  backdrop-filter: blur(4px);
}
dialog[open] {
  animation: sheet-rise 380ms var(--spring);
}
dialog img {
  max-width: 100%;
  max-height: 38dvh;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  padding: 6px;
  background: var(--mat-frame);
  box-shadow: var(--shadow-card);
  margin: 0 auto 18px;
}
dialog h2 {
  margin: 0 0 8px;
}
dialog .sheet-heading h2 {
  margin: 0;
}
.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.choices {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.choices button {
  font: 600 14px var(--sans);
  padding: 10px 0;
  border-radius: 14px;
  background: var(--mat-frame);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 rgba(70, 54, 36, 0.09);
}
.choices button.active {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fdfbf6;
  box-shadow: 0 2px 0 var(--green-dark);
}
body[data-theme="evening"] .choices button.active {
  color: #161c17;
}

.collection-sheet {
  width: min(720px, 100%);
}
.collection-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}
.collection-option {
  justify-content: flex-start;
  text-align: left;
  padding: 8px 12px;
  border-radius: 16px;
  gap: 12px;
  background: var(--mat-frame);
  border: 1px solid var(--line);
}
.collection-option img,
.collection-symbol {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  margin: 0;
  padding: 0;
  box-shadow: none;
}
.collection-symbol {
  display: grid;
  place-items: center;
  background: var(--surface-soft);
}
.collection-option > span:not(.icon) {
  flex: 1;
}
.collection-option small {
  display: block;
  font-size: 12px;
  color: var(--secondary);
  margin-top: 2px;
}
.collection-option > .icon {
  width: 18px;
}

.search-sheet {
  height: min(720px, 88dvh);
}
.search-field {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--mat-frame);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 999px;
}
.search-field input {
  background: transparent;
  border: 0;
  color: var(--ink);
  width: 100%;
  min-height: 28px;
  outline: none;
}
.search-results {
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.search-results button {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  padding: 8px 10px;
  border-radius: 14px;
  gap: 14px;
}
.search-results img {
  width: 66px;
  height: 52px;
  object-fit: cover;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  box-shadow: none;
  flex: none;
}
.search-results small {
  display: block;
  font: italic 13px var(--serif);
  color: var(--secondary);
  margin-top: 2px;
}

.compact-sheet {
  width: min(440px, 100%);
}
.menu-actions {
  display: grid;
  gap: 8px;
}
.menu-actions > button {
  justify-content: flex-start;
  background: var(--mat-frame);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 16px;
}
.guide-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 14px;
}
.guide-control select {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--mat-frame);
  padding: 9px 14px;
  border-radius: 12px;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 16px;
}
.theme-pill {
  justify-content: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--mat-frame);
  font-size: 13px;
}
.theme-pill[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--selected);
}
.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
  flex: none;
}

.audio-settings {
  display: grid;
  gap: 6px;
  margin: 14px 0;
}
.audio-settings label {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-size: 14px;
}
.audio-settings output {
  font-size: 13px;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}
.audio-settings input {
  width: 100%;
  min-height: 28px;
  accent-color: var(--green);
  cursor: pointer;
}

.reference-sheet {
  width: min(740px, 100%);
}
.reference-sheet img {
  max-height: 60dvh;
}
.reference-sheet h2 {
  font-size: 22px;
}

#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #fdfbf6;
  padding: 11px 22px;
  border-radius: 999px;
  display: none;
  z-index: 60;
  max-width: 90vw;
  font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(48, 36, 24, 0.22);
}

.grid:empty::after {
  content: "A little room for something lovely.";
  font: italic 22px var(--serif);
  color: var(--secondary);
  padding: 40px 0;
  grid-column: 1 / -1;
  text-align: center;
}

@keyframes sheet-rise {
  from { transform: translateY(38px); }
  to { transform: translateY(0); }
}
@keyframes dock-rise {
  from { transform: translate(-50%, 24px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes chrome-enter {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 1500px) {
  #app {
    height: min(94dvh, 1100px);
    border-radius: 26px;
    box-shadow: 0 18px 64px rgba(48, 36, 24, 0.18);
  }
}
@media (max-width: 1000px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 18px;
  }
  .art {
    height: 215px;
  }
}
@media (max-width: 640px) {
  .library {
    padding: 16px 16px 40px;
  }
  .wordmark {
    font-size: 20px;
  }
  .grid {
    gap: 16px 12px;
  }
  .card {
    padding: 7px 7px 11px;
    border-radius: 15px;
  }
  .art {
    height: 152px;
    border-radius: 9px;
  }
  .info h3 {
    font-size: 15.5px;
  }
  .info p {
    font-size: 12px;
  }
  .piece-drawer {
    left: 0;
    right: 0;
  }
  .floating-title {
    left: 10px;
    top: 12px;
    max-width: calc(100% - 118px);
  }
  .floating-title h2 {
    font-size: 15px;
    max-width: 42vw;
  }
  .progress-track {
    width: 52px;
  }
  .floating-actions {
    right: 10px;
    top: 12px;
    gap: 6px;
  }
  .resume-print {
    flex-wrap: wrap;
    padding: 12px;
  }
  .completion-dock {
    bottom: 16px;
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  .tray {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    grid-auto-rows: 90px;
    margin: 0 8px 8px;
  }
  .tray button {
    height: 90px;
  }
  .collection-list {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .travelling-art {
    display: none;
  }
}
