:root {
  color-scheme: light dark;
  --bg: #e9dfcf;
  --bg-deep: #d6c7ae;
  --surface: rgba(252, 246, 236, 0.92);
  --surface-strong: rgba(255, 250, 243, 0.97);
  --surface-ghost: rgba(246, 236, 221, 0.68);
  --ink: #221a14;
  --muted: #736456;
  --line: rgba(99, 78, 58, 0.18);
  --line-strong: rgba(87, 63, 41, 0.38);
  --moss: #566d4f;
  --moss-soft: #c8d8b6;
  --copper: #b46841;
  --copper-soft: #e9c3a6;
  --river: #4f6f86;
  --river-soft: #c8d9e5;
  --sand: #e2d1b1;
  --context: rgba(228, 218, 203, 0.78);
  --shadow: 0 24px 70px rgba(48, 34, 24, 0.14);
  --shadow-tight: 0 12px 30px rgba(48, 34, 24, 0.12);
  --radius: 6px;
  --radius-soft: 10px;
  --mono: "SFMono-Regular", "IBM Plex Mono", "Fira Code", Consolas, monospace;
  --ui: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  --display: "Iowan Old Style", Baskerville, "Palatino Linotype", "Book Antiqua", serif;
  --body-glow-a: rgba(255, 250, 240, 0.92);
  --body-glow-b: rgba(201, 217, 229, 0.32);
  --body-glow-c: rgba(180, 104, 65, 0.12);
  --body-top: #f3eadb;
  --body-dot-a: rgba(91, 76, 60, 0.06);
  --body-dot-b: rgba(79, 111, 134, 0.05);
  --button-ink: #fbf6ee;
  --button-top: #5d7f97;
  --button-bottom: #43627b;
  --quiet-surface: rgba(255, 250, 243, 0.72);
  --secondary-surface: rgba(200, 216, 182, 0.5);
  --help-surface: rgba(255, 250, 243, 0.98);
  --help-border: rgba(87, 63, 41, 0.16);
  --chip-surface: rgba(255, 250, 243, 0.72);
  --chip-border: rgba(87, 63, 41, 0.18);
  --summary-surface: rgba(255, 251, 244, 0.78);
  --summary-border: rgba(87, 63, 41, 0.12);
  --pill-surface: rgba(255, 250, 243, 0.8);
  --pill-surface-active: rgba(244, 249, 252, 0.92);
  --pill-border: rgba(87, 63, 41, 0.14);
  --editor-surface: linear-gradient(180deg, rgba(251, 245, 235, 0.98) 0%, rgba(242, 232, 216, 0.96) 100%);
  --editor-note-surface: rgba(255, 250, 243, 0.72);
  --choice-surface: rgba(255, 250, 243, 0.78);
  --selection-card-surface: linear-gradient(180deg, rgba(250, 243, 231, 0.93) 0%, rgba(242, 233, 218, 0.9) 100%);
  --field-surface: rgba(255, 251, 245, 0.9);
  --segmented-surface: rgba(255, 249, 241, 0.88);
  --board-panel-surface: linear-gradient(180deg, rgba(255, 252, 246, 0.94) 0%, rgba(244, 233, 216, 0.92) 100%);
  --board-shell-surface:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.64), transparent 28%),
    linear-gradient(180deg, rgba(255, 251, 244, 0.96) 0%, rgba(244, 233, 216, 0.96) 100%);
  --transport-surface: linear-gradient(180deg, rgba(250, 243, 231, 0.95) 0%, rgba(241, 231, 216, 0.96) 100%);
  --metric-surface: linear-gradient(180deg, rgba(250, 242, 229, 0.92) 0%, rgba(242, 232, 216, 0.9) 100%);
  --map-surface: linear-gradient(180deg, rgba(255, 251, 244, 0.9) 0%, rgba(245, 236, 222, 0.92) 100%);
  --track-surface: rgba(232, 226, 216, 0.9);
  --map-strong: rgba(34, 26, 20, 0.46);
  --map-label: rgba(34, 26, 20, 0.72);
  --brace-line: rgba(87, 63, 41, 0.38);
  --grid-surface: linear-gradient(180deg, rgba(238, 226, 209, 0.62) 0%, rgba(225, 212, 194, 0.74) 100%);
  --cell-sub: rgba(72, 64, 57, 0.7);
  --transport-chip-surface: rgba(255, 255, 255, 0.3);
  --transport-chip-shine: inset 0 1px 0 rgba(255, 255, 255, 0.34);
  --pill-start-surface: rgba(200, 216, 182, 0.9);
  --pill-completion-surface: rgba(233, 195, 166, 0.92);
  --pill-eduppu-surface: rgba(200, 217, 229, 0.96);
  --pill-samam-surface: rgba(231, 224, 215, 0.98);
  --pill-phrase-surface: rgba(214, 231, 198, 0.94);
  --pill-karvai-surface: rgba(242, 214, 191, 0.94);
  --phrase-cell-surface: linear-gradient(180deg, rgba(214, 231, 198, 0.94) 0%, rgba(193, 212, 176, 0.96) 100%);
  --karvai-cell-surface: linear-gradient(180deg, rgba(242, 214, 191, 0.94) 0%, rgba(233, 195, 166, 0.94) 100%);
  --phrase-cell-surface-active: linear-gradient(180deg, rgba(235, 246, 224, 0.98) 0%, rgba(208, 230, 190, 0.98) 100%);
  --karvai-cell-surface-active: linear-gradient(180deg, rgba(248, 226, 205, 0.98) 0%, rgba(235, 201, 172, 0.98) 100%);
  --notation-surface: rgba(255, 250, 243, 0.8);
  --notebook-surface: linear-gradient(180deg, rgba(250, 243, 231, 0.94) 0%, rgba(238, 231, 220, 0.92) 100%);
  --samam-dot: #2a241f;
  --hand-cue-panel-line: rgba(87, 63, 41, 0.1);
  --hand-cue-stage-surface: transparent;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11161a;
  --bg-deep: #0b1014;
  --surface: rgba(20, 26, 31, 0.9);
  --surface-strong: rgba(24, 31, 37, 0.96);
  --surface-ghost: rgba(18, 24, 29, 0.72);
  --ink: #edf0e8;
  --muted: #aab2ab;
  --line: rgba(183, 196, 189, 0.16);
  --line-strong: rgba(183, 196, 189, 0.28);
  --moss: #7f9c74;
  --moss-soft: rgba(127, 156, 116, 0.24);
  --copper: #cf936d;
  --copper-soft: rgba(207, 147, 109, 0.24);
  --river: #83a8c4;
  --river-soft: rgba(131, 168, 196, 0.26);
  --sand: #8e816f;
  --context: rgba(41, 49, 56, 0.9);
  --shadow: 0 28px 76px rgba(0, 0, 0, 0.36);
  --shadow-tight: 0 14px 32px rgba(0, 0, 0, 0.3);
  --body-glow-a: rgba(67, 90, 83, 0.14);
  --body-glow-b: rgba(84, 117, 142, 0.14);
  --body-glow-c: rgba(176, 111, 76, 0.1);
  --body-top: #151b20;
  --body-dot-a: rgba(194, 208, 199, 0.04);
  --body-dot-b: rgba(131, 168, 196, 0.04);
  --button-ink: #f4f7ef;
  --button-top: #6f9179;
  --button-bottom: #51695c;
  --quiet-surface: rgba(28, 35, 41, 0.86);
  --secondary-surface: rgba(70, 93, 74, 0.46);
  --help-surface: rgba(18, 24, 29, 0.98);
  --help-border: rgba(183, 196, 189, 0.18);
  --chip-surface: rgba(25, 32, 37, 0.86);
  --chip-border: rgba(183, 196, 189, 0.2);
  --summary-surface: rgba(22, 29, 35, 0.84);
  --summary-border: rgba(183, 196, 189, 0.14);
  --pill-surface: rgba(24, 31, 37, 0.88);
  --pill-surface-active: rgba(29, 41, 49, 0.92);
  --pill-border: rgba(183, 196, 189, 0.16);
  --editor-surface: linear-gradient(180deg, rgba(20, 26, 31, 0.98) 0%, rgba(16, 21, 26, 0.96) 100%);
  --editor-note-surface: rgba(24, 31, 37, 0.84);
  --choice-surface: rgba(25, 32, 37, 0.9);
  --selection-card-surface: linear-gradient(180deg, rgba(23, 30, 35, 0.96) 0%, rgba(17, 23, 28, 0.94) 100%);
  --field-surface: rgba(17, 23, 28, 0.94);
  --segmented-surface: rgba(19, 25, 30, 0.9);
  --board-panel-surface: linear-gradient(180deg, rgba(21, 28, 33, 0.95) 0%, rgba(15, 20, 25, 0.93) 100%);
  --board-shell-surface:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.04), transparent 28%),
    linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(16, 21, 26, 0.96) 100%);
  --transport-surface: linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(16, 21, 26, 0.96) 100%);
  --metric-surface: linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(16, 21, 26, 0.93) 100%);
  --map-surface: linear-gradient(180deg, rgba(23, 30, 35, 0.95) 0%, rgba(16, 21, 26, 0.95) 100%);
  --track-surface: rgba(29, 37, 43, 0.92);
  --map-strong: rgba(238, 241, 233, 0.46);
  --map-label: rgba(226, 230, 224, 0.74);
  --brace-line: rgba(183, 196, 189, 0.3);
  --grid-surface: linear-gradient(180deg, rgba(29, 37, 43, 0.86) 0%, rgba(24, 31, 37, 0.9) 100%);
  --cell-sub: rgba(200, 208, 202, 0.72);
  --transport-chip-surface: rgba(21, 28, 33, 0.92);
  --transport-chip-shine: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --pill-start-surface: rgba(72, 99, 66, 0.92);
  --pill-completion-surface: rgba(126, 82, 58, 0.92);
  --pill-eduppu-surface: rgba(59, 84, 103, 0.92);
  --pill-samam-surface: rgba(43, 52, 59, 0.96);
  --pill-phrase-surface: rgba(63, 87, 58, 0.92);
  --pill-karvai-surface: rgba(122, 80, 58, 0.92);
  --phrase-cell-surface: linear-gradient(180deg, rgba(68, 92, 62, 0.96) 0%, rgba(50, 70, 46, 0.98) 100%);
  --karvai-cell-surface: linear-gradient(180deg, rgba(132, 89, 64, 0.96) 0%, rgba(101, 67, 48, 0.98) 100%);
  --phrase-cell-surface-active: linear-gradient(180deg, rgba(80, 108, 73, 0.98) 0%, rgba(58, 81, 52, 1) 100%);
  --karvai-cell-surface-active: linear-gradient(180deg, rgba(149, 101, 73, 0.98) 0%, rgba(116, 77, 56, 1) 100%);
  --notation-surface: rgba(24, 31, 37, 0.86);
  --notebook-surface: linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(18, 24, 29, 0.94) 100%);
  --samam-dot: #f0f3eb;
  --hand-cue-panel-line: rgba(238, 241, 233, 0.08);
  --hand-cue-stage-surface: transparent;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #11161a;
    --bg-deep: #0b1014;
    --surface: rgba(20, 26, 31, 0.9);
    --surface-strong: rgba(24, 31, 37, 0.96);
    --surface-ghost: rgba(18, 24, 29, 0.72);
    --ink: #edf0e8;
    --muted: #aab2ab;
    --line: rgba(183, 196, 189, 0.16);
    --line-strong: rgba(183, 196, 189, 0.28);
    --moss: #7f9c74;
    --moss-soft: rgba(127, 156, 116, 0.24);
    --copper: #cf936d;
    --copper-soft: rgba(207, 147, 109, 0.24);
    --river: #83a8c4;
    --river-soft: rgba(131, 168, 196, 0.26);
    --sand: #8e816f;
    --context: rgba(41, 49, 56, 0.9);
    --shadow: 0 28px 76px rgba(0, 0, 0, 0.36);
    --shadow-tight: 0 14px 32px rgba(0, 0, 0, 0.3);
    --body-glow-a: rgba(67, 90, 83, 0.14);
    --body-glow-b: rgba(84, 117, 142, 0.14);
    --body-glow-c: rgba(176, 111, 76, 0.1);
    --body-top: #151b20;
    --body-dot-a: rgba(194, 208, 199, 0.04);
    --body-dot-b: rgba(131, 168, 196, 0.04);
    --button-ink: #f4f7ef;
    --button-top: #6f9179;
    --button-bottom: #51695c;
    --quiet-surface: rgba(28, 35, 41, 0.86);
    --secondary-surface: rgba(70, 93, 74, 0.46);
    --help-surface: rgba(18, 24, 29, 0.98);
    --help-border: rgba(183, 196, 189, 0.18);
    --chip-surface: rgba(25, 32, 37, 0.86);
    --chip-border: rgba(183, 196, 189, 0.2);
    --summary-surface: rgba(22, 29, 35, 0.84);
    --summary-border: rgba(183, 196, 189, 0.14);
    --pill-surface: rgba(24, 31, 37, 0.88);
    --pill-surface-active: rgba(29, 41, 49, 0.92);
    --pill-border: rgba(183, 196, 189, 0.16);
    --editor-surface: linear-gradient(180deg, rgba(20, 26, 31, 0.98) 0%, rgba(16, 21, 26, 0.96) 100%);
    --editor-note-surface: rgba(24, 31, 37, 0.84);
    --choice-surface: rgba(25, 32, 37, 0.9);
    --selection-card-surface: linear-gradient(180deg, rgba(23, 30, 35, 0.96) 0%, rgba(17, 23, 28, 0.94) 100%);
    --field-surface: rgba(17, 23, 28, 0.94);
    --segmented-surface: rgba(19, 25, 30, 0.9);
    --board-panel-surface: linear-gradient(180deg, rgba(21, 28, 33, 0.95) 0%, rgba(15, 20, 25, 0.93) 100%);
    --board-shell-surface:
      radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.04), transparent 28%),
      linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(16, 21, 26, 0.96) 100%);
    --transport-surface: linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(16, 21, 26, 0.96) 100%);
    --metric-surface: linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(16, 21, 26, 0.93) 100%);
    --map-surface: linear-gradient(180deg, rgba(23, 30, 35, 0.95) 0%, rgba(16, 21, 26, 0.95) 100%);
    --track-surface: rgba(29, 37, 43, 0.92);
    --map-strong: rgba(238, 241, 233, 0.46);
    --map-label: rgba(226, 230, 224, 0.74);
    --brace-line: rgba(183, 196, 189, 0.3);
    --grid-surface: linear-gradient(180deg, rgba(29, 37, 43, 0.86) 0%, rgba(24, 31, 37, 0.9) 100%);
    --cell-sub: rgba(200, 208, 202, 0.72);
    --transport-chip-surface: rgba(21, 28, 33, 0.92);
    --transport-chip-shine: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --pill-start-surface: rgba(72, 99, 66, 0.92);
    --pill-completion-surface: rgba(126, 82, 58, 0.92);
    --pill-eduppu-surface: rgba(59, 84, 103, 0.92);
    --pill-samam-surface: rgba(43, 52, 59, 0.96);
    --pill-phrase-surface: rgba(63, 87, 58, 0.92);
    --pill-karvai-surface: rgba(122, 80, 58, 0.92);
    --phrase-cell-surface: linear-gradient(180deg, rgba(68, 92, 62, 0.96) 0%, rgba(50, 70, 46, 0.98) 100%);
    --karvai-cell-surface: linear-gradient(180deg, rgba(132, 89, 64, 0.96) 0%, rgba(101, 67, 48, 0.98) 100%);
    --phrase-cell-surface-active: linear-gradient(180deg, rgba(80, 108, 73, 0.98) 0%, rgba(58, 81, 52, 1) 100%);
    --karvai-cell-surface-active: linear-gradient(180deg, rgba(149, 101, 73, 0.98) 0%, rgba(116, 77, 56, 1) 100%);
    --notation-surface: rgba(24, 31, 37, 0.86);
    --notebook-surface: linear-gradient(180deg, rgba(24, 31, 37, 0.96) 0%, rgba(18, 24, 29, 0.94) 100%);
    --samam-dot: #f0f3eb;
    --hand-cue-panel-line: rgba(238, 241, 233, 0.08);
    --hand-cue-stage-surface: transparent;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 16%, var(--body-glow-a), transparent 28%),
    radial-gradient(circle at 88% 12%, var(--body-glow-b), transparent 24%),
    radial-gradient(circle at 76% 72%, var(--body-glow-c), transparent 22%),
    linear-gradient(180deg, var(--body-top) 0%, var(--bg) 100%);
  font-family: var(--ui);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-radial-gradient(circle at 18% 24%, var(--body-dot-a) 0 1px, transparent 1px 20px),
    repeating-radial-gradient(circle at 82% 74%, var(--body-dot-b) 0 1px, transparent 1px 22px);
  opacity: 0.55;
}

button,
input,
select,
textarea,
summary {
  font: inherit;
}

button,
select,
summary {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(79, 111, 134, 0.22);
  outline-offset: 2px;
}

button {
  min-height: 40px;
  border: 1px solid var(--river);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--button-ink);
  background:
    linear-gradient(180deg, var(--button-top) 0%, var(--button-bottom) 100%);
  box-shadow: 0 10px 20px rgba(79, 111, 134, 0.18);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

button:hover {
  filter: saturate(1.04);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: default;
  opacity: 0.52;
  filter: none;
  transform: none;
}

.quiet-button,
.secondary-button {
  color: var(--ink);
  background: var(--quiet-surface);
  border-color: var(--line-strong);
  box-shadow: none;
}

.secondary-button {
  background: var(--secondary-surface);
}

.active {
  background: linear-gradient(180deg, #637d59 0%, #485e42 100%);
  border-color: #485e42;
  color: #f6f1e8;
}

.hidden {
  display: none !important;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 44px) 14px;
  position: relative;
  z-index: 30;
  align-items: start;
}

.title-cluster {
  display: grid;
  gap: 8px;
}

.header-help {
  display: flex;
  align-items: start;
  gap: 10px;
  position: relative;
  justify-self: end;
  z-index: 40;
}

.corner-theme-button,
.corner-help-button,
.help-close {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 14px;
}

.corner-theme-button {
  min-width: 72px;
  text-align: center;
}

.help-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--help-border);
  border-radius: 12px;
  background: var(--help-surface);
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(14px);
  z-index: 50;
}

.help-popup-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.help-popup h2 {
  font-size: 1.08rem;
  line-height: 1.08;
}

.eyebrow,
.section-kicker,
label span,
.metric-label,
.notation-card span,
.summary-list span,
.tala-rail-copy p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header h1,
.tala-rail h2,
.panel-block h2,
.board-head h2,
.summary-card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: clamp(2rem, 3vw, 3.1rem);
  line-height: 0.95;
}

.scope-note {
  max-width: 720px;
  margin: 0;
  color: color-mix(in srgb, var(--muted) 82%, var(--ink) 18%);
  font-size: 0.98rem;
  line-height: 1.5;
}

.app-shell {
  padding: 0 clamp(18px, 4vw, 44px) 44px;
  position: relative;
  z-index: 1;
}

.tala-rail,
.control-panel,
.board-panel,
.route-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.tala-rail {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: start;
  padding: 18px 20px;
}

.tala-rail-copy {
  display: grid;
  gap: 6px;
}

.tala-rail h2 {
  font-size: 1.5rem;
  line-height: 1.08;
}

.tala-rail-controls {
  display: grid;
  gap: 12px;
}

.compact-state-strip {
  padding: 12px 14px;
  border: 1px solid var(--summary-border);
  border-radius: var(--radius-soft);
  background: var(--summary-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.44);
}

.tala-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tala-chip {
  min-height: 42px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--chip-surface);
  box-shadow: none;
}

.tala-chip.active {
  background: linear-gradient(180deg, rgba(86, 109, 79, 0.95) 0%, rgba(67, 85, 61, 1) 100%);
  color: #f6f0e5;
  border-color: rgba(67, 85, 61, 1);
}

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

.selection-pill {
  min-height: 58px;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--pill-border);
  border-radius: 12px;
  background: var(--pill-surface);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
  text-align: left;
  box-shadow: none;
}

.selection-pill:hover {
  background: color-mix(in srgb, var(--pill-surface) 92%, var(--surface-strong) 8%);
  border-color: rgba(79, 111, 134, 0.28);
  filter: none;
}

.selection-pill:active {
  transform: translateY(0);
}

.selection-pill.active-editor {
  border-color: rgba(79, 111, 134, 0.4);
  background: var(--pill-surface-active);
}

.selection-pill strong {
  color: var(--ink);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.selection-pill span {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.selection-editor {
  display: grid;
  margin-top: 10px;
}

.selection-editor-panel {
  display: grid;
  gap: 14px;
  padding: 14px 16px 16px;
  border: 1px solid var(--pill-border);
  border-radius: 16px;
  background: var(--editor-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.selection-editor-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.selection-editor-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.18rem;
  line-height: 1.04;
}

.selection-editor-close {
  justify-self: end;
}

.editor-panel,
.editor-field,
.editor-note {
  display: grid;
  gap: 10px;
}

.editor-toggle-row {
  display: flex;
  justify-content: start;
}

.subtle-toggle {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
}

.editor-note {
  padding: 12px;
  border: 1px solid var(--pill-border);
  border-radius: 10px;
  background: var(--editor-note-surface);
}

.editor-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.choice-chip {
  min-height: 40px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  color: var(--ink);
  background: var(--choice-surface);
  box-shadow: none;
}

.choice-chip.active {
  color: #f9f4eb;
  background: linear-gradient(180deg, rgba(86, 109, 79, 0.95) 0%, rgba(67, 85, 61, 1) 100%);
  border-color: rgba(67, 85, 61, 1);
}

.compact-choice-row,
.compact-mode-row {
  gap: 8px;
}

.compact-choice-row .choice-chip,
.compact-mode-row .choice-chip {
  min-height: 38px;
}

.selection-card {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--pill-border);
  border-radius: var(--radius-soft);
  background: var(--selection-card-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.selection-card-head {
  display: grid;
  gap: 4px;
}

.selection-card-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.08rem;
  line-height: 1.06;
}

.selected-tala-strip {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(87, 63, 41, 0.12);
  border-radius: var(--radius-soft);
  background: rgba(255, 251, 244, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.44);
}

.selection-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-items: start;
}

.rhythm-editors {
  display: grid;
  gap: 10px;
}

.rhythm-editors summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}

.rhythm-editors summary::-webkit-details-marker {
  display: none;
}

.custom-tala-card {
  background: linear-gradient(180deg, rgba(251, 245, 235, 0.96) 0%, rgba(242, 232, 216, 0.95) 100%);
}

.quick-presets {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.quick-presets summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}

.quick-presets summary::-webkit-details-marker {
  display: none;
}

.more-tala {
  display: grid;
  gap: 8px;
}

.more-tala summary,
.rhythm-editors summary,
.quick-presets summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}

.more-tala summary::-webkit-details-marker,
.rhythm-editors summary::-webkit-details-marker,
.quick-presets summary::-webkit-details-marker {
  display: none;
}

.more-tala-panel {
  display: grid;
  gap: 12px;
}

.how-to-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 12px;
  color: var(--ink);
  line-height: 1.45;
}

.how-to-list strong {
  font-weight: 800;
}

.eduppu-presets {
  margin-top: 12px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--chip-border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--field-surface);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(232px, 272px) minmax(0, 1fr);
  gap: 20px;
  align-items: flex-start;
  margin-top: 18px;
}

.board-panel,
.control-panel,
.route-card {
  align-self: flex-start;
}

.control-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.board-panel {
  grid-column: 2;
  grid-row: 1;
}

.route-card {
  grid-column: 2;
  grid-row: 2;
}

.panel-block {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-block:last-child {
  border-bottom: 0;
}

.panel-block h2 {
  font-size: 1.25rem;
  line-height: 1.1;
}

.panel-block label + label,
.panel-block label + .support-text,
.panel-block label + .structure-grid,
.panel-block summary + .structure-grid,
.panel-block .structure-grid + .support-text,
.panel-block .support-text + .advanced-grid,
.panel-block .inline-fields,
.support-text + .button-row,
.button-row + .inline-warning {
  margin-top: 14px;
}

.support-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--chip-border);
  border-radius: 8px;
  background: var(--segmented-surface);
}

.segmented button {
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--summary-border);
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: linear-gradient(180deg, rgba(86, 109, 79, 0.94) 0%, rgba(67, 85, 61, 1) 100%);
  color: #f9f4eb;
}

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

.segmented-triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented-quad {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.inline-fields,
.structure-grid,
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide-advanced {
  grid-column: span 2;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-warning,
.status-line {
  min-height: 20px;
  margin: 0;
  color: #92462c;
  font-size: 0.9rem;
  line-height: 1.35;
}

.korvai-builder {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--summary-border);
  border-left: 5px solid var(--river);
  border-radius: 6px;
  background: color-mix(in srgb, var(--field-surface) 76%, transparent);
}

.korvai-builder-head,
.korvai-suggestions-head,
.korvai-canvas-head,
.korvai-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.korvai-builder-head > div,
.korvai-suggestions-head > div,
.korvai-canvas-head > div,
.korvai-editor-head > div {
  display: grid;
  gap: 3px;
}

.korvai-builder-head h2,
.korvai-editor-head h3 {
  margin: 0;
  font-family: var(--display);
}

.korvai-builder-head h2 {
  font-size: 1.4rem;
}

.korvai-editor-head h3 {
  font-size: 1.08rem;
}

.korvai-add-button {
  min-height: 36px;
  padding-inline: 10px;
  white-space: nowrap;
}

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

.korvai-destination-grid label,
.korvai-editor-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.korvai-destination-grid select,
.korvai-editor-fields input {
  min-height: 38px;
  padding: 7px 9px;
}

.korvai-canvas {
  display: grid;
  gap: 12px;
  padding-block: 14px;
  border-block: 1px solid var(--summary-border);
}

.korvai-line-summary {
  margin: 3px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.35;
}

.korvai-fit-status {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--summary-border);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--chip-surface);
  font-size: 0.76rem;
  line-height: 1.2;
  text-align: center;
}

.korvai-fit-status[data-state="exact"] {
  border-color: color-mix(in srgb, var(--moss) 64%, var(--summary-border));
  color: var(--moss);
  background: color-mix(in srgb, var(--moss-soft) 46%, var(--chip-surface));
}

.korvai-fit-status[data-state="over"] {
  border-color: color-mix(in srgb, var(--copper) 64%, var(--summary-border));
  color: var(--copper);
  background: color-mix(in srgb, var(--copper-soft) 42%, var(--chip-surface));
}

.korvai-timeline {
  display: grid;
  gap: 13px;
}

.korvai-cycle {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-areas:
    "head ruler"
    "head track"
    "head sections";
  gap: 4px 10px;
  min-width: 0;
}

.korvai-cycle-head {
  grid-area: head;
  display: grid;
  align-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.68rem;
}

.korvai-cycle-head strong {
  color: var(--ink);
  font-size: 0.76rem;
}

.korvai-cycle-ruler,
.korvai-cycle-track,
.korvai-cycle-sections {
  display: grid;
  grid-template-columns: repeat(var(--matras), minmax(0, 1fr));
  min-width: 0;
}

.korvai-cycle-ruler {
  grid-area: ruler;
  min-height: 13px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  line-height: 1;
}

.korvai-cycle-ruler span {
  justify-self: start;
}

.korvai-cycle-track {
  grid-area: track;
  position: relative;
  min-height: 52px;
  overflow: visible;
  border: 1px solid var(--summary-border);
  border-radius: 5px;
  background-color: color-mix(in srgb, var(--track-surface) 70%, transparent);
  background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--summary-border) calc(100% - 1px));
  background-size: calc(100% / var(--matras)) 100%;
}

.korvai-open-space,
.korvai-segment,
.korvai-start-marker,
.korvai-section-divider {
  grid-row: 1;
}

.korvai-open-space {
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-ghost) 58%, transparent);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.korvai-segment {
  z-index: 2;
  min-width: 0;
  min-height: 50px;
  overflow: hidden;
  padding: 0 4px;
  border-width: 1px;
  border-radius: 3px;
  color: var(--ink);
  background: none;
  box-shadow: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.korvai-segment.purvanga {
  border-color: color-mix(in srgb, var(--river) 62%, var(--summary-border));
  background: color-mix(in srgb, var(--river-soft) 70%, var(--field-surface));
}

.korvai-segment.uttaranga {
  border-color: color-mix(in srgb, var(--copper) 62%, var(--summary-border));
  background: color-mix(in srgb, var(--copper-soft) 68%, var(--field-surface));
}

.korvai-segment.karvai {
  color: var(--muted);
  background-color: color-mix(in srgb, var(--field-surface) 88%, transparent);
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--muted) 22%, transparent) 5px 6px);
}

.korvai-segment.selected {
  z-index: 3;
  outline: 3px solid color-mix(in srgb, var(--moss) 62%, transparent);
  outline-offset: -3px;
  filter: saturate(1.08);
}

.korvai-start-marker,
.korvai-section-divider {
  z-index: 4;
  width: 0;
  justify-self: start;
  pointer-events: none;
}

.korvai-start-marker {
  height: 100%;
  border-left: 3px solid var(--moss);
}

.korvai-start-marker::before {
  content: "START";
  position: absolute;
  top: -17px;
  color: var(--moss);
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 800;
  transform: translateX(-2px);
}

.korvai-section-divider {
  height: 100%;
  border-left: 2px solid var(--line-strong);
}

.korvai-landing-marker {
  position: absolute;
  right: -1px;
  top: -20px;
  z-index: 5;
  height: calc(100% + 21px);
  display: flex;
  align-items: flex-start;
  padding-right: 5px;
  border-right: 4px solid var(--copper);
  color: var(--copper);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.korvai-overflow-marker {
  position: absolute;
  top: 50%;
  left: -1px;
  z-index: 5;
  min-width: 28px;
  padding: 4px 5px;
  border-radius: 0 999px 999px 0;
  color: var(--button-ink);
  background: var(--copper);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 800;
  transform: translateY(-50%);
}

.korvai-cycle-sections {
  grid-area: sections;
  min-height: 18px;
  gap: 2px;
}

.korvai-cycle-sections span {
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  border-top: 2px solid;
  color: var(--muted);
  font-size: 0.6rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.korvai-cycle-sections .purvanga {
  border-color: var(--river);
}

.korvai-cycle-sections .uttaranga {
  border-color: var(--copper);
}

.korvai-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  color: var(--muted);
  font-size: 0.7rem;
}

.korvai-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.korvai-legend i {
  width: 12px;
  height: 12px;
  border: 1px solid var(--summary-border);
  border-radius: 2px;
}

.korvai-legend .purvanga {
  background: var(--river-soft);
}

.korvai-legend .uttaranga {
  background: var(--copper-soft);
}

.korvai-legend .karvai {
  background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--muted) 28%, transparent) 4px 5px);
}

.korvai-block-editor {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) minmax(280px, 1.28fr);
  grid-template-areas:
    "head fields"
    "role fields"
    "shape actions";
  gap: 10px 16px;
  align-items: center;
  padding: 13px 14px;
  border-left: 4px solid var(--moss);
  background: color-mix(in srgb, var(--editor-note-surface) 76%, transparent);
}

.korvai-editor-head {
  grid-area: head;
}

.korvai-editor-head > strong {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.korvai-role-switch {
  grid-area: role;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.korvai-editor-fields {
  grid-area: fields;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.korvai-editor-fields input {
  width: 100%;
  min-width: 0;
  font-family: var(--mono);
  font-size: 16px;
  text-align: center;
}

.korvai-editor-fields input[aria-invalid="true"] {
  border-color: var(--copper);
}

.korvai-editor-shape {
  grid-area: shape;
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.korvai-editor-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.korvai-editor-actions button {
  min-height: 32px;
  padding-inline: 9px;
  font-size: 0.72rem;
}

.korvai-suggestions {
  display: grid;
  gap: 9px;
}

.korvai-suggestions h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.02rem;
}

.korvai-suggestion-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.korvai-suggestion-list > .support-text {
  grid-column: 1 / -1;
  margin: 0;
}

.korvai-suggestion {
  min-width: 0;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 0.7fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--summary-border);
  border-radius: 5px;
  color: var(--ink);
  background: var(--field-surface);
  text-align: left;
  box-shadow: none;
}

.korvai-suggestion-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.korvai-suggestion small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
}

.korvai-suggestion strong,
.korvai-suggestion b {
  overflow-wrap: anywhere;
}

.korvai-suggestion b {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
}

.korvai-suggestion-preview {
  min-width: 0;
  height: 24px;
  display: flex;
  gap: 2px;
}

.korvai-suggestion-preview i {
  min-width: 2px;
  border: 1px solid color-mix(in srgb, var(--copper) 58%, var(--summary-border));
  border-radius: 2px;
  background: color-mix(in srgb, var(--copper-soft) 66%, var(--field-surface));
}

.korvai-suggestion-preview i.karvai {
  border-color: var(--summary-border);
  background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--muted) 25%, transparent) 4px 5px);
}

.korvai-suggestion-use {
  color: var(--moss);
  font-size: 0.72rem;
  font-weight: 800;
}

.status-line {
  color: var(--muted);
}

.advanced-panel summary,
.saved-panel summary {
  list-style: none;
}

.advanced-panel summary::-webkit-details-marker,
.saved-panel summary::-webkit-details-marker {
  display: none;
}

.advanced-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-action {
  color: var(--river);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.advanced-panel[open] .summary-action::after {
  content: "Close";
  margin-left: 4px;
}

.advanced-panel:not([open]) .summary-action::after {
  content: "Open";
  margin-left: 4px;
}

.more-tala[open] .summary-action::after,
.rhythm-editors[open] .summary-action::after,
.quick-presets[open] .summary-action::after {
  content: "Close";
  margin-left: 4px;
}

.more-tala:not([open]) .summary-action::after,
.rhythm-editors:not([open]) .summary-action::after,
.quick-presets:not([open]) .summary-action::after {
  content: "Open";
  margin-left: 4px;
}

.board-panel {
  padding: 10px;
  background: var(--board-panel-surface);
}

.board-shell {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--summary-border);
  border-radius: 6px;
  background: var(--board-shell-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), var(--shadow-tight);
}

.board-head {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.practice-mode-panel {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--summary-border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--board-shell-surface) 84%, var(--surface-strong) 16%);
}

.practice-mode-copy {
  display: grid;
  gap: 4px;
}

.board-head h2 {
  font-size: clamp(1.55rem, 2.4vw, 2.25rem);
  line-height: 1;
}

.board-copy {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.transport-card {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--summary-border);
  border-radius: 6px;
  background: var(--transport-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.transport-head {
  display: grid;
  gap: 6px;
}

.transport-head-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.transport-action-button {
  min-width: 74px;
  min-height: 40px;
  padding-inline: 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.transport-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.22rem;
  line-height: 1.06;
}

.tala-guide {
  container: tala-guide / inline-size;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--river) 54%, var(--summary-border));
  border-left: 5px solid var(--river);
  border-radius: 6px;
  background: color-mix(in srgb, var(--field-surface) 82%, var(--river-soft) 18%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.tala-guide-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.tala-guide-heading > div {
  display: grid;
  gap: 4px;
}

.tala-guide-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1;
}

.tala-guide-heading > p {
  text-align: right;
}

.hand-cue-panel {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(300px, 0.85fr);
  grid-template-areas:
    "stage head"
    "stage transport"
    "stage rail";
  gap: 14px 18px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--summary-border);
}

.hand-cue-head {
  grid-area: head;
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  text-align: left;
}

.hand-cue-stage {
  grid-area: stage;
  --hand-cue-duration: 760ms;
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 258px;
  overflow: hidden;
  background: var(--hand-cue-stage-surface);
}

.hand-cue-stage svg {
  position: relative;
  z-index: 1;
  display: block;
  width: min(100%, 332px);
  height: auto;
}

.hand-cue-panel > .transport-card {
  grid-area: transport;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.hand-cue-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  justify-items: start;
  text-align: left;
}

.hand-cue-copy h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.52rem;
  line-height: 1.1;
}

.hand-cue-progress {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  justify-content: center;
}

.hand-cue-count {
  min-width: 48px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--help-border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--field-surface) 82%, var(--river-soft) 18%);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
}

.hand-cue-ticks {
  --hand-cue-tick-count: 4;
  display: grid;
  grid-template-columns: repeat(var(--hand-cue-tick-count), minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
  padding: 10px 10px 8px;
  border: 1px solid var(--help-border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--field-surface) 92%, transparent);
  overflow: visible;
}

.hand-cue-tick {
  position: relative;
  min-width: 0;
  height: 12px;
  border-radius: 999px;
  background: rgba(115, 100, 86, 0.16);
  box-shadow: inset 0 0 0 1px rgba(87, 63, 41, 0.12);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.hand-cue-tick[data-state="complete"] {
  background: color-mix(in srgb, var(--river) 58%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--river) 54%, transparent);
}

.hand-cue-tick[data-state="current"] {
  background: var(--river);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--river-soft) 72%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  transform: scaleY(1.18);
}

.hand-cue-tick[data-start="true"] {
  background: color-mix(in srgb, var(--moss-soft) 76%, var(--field-surface) 24%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--moss) 64%, transparent);
}

.hand-cue-tick[data-start="true"]::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--moss);
  box-shadow: 0 0 0 2px var(--surface);
  transform: translateX(-50%);
}

.hand-cue-tick[data-start="true"][data-state="complete"] {
  background: color-mix(in srgb, var(--moss) 72%, var(--moss-soft) 28%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--moss) 76%, transparent);
}

.hand-cue-tick[data-start="true"][data-state="current"] {
  background: linear-gradient(90deg, var(--moss) 0%, color-mix(in srgb, var(--moss) 62%, var(--river) 38%) 100%);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--moss-soft) 48%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.hand-cue-rail {
  grid-area: rail;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
}

.hand-cue-rail-item {
  position: relative;
  min-width: 92px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.hand-cue-rail-item::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  grid-column: 1;
  grid-row: 1;
  background: rgba(115, 100, 86, 0.28);
  box-shadow: inset 0 0 0 1px rgba(87, 63, 41, 0.16);
}

.hand-cue-rail-item b {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.52rem;
  line-height: 1;
}

.hand-cue-rail-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hand-cue-rail-item[data-state="rest"] {
  opacity: 0.62;
}

.hand-cue-rail-item[data-state="cue"]::before {
  background: rgba(79, 111, 134, 0.38);
}

.hand-cue-rail-item[data-state="current"] {
  color: var(--ink);
}

.hand-cue-rail-item[data-state="current"]::before {
  background: var(--river);
  box-shadow: 0 0 0 4px rgba(200, 217, 229, 0.42);
}

.hand-cue-rail-item[data-state="current"] b {
  color: #fff;
}

.hand-cue-rail-item[data-state="next"] {
  color: var(--river);
}

.hand-cue-rail-item[data-state="next"]::before {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--river);
}

.hand-cue-current {
  transform-box: fill-box;
  transform-origin: 50% 76%;
}

.hand-cue-current {
  opacity: 0.96;
  transform: translate3d(-12px, -110px, 0) rotate(-5deg);
}

.hand-cue-stage.is-animating .hand-cue-current {
  animation: hand-cue-current-strike var(--hand-cue-duration) cubic-bezier(0.2, 0.78, 0.26, 1) both;
}

.hand-cue-impact-particles {
  pointer-events: none;
}

.hand-cue-impact-particle {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.hand-cue-impact-particle[data-tone="moss"] {
  fill: var(--moss);
}

.hand-cue-impact-particle[data-tone="river"] {
  fill: var(--river);
}

.hand-cue-stage.is-animating .hand-cue-impact-particle {
  animation: hand-cue-particle-burst var(--hand-cue-duration) cubic-bezier(0.16, 0.72, 0.24, 1) both;
  animation-delay: var(--particle-delay);
}

@keyframes hand-cue-current-strike {
  0% {
    opacity: 1;
    transform: translate3d(-2px, -10px, 0) rotate(-1deg);
  }

  38% {
    opacity: 1;
    transform: translate3d(-16px, -118px, 0) rotate(-8deg);
  }

  100% {
    opacity: 0.96;
    transform: translate3d(-12px, -110px, 0) rotate(-5deg);
  }
}

@keyframes hand-cue-particle-burst {
  0% {
    opacity: 0;
    transform: translate(var(--particle-start-x), var(--particle-start-y)) scale(0.55);
  }

  20% {
    opacity: 0.88;
  }

  100% {
    opacity: 0;
    transform: translate(var(--particle-dx), var(--particle-dy)) scale(0.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hand-cue-stage.is-animating .hand-cue-current {
    animation: none;
    transform: translate3d(-12px, -110px, 0) rotate(-5deg);
  }

  .hand-cue-stage.is-animating .hand-cue-impact-particle {
    animation: hand-cue-particle-reduced 180ms linear both;
  }
}

@keyframes hand-cue-particle-reduced {
  0%, 65% {
    opacity: 0.72;
    transform: translate(var(--particle-start-x), var(--particle-start-y));
  }

  100% {
    opacity: 0;
    transform: translate(var(--particle-start-x), var(--particle-start-y));
  }
}

.transport-toggle,
.transport-stop,
.transport-tap-button {
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.transport-stop {
  background: var(--chip-surface);
  border-color: var(--chip-border);
}

.transport-controls {
  display: grid;
  gap: 8px;
}

.playback-options {
  border-block: 1px solid var(--summary-border);
}

.playback-options-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
}

.playback-options-summary::-webkit-details-marker {
  display: none;
}

.playback-options-summary p {
  margin: 3px 0 0;
}

.playback-options-chevron {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.playback-options[open] .playback-options-chevron {
  transform: rotate(225deg);
}

.playback-options-body {
  display: grid;
  gap: 14px;
  padding: 0 12px 12px;
}

.playback-option-group {
  display: grid;
  gap: 7px;
}

.playback-option-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.accent-mode-buttons {
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.custom-accent-editor {
  display: grid;
  gap: 7px;
}

.custom-accent-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
  gap: 6px;
}

.custom-accent-count {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--summary-border);
  border-radius: 4px;
  background: var(--field-surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-weight: 700;
}

.custom-accent-count.active {
  border-color: var(--moss);
  background: var(--moss);
  color: var(--paper);
}

.transport-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-areas: "bpm actions buttons";
  align-items: center;
  gap: 10px 12px;
}

.transport-bpm-chip {
  grid-area: bpm;
  width: fit-content;
  display: inline-grid;
  grid-template-columns: auto 72px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--summary-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--field-surface) 88%, transparent);
}

.transport-bpm-chip[data-state="invalid"] {
  border-color: color-mix(in srgb, var(--copper) 72%, var(--line-strong));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--copper) 34%, transparent);
}

.transport-bpm-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.transport-bpm-chip input {
  width: 72px;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: right;
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.2;
}

.transport-bpm-chip input:focus-visible {
  outline: none;
}

.transport-bpm-chip input[aria-invalid="true"] {
  color: var(--copper);
}

.transport-tap-button {
  grid-area: actions;
  min-height: 42px;
  padding-inline: 14px;
  white-space: nowrap;
  user-select: none;
}

.transport-bpm-quick {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.transport-bpm-quick-button {
  min-height: 42px;
  min-width: 48px;
  padding-inline: 10px;
  font-size: 0.92rem;
  user-select: none;
}

.transport-button-row {
  grid-area: buttons;
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.transport-bpm-hint {
  margin: 0;
  min-height: 0;
  font-size: 0.82rem;
  line-height: 1.3;
}

.transport-bpm-hint[data-state="invalid"] {
  color: var(--copper);
}

.transport-bpm-hint[data-state="active"] {
  color: var(--river);
}

.transport-option-toggle {
  width: fit-content;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  padding: 0 12px;
  border: 1px solid var(--summary-border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-surface) 78%, transparent);
}

.transport-option-toggle input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--moss);
}

.transport-progress {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--help-border);
  border-radius: 999px;
  background: var(--field-surface);
  cursor: pointer;
}

.transport-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--moss) 0%, var(--river) 50%, var(--copper) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: width 180ms linear;
}

.metric-ribbon {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 78px;
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--summary-border);
  border-radius: 6px;
  background: var(--metric-surface);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--copper) 0%, rgba(86, 109, 79, 0.82) 100%);
}

.metric-card strong {
  font-size: clamp(1.18rem, 1.7vw, 1.35rem);
  line-height: 1.06;
  overflow-wrap: anywhere;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-compact {
  gap: 10px;
  font-size: 0.84rem;
}

.legend-compact span {
  gap: 6px;
}

.legend-swatch,
.marker-dot {
  display: inline-block;
  border-radius: 999px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border: 1px solid var(--chip-border);
}

.phrase-swatch {
  background: rgba(200, 216, 182, 0.9);
}

.karvai-swatch {
  background: rgba(233, 195, 166, 0.92);
}

.inactive-swatch {
  background: rgba(228, 218, 203, 0.92);
}

.marker-dot {
  width: 10px;
  height: 10px;
}

.start-dot {
  background: var(--moss);
}

.completion-dot {
  background: var(--copper);
}

.eduppu-dot {
  background: var(--river);
}

.grid-stage {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.cycle-strip {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.cycle-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.cycle-title strong {
  font-family: var(--display);
  font-size: 1.04rem;
}

.cycle-title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-cycle {
  gap: 12px;
}

.tala-map {
  --map-tala-row-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--map-tala-row-height) 18px 40px 54px;
  position: relative;
  row-gap: 6px;
  padding: 10px 12px 12px;
  border: 1px solid var(--pill-border);
  border-radius: 8px;
  background: var(--map-surface);
  overflow: hidden;
}

.nadai-track,
.map-marker-layer,
.route-backdrop,
.route-layer,
.group-brace-layer {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(var(--matra-count), minmax(0, 1fr));
  width: 100%;
}

.nadai-track {
  grid-row: 1;
  min-width: 0;
  border: 1px solid var(--chip-border);
  border-radius: 6px;
  overflow: hidden;
}

.map-marker-layer {
  grid-row: 2;
  align-items: center;
  min-width: 0;
}

.nadai-cell {
  position: relative;
  min-width: 0;
  border-right: 1px solid var(--summary-border);
  background: var(--track-surface);
  cursor: pointer;
}

.nadai-cell:last-child {
  border-right: 0;
}

.nadai-cell.beat-start {
  border-left: 2px solid var(--map-strong);
}

.nadai-cell.group-end {
  box-shadow: inset -2px 0 color-mix(in srgb, var(--map-strong) 72%, transparent);
}

.nadai-cell.samam {
  box-shadow: inset 3px 0 var(--map-label), inset -2px 0 color-mix(in srgb, var(--map-strong) 72%, transparent);
}

.nadai-label {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 1px;
  color: var(--map-label);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.nadai-matra-count {
  opacity: 0.76;
  font-size: 0.54rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
}

.marker-cell {
  position: relative;
  min-width: 0;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.marker-cell.has-marker::before {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 50%;
  width: 1px;
  background: color-mix(in srgb, var(--map-strong) 28%, transparent);
  transform: translateX(-50%);
}

.marker-stack {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.map-marker-pin {
  width: 4px;
  height: 15px;
  display: block;
  border-radius: 999px;
}

.map-marker-pin.start {
  background: var(--moss);
}

.map-marker-pin.completion {
  background: var(--copper);
}

.map-marker-pin.eduppu {
  background: var(--river);
}

.route-backdrop {
  grid-row: 3;
  position: relative;
  min-width: 0;
  border: 1px solid var(--chip-border);
  border-radius: 6px;
  overflow: hidden;
  background: color-mix(in srgb, var(--track-surface) 82%, var(--surface-strong) 18%);
}

.route-backdrop::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: color-mix(in srgb, var(--map-strong) 22%, transparent);
  transform: translateY(-50%);
}

.route-slot {
  position: relative;
  min-width: 0;
  min-height: 40px;
  border-right: 1px solid var(--summary-border);
  background: color-mix(in srgb, var(--track-surface) 88%, transparent);
  cursor: pointer;
}

.route-slot:last-child {
  border-right: 0;
}

.route-slot.beat-start {
  border-left: 2px solid var(--map-strong);
}

.route-slot.group-end {
  box-shadow: inset -2px 0 color-mix(in srgb, var(--map-strong) 72%, transparent);
}

.route-slot.samam {
  box-shadow: inset 3px 0 var(--map-label), inset -2px 0 color-mix(in srgb, var(--map-strong) 72%, transparent);
}

.route-slot.playing {
  background: color-mix(in srgb, var(--river-soft) 70%, var(--field-surface) 30%);
}

.route-layer {
  grid-row: 3;
  align-items: center;
  min-width: 0;
  padding: 2px 0;
  pointer-events: none;
}

.route-band {
  position: relative;
  min-width: 0;
  min-height: 34px;
  display: grid;
  align-items: stretch;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(34, 26, 20, 0.26);
  box-shadow: none;
  pointer-events: auto;
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
  align-self: stretch;
}

.route-band:hover {
  filter: brightness(1.02);
}

.route-band.phrase {
  color: #f7f0e5;
  background: linear-gradient(180deg, rgba(89, 116, 82, 0.96) 0%, rgba(70, 92, 64, 0.98) 100%);
}

.route-band.phrase.block-1 {
  background: linear-gradient(180deg, rgba(76, 111, 132, 0.97) 0%, rgba(54, 82, 99, 0.99) 100%);
}

.route-band.phrase.block-2 {
  background: linear-gradient(180deg, rgba(162, 101, 67, 0.97) 0%, rgba(126, 75, 49, 0.99) 100%);
}

.route-band.phrase.block-3 {
  background: linear-gradient(180deg, rgba(112, 91, 126, 0.97) 0%, rgba(81, 65, 94, 0.99) 100%);
}

.route-band.phrase.block-4 {
  background: linear-gradient(180deg, rgba(104, 111, 78, 0.97) 0%, rgba(75, 82, 54, 0.99) 100%);
}

.route-band.karvai {
  color: #321e14;
  background: linear-gradient(180deg, rgba(236, 184, 145, 0.96) 0%, rgba(208, 143, 97, 0.98) 100%);
}

.route-band-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--range-span), minmax(0, 1fr));
  pointer-events: none;
}

.route-band-unit {
  min-width: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
}

.route-band.karvai .route-band-unit {
  border-right-color: rgba(50, 30, 20, 0.12);
}

.route-band-unit:last-child {
  border-right: 0;
}

.route-band-text {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.route-band.selected {
  outline: 2px solid rgba(34, 26, 20, 0.7);
  outline-offset: 1px;
}

.route-band.playing {
  outline: 2px solid rgba(79, 111, 134, 0.92);
  outline-offset: 1px;
  box-shadow: 0 0 0 2px rgba(200, 217, 229, 0.24);
}

.route-band.phrase.playing {
  color: #fbf8f2;
  background: linear-gradient(180deg, rgba(102, 136, 92, 1) 0%, rgba(70, 95, 61, 1) 100%);
}

.route-band.karvai.playing {
  color: #2f1c12;
  background: linear-gradient(180deg, rgba(245, 202, 165, 1) 0%, rgba(216, 149, 103, 1) 100%);
}

.group-brace-layer {
  grid-row: 4;
  align-items: start;
  column-gap: 0;
  padding-top: 7px;
}

.tala-map.tala-only {
  grid-template-rows: var(--map-tala-row-height) 18px 54px;
}

.tala-map.tala-only .group-brace-layer {
  grid-row: 3;
}

.group-brace {
  display: grid;
  grid-template-rows: 12px auto auto;
  justify-items: center;
  gap: 1px;
  min-width: 0;
  color: var(--map-label);
}

.group-brace i {
  width: calc(100% - 4px);
  height: 10px;
  border-bottom: 2px solid var(--brace-line);
  border-left: 2px solid var(--brace-line);
  border-right: 2px solid var(--brace-line);
  border-radius: 0 0 6px 6px;
}

.group-brace span,
.group-brace b {
  max-width: 100%;
  overflow: hidden;
  text-align: center;
}

.group-brace span {
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.08;
}

.group-brace b {
  font-family: var(--mono);
  font-size: 0.68rem;
}

.detail-pill {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--pill-surface);
}

.detail-pill.start {
  background: var(--pill-start-surface);
}

.detail-pill.completion {
  background: var(--pill-completion-surface);
}

.detail-pill.eduppu {
  background: var(--pill-eduppu-surface);
}

.detail-pill.samam {
  background: var(--pill-samam-surface);
}

.detail-pill.phrase {
  background: var(--pill-phrase-surface);
}

.detail-pill.karvai {
  background: var(--pill-karvai-surface);
}

.selected-range-panel {
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--summary-border);
  border-radius: 10px;
  background: var(--editor-surface);
}

.selected-range-panel.playing {
  border-color: rgba(79, 111, 134, 0.28);
  box-shadow: 0 0 0 3px rgba(200, 217, 229, 0.16), 0 12px 22px rgba(48, 34, 24, 0.12);
}

.selected-range-panel.playing .detail-title strong {
  color: var(--river);
}

.selected-range-panel.playing .matra-cell.segment-playing {
  outline-color: rgba(79, 111, 134, 0.78);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24), 0 0 0 4px rgba(200, 217, 229, 0.22);
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.detail-title {
  display: grid;
  gap: 4px;
}

.detail-title strong {
  font-family: var(--display);
  font-size: 1.08rem;
}

.detail-title span {
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-pill-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 6px;
}

.tala-rail,
.compact-state-strip,
.selection-editor-panel,
.selected-tala-strip,
.selection-card,
.panel-block,
.board-shell {
  scroll-margin-top: 18px;
}

.section-spotlight {
  outline: 2px solid rgba(79, 111, 134, 0.3);
  outline-offset: 4px;
}

.matra-grid {
  --cell-size: 58px;
  display: grid;
  grid-template-columns: repeat(var(--matra-count), minmax(var(--cell-size), 1fr));
  overflow-x: auto;
  border: 1px solid var(--pill-border);
  border-radius: 10px;
  background: var(--grid-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.matra-grid.route-grid {
  --cell-size: 42px;
}

.detail-grid {
  --cell-size: 72px;
  overflow-x: auto;
}

.matra-cell {
  position: relative;
  min-width: var(--cell-size);
  min-height: 92px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 4px;
  padding: 8px 7px 7px;
  border-right: 1px solid rgba(87, 63, 41, 0.12);
  background: var(--context);
  cursor: pointer;
}

.matra-cell:last-child {
  border-right: 0;
}

.matra-cell.group-end {
  border-right: 3px solid rgba(87, 63, 41, 0.34);
}

.matra-cell.phrase {
  background: var(--phrase-cell-surface);
}

.matra-cell.karvai {
  background: var(--karvai-cell-surface);
}

.matra-cell.inactive {
  color: rgba(115, 100, 86, 0.62);
}

.matra-cell.playing {
  outline: 0;
  color: #fbf8f2;
  background:
    linear-gradient(180deg, rgba(79, 111, 134, 0.98) 0%, rgba(42, 70, 90, 0.98) 100%);
  box-shadow:
    inset 0 -5px 0 rgba(245, 198, 127, 0.92),
    inset 0 0 0 1px rgba(33, 55, 70, 0.58),
    0 0 0 3px rgba(200, 217, 229, 0.42),
    0 12px 18px rgba(48, 34, 24, 0.22);
  animation: matra-step-press 190ms ease-out both;
  z-index: 1;
}

.matra-cell.playing::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 250, 243, 0.76);
  border-radius: var(--radius);
  pointer-events: none;
  animation: matra-step-ring 260ms ease-out both;
}

.matra-cell.playing .number,
.matra-cell.playing .sub {
  color: rgba(255, 250, 243, 0.84);
}

.matra-cell.playing .token {
  color: #fff;
}

.matra-cell.segment-playing {
  outline: 2px solid rgba(79, 111, 134, 0.58);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2), 0 0 0 3px rgba(200, 217, 229, 0.14);
  z-index: 1;
}

.matra-cell.segment-playing.playing {
  outline: 0;
  color: #fbf8f2;
  background:
    linear-gradient(180deg, rgba(79, 111, 134, 0.98) 0%, rgba(42, 70, 90, 0.98) 100%);
  box-shadow:
    inset 0 -5px 0 rgba(245, 198, 127, 0.92),
    inset 0 0 0 1px rgba(33, 55, 70, 0.58),
    0 0 0 3px rgba(200, 217, 229, 0.42),
    0 12px 18px rgba(48, 34, 24, 0.22);
}

.matra-cell.segment-playing.phrase {
  background: var(--phrase-cell-surface-active);
}

.matra-cell.segment-playing.karvai {
  background: var(--karvai-cell-surface-active);
}

.matra-cell.phrase.playing,
.matra-cell.karvai.playing,
.matra-cell.segment-playing.phrase.playing,
.matra-cell.segment-playing.karvai.playing {
  color: #fbf8f2;
  background:
    linear-gradient(180deg, rgba(79, 111, 134, 0.98) 0%, rgba(42, 70, 90, 0.98) 100%);
}

.nadai-cell.playing {
  background:
    linear-gradient(180deg, rgba(79, 111, 134, 0.98) 0%, rgba(42, 70, 90, 0.98) 100%);
  color: #fff;
  box-shadow:
    inset 0 -4px 0 rgba(245, 198, 127, 0.92),
    inset 0 0 0 1px rgba(33, 55, 70, 0.58),
    0 0 0 2px rgba(200, 217, 229, 0.34);
  animation: matra-step-press 190ms ease-out both;
}

.nadai-cell.playing::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 250, 243, 0.72);
  border-radius: 5px;
  pointer-events: none;
  animation: matra-step-ring 260ms ease-out both;
}

.nadai-cell.playing .nadai-label,
.nadai-cell.playing .nadai-matra-count {
  color: rgba(255, 250, 243, 0.92);
}

@keyframes matra-step-press {
  0% {
    transform: translateY(0) scale(0.98);
  }

  44% {
    transform: translateY(-3px) scale(1.02);
  }

  100% {
    transform: translateY(-2px) scale(1);
  }
}

@keyframes matra-step-ring {
  0% {
    opacity: 0.78;
    transform: scale(0.9);
  }

  100% {
    opacity: 0;
    transform: scale(1.12);
  }
}

.matra-cell .number {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.matra-cell .token {
  align-self: center;
  justify-self: center;
  font-family: var(--mono);
  font-size: 1.14rem;
  font-weight: 700;
}

.matra-cell .sub {
  min-height: 14px;
  color: var(--cell-sub);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.markers {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 3px;
}

.markers i {
  width: 8px;
  height: 8px;
  display: block;
  border-radius: 50%;
}

.markers .start {
  background: var(--moss);
}

.markers .completion {
  background: var(--copper);
}

.markers .eduppu {
  background: var(--river);
}

.markers .samam {
  background: var(--samam-dot);
}

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

.notation-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--summary-border);
  border-radius: 10px;
  background: var(--notation-surface);
}

.notation-card p {
  margin: 0;
  min-height: 42px;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.35;
}

.summary-card,
.saved-panel {
  padding: 18px;
}

.summary-card {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-card h2 {
  font-size: 1.38rem;
}

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

.saved-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
}

.count-badge {
  min-width: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #faf4e8;
  background: linear-gradient(180deg, rgba(180, 104, 65, 0.95) 0%, rgba(140, 76, 45, 1) 100%);
}

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

.notebook-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--summary-border);
  border-radius: 8px;
  background: var(--notebook-surface);
}

.notebook-item strong {
  font-family: var(--display);
  font-size: 1.06rem;
}

.notebook-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.clear-button {
  justify-self: start;
}

@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: minmax(232px, 272px) minmax(0, 1fr) minmax(280px, 320px);
  }

  .control-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .board-panel {
    grid-column: 2;
    grid-row: 1;
  }

  .route-card {
    grid-column: 3;
    grid-row: 1;
  }

}

@container tala-guide (max-width: 920px) {
  .hand-cue-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "stage"
      "transport"
      "rail";
  }

  .hand-cue-stage svg {
    width: min(100%, 380px);
  }

  .transport-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "bpm actions"
      "buttons buttons";
    align-items: stretch;
    gap: 8px;
  }

  .transport-bpm-chip {
    width: 100%;
  }

  .transport-button-row {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-self: stretch;
  }

  .transport-action-button {
    width: 100%;
  }
}

@media (max-width: 920px) {
  .app-header,
  .tala-rail,
  .workspace,
  .metric-ribbon,
  .notation-strip,
  .inline-fields,
  .selection-fields,
  .structure-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .board-head,
  .saved-panel summary,
  .advanced-panel summary {
    align-items: start;
  }

  .app-header {
    gap: 14px;
  }

  .board-head,
  .tala-rail {
    gap: 14px;
  }

  .transport-head {
    align-items: center;
  }

  .detail-head {
    flex-direction: column;
  }

  .detail-pill-strip {
    justify-content: start;
  }

  .detail-grid {
    --cell-size: 58px;
  }

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

  .selection-pill {
    min-height: 62px;
    padding: 9px;
  }

  .selection-pill span {
    font-size: 0.9rem;
  }

  .selection-editor-panel {
    padding: 13px 14px 14px;
  }

  .control-panel,
  .board-panel,
  .route-card {
    grid-column: auto;
    grid-row: auto;
  }

  .board-panel {
    order: 1;
  }

  .control-panel {
    order: 2;
  }

  .route-card {
    order: 3;
  }

  .help-popup {
    position: fixed;
    top: 16px;
    right: 18px;
    left: 18px;
    width: auto;
  }

  .transport-head {
    align-items: stretch;
  }

  .korvai-builder {
    gap: 14px;
    padding: 13px 12px;
  }

  .korvai-canvas-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .korvai-fit-status {
    align-self: flex-start;
  }

  .korvai-cycle {
    grid-template-columns: 44px minmax(0, 1fr);
    gap-inline: 7px;
  }

  .korvai-cycle-head span {
    display: none;
  }

  .korvai-segment {
    padding-inline: 2px;
    font-size: 0.62rem;
  }

  .korvai-start-marker::before {
    display: none;
  }

  .korvai-landing-marker {
    top: 0;
    height: 100%;
    padding-right: 0;
    font-size: 0;
  }

  .korvai-block-editor {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "role"
      "fields"
      "shape"
      "actions";
    gap: 10px;
  }

  .korvai-editor-actions {
    justify-content: flex-start;
  }

  .korvai-suggestion-list {
    grid-template-columns: 1fr;
  }

  .korvai-suggestion {
    grid-template-columns: minmax(0, 1fr) minmax(72px, 0.65fr) auto;
  }

  .transport-card {
    gap: 12px;
    padding: 14px;
  }

  .hand-cue-panel {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "transport"
      "stage"
      "rail";
    gap: 10px;
  }

  .tala-guide {
    padding: 12px;
  }

  .tala-guide-heading {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  .tala-guide-heading > p {
    text-align: left;
  }

  .hand-cue-head {
    align-items: flex-start;
    text-align: left;
    gap: 8px;
  }

  .hand-cue-stage {
    min-height: 184px;
  }

  .hand-cue-stage svg {
    width: min(100%, 260px);
  }

  .hand-cue-copy {
    gap: 5px;
    justify-items: start;
    text-align: left;
  }

  .hand-cue-progress {
    width: 100%;
    gap: 10px;
  }

  .hand-cue-count {
    min-width: 44px;
    min-height: 28px;
    padding: 0 8px;
  }

  .hand-cue-ticks {
    gap: 4px;
    padding: 9px 8px 7px;
  }

  .hand-cue-rail {
    gap: 7px 10px;
    justify-content: flex-start;
  }

  .hand-cue-rail-item {
    min-width: 88px;
  }

  .transport-button-row {
    width: auto;
    justify-content: flex-start;
  }

  .transport-action-button {
    flex: 1 1 0;
  }

  .transport-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "bpm actions"
      "buttons buttons";
    align-items: start;
    gap: 8px;
  }

  .accent-mode-buttons {
    width: 100%;
  }

  .transport-bpm-chip {
    width: 100%;
    min-width: 0;
  }

  .transport-bpm-chip input {
    width: 100%;
    min-width: 0;
  }

  .transport-tap-button,
  .transport-bpm-quick-button,
  .transport-action-button {
    min-height: 40px;
  }

  .transport-bpm-quick {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .transport-bpm-quick-button {
    min-width: 0;
    padding-inline: 0;
  }

  .transport-button-row {
    width: 100%;
  }

  .playback-option-toggles {
    display: grid;
    grid-template-columns: 1fr;
  }

  .transport-option-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .metric-ribbon {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .metric-card {
    min-height: 84px;
    padding: 12px 10px;
    gap: 6px;
  }

  .metric-card strong {
    font-size: 1.02rem;
  }

  .cycle-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .cycle-title span {
    white-space: normal;
  }

  .tala-map {
    --map-tala-row-height: 52px;
    grid-template-rows: var(--map-tala-row-height) 16px 36px 48px;
    row-gap: 5px;
    padding: 9px 10px 10px;
  }

  .tala-map.tala-only {
    grid-template-rows: var(--map-tala-row-height) 16px 48px;
  }

  .route-slot {
    min-height: 36px;
  }

  .route-layer {
    padding: 2px 0;
  }

  .route-band {
    min-height: 28px;
  }

  .route-band-text {
    padding: 0 4px;
    font-size: 0.66rem;
  }

  .group-brace span,
  .group-brace b {
    font-size: 0.62rem;
  }

  .notation-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .notation-card {
    padding: 12px;
  }

  .notation-card p {
    min-height: 0;
    font-size: 0.94rem;
  }
}
