@font-face { font-family: Andika; src: url(fonts/Andika-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: Andika; src: url(fonts/Andika-Bold.ttf); font-weight: 700; font-display: swap; }
@font-face { font-family: Bravura; src: url(fonts/Bravura.otf); }
:root { --bg:#FBF3E4; --card:#fff; --edge:#E8D5B5; --ink:#131C44; --sub:#5B6478; --faint:#CFC6B4; --accent:#2559E8; --deep:#1B3FA8; --soft:#E6EDFF; --amber-soft:#FFE9C2; --on:#fff; --green:#22A35A; --amber:#EE9A0B; --coral:#EF4E4E; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: Andika, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 1100px; margin: 0 auto; }
#top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; margin-right: auto; }
.brand { color: inherit; text-decoration: none; }
.brand img { border-radius: 8px; }
.modes { display: flex; background: var(--card); border: 1.5px solid var(--edge); border-radius: 999px; padding: 3px; }
.modes button { padding: 7px 16px; border-radius: 999px; font-weight: 700; color: var(--sub); }
.modes button.on { background: var(--accent); color: var(--on); }
.chipbtn { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1.5px solid var(--edge); border-radius: 999px; padding: 4px 14px 4px 5px; font-weight: 700; }
.chipbtn img { background: var(--soft); border-radius: 50%; padding: 2px; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--edge); font-size: 20px; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 16px 12px; }
section { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#stage { flex: 1; min-height: 0; width: 100%; }
#tc { width: 100%; height: 100%; display: block; }
#status { text-align: center; min-height: 64px; }
#stTitle { font-size: 24px; font-weight: 700; }
#stHint { color: var(--sub); font-size: 15px; min-height: 22px; }
.primary { background: var(--accent); color: var(--on); font-weight: 700; padding: 14px 34px; border-radius: 999px; font-size: 17px; min-width: 150px; }
.secondary { background: var(--card); border: 1.5px solid var(--edge); font-weight: 700; padding: 13px 26px; border-radius: 999px; }
.row { display: flex; gap: 12px; justify-content: center; margin-top: 4px; }
#metro { justify-content: center; overflow: auto; }
#tempoRow { display: flex; align-items: center; gap: 22px; }
#tempoBox { text-align: center; min-width: 170px; }
#bpmNum { font-size: 76px; font-weight: 700; line-height: 1; }
#bpmName { color: var(--sub); font-style: italic; font-size: 18px; }
.round { width: 56px; height: 56px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--edge); font-size: 30px; font-weight: 700; color: var(--accent); }
#bpmSlider { width: min(520px, 100%); accent-color: var(--accent); }
#lights { display: flex; gap: 8px; min-height: 80px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.light { width: 54px; height: 54px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--edge); display: grid; place-items: center; font-weight: 700; color: var(--sub); position: relative; }
.light.first { border: 2.5px solid var(--accent); color: var(--accent); }
.light.lit { background: var(--accent); color: var(--on); border-color: var(--accent); transform: scale(1.1); }
.light.lit:not(.first) { background: color-mix(in srgb, var(--accent) 45%, var(--ink)); }
.dots { position: absolute; bottom: -14px; display: flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.dots i.on { background: var(--accent); transform: scale(1.35); }
.sigcard { display: flex; align-items: center; gap: 18px; background: var(--card); border: 1.5px solid var(--edge); border-radius: 22px; padding: 12px 22px; }
.sigcol { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 110px; }
.sigcol small { color: var(--sub); }
.sigdigits { font-weight: 700; font-size: 30px; }
.arrow { width: 52px; height: 36px; border-radius: 12px; background: var(--soft); color: var(--accent); font-size: 16px; }
.sigmid { position: relative; width: 120px; height: 90px; display: grid; place-items: center; }
.staff { position: absolute; left: 0; right: 0; top: 17px; bottom: 17px; background: repeating-linear-gradient(to bottom, var(--ink) 0 1.5px, transparent 1.5px 18.5px); background-size: 100% 18.5px; height: 74px; top: 8px; opacity: .85; }
#sigNums { position: relative; display: flex; flex-direction: column; font-family: Bravura; font-size: 74px; line-height: 0; }
#sigNums .big { font-family: Bravura; font-weight: 400; font-size: 74px; height: 37px; display: flex; align-items: center; justify-content: center; line-height: 1; background: var(--card); }
.seglabel { color: var(--sub); font-weight: 700; font-size: 14px; margin-top: 4px; }
.seg { display: flex; background: var(--card); border: 1.5px solid var(--edge); border-radius: 999px; padding: 3px; flex-wrap: wrap; justify-content: center; }
.seg button { padding: 9px 18px; border-radius: 999px; font-weight: 700; color: var(--sub); }
.seg button[aria-checked=true] { background: var(--accent); color: var(--on); }
#adslot { height: 62px; overflow: hidden; border-top: 1px solid var(--edge); text-align: center; flex: none; }
@media (max-height: 480px) { #adslot { display: none; } }
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: 100vw; max-height: 100vh; }
dialog::backdrop { background: rgba(10,15,30,.5); }
.sheet { background: var(--bg); width: min(760px, 94vw); max-height: 90vh; overflow: auto; border-radius: 24px; padding: 18px 20px 22px; }
.sheet.small { width: min(380px, 92vw); text-align: center; }
.sheethead { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0 0 8px; font-size: 22px; }
.x { font-size: 30px; width: 40px; height: 40px; border-radius: 50%; }
.legend { display: flex; gap: 8px; margin: 4px 0; }
.pill { background: color-mix(in srgb, var(--c) 18%, white); color: color-mix(in srgb, var(--c) 70%, black); font-weight: 700; border-radius: 999px; padding: 3px 12px; font-size: 14px; }
.info { color: var(--sub); font-size: 14px; margin: 6px 0 12px; }
.fam { font-weight: 700; color: var(--sub); text-transform: uppercase; font-size: 13px; letter-spacing: .06em; margin: 14px 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--card); border: 2px solid var(--edge); border-radius: 18px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.card.sel { border-color: var(--accent); background: var(--soft); }
.card .tile { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; }
.card .tile img { width: 56px; height: 56px; }
.card b { font-size: 15px; line-height: 1.15; }
.card small { color: var(--sub); }
.card .pill { align-self: flex-start; font-size: 12px; padding: 1px 9px; }
.opt { background: var(--card); border: 1.5px solid var(--edge); border-radius: 18px; padding: 12px 14px; margin: 10px 0; }
.opt h3 { margin: 0 0 8px; font-size: 14px; color: var(--sub); text-transform: uppercase; letter-spacing: .05em; }
.opt .seg { justify-content: flex-start; }
.check { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.theme { border: 2px solid var(--edge); border-radius: 14px; padding: 6px; background: var(--card); font-size: 13px; font-weight: 700; text-align: center; position: relative; }
.theme.sel { border-color: var(--accent); }
.theme .sw { height: 34px; border-radius: 8px; margin-bottom: 4px; display: flex; align-items: flex-end; gap: 3px; padding: 4px; }
.theme .sw i { flex: 1; height: 100%; border-radius: 4px; }
.theme.locked::after { content: "\1F512"; position: absolute; top: 4px; right: 6px; font-size: 13px; }
.plus { background: var(--soft); border-color: var(--accent); }
.plus p { margin: 4px 0 10px; color: var(--sub); }
.sum { font-size: 34px; font-weight: 700; margin: 6px 0; }
#gateA { font-size: 24px; text-align: center; width: 120px; padding: 8px; border-radius: 12px; border: 2px solid var(--edge); background: var(--card); color: var(--ink); }
.err { color: var(--coral); font-weight: 700; }
@media (max-height: 520px) { #bpmNum { font-size: 52px; } .light { width: 40px; height: 40px; } .sigcard { padding: 6px 14px; } }

/* ---- pass 2: tactile surfaces, calmer spacing ---- */
:root { --lip: color-mix(in srgb, var(--edge) 100%, black 6%); --deep: color-mix(in srgb, var(--accent) 72%, black); --gap: 16px; }
.modes, .chipbtn, .iconbtn, .secondary, .round, .light, .sigcard, .opt, .card, .theme { border-width: 2px; box-shadow: 0 3px 0 var(--edge); }
.primary { box-shadow: 0 4px 0 var(--deep); transition: transform .12s, box-shadow .12s; padding: 16px 38px; font-size: 18px; }
.primary:active, .secondary:active, .round:active { transform: translateY(3px); box-shadow: none; }
.modes button.on, .seg button[aria-checked=true] { box-shadow: 0 2px 0 var(--deep); }
.light.lit { box-shadow: 0 3px 0 var(--deep); }
#top { padding: 14px 20px 10px; gap: 12px; }
main { padding: 0 20px 14px; }
section { gap: var(--gap); }
#stTitle { font-size: 28px; letter-spacing: -.01em; }
#stHint { font-size: 17px; }
#bpmNum { font-size: 88px; letter-spacing: -.02em; }
.sheet { border-radius: 28px; padding: 22px 24px 26px; background: var(--bg); box-shadow: 0 24px 60px -20px rgba(10,15,30,.5); }
.opt { border-radius: 20px; padding: 14px 16px; margin: 14px 0; }
.card.sel, .theme.sel { box-shadow: 0 3px 0 var(--accent); }
.fam { margin: 22px 0 10px; }
.fam::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #F2A23A; margin-right: 8px; }
.pill { border: 1.5px solid color-mix(in srgb, var(--c) 45%, white); }
@media (prefers-reduced-motion: reduce) { .primary { transition: none; } }

.opt .hint { margin: 8px 0 0; color: var(--sub); font-size: 13px; line-height: 1.35; }
.keygrid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); margin-top: 10px; }
.keycard { align-items: center; text-align: center; gap: 2px; padding: 8px 6px; }
.keycard canvas { width: 100%; height: 66px; display: block; }
.keycard b { font-size: 15px; }
.keycard small { font-size: 12px; }

.advnote { color: var(--sub); font-size: 14px; margin: 18px 4px 10px; }
#tuneStrip { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 0 8px; }
#tuneStrip .seg { justify-content: center; flex-wrap: nowrap; }
#tuneStrip .seg button { padding: 8px 22px; min-height: 44px; }
.keybtn { min-height: 44px; padding: 8px 16px; font-weight: 700; }
