/* Design tokens shared with sonotopy-web (landing page). Keep in step. */
:root {
  --bg: #07060b;
  --bg2: #0e0c16;
  --card: #12101c;
  --ink: #f3f1fa;
  --mute: #9b97ad;
  --line: rgba(255, 255, 255, 0.08);
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --coral: #ff7a59;
  --grad: linear-gradient(100deg, var(--violet), var(--cyan) 55%, var(--coral));
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* event colours */
  --ev-pause: #9b97ad;
  --ev-hesitation: #ff7a59;
  --ev-emphasis: #22d3ee;
  --ev-intonation: #7c5cff;
  --ev-emotion: #f472b6;
  --ev-pronunciation: #facc15;
  --ev-overlap: #34d399;
  --ev-pace: #60a5fa;
  --ev-other: #d4d4d8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, 0.14), transparent 60%), var(--bg);
  color: var(--ink); font-family: var(--sans); line-height: 1.55;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.08em; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 14px;
  background: rgba(7, 6, 11, 0.7); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-word { font-weight: 600; letter-spacing: -0.03em; font-size: 19px; }
.brand-tag { font: 400 11px var(--mono); color: var(--mute); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.brand-mark { display: inline-flex; align-items: center; gap: 2px; height: 20px; }
.brand-mark i { width: 3px; border-radius: 2px; background: var(--grad); background-size: 100% 300%; animation: bar 1.2s ease-in-out infinite; }
.brand-mark i:nth-child(1) { height: 40%; animation-delay: -0.2s; }
.brand-mark i:nth-child(2) { height: 80%; animation-delay: -0.5s; }
.brand-mark i:nth-child(3) { height: 100%; animation-delay: -0.1s; }
.brand-mark i:nth-child(4) { height: 60%; animation-delay: -0.7s; }
.brand-mark i:nth-child(5) { height: 30%; animation-delay: -0.4s; }
@keyframes bar { 50% { transform: scaleY(0.4); } }
.tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font-size: 14px; color: var(--mute); cursor: pointer; }
.tabs button[aria-selected="true"] { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.icon-btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: var(--mute); }

main { max-width: 1100px; margin: 0 auto; padding: clamp(20px, 5vw, 48px) clamp(16px, 4vw, 40px) 64px; }
.intro h1 { font-size: clamp(36px, 6vw, 64px); line-height: 1.05; font-weight: 400; }
.intro p { color: var(--mute); max-width: 560px; margin-top: 12px; font-size: 17px; }
.view { margin-top: 32px; }

/* gallery */
.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.clip {
  text-align: left; cursor: pointer; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px; transition: border-color 0.3s, transform 0.3s var(--ease);
}
.clip:hover { transform: translateY(-2px); border-color: rgba(124, 92, 255, 0.5); }
.clip[aria-pressed="true"] { border-color: var(--cyan); }
.clip b { font-weight: 500; }
.clip span { color: var(--mute); font-size: 14px; }
.clip small { font: 400 11px var(--mono); color: var(--mute); }
.empty { color: var(--mute); }

/* recorder */
.recorder { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; text-align: center; }
.consent, .hint { color: var(--mute); font-size: 14px; max-width: 460px; }
.rec-btn {
  display: inline-flex; align-items: center; gap: 12px; border: 0; cursor: pointer; border-radius: 999px;
  padding: 18px 28px; font-weight: 500; font-size: 16px; color: #0a0810; background: var(--grad);
  box-shadow: 0 8px 40px -8px rgba(124, 92, 255, 0.6);
}
.rec-btn .dot { width: 12px; height: 12px; border-radius: 50%; background: #0a0810; }
.rec-btn.recording .dot { background: #e11d48; animation: pulse 1s infinite; }
.rec-btn:disabled { opacity: 0.6; cursor: wait; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 10px; border: 0; cursor: pointer; font: 500 15px/1 var(--sans); padding: 12px 20px; border-radius: 999px; }
.btn-primary { color: #0a0810; background: var(--grad); }
.btn-ghost { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.play-ico { width: 0; height: 0; border-left: 10px solid #0a0810; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.playing .play-ico { width: 10px; height: 12px; border: 0; border-left: 3px solid #0a0810; border-right: 3px solid #0a0810; }

/* result */
.result { scroll-margin-top: 84px; margin-top: 32px; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 3vw, 28px); }
.result-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.result-head h2 { font-weight: 500; font-size: 20px; }
.listen { color: var(--mute); font-size: 15px; margin-top: 4px; }
.notice { margin-top: 14px; padding: 10px 14px; border-radius: 10px; font-size: 13px; background: rgba(255, 122, 89, 0.1); border: 1px solid rgba(255, 122, 89, 0.35); color: #ffc9b8; }
.wave-wrap { margin-top: 18px; }
#wave { width: 100%; height: 140px; display: block; cursor: pointer; border-radius: 10px; background: rgba(255, 255, 255, 0.02); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--mute); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.compare { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; margin-top: 20px; }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } .result-head { flex-direction: column; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.panel-main { border-color: rgba(34, 211, 238, 0.35); }
.panel header { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.panel h3 { font-weight: 500; font-size: 16px; }
.kind { font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
.panel-main .kind { color: var(--cyan); }
.kind.ours::after { content: " · Sonotopy"; color: var(--coral); }
.summary { font-size: 15px; }
.transcript { margin-top: 10px; color: var(--mute); font-style: italic; }
.events { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.events li {
  display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 8px 10px; border-radius: 10px;
  border-left: 3px solid var(--c, var(--ev-other)); background: rgba(255, 255, 255, 0.03);
  opacity: 0.35; transition: opacity 0.4s, background 0.4s; cursor: pointer;
}
.events li.seen { opacity: 1; }
.events li.now { background: rgba(255, 255, 255, 0.08); }
.events time { font: 400 12px var(--mono); color: var(--mute); padding-top: 2px; }
.events b { font-weight: 500; font-size: 14px; }
.events p { color: var(--mute); font-size: 13px; }
.meta { margin-top: 14px; font: 400 11px var(--mono); color: var(--mute); }

/* settings */
dialog { margin: auto; background: var(--bg2); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--mute); }
dialog input { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; }

/* phones */
.tabs button, .brand-word { white-space: nowrap; }
.icon-btn { flex-shrink: 0; display: grid; place-items: center; font-size: 16px; }
.brand { min-width: 0; }
@media (max-width: 480px) {
  .top { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .brand { gap: 8px; }
  .brand-word { font-size: 17px; }
  .brand-tag { display: none; }
  .tabs button { padding: 7px 11px; font-size: 13px; }
  .icon-btn { width: 34px; height: 34px; }
  main { padding-top: 24px; }
  .intro h1 { font-size: 34px; }
  .intro p { font-size: 16px; }
  .view { margin-top: 24px; }
  .recorder { padding: 24px 14px; }
  .rec-btn { width: 100%; justify-content: center; padding: 16px 20px; font-size: 15px; }
  .result-head .btn { align-self: stretch; justify-content: center; }
  .events li { grid-template-columns: 44px 1fr; }
}
