:root {
  --primary: #118659; --warm: #16827d; --bg: #fafafb; --fg: #18181d; --card: #ffffff;
  --fill: #f0f0f2; --muted: #5d5d64; --destructive: #c92f33; --line: #e7e7ec;
  --happy: #16a34a; --neutral: #e0a200; --sad: #2f6fed; --angry: #e5484d;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --serif: "Instrument Serif", Georgia, serif;
  --shadow: 0 1px 2px rgba(24,24,29,0.05), 0 16px 44px -20px rgba(24,24,29,0.22);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans); color: var(--fg); letter-spacing: -0.01em; min-height: 100dvh; -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1000px 520px at 50% -12%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 60%),
    radial-gradient(760px 520px at 50% 116%, color-mix(in srgb, var(--warm) 11%, transparent), transparent 62%),
    var(--bg);
}
.stage { max-width: 46rem; margin: 0 auto; padding: 1.4rem 1.1rem 2.5rem; }

/* masthead */
.masthead { text-align: center; margin-bottom: 1.3rem; }
.brandrow { display: flex; align-items: center; justify-content: center; gap: 0.6rem; }
.mark { width: clamp(2.2rem, 8vw, 3rem); height: auto; }
.logo { font-weight: 600; font-size: clamp(2rem, 7vw, 3rem); line-height: 1; letter-spacing: -0.03em; }
.logo .oruk { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--primary); }
.tagline { color: var(--muted); font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.24em; text-transform: uppercase; margin-top: 0.55rem; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem; box-shadow: var(--shadow); }

/* select */
.lead { font-size: 1.02rem; line-height: 1.55; margin: 0 0 1.2rem; text-align: center; color: var(--fg); }
.lead strong { color: var(--primary); font-weight: 600; }
.headphones { display: flex; align-items: center; gap: 0.6rem; justify-content: center; background: color-mix(in srgb, var(--warm) 8%, var(--card)); border: 1px solid color-mix(in srgb, var(--warm) 30%, var(--line)); border-radius: 12px; padding: 0.7rem 0.9rem; font-size: 0.9rem; color: var(--muted); margin-bottom: 1.5rem; }
.headphones b { color: var(--fg); font-weight: 600; }
.hp-icon { font-size: 1.2rem; }
.section-label { font-family: var(--mono); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); margin: 0 0 0.7rem; }

.cliplist { display: grid; gap: 0.6rem; }
.clip-empty { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 1.5rem; font-family: var(--mono); }
.clip-card { --c: var(--muted); display: flex; align-items: center; gap: 0.9rem; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 0.85rem 1rem; cursor: pointer; color: var(--fg); transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s; }
.clip-card:hover { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); box-shadow: 0 8px 22px -14px color-mix(in srgb, var(--c) 80%, transparent); transform: translateY(-1px); }
/* soft, glowing emotion orb with swirling gradient clouds */
.orb {
  --p1: color-mix(in srgb, var(--c) 58%, #fff);   /* pastel emotion */
  --p2: color-mix(in srgb, var(--c2) 62%, #fff);  /* pastel secondary */
  --p3: color-mix(in srgb, var(--c) 40%, #fff);   /* light wash */
  width: 3.1rem; height: 3.1rem; border-radius: 50%; flex: none; position: relative; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(60% 58% at 30% 26%, var(--p2) 0%, transparent 62%),
    radial-gradient(64% 60% at 72% 70%, var(--p1) 0%, transparent 62%),
    radial-gradient(circle at 48% 46%, var(--p3) 0%, color-mix(in srgb, var(--c) 55%, #000) 112%);
  box-shadow: 0 7px 22px -8px color-mix(in srgb, var(--c) 55%, transparent);
  animation: orb-bob 5.5s ease-in-out infinite;
}
.orb-layer { position: absolute; border-radius: 50%; pointer-events: none; }
.orb-a {
  inset: -32%; filter: blur(8px); animation: orb-swirl 15s linear infinite;
  background:
    radial-gradient(40% 40% at 34% 32%, var(--p2) 0%, transparent 60%),
    radial-gradient(44% 44% at 70% 66%, var(--p1) 0%, transparent 60%),
    radial-gradient(26% 26% at 58% 42%, color-mix(in srgb, #fff 78%, var(--c2)) 0%, transparent 60%);
}
.orb-b {
  inset: -26%; filter: blur(10px); opacity: 0.9; animation: orb-swirl-rev 19s linear infinite;
  background:
    radial-gradient(46% 46% at 66% 36%, var(--p2) 0%, transparent 60%),
    radial-gradient(38% 38% at 30% 70%, color-mix(in srgb, #fff 65%, var(--c)) 0%, transparent 60%),
    radial-gradient(32% 32% at 44% 48%, var(--p1) 0%, transparent 60%);
}
/* film grain - the matte speckle that gives it the ElevenLabs look */
.orb-grain {
  position: absolute; inset: 0; border-radius: 50%; z-index: 3; pointer-events: none; opacity: 0.6; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 120px 120px;
}
@keyframes orb-swirl { to { transform: rotate(360deg); } }
@keyframes orb-swirl-rev { to { transform: rotate(-360deg); } }
@keyframes orb-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .orb, .orb-a, .orb-b { animation: none; } }
.orb { display: inline-block; vertical-align: middle; }
.orb-sm { width: 1.4rem; height: 1.4rem; }
.orb-xs { width: 0.95rem; height: 0.95rem; box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--c) 55%, transparent); }
.cc-body { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 0; }
.cc-title { font-weight: 600; font-size: 1rem; }
.cc-meta { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.cc-go { color: var(--c); font-size: 0.9rem; }

/* play */
.video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--line); margin-bottom: 1rem; }
.video-wrap #player, .video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-guard { position: absolute; inset: 0; z-index: 2; cursor: default; } /* swallows clicks so the clip can't be paused/scrubbed */

.playbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.9rem; }
.pb-btn { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 10px; padding: 0.5rem 0.85rem; cursor: pointer; font-family: var(--sans); font-weight: 600; font-size: 0.85rem; transition: border-color 0.15s, background 0.15s, color 0.15s; }
.pb-btn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
.pb-ico { font-size: 0.8rem; line-height: 1; }
.pb-btn.exit { margin-left: auto; }
.pb-btn.exit:hover { border-color: var(--destructive); color: var(--destructive); background: color-mix(in srgb, var(--destructive) 6%, var(--card)); }

.hud { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.hud-item { display: flex; align-items: baseline; gap: 0.35rem; }
.hud-label { font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.hud-val { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.hud-of { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.hud-item.target { margin-left: auto; align-items: center; }
.hud-item.target[hidden] { display: none; }
.target-emo { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; font-size: 0.95rem; }
.target-label { line-height: 1; }
.iconbtn { width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.iconbtn:hover { border-color: var(--destructive); color: var(--destructive); }

.syncbar { display: flex; align-items: center; gap: 0.5rem; justify-content: center; margin-bottom: 0.7rem; }
.sync-label { font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.syncbtn { width: 1.7rem; height: 1.7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; font-weight: 600; font-size: 0.95rem; line-height: 1; }
.syncbtn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); color: var(--primary); }
.sync-val { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; color: var(--fg); min-width: 3rem; text-align: center; font-variant-numeric: tabular-nums; }

.lyrics { max-height: 40vh; overflow-y: auto; padding: 0.4rem; border-radius: 14px; background: var(--fill); border: 1px solid var(--line); scroll-behavior: smooth; }
.lyric { --c: var(--muted); display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem; border-radius: 10px; opacity: 0.55; transition: opacity 0.2s, background 0.2s, transform 0.2s; }
.lyric.active { opacity: 1; background: var(--card); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent); transform: scale(1.015); }
.lyric.done { opacity: 0.9; }
.ly-tag { flex: none; display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; align-self: flex-start; }
.ly-tag-label { line-height: 1; }
.ly-text { flex: 1; font-size: 1.06rem; font-weight: 500; line-height: 1.45; }
.ly-word { color: var(--muted); transition: color 0.1s, text-shadow 0.1s; }
.lyric.active .ly-word { color: color-mix(in srgb, var(--fg) 55%, var(--muted)); }
.ly-word.sung { color: var(--c); font-weight: 600; }
.ly-word.cur { color: var(--c); font-weight: 700; text-shadow: 0 0 14px color-mix(in srgb, var(--c) 50%, transparent); }
.ly-score { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; align-self: flex-start; margin-top: 0.15rem; }
.ly-score.good { color: var(--primary); }
.ly-score.ok { color: var(--neutral); }
.ly-score.miss { color: var(--destructive); }

.linefeed { display: flex; align-items: center; gap: 0.55rem; justify-content: center; margin-top: 0.9rem; font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.linefeed[hidden] { display: none; }
.lf-emo { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; }
.lf-score { margin-left: 0.3rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--fill); }
.lf-score.good { color: #06341f; background: color-mix(in srgb, var(--primary) 20%, var(--card)); }
.lf-score.ok { color: #4a3a00; background: color-mix(in srgb, var(--neutral) 22%, var(--card)); }
.lf-score.miss { color: #4a0a0c; background: color-mix(in srgb, var(--destructive) 18%, var(--card)); }

.mic-state { display: flex; align-items: center; gap: 0.5rem; justify-content: center; margin-top: 1rem; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--muted); }
.dot[data-k="live"] { background: var(--destructive); animation: pulse 1.1s ease-out infinite; }
.dot[data-k="wait"] { background: var(--neutral); }
.dot[data-k="err"] { background: var(--destructive); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--destructive) 55%, transparent); } 100% { box-shadow: 0 0 0 8px rgba(201,47,51,0); } }

.foot { color: var(--muted); font-size: 0.76rem; text-align: center; margin: 1.5rem auto 0; }
.foot a { color: var(--primary); text-decoration: none; }
.foot strong { color: var(--fg); font-weight: 600; }

/* results */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--fg) 32%, transparent); backdrop-filter: blur(6px); display: grid; place-items: safe center; overflow-y: auto; z-index: 30; padding: 1.5rem 1rem; }
.overlay[hidden] { display: none; }
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1.8rem; text-align: center; max-width: 30rem; width: 100%; box-shadow: 0 40px 90px -30px rgba(24,24,29,0.4); }
.grade { font-family: var(--mono); font-weight: 700; font-size: 3.2rem; line-height: 1; color: var(--primary); }
.grade[data-g="S"] { color: #b8860b; } .grade[data-g="D"] { color: var(--muted); }
.result-card h1 { margin: 0.3rem 0 0.2rem; font-size: 1.5rem; font-weight: 600; }
.finalscore { font-family: var(--mono); font-size: 2.4rem; font-weight: 600; color: var(--fg); margin-bottom: 1.1rem; font-variant-numeric: tabular-nums; }
.fs-of { font-size: 1rem; color: var(--muted); }
.result-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 1.1rem; }
.rs { background: var(--fill); border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.3rem; }
.rs-n { font-family: var(--mono); font-size: 1.1rem; font-weight: 600; }
.rs-l { font-family: var(--mono); font-size: 0.56rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 0.15rem; }
.result-lines { text-align: left; max-height: 30vh; overflow-y: auto; margin-bottom: 1.1rem; display: grid; gap: 0.3rem; }
.rl-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.55rem; font-size: 0.85rem; }
.rl-mid { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.rl-sub { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-score { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.rl-score.good { color: var(--primary); } .rl-score.ok { color: var(--neutral); } .rl-score.miss { color: var(--destructive); }
.result-actions { display: flex; gap: 0.6rem; }
.btn { flex: 1; border: none; border-radius: 12px; cursor: pointer; font-family: var(--sans); font-weight: 600; font-size: 1rem; padding: 0.85rem 1rem; transition: filter 0.15s, border-color 0.15s; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--warm)); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--card); border: 1px solid var(--line); color: var(--fg); }
.btn.ghost:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }

.perm-hint { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); border-radius: 999px; padding: 0.6rem 1rem; font-size: 0.85rem; z-index: 50; box-shadow: var(--shadow); }
.perm-hint[hidden] { display: none; }

@media (max-width: 560px) {
  .stage { padding: 1rem 0.85rem 2rem; }
  .panel { padding: 1.2rem; }
  .ly-text { font-size: 0.98rem; }
  .result-split { gap: 0.4rem; }
}
