/* PandaCut web. Tokens first; the dark set overrides the same names. No third-party fonts or scripts. */
:root {
  --bg: #FFF9F3; --panel: #FFFFFF; --raised: #F1EAFF; --text: #2A1540; --dim: #6B5A7E; --faint: #8E7FA0;
  --hair: rgba(42, 21, 64, .10); --tint: #6A32FF; --onTint: #FFFFFF; --orange: #FF8A3D;
  --lane: #EFE8F8; --clip: #2A2340; --wave: #CFC8DE; --stage: #050505; --shadow: 0 1px 2px rgba(42, 21, 64, .08), 0 8px 24px rgba(106, 50, 255, .08);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #130C26; --panel: #1E1536; --raised: #2A1E48; --text: #F5F0FF; --dim: #B9AAD6; --faint: #8878AA;
    --hair: rgba(255, 255, 255, .085); --tint: #A98BFF; --onTint: #160C2E;
    --lane: #1A1230; --clip: #241B3D; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #130C26; --panel: #1E1536; --raised: #2A1E48; --text: #F5F0FF; --dim: #B9AAD6; --faint: #8878AA;
  --hair: rgba(255, 255, 255, .085); --tint: #A98BFF; --onTint: #160C2E;
  --lane: #1A1230; --clip: #241B3D; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); -webkit-font-smoothing: antialiased;
  min-height: 100dvh; overflow: hidden;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  height: 100dvh; display: grid; grid-template-rows: auto 1fr auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---- top bar ---- */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; transition: opacity .3s; }
.word { font: 800 20px var(--round); letter-spacing: -.01em; }
.title { flex: 1; text-align: center; color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity .3s; }
.barActions { display: flex; gap: 8px; align-items: center; position: relative; z-index: 5; }

.btn {
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--raised); color: var(--text);
  font: 600 14px var(--sans); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s, opacity .15s, background .15s;
}
.btn.primary { background: var(--tint); color: var(--onTint); min-height: 48px; padding: 0 26px; font-family: var(--round); font-weight: 800; font-size: 15px; }
.btn.icon { padding: 0; width: 44px; }
.btn.small { min-height: 36px; padding: 0 16px; font-size: 13px; }
.btn:active:not(:disabled), .play:active, .skip:active { transform: scale(.97); opacity: .75; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
@media (hover: hover) { .btn:hover:not(:disabled) { filter: brightness(1.05); } }

/* ---- layout ---- */
.work { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 0 16px; min-height: 0; }
.rail { background: var(--panel); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); overflow: hidden; transition: opacity .3s; }
.lbl { font: 700 10px var(--mono); letter-spacing: .16em; color: var(--faint); margin-bottom: 12px; }
.clipThumb { position: relative; border-radius: 10px; overflow: hidden; background: var(--stage); aspect-ratio: 16/9; }
.clipThumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.clipName { margin-top: 8px; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clipMeta { color: var(--dim); font-size: 11px; margin-top: 2px; }
.railNote { margin-top: 14px; color: var(--dim); font-size: 12px; }

.stageWrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 8px; }
.stage { position: relative; flex: 1; min-height: 0; background: var(--stage); border-radius: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.app[data-state="empty"] video, .app[data-state="loading"] video { visibility: hidden; }
.stage.over { outline: 3px dashed var(--tint); outline-offset: -8px; }
#dots { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .3s; }
.stage.dotsOn #dots { opacity: 1; }

/* the drop zone is the empty state and the problem state */
.drop { position: absolute; inset: 14px; border: 2px dashed rgba(255, 255, 255, .22); border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 20px; color: #F5F0FF; }
.drop h1 { font: 800 clamp(22px, 3vw, 30px) var(--round); letter-spacing: -.01em; }
.drop p { max-width: 460px; color: #CFC4E6; }
.drop .fine { font-size: 12px; color: #A99CC6; margin-top: 6px; }
.drop .btn.primary { background: #A98BFF; color: #160C2E; margin-top: 4px; }
.app:not([data-state="empty"]):not([data-state="problem"]) .drop { display: none; }

.status { position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 6px; border-radius: 999px; background: rgba(20, 12, 38, .72); color: #F5F0FF; font-weight: 600; font-size: 13px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); max-width: calc(100% - 24px); z-index: 4; }
.status img { border-radius: 50%; }
.status span { padding-right: 6px; }
.app[data-state="empty"] .status, .app[data-state="problem"] .status { display: none; }
.skip { border: 0; border-radius: 999px; min-height: 32px; padding: 0 14px; background: #fff; color: #160C2E; font: 700 12px var(--sans); cursor: pointer; transition: transform .1s, opacity .15s; }

.hero { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; background: var(--panel); color: var(--text); padding: 14px 20px 14px 14px; border-radius: 24px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); max-width: calc(100% - 24px); animation: rise .45s var(--ease); z-index: 4; }
.hero img { flex: none; }
.heroBig { font: 800 clamp(26px, 4vw, 38px)/1.05 var(--round); letter-spacing: -.02em; color: var(--tint); }
.heroSmall { color: var(--dim); font-size: 13px; margin-top: 2px; }
.heroBtns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 16px); } }

.transport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 56px; transition: opacity .3s; }
.tc { display: flex; align-items: baseline; gap: 8px; }
.tc .now { font-size: clamp(18px, 2.4vw, 24px); font-weight: 500; }
.tc .dur { color: var(--faint); font-size: 12px; }
.keys { display: flex; align-items: center; gap: 6px; }
.play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 0 0 5px var(--raised); transition: transform .1s, opacity .15s; }
.seg { justify-self: end; display: flex; background: var(--raised); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--dim); font: 600 12px var(--sans); min-height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--tint); color: var(--onTint); }

/* ---- timeline ---- */
.tl { background: var(--panel); margin: 8px 16px 16px; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.tools { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--hair); }
.tlInfo { margin-left: auto; color: var(--dim); font-size: 12px; }
.tlCanvas { position: relative; width: 100%; padding-top: 4px; touch-action: none; }
.tlCanvas canvas { display: block; width: 100%; cursor: pointer; }

/* ---- the show ---- */
.app.dimmed .rail, .app.dimmed .brand, .app.dimmed .title, .app.dimmed .transport { opacity: .35; }
.br { position: absolute; width: 18px; height: 18px; border: 0 solid var(--orange); opacity: 0; transition: opacity .25s; pointer-events: none; }
.br.tl { left: 10px; top: 10px; border-width: 2px 0 0 2px; border-top-left-radius: 5px; }
.br.tr { right: 10px; top: 10px; border-width: 2px 2px 0 0; border-top-right-radius: 5px; }
.br.bl { left: 10px; bottom: 10px; border-width: 0 0 2px 2px; border-bottom-left-radius: 5px; }
.br.brr { right: 10px; bottom: 10px; border-width: 0 2px 2px 0; border-bottom-right-radius: 5px; }
.clipThumb .br { width: 12px; height: 12px; }
.clipThumb .br.tl { left: 4px; top: 4px; } .clipThumb .br.tr { right: 4px; top: 4px; } .clipThumb .br.bl { left: 4px; bottom: 4px; } .clipThumb .br.brr { right: 4px; bottom: 4px; }
.scanLine { position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--orange); box-shadow: 0 0 24px 8px rgba(255, 138, 61, .45); opacity: 0; pointer-events: none; }
.app.scanning .br { opacity: 1; }
.app.scanning .scanLine { opacity: 1; animation: sweep 1.3s ease-in-out infinite alternate; }
@keyframes sweep { from { left: 0; } to { left: calc(100% - 3px); } }

.cursor { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; color: var(--tint); will-change: transform; }
.cursor svg { display: block; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
.cursor .tag { position: absolute; left: 14px; top: 16px; background: var(--tint); color: var(--onTint); font: 700 10px var(--sans); padding: 2px 7px; border-radius: 999px; white-space: nowrap; }

/* ---- export sheet ---- */
dialog { border: 0; border-radius: 24px; padding: 24px; width: min(440px, calc(100vw - 32px)); background: var(--panel); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .45); margin: auto; }
dialog::backdrop { background: rgba(10, 5, 22, .55); }
dialog h2 { font: 800 22px var(--round); margin-bottom: 14px; }
dialog fieldset { border: 0; display: grid; gap: 8px; }
dialog legend { font: 700 10px var(--mono); letter-spacing: .16em; color: var(--faint); margin-bottom: 8px; text-transform: uppercase; }
dialog label { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--raised); cursor: pointer; min-height: 56px; }
dialog label small { display: block; color: var(--dim); font-size: 12px; }
dialog input[type=radio] { accent-color: var(--tint); width: 20px; height: 20px; }
dialog .fine { color: var(--dim); font-size: 12px; margin-top: 12px; }
.dlgBtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.bar2 { height: 10px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.bar2 i { display: block; height: 100%; width: 0; background: var(--tint); border-radius: 999px; transition: width .2s linear; }
#exProgress p, #exDone p { margin-top: 10px; color: var(--dim); }
#exDone .btn { margin-top: 8px; text-decoration: none; }

/* ---- phones ---- */
@media (max-width: 768px) {
  .work { grid-template-columns: 1fr; padding: 0 12px; }
  .rail { display: none; }
  .bar { padding: 8px 12px; gap: 8px; }
  .title { display: none; }
  .brand { flex: 1; }
  .tl { margin: 6px 12px 12px; }
  .drop { inset: 8px; padding: 12px; gap: 6px; }
  .drop img { width: 72px; height: 72px; }
  .drop .fine { font-size: 11px; }
  .hero { flex-direction: column; text-align: center; padding: 12px 16px; bottom: 10px; }
  .heroBtns { justify-content: center; }
  .hero img { width: 56px; height: 56px; }
  .transport { grid-template-columns: auto 1fr auto; gap: 8px; }
  .keys { justify-self: center; }
  .tc .dur { display: none; }
  .seg button { padding: 0 10px; }
  .btn.primary { padding: 0 20px; }
}

/* ---- Reduce Motion: cross-fade, no travel, no sweep, no shimmer ---- */
@media (prefers-reduced-motion: reduce) {
  .app.scanning .scanLine { animation: none; opacity: 0; }
  .hero { animation: none; }
  #dots, .cursor { display: none; }
  .btn, .play, .skip { transition: opacity .15s; }
  .btn:active:not(:disabled), .play:active, .skip:active { transform: none; }
}
