:root {
  --gold: #edb959;
  --gold-deep: #de7d2e;
  --teal: #70c7a6;
  --bg0: #0b1226;
  --bg1: #12213f;
  --bg2: #28170f;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.10);
  --text: #f1f1f5;
  --text-dim: rgba(255, 255, 255, 0.60);
  --text-faint: rgba(255, 255, 255, 0.40);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at top left, var(--bg1) 0%, var(--bg0) 40%, var(--bg2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  color: var(--text);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text);
  opacity: 0.9;
  padding: 6px;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, background 0.15s;
}

.icon-btn:hover { background: var(--glass); }
.icon-btn.active { color: var(--gold); }
.icon-btn.small { padding: 4px; }
.close-btn { font-size: 22px; line-height: 1; }

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 18px 160px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

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

.row-header { gap: 10px; }

.row-pills > * {
  flex: 1;
}
.row-pills > .icon-btn.small { flex: 0 0 auto; }

.row-scroll {
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.row-scroll::-webkit-scrollbar { display: none; }

.spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--glass);
  border: 0;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.chip-small { padding: 5px 10px; font-size: 12px; }

.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 11px;
}
.meta .accent { color: var(--gold); font-weight: 600; font-size: 12px; }
.meta #ref-label { color: var(--text-faint); }

.accent { color: var(--gold); }

.pill {
  background: var(--glass);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill.small { font-size: 12px; padding: 7px 12px; }
.pill.active {
  background: var(--gold);
  color: #1a1005;
  border-color: transparent;
}
.pill:disabled { opacity: 0.35; cursor: default; }

/* Note ring */

.ring-wrap {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  margin: 6px auto 0;
}

.ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ring-buttons {
  position: absolute;
  inset: 0;
}

.ring-orb {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--glass);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transform: translate(-50%, -50%);
  transition: background 0.15s, color 0.15s;
}
.ring-orb.active {
  background: var(--gold);
  color: #1a1005;
  border-color: transparent;
}

.ring-center {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 170px;
  text-align: center;
  pointer-events: none;
}
.ring-center .degree-label {
  color: var(--gold);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
}
.ring-center .pitch-name {
  color: var(--text);
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.ring-center .hz {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* Timbre cards */

.timbre-card {
  flex: 0 0 auto;
  width: 110px;
  height: 86px;
  background: var(--glass);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.timbre-card.active {
  background: var(--gold);
  color: #1a1005;
  border-color: transparent;
}
.timbre-card svg { width: 22px; height: 22px; }

/* Play dock */

.play-dock {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 18px;
  background: rgba(14, 22, 44, 0.7);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  z-index: 40;
  max-width: 520px;
  margin: 0 auto;
}

.play-dock input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 0;
}

.fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #f6c66b, var(--gold-deep));
  color: #1a1005;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.fab:active { transform: scale(0.96); }

/* Sheets */

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  background: linear-gradient(to bottom, #1b2745, #0c1328);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  max-height: 85vh;
  z-index: 60;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet[hidden] { display: none; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sheet-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.sheet-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.field .field-label {
  font-weight: 600;
  color: var(--text);
}
.field .field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.field-row input[type="range"] { flex: 1; }
.field-row .num { min-width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.field-row input.num {
  width: 72px;
  min-width: 72px;
  padding: 6px 10px;
  color: var(--gold);
  font-size: 16px;
}
.field-row input.num::-webkit-inner-spin-button,
.field-row input.num::-webkit-outer-spin-button { opacity: 1; }

.field.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.field.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--gold);
}

select, input[type="text"], input[type="number"] {
  background: var(--glass);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.text-btn {
  background: transparent;
  border: 0;
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.big-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #1a1005;
  background: linear-gradient(135deg, #f6c66b, var(--gold-deep));
  cursor: pointer;
  font-family: inherit;
  margin-top: 12px;
}
.big-btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.big-btn.stop {
  background: linear-gradient(135deg, #ff9b6e, #c83c3c);
  color: #fff;
}

.progression-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.bar-row {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--glass);
  border-radius: 10px;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.bar-row.active { background: rgba(237, 185, 89, 0.22); }
.bar-row .idx { color: var(--text-faint); font-weight: 700; font-size: 12px; }
.bar-row .degree-pick { display: flex; align-items: center; gap: 6px; }
.bar-row select { padding: 5px 10px; font-size: 13px; }
.bar-row .remove {
  background: transparent;
  border: 0;
  color: rgba(255, 110, 110, 0.9);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.note {
  font-size: 12px;
  color: var(--text-dim);
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  margin: 10px 0;
}

.intro { color: var(--text); font-size: 14px; line-height: 1.6; }
.sheet-body h3 { font-size: 14px; margin: 18px 0 6px; color: var(--text); }
.sheet-body p { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin: 0 0 6px; }
.meta-line { font-size: 11px; color: var(--text-faint); margin-top: 14px; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
}
.backdrop[hidden] { display: none; }

.bottom-spacer { height: 100px; }

@media (min-width: 560px) {
  .app { gap: 18px; }
  .ring-wrap { max-width: 380px; }
}

/* =========================================== */
/* Multi-view navigation                       */
/* =========================================== */

.view[hidden] { display: none; }

/* Menu view */
.view-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 22px;
  gap: 24px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.menu-hero {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 10px;
}
.menu-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0 0 4px;
  color: var(--text);
}
.menu-byline {
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0 0 4px;
  opacity: 0.85;
}
.menu-tagline {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

.menu-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.1s, background 0.15s;
}
.menu-card:active { transform: scale(0.98); }
.menu-card:hover { background: rgba(255, 255, 255, 0.08); }
.menu-card.primary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(237, 185, 89, 0.4);
}
.menu-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.menu-card.primary .menu-card-icon {
  background: var(--gold);
  color: #1a1005;
}
.menu-card-text { flex: 1; min-width: 0; }
.menu-card-text h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.menu-card-text p {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.4;
}
.menu-card-arrow {
  color: var(--text-faint);
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  flex-shrink: 0;
}

.menu-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  margin: 0;
  padding: 0 20px;
  line-height: 1.6;
}

/* Back button in top bars */
.back-btn {
  padding: 8px;
  margin-left: -6px;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
}

/* Standalone sheet body (used in progression / reading views) */
.sheet-body.standalone {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 40px;
}

.sheet-body.article {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 22px 60px;
}
.sheet-body.article h3 {
  color: var(--text);
  font-size: 15px;
  margin: 20px 0 8px;
}
.sheet-body.article p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
  margin: 0 0 12px;
}
.sheet-body.article p.intro {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  padding: 14px 16px;
  background: rgba(237, 185, 89, 0.08);
  border-radius: 12px;
  margin-bottom: 18px;
}
.sheet-body.article .meta-line {
  font-size: 12px;
  color: var(--text-faint);
}
.sheet-body.article ul { padding-left: 20px; color: var(--text-dim); font-size: 14px; line-height: 1.7; }

/* Reading list cards */
.reading-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 10px;
  transition: background 0.15s;
}
.reading-card:hover { background: rgba(255, 255, 255, 0.08); }
.reading-card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.reading-card-sub {
  font-size: 12px;
  color: var(--text-dim);
}
