:root {
  --bg: #0b0d12;
  --panel: #141821;
  --line: #232937;
  --text: #e8ebf2;
  --muted: #8a93a6;
  --good: #4ade80;
  --close: #facc15;
  --off: #f87171;
  --accent: #7dd3fc;
}

* { box-sizing: border-box; }

/* Component display rules must not override the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.readout {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  height: 88px; /* fixed, so changing text never resizes (and blanks) the canvas */
  flex-shrink: 0;
}

.detail {
  flex: 1;
  min-width: 0;
}

.cents, .freq {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  min-width: 3ch;
  font-variant-numeric: tabular-nums;
}

.cents {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.freq {
  color: var(--muted);
  font-size: 14px;
}

main {
  flex: 1;
  min-height: 0;
  padding: 0 8px;
  position: relative;
}

.view-toggle {
  position: absolute;
  top: 8px;
  right: 16px;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

#lane {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: var(--panel);
}

.controls {
  padding: 12px 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

button, select {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06212e;
  font-weight: 600;
}

button:disabled { opacity: 0.4; }

.target {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  margin-left: auto;
}

.grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* Mode switch */
.modes {
  display: flex;
  margin-left: auto;
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.modes button {
  border: 0;
  border-radius: 0;
  padding: 8px 12px;
  min-height: 36px;
  font-size: 14px;
}

.modes button[aria-pressed="true"] {
  background: var(--line);
  color: var(--text);
  font-weight: 600;
}

/* Hymn setup */
.setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 10px;
}

.setup label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.setup .wide { grid-column: 1 / -1; }

.setup .check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.setup .check input { width: 22px; height: 22px; }

.setup select { width: 100%; }

/* Report and takes sheets */
dialog.sheet {
  width: min(640px, 100vw);
  max-width: 100vw;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  background: var(--bg);
  color: var(--text);
}

dialog.sheet::backdrop { background: #000a; }

dialog h2 { margin: 0 0 4px; font-size: 20px; }
dialog p { margin: 8px 0; line-height: 1.4; }
dialog form { display: flex; justify-content: flex-end; margin-top: 12px; }

.chart {
  display: block;
  width: 100%;
  height: 160px;
  margin: 12px 0;
  border-radius: 10px;
  background: var(--panel);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-variant-numeric: tabular-nums;
}

.chip b { font-weight: 600; font-size: 14px; }
.chip small { font-size: 12px; }
.chip.good small { color: var(--good); }
.chip.close small { color: var(--close); }
.chip.off small { color: var(--off); }
.chip.missed { opacity: 0.5; }
.chip.good { border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.chip.close { border-color: color-mix(in srgb, var(--close) 40%, transparent); }
.chip.off { border-color: color-mix(in srgb, var(--off) 50%, transparent); }

.take-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.take-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.take-list li span {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.take-list small { color: var(--muted); }
.take-list button { padding: 8px 12px; min-height: 40px; }

.play { margin: 8px 0 0; }

.chart-wrap { position: relative; }

.cursor {
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
}

button.link {
  background: none;
  border: 0;
  padding: 8px 0;
  min-height: 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: 14px;
}
