:root {
  color-scheme: light dark;
  --bg: #f7f4ee;
  --text: #171717;
  --muted: #5d5a55;
  --accent: #0a7a75;
  --accent-strong: #075c58;
  --panel: #ffffff;
  --line: rgba(23, 23, 23, 0.16);
  --shadow: 0 18px 48px rgba(23, 23, 23, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111312;
    --text: #f3f0ea;
    --muted: #b9b2a8;
    --accent: #4ecdc4;
    --accent-strong: #7de4de;
    --panel: #181b1a;
    --line: rgba(243, 240, 234, 0.18);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Overpass, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

body {
  min-height: 100%;
  margin: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

textarea {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.page-shell {
  display: grid;
  align-content: center;
  min-height: 100svh;
  width: min(100% - 40px, 760px);
  margin: 0 auto;
  padding: 56px 0;
}

.intro {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(3.25rem, 6rem, 6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.site-title {
  display: inline-block;
  width: max-content;
  max-width: 100%;
  font-size: clamp(2.25rem, 14vw, 6rem);
  cursor: default;
}

.brand-prefix,
.brand-middle,
.brand-suffix,
.brand-suffix::after {
  transition: color 180ms ease, opacity 180ms ease;
}

.brand-suffix::after {
  content: ".fi";
  color: var(--accent);
  opacity: 0;
}

.site-title:hover .brand-suffix::after,
.site-title:focus-visible .brand-suffix::after {
  opacity: 1;
}

.site-title:hover .brand-prefix,
.site-title:hover .brand-suffix,
.site-title:focus-visible .brand-prefix,
.site-title:focus-visible .brand-suffix {
  color: var(--accent);
}

.site-title:hover .brand-middle,
.site-title:focus-visible .brand-middle {
  color: var(--muted);
  opacity: 0.72;
}

.lede {
  max-width: 36rem;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.2rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  padding-top: 26px;
}

.links a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  color: var(--text);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.links a:hover,
.links a:focus-visible {
  color: var(--accent);
}

.blog-shell {
  align-content: start;
  width: min(100% - 40px, 860px);
}

.blog-intro h1,
.blog-post-header h1 {
  max-width: 11em;
  overflow-wrap: anywhere;
  font-size: 4.5rem;
}

.blog-list {
  display: grid;
  gap: 16px;
  padding-top: 28px;
}

.blog-list-item {
  margin: 0;
}

.blog-list-item a {
  display: grid;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.blog-list-item a:hover,
.blog-list-item a:focus-visible {
  border-color: var(--accent);
}

.blog-list-item time,
.blog-post-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.blog-list-item h2 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.15;
}

.blog-list-item p,
.blog-empty {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
}

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.blog-tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.blog-post-header {
  display: grid;
  gap: 14px;
}

.blog-post-header .lede {
  margin-top: 0;
}

.blog-post-body {
  display: flow-root;
  padding-top: 32px;
  font-size: 1.08rem;
  line-height: 1.72;
}

.blog-post-body > * {
  max-width: 68ch;
  margin: 0;
}

.blog-post-body > * + * {
  margin-top: 1.15em;
}

.blog-post-body h2,
.blog-post-body h3,
.blog-post-body h4 {
  line-height: 1.16;
}

.blog-post-body h2 {
  margin-top: 2.2em;
  font-size: 1.85rem;
}

.blog-post-body h3 {
  margin-top: 1.8em;
  font-size: 1.35rem;
}

.blog-post-body h4 {
  margin-top: 1.6em;
  font-size: 1.08rem;
}

.blog-post-body a {
  color: var(--accent);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.blog-post-body ul,
.blog-post-body ol {
  padding-left: 1.4em;
}

.blog-post-body li + li {
  margin-top: 0.35em;
}

.blog-post-body blockquote {
  padding-left: 18px;
  border-left: 4px solid var(--accent);
  color: var(--muted);
  font-size: 1.05rem;
}

.blog-post-body pre {
  max-width: 100%;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}

.blog-post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.94em;
}

.blog-post-body :not(pre) > code {
  padding: 0.08em 0.28em;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
}

.blog-post-body img,
.blog-post-body video,
.blog-post-body canvas,
.blog-post-body iframe {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.blog-post-body figure {
  max-width: 100%;
}

.blog-post-body figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.blog-post-body table {
  display: block;
  max-width: 100%;
  overflow: auto;
  border-collapse: collapse;
}

.blog-post-body th,
.blog-post-body td {
  padding: 9px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.blog-post-body th {
  background: var(--panel);
}

.blog-post-body button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.blog-post-body button:hover,
.blog-post-body button:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.blog-post-body .blog-wide,
.blog-post-body .blog-grid,
.blog-post-body .blog-note {
  max-width: 100%;
}

.blog-post-body .blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 14px;
}

.blog-post-body .blog-note {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

body[data-page="music"] {
  --music-library-width: 340px;
  --music-library-collapsed-width: 58px;
}

.music-shell {
  display: block;
  align-content: stretch;
  width: 100%;
  min-height: 100svh;
  margin: 0;
  padding: 0;
}

.music-content {
  display: grid;
  gap: 22px;
  min-height: 100svh;
  margin-left: var(--music-library-width);
  padding: 48px 36px 56px;
  transition: margin-left 180ms ease;
}

.music-intro {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.music-intro h1 {
  font-size: clamp(2.75rem, 5rem, 5rem);
}

.music-main-column {
  display: grid;
  gap: 18px;
  width: min(100%, 1040px);
  margin: 0 auto;
  min-width: 0;
}

.music-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 18px;
  align-items: stretch;
}

.music-editor-panel,
.music-side-panel,
.music-library-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.music-editor-panel {
  grid-template-rows: auto auto minmax(360px, 1fr);
}

.music-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.music-editor-label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.music-code {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  tab-size: 2;
}

.music-code:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 36%, transparent);
}

.music-side-panel {
  align-content: start;
}

.music-library-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  grid-template-rows: auto minmax(0, 1fr);
  width: var(--music-library-width);
  padding: 18px;
  overflow: hidden;
  border-width: 0 1px 0 0;
  border-radius: 0;
  transition: width 180ms ease, padding 180ms ease;
}

.music-library-header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.music-library-header h2 {
  margin: 0;
  font-size: 1.15rem;
  white-space: nowrap;
}

.music-library-toggle {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.music-library-toggle:hover,
.music-library-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

body.music-library-collapsed .music-content {
  margin-left: var(--music-library-collapsed-width);
}

body.music-library-collapsed .music-library-panel {
  width: var(--music-library-collapsed-width);
  padding: 12px 8px;
}

body.music-library-collapsed .music-library-header {
  justify-content: center;
}

body.music-library-collapsed .music-library-header h2,
body.music-library-collapsed .music-library {
  display: none;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.music-control-grid {
  display: grid;
  gap: 14px;
}

.music-control-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.music-control-grid input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.music-control-grid input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.music-examples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.music-examples button {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.music-examples button:hover,
.music-examples button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.music-library {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.music-library details {
  display: grid;
}

.music-library summary {
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.music-library summary:hover,
.music-library summary:focus-visible {
  background: var(--bg);
  color: var(--accent);
}

.music-library-list {
  display: grid;
  gap: 4px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.music-library-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
}

.music-library-row.has-preview {
  grid-template-columns: auto minmax(0, 1fr);
}

.music-library-play {
  display: inline-grid;
  width: 30px;
  min-height: 32px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1;
  cursor: pointer;
}

.music-library-play:hover,
.music-library-play:focus-visible {
  background: var(--bg);
  color: var(--accent);
}

.music-library-leaf {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.music-library-leaf:hover,
.music-library-leaf:focus-visible {
  background: var(--bg);
  color: var(--accent);
}

.music-library-value {
  cursor: default;
}

.music-library-value:hover,
.music-library-value:focus-visible {
  color: var(--muted);
}

.music-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.music-status.is-error {
  color: #b3261e;
}

.music-waveform {
  display: block;
  width: 100%;
  height: auto;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quiz-shell {
  align-content: start;
  width: min(100% - 40px, 880px);
}

.quiz-intro {
  margin-bottom: 28px;
}

.quiz-intro h1 {
  font-size: clamp(2.75rem, 4.75rem, 4.75rem);
}

.quiz-progress {
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 700;
}

.quiz-form {
  display: grid;
  gap: 20px;
}

.question-list {
  display: grid;
  gap: 18px;
}

.question {
  margin: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.question legend {
  margin: 0 0 16px;
  padding: 0;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 800;
}

.answer-list {
  display: grid;
  gap: 10px;
}

.answer {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.answer:hover,
.answer:has(input:checked) {
  border-color: var(--accent);
}

.answer input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.form-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button.secondary {
  background: transparent;
  color: var(--accent);
}

.results-panel {
  display: grid;
  gap: 22px;
}

.score-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.result-label {
  margin: 0;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 800;
}

.score {
  margin: 8px 0 0;
  font-size: clamp(3.5rem, 6rem, 6rem);
  font-weight: 900;
  line-height: 1;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.result-stats div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-stats dt {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.result-stats dd {
  margin: 4px 0 0;
  font-size: 2rem;
  font-weight: 900;
}

.axis-section {
  display: grid;
  gap: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.axis-list {
  display: grid;
  gap: 12px;
}

.axis-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.axis-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  justify-content: space-between;
}

.axis-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.axis-heading p,
.axis-meta {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.axis-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.axis-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.axis-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-shell {
  align-content: start;
  width: min(100% - 40px, 1100px);
}

.gallery-intro {
  margin-bottom: 28px;
}

.gallery-intro h1 {
  font-size: clamp(2.75rem, 5rem, 5rem);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.gallery-empty {
  margin: 0;
  color: var(--muted);
}

.gallery-item {
  margin: 0;
}

.gallery-item a {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.gallery-item a:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

@media (hover: hover) {
  .gallery-item a:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
  }
}

.gallery-item a.is-gallery-source {
  border-color: transparent;
  box-shadow: none;
  transition: none;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item-title {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 28px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0));
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  transition: opacity 160ms ease;
}

.gallery-item a:focus-visible .gallery-item-title {
  opacity: 1;
}

@media (hover: hover) {
  .gallery-item a:hover .gallery-item-title {
    opacity: 1;
  }
}

.gallery-item a.is-gallery-source .gallery-item-title {
  opacity: 0;
  transition: none;
}

/* Static fallback shown only when JavaScript is unavailable. */
.gallery-figure {
  margin: 28px 0 0;
}

.gallery-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.gallery-figure figcaption {
  max-width: 68ch;
  margin: 14px auto 0;
  color: var(--muted);
}

/* Fullscreen viewer overlay. */
.gallery-viewer {
  --gv-bg: #ececee;
  --gv-text: #1b1b1d;
  --gv-muted: rgba(27, 27, 29, 0.66);
  --gv-line: rgba(0, 0, 0, 0.16);
  --gv-btn-bg: rgba(255, 255, 255, 0.72);
  --gv-btn-line: rgba(0, 0, 0, 0.2);
  --gv-btn-hover: rgba(255, 255, 255, 0.96);
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  color: var(--gv-text);
  pointer-events: none;
}

/* Opaque themed gray. It never fades: during a flight JS grows/shrinks it as a
   fixed box (see gallery.js) so the gray expands and contracts geometrically
   inside the viewer stage, leaving the info panel separate. */
.gallery-viewer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--gv-bg);
  pointer-events: none;
}

.gallery-viewer-hover-effect {
  position: fixed;
  pointer-events: none;
}

.gallery-viewer-hover-effect-state,
.gallery-viewer-hover-effect-fade,
.gallery-viewer-hover-effect-clip {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.gallery-viewer-hover-effect-state {
  opacity: 0;
  transition: opacity 160ms ease;
}

body:has(.gallery-grid a.is-gallery-source:focus-visible) .gallery-viewer-hover-effect-state {
  opacity: 1;
}

@media (hover: hover) {
  body:has(.gallery-grid a.is-gallery-source:hover) .gallery-viewer-hover-effect-state,
  body:has(.gallery-viewer-img:hover) .gallery-viewer-hover-effect-state {
    opacity: 1;
  }
}

.gallery-viewer-hover-effect-fade {
  border: 1px solid var(--accent);
  box-shadow: var(--shadow);
}

.gallery-viewer-hover-effect-clip {
  overflow: hidden;
}

.gallery-viewer-hover-effect-title {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 28px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0));
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
}

.gallery-viewer-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-viewer-backdrop,
  .gallery-viewer-info,
  .gallery-viewer-btn {
    transition: none;
  }
}

@media (prefers-color-scheme: dark) {
  .gallery-viewer {
    --gv-bg: #1b1b1e;
    --gv-text: #f1efe9;
    --gv-muted: rgba(241, 239, 233, 0.68);
    --gv-line: rgba(255, 255, 255, 0.16);
    --gv-btn-bg: rgba(22, 22, 26, 0.72);
    --gv-btn-line: rgba(255, 255, 255, 0.24);
    --gv-btn-hover: rgba(48, 48, 56, 0.92);
  }
}

.gallery-viewer[hidden] {
  display: none;
}

body.gallery-viewer-active {
  overflow: hidden;
}

/* Resting (open) state. The open/close motion is driven by the JS flight
   (Web Animations API), so these define where things sit at rest; JS animates
   them to/from their off-screen state. */
.gallery-viewer-info {
  position: relative;
  z-index: 1;
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 30px 28px;
  overflow: auto;
  background: var(--gv-bg);
  border-right: 1px solid var(--gv-line);
  pointer-events: auto;
}

.gallery-viewer-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 800;
}

.gallery-viewer-title {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.12;
}

.gallery-viewer-date {
  margin: 0;
  color: var(--gv-muted);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 0.9rem;
  font-weight: 700;
}

.gallery-viewer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-viewer-tags:empty {
  display: none;
}

.gallery-viewer-tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--gv-line);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  user-select: none;
}

.gallery-viewer-caption {
  color: var(--gv-muted);
  line-height: 1.6;
}

.gallery-viewer-caption p {
  margin: 0;
}

.gallery-viewer-caption p + p {
  margin-top: 0.8em;
}

.gallery-viewer-count {
  margin: auto 0 0;
  padding-top: 12px;
  color: var(--gv-muted);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 0.9rem;
  font-weight: 700;
}

.gallery-viewer-stage {
  position: relative;
  z-index: 5;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  touch-action: none;
  pointer-events: none;
}

/* Applied to the grid <img> while it lives in the viewer. width/height: auto
   overrides the tile's width/height attributes so max-width/max-height scale
   the image proportionally to a true image-ratio box (no independent clamping,
   so no letterbox). */
.gallery-viewer-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  cursor: pointer;
  pointer-events: auto;
}

.gallery-viewer-img.is-zoom-ready {
  cursor: zoom-in;
}

.gallery-viewer-img.is-zoom-ready.is-zoomed {
  cursor: grab;
}

.gallery-viewer-btn {
  position: absolute;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--gv-btn-line);
  border-radius: 999px;
  background: var(--gv-btn-bg);
  color: var(--gv-text);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 160ms ease, background 160ms ease;
  pointer-events: auto;
}

.gallery-viewer-btn svg {
  display: block;
}

.gallery-viewer-btn:hover:not(:disabled),
.gallery-viewer-btn:focus-visible {
  border-color: currentColor;
  background: var(--gv-btn-hover);
}

.gallery-viewer-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.gallery-viewer-close {
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
}

.gallery-viewer-prev,
.gallery-viewer-next {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
}

.gallery-viewer-prev {
  left: 16px;
}

.gallery-viewer-next {
  right: 16px;
}

@media (max-width: 760px) {
  .gallery-viewer {
    flex-direction: column;
  }

  .gallery-viewer-stage {
    order: 1;
    min-height: 0;
  }

  .gallery-viewer-info {
    order: 2;
    flex: 0 0 auto;
    max-height: 32vh;
    padding: 16px 18px 20px;
    border-right: 0;
    border-top: 1px solid var(--gv-line);
  }

  .gallery-viewer-title {
    font-size: 1.25rem;
  }

  .gallery-viewer-prev,
  .gallery-viewer-next {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 560px) {
  .gallery-shell {
    width: min(100% - 28px, 1100px);
  }

  .gallery-intro h1 {
    font-size: 3rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 8px;
  }
}

@media (max-width: 900px) {
  body[data-page="music"] {
    --music-library-width: min(82vw, 320px);
  }

  .music-content {
    padding: 36px 20px 44px;
  }

  .music-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 28px, 760px);
    padding: 36px 0;
  }

  .music-shell {
    width: 100%;
    padding: 0;
  }

  .music-content {
    padding: 28px 14px 36px;
  }

  h1:not(.site-title) {
    font-size: clamp(2.5rem, 4.3rem, 4.3rem);
  }

  .site-title {
    font-size: clamp(1.85rem, 12.6vw, 4.3rem);
  }

  .lede {
    font-size: 1.05rem;
  }

  .blog-shell {
    width: min(100% - 28px, 860px);
  }

  .blog-intro h1,
  .blog-post-header h1 {
    font-size: 3rem;
  }

  .blog-list-item a,
  .blog-post-body .blog-note {
    padding: 16px;
  }

  .blog-post-body {
    font-size: 1rem;
  }

  .question {
    padding: 18px;
  }

  .question legend {
    font-size: 1rem;
  }

  .answer {
    font-size: 0.96rem;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }

  .music-editor-panel,
  .music-side-panel,
  .music-library-panel {
    padding: 14px;
  }

  .music-code {
    min-height: 320px;
    font-size: 0.88rem;
  }

  .music-examples {
    grid-template-columns: 1fr;
  }
}
