:root {
  --caramel: #C2733B;
  --cream: #F4D1AE;
  --teal: #3D9994;
  --saffron: #E86826;
  --gold: #DCA432;
  --bg: #1d1712;
  --panel: #2a211a;
  --line: #43352a;
  --text: #fbf1e4;
  --muted: #b9a590;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  max-width: 560px; margin: 0 auto;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:disabled { opacity: .4; }
h1, h2 { margin: 0; }
h2 { font-size: 15px; color: var(--cream); margin-bottom: 8px; }
h2 small, label small { color: var(--muted); font-weight: 400; }

.top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.top .bole { border-radius: 50%; background: var(--cream); }
.top h1 { font-size: 22px; letter-spacing: .02em; color: var(--saffron); }
.top .tag { flex: 1; font-size: 11px; color: var(--muted); }

main { padding: 0 14px calc(120px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }

/* stage */
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.vid { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.vid.on { opacity: 1; pointer-events: auto; }
.vid iframe, .vid > div { width: 100%; height: 100%; }
.count {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(29, 23, 18, .94);
}
.count img { border-radius: 50%; background: var(--cream); }
.count small { color: var(--muted); }
.count span { font-size: min(52vw, 260px); font-weight: 800; color: var(--saffron); line-height: 1; font-variant-numeric: tabular-nums; }
.count span.last { color: var(--gold); }
.count[hidden], .msg[hidden], .toast[hidden], .editor[hidden] { display: none; }
.msg {
  position: absolute; inset: auto 0 0 0; padding: 10px 12px; font-size: 13px;
  background: rgba(232, 104, 38, .92); color: #fff;
}

/* now playing */
.now-title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-time { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; color: var(--cream); }
.now-time small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--teal); }

/* transport */
.transport { display: grid; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big {
  min-height: 72px; border-radius: 14px; font-size: 18px; font-weight: 700;
  background: var(--panel); border: 2px solid var(--line);
}
.big:active, .mid:active { transform: scale(.98); }
.big.play { min-height: 92px; font-size: 26px; background: var(--saffron); border-color: var(--saffron); color: #fff; }
.big.play.playing { background: var(--teal); border-color: var(--teal); }
.mid { min-height: 52px; border-radius: 12px; font-weight: 600; background: var(--panel); border: 2px solid var(--line); }

/* options */
.opts { display: grid; gap: 12px; background: var(--panel); border-radius: 12px; padding: 12px; }
.group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { min-height: 48px; border-radius: 10px; background: var(--bg); border: 2px solid var(--line); font-weight: 700; }
.seg button.on { border-color: var(--gold); color: var(--gold); }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  background: var(--bg); border: 2px solid var(--line); font-weight: 600;
}
.chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip.danger { color: #ff8a73; }
.top .chip { min-height: 36px; padding: 0 12px; }
.bpm { display: flex; gap: 6px; }
.bpm input {
  flex: 1; min-width: 0; text-align: center; font-size: 20px; font-weight: 700;
  background: var(--bg); border: 2px solid var(--line); border-radius: 10px; color: var(--text);
  -webkit-user-select: text; user-select: text;
}

/* list */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 56px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
}
.item.cur { border-color: var(--teal); }
.item.editing { box-shadow: 0 0 0 2px var(--gold); }
.item .n { width: 24px; text-align: center; font-weight: 800; color: var(--saffron); }
.item .meta { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .edit { min-height: 40px; padding: 0 12px; border-radius: 8px; background: var(--bg); border: 2px solid var(--line); }
.empty { color: var(--muted); font-size: 14px; padding: 10px 2px; }
.add { display: flex; gap: 8px; margin-top: 10px; }
.add input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; font-size: 16px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 10px; color: var(--text);
  -webkit-user-select: text; user-select: text;
}

/* editor */
.editor { background: var(--panel); border-radius: 12px; padding: 12px; display: grid; gap: 12px; }
.title-in {
  min-height: 44px; padding: 0 12px; font-size: 16px; color: var(--text);
  background: var(--bg); border: 2px solid var(--line); border-radius: 10px;
  -webkit-user-select: text; user-select: text;
}
.ed-row label { font-size: 13px; color: var(--cream); }
.ed-row input[type=range] { width: 100%; accent-color: var(--saffron); margin: 6px 0; }
.nudge { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nudge button { min-height: 44px; border-radius: 8px; background: var(--bg); border: 2px solid var(--line); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.nudge .now-btn { border-color: var(--gold); color: var(--gold); }
.ed-actions { display: flex; gap: 6px; flex-wrap: wrap; }

footer { padding: 0 14px 28px; font-size: 11px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--cream); color: #2a1a0c; font-weight: 700; padding: 10px 16px; border-radius: 999px;
  max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* bottom dock: always within thumb reach */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(29, 23, 18, .96); border-top: 1px solid var(--line);
}
.dk { min-height: 76px; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); font-weight: 700; }
.dk.side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; }
.dk.side span { font-size: 22px; line-height: 1; }
.dk.play { font-size: 22px; background: var(--saffron); border-color: var(--saffron); color: #fff; }
.dk.play.playing { background: var(--teal); border-color: var(--teal); }
.dk:active { transform: scale(.97); }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opts { gap: 10px; }
.bpm { align-items: center; }
.bpm-l { font-size: 12px; color: var(--muted); }
.bpm .chip { padding: 0 12px; }
.top-add { margin: 0 0 10px; }
.toast { z-index: 30; bottom: calc(110px + env(safe-area-inset-bottom)); }
.editor { scroll-margin-top: 12px; }

/* simplified flow */
.step h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.step h2 i {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--saffron); color: #fff; font-style: normal; font-size: 14px; font-weight: 800;
}
.hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.seek { width: 100%; height: 36px; margin: 6px 0 0; -webkit-appearance: none; appearance: none; background: transparent; }
.seek::-webkit-slider-runnable-track {
  height: 10px; border-radius: 5px;
  background: linear-gradient(to right, var(--line) 0 var(--a, 0%), var(--teal) var(--a, 0%) var(--b, 100%), var(--line) var(--b, 100%) 100%);
}
.seek::-moz-range-track {
  height: 10px; border-radius: 5px;
  background: linear-gradient(to right, var(--line) 0 var(--a, 0%), var(--teal) var(--a, 0%) var(--b, 100%), var(--line) var(--b, 100%) 100%);
}
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%; background: var(--saffron); border: 3px solid var(--cream); }
.seek::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--saffron); border: 3px solid var(--cream); }
.ed-row { display: grid; gap: 8px; }
.ed-val { display: flex; align-items: baseline; gap: 10px; }
.ed-val span { font-size: 13px; color: var(--muted); }
.ed-val b { font-size: 26px; font-variant-numeric: tabular-nums; color: var(--cream); }
.nudge { grid-template-columns: 2fr 1fr 1fr; }
.nudge button { min-height: 52px; font-size: 14px; }
.nudge .now-btn { background: var(--teal); border-color: var(--teal); color: #fff; font-size: 17px; font-weight: 800; }
.link { background: none; color: var(--muted); text-decoration: underline; justify-self: start; padding: 6px 0; font-size: 13px; }
.list-sec .ed-actions { margin-top: 10px; }
.list-sec .ed-actions[hidden] { display: none; }
.adv summary { padding: 12px; background: var(--panel); border-radius: 12px; color: var(--muted); font-size: 14px; cursor: pointer; }
.adv[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.adv .opts { border-top-left-radius: 0; border-top-right-radius: 0; }
.item { cursor: pointer; }

/* search results */
.results { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.results[hidden] { display: none; }
.results li {
  display: flex; align-items: center; gap: 10px; padding: 8px; cursor: pointer;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
}
.results li:active { border-color: var(--teal); }
.results img { border-radius: 6px; background: #000; flex: none; object-fit: cover; }
.results div { flex: 1; min-width: 0; }
.results b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.3; }
.results small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results span { flex: none; color: var(--teal); font-weight: 800; padding: 0 6px; }
.results li.none { display: block; cursor: default; color: var(--muted); font-size: 13px; }
.results li.none a { color: var(--gold); font-weight: 700; }

.fine-l { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }
.fine-l b { color: var(--cream); font-variant-numeric: tabular-nums; }
.fine::-webkit-slider-thumb { background: var(--gold); }
.fine::-moz-range-thumb { background: var(--gold); }
.fine::-webkit-slider-runnable-track { height: 14px; border-radius: 7px; }
.fine::-webkit-slider-thumb { margin-top: -7px; }
.nudge { grid-template-columns: 1fr; }

/* centered, compact range editor */
.ed-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-col { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; background: var(--bg); border: 2px solid var(--line); border-radius: 12px; }
.ed-lab { font-size: 12px; color: var(--muted); }
.ed-col b { font-size: 24px; font-variant-numeric: tabular-nums; color: var(--cream); min-height: 32px; display: flex; align-items: center; }
.ed-col .nudge { width: 100%; }
.ed-col .nudge button { width: 100%; }
.ed-col .link { justify-self: center; padding: 2px 0; }
.ed-actions { justify-content: center; }
.editor h2, .editor .hint { text-align: center; justify-content: center; }
.list-sec .ed-actions { justify-content: center; }
.chip, .mid, .dk, .seg button { text-align: center; }
.add .chip { flex: none; }
.now-title, .now-time, .fine-l { text-align: center; }
.fine-l { justify-content: center; gap: 8px; }
.now-time { justify-content: center; }
.opt-row .chip { width: 100%; }
.bpm { justify-content: center; }
.adv summary { text-align: center; }

/* language select */
.lang { min-height: 36px; border-radius: 10px; background: var(--panel); color: var(--text); border: 2px solid var(--line); padding: 0 6px; font: inherit; font-size: 13px; }
@media (max-width: 420px) { .top .tag { display: none; } .top { gap: 6px; } }

/* 2-stage splash */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; overflow: hidden; background: #1a0000; transition: opacity .3s; }
.splash.out { opacity: 0; pointer-events: none; }
.sp-brand, .sp-app { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transition: opacity .35s; }
.sp-brand { background: linear-gradient(180deg, #a51c1c 0%, #8b1111 25%, #6b0a0a 50%, #3a0000 75%, #1a0000 100%); opacity: 1; }
.sp-brand span {
  display: inline-block; margin: 0 2px; font-size: 72px; font-weight: 900; color: #000; line-height: 1;
  text-shadow: 0 0 10px rgba(255, 180, 180, .6); opacity: 0;
  animation: sp-letter .52s cubic-bezier(.2, .8, .2, 1) forwards;
}
.sp-brand span.sm { font-size: 56px; }
.sp-brand span:nth-child(1) { animation-delay: .18s; --x: -56px; --y: -18px; --r: -18deg; }
.sp-brand span:nth-child(2) { animation-delay: .44s; --x: 0; --y: -70px; --r: 0deg; }
.sp-brand span:nth-child(3) { animation-delay: .70s; --x: 0; --y: 30px; --r: 0deg; }
.sp-brand span:nth-child(4) { animation-delay: .96s; --x: 52px; --y: -12px; --r: 22deg; }
@keyframes sp-letter {
  from { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(.85); }
  to { opacity: 1; transform: none; }
}
.sp-app { flex-direction: column; gap: 10px; background: var(--bg); opacity: 0; }
.splash.s2 .sp-brand { opacity: 0; }
.splash.s2 .sp-app { opacity: 1; }
.sp-bole { border-radius: 50%; background: var(--cream); }
.splash.s2 .sp-bole { animation: sp-jump .6s ease-in-out 2; }
@keyframes sp-jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-26px) scale(1.04); } }
.sp-title { font-size: 44px; font-weight: 800; color: var(--saffron); letter-spacing: .02em; }
.sp-tag { font-size: 13px; color: var(--muted); }
.sp-beat { display: flex; gap: 14px; margin-top: 10px; }
.sp-beat i { font-style: normal; font-size: 28px; font-weight: 800; color: var(--line); }
.splash.s2 .sp-beat i { animation: sp-beat .4s ease forwards; }
.splash.s2 .sp-beat i:nth-child(1) { animation-delay: .1s; }
.splash.s2 .sp-beat i:nth-child(2) { animation-delay: .5s; }
.splash.s2 .sp-beat i:nth-child(3) { animation-delay: .9s; }
.splash.s2 .sp-beat i:nth-child(4) { animation-delay: 1.3s; }
@keyframes sp-beat { to { color: var(--gold); transform: scale(1.25); } }
.sp-skip { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); font-size: 11px; color: rgba(255, 255, 255, .45); }
@media (prefers-reduced-motion: reduce) { .sp-brand span { animation-duration: .01s; animation-delay: 0s; } .splash.s2 .sp-bole, .splash.s2 .sp-beat i { animation: none; } }

.dk.play.blocked { opacity: .4; }
