/* Nova Animate 3D — phone-first layout. Portrait: top bar / preview / time / tabs / panel.
   Landscape (and desktop): the tabs and the panel go to a column on the right, so the preview keeps its height. */
:root {
  --bg: #0b0b12;
  --panel: #14141d;
  --panel-2: #1c1c28;
  --line: #2a2a3a;
  --text: #ecebf7;
  --muted: #9a99b4;
  --accent: #7DFABC;
  --accent-ink: #08080E;
  --danger: #ff6b6b;
  --stage: #07070d;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 14px/1.4 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-text-size-adjust: 100%; overflow: hidden; }
button, input, a { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.a3-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.a3-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.a3-grow { flex: 1; min-width: 0; }

#a3-app {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh; height: var(--a3-h, 100dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "top" "stage" "bar" "tabs" "panel";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* ── Top bar ── */
#a3-top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.a3-title { font-weight: 700; font-size: 15px; letter-spacing: .01em; white-space: nowrap; margin-left: 2px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.a3-title span:last-of-type { color: var(--accent); }
.a3-beta { font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.a3-ibtn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-decoration: none; flex-shrink: 0; }
.a3-ibtn:active { background: var(--panel-2); }
.a3-primary { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; flex-shrink: 0; }
.a3-primary:active { filter: brightness(.9); }
.a3-primary:disabled { opacity: .45; cursor: default; }
.a3-ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-weight: 600; text-align: center; text-decoration: none; }
.a3-ghost:active { background: var(--line); }
.a3-wide { width: 100%; min-height: 46px; }
.a3-row { display: flex; gap: 8px; margin-bottom: 8px; }
.a3-row > * { flex: 1; }

/* ── Preview ── */
#a3-stage { grid-area: stage; position: relative; overflow: hidden; background: var(--stage); min-height: 0; min-width: 0; touch-action: manipulation; }
#a3-frame { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 100%; height: 100%; border-radius: 8px; overflow: hidden; background: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 8px 30px rgba(0,0,0,.5); }
#a3-canvas { display: block; width: 100%; height: 100%; }
#a3-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--stage); z-index: 3; }
#a3-msg[hidden] { display: none; }
#a3-msg p { margin: 0; max-width: 32ch; font-size: 15px; color: var(--text); }
#a3-msg-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.a3-round { position: absolute; left: 10px; bottom: 10px; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: rgba(20,20,29,.92); color: var(--text); display: inline-flex; align-items: center; justify-content: center; z-index: 2; }
.a3-round:active { background: var(--line); }
.a3-round:disabled { opacity: .4; }
.a3-round-r { left: auto; right: 10px; }
#a3-toast { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 18px; background: rgba(28,28,40,.96); border: 1px solid var(--line); font-size: 13px; text-align: center; pointer-events: none; z-index: 5; }

/* ── Time ── */
#a3-bar { grid-area: bar; display: flex; align-items: center; gap: 10px; padding: 4px 14px; background: var(--panel); border-top: 1px solid var(--line); }
#a3-scrub { flex: 1; min-width: 0; height: 32px; margin: 0; accent-color: var(--accent); }
#a3-scrub:disabled { opacity: .4; }
#a3-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 6.4em; text-align: right; }

/* ── Tabs ── */
#a3-tabs { grid-area: tabs; display: flex; gap: 2px; padding: 4px 6px; background: var(--panel); border-top: 1px solid var(--line); }
#a3-tabs button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: 50px; padding: 2px 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
#a3-tabs button i { font-style: normal; font-size: 19px; line-height: 1; filter: grayscale(.4); }
#a3-tabs button[aria-selected="true"] { color: var(--accent-ink); background: var(--accent); }
#a3-tabs button[aria-selected="true"] i { filter: none; }
#a3-tabs button:not([aria-selected="true"]):active { background: var(--panel-2); }

/* ── Panels ── */
#a3-panel { grid-area: panel; height: clamp(190px, 38vh, 340px); height: clamp(190px, 38dvh, 340px); overflow-y: auto; overflow-x: hidden; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px) * 0); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.a3-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 12px 0 8px; }
.a3-label:first-child { margin-top: 2px; }
.a3-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.a3-total { text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.a3-hint { color: var(--muted); font-size: 13px; margin: 8px 0; text-align: center; }
.a3-grid { display: grid; gap: 8px; }
.a3-chars { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.a3-moves { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.a3-scenes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.a3-cams { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.a3-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 52px; padding: 6px 4px; border: 2px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: 12px; font-weight: 700; text-align: center; }
.a3-card[aria-pressed="true"] { border-color: var(--accent); background: rgba(125,250,188,.12); }
.a3-card:active { background: var(--line); }
.a3-card span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a3-card i { font-style: normal; font-size: 22px; line-height: 1; }
.a3-th { position: relative; width: 100%; aspect-ratio: 1; border-radius: 8px; background: linear-gradient(#bfe3ff, #eaf6ff 62%, #8fd47c 62%); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.a3-th canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.a3-th i { font-size: 26px; }
.a3-scn { min-height: 62px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); border-color: transparent; position: relative; overflow: hidden; }
.a3-scn[aria-pressed="true"] { border-color: var(--accent); }
.a3-scn i, .a3-scn span { position: relative; }
.a3-scn span { padding: 1px 8px; border-radius: 10px; background: rgba(8,8,14,.55); text-shadow: none; }
.a3-outfits { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.a3-sw { aspect-ratio: 1; min-height: 40px; width: 100%; border-radius: 50%; border: 2px solid var(--line); padding: 0; position: relative; }
.a3-sw[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,250,188,.3); }
.a3-sw.none { background: repeating-linear-gradient(45deg, var(--panel-2), var(--panel-2) 5px, var(--line) 5px, var(--line) 10px); font-size: 11px; font-weight: 800; color: var(--text); }

.a3-clips { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 6px; touch-action: pan-x; scrollbar-width: thin; }
.a3-clip { flex: 0 0 auto; width: 76px; min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px 4px; border: 2px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: 12px; font-weight: 700; position: relative; }
.a3-clip i { font-style: normal; font-size: 22px; line-height: 1.1; }
.a3-clip small { color: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.a3-clip[aria-pressed="true"] { border-color: var(--accent); background: rgba(125,250,188,.12); }
.a3-clip .n { position: absolute; left: 4px; top: 2px; font-size: 10px; color: var(--muted); font-weight: 700; }
.a3-clipbar { display: flex; align-items: center; gap: 6px; margin: 4px 0 2px; }
.a3-clipbar b { min-width: 3.4em; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.a3-sq { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); flex-shrink: 0; padding: 0; }
.a3-sq:active { background: var(--line); }
.a3-sq:disabled { opacity: .35; cursor: default; }
.a3-danger { color: var(--danger); }

.a3-seg { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.a3-seg button { flex: 1 1 0; min-width: 0; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.a3-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ── Voice ── */
.a3-lead { margin-top: 2px; }
.a3-vhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 10px 0 6px; min-width: 0; }
.a3-vhead b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a3-vhead span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#a3-wave { display: block; width: 100%; height: 44px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.a3-vlabel { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.a3-clipbar b#a3-vat { min-width: 3.4em; }
.a3-vrow { margin: 10px 0 0; }
.a3-danger-text { color: var(--danger); }
.a3-vfill { margin-top: 8px; border-top: 1px solid var(--line); }
#a3-rec[aria-pressed="true"] { border-color: var(--danger); color: var(--danger); background: rgba(255,107,107,.12); }
#a3-rec[aria-pressed="true"] .a3-ic { animation: a3-pulse 1s ease-in-out infinite; }
@keyframes a3-pulse { 50% { opacity: .35; } }
.a3-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 4px 0; padding: 4px 2px; font-size: 14px; }
.a3-check input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; margin: 0; }

/* ── Your face ── */
.a3-camrow { display: flex; gap: 10px; align-items: stretch; margin: 6px 0; }
#a3-cam-video { width: 76px; height: 100px; flex: 0 0 auto; border-radius: 10px; border: 1px solid var(--line); background: #000; object-fit: cover; transform: scaleX(-1); }
.a3-camside { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
#a3-cam-status { margin: 0; color: var(--muted); font-size: 13px; }
#a3-cam[aria-pressed="true"] { border-color: var(--accent); }
#a3-frec[aria-pressed="true"] { border-color: var(--danger); color: var(--danger); background: rgba(255,107,107,.12); }
#a3-frec[aria-pressed="true"] .a3-ic { animation: a3-pulse 1s ease-in-out infinite; }
#a3-voice-card[inert] { opacity: .5; }
.a3-vface { margin-top: 8px; }
.a3-vface .a3-wide { margin-top: 8px; }
.a3-clipbar b#a3-fl { min-width: 6em; }

/* ── Make video ── */
#a3-sheets { position: fixed; inset: 0; z-index: 50; }
#a3-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.a3-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain; max-width: 560px; margin: 0 auto; }
.a3-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.a3-sheet-head h2 { margin: 0; font-size: 17px; }
.a3-x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--panel-2); font-size: 16px; }
.a3-bar-track { height: 10px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; margin: 14px 0 6px; }
.a3-bar-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
#a3-ex-video { display: block; width: 100%; max-height: 52vh; max-height: 52dvh; border-radius: 12px; background: #000; margin: 4px auto 8px; object-fit: contain; }
.a3-sheet .a3-wide { margin-top: 8px; }
.a3-sheet .a3-row .a3-wide { margin-top: 0; }
.a3-linkbox { display: block; width: 100%; min-height: 46px; margin: 8px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 13px; text-overflow: ellipsis; -webkit-user-select: text; user-select: text; }
.a3-opened { margin: 4px 0; font-size: 15px; font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.a3-opened-moves { font-size: 22px; font-weight: 400; letter-spacing: .08em; }

/* ── Landscape and desktop: the tabs and the panel on the right ── */
@media (orientation: landscape) and (min-width: 600px) {
  #a3-app {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 38%);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "stage tabs" "stage panel" "bar panel";
  }
  #a3-panel { height: auto; min-height: 0; border-top: 0; border-left: 1px solid var(--line); }
  #a3-tabs { border-left: 1px solid var(--line); }
  #a3-bar { border-top: 1px solid var(--line); }
  .a3-chars { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 359px) {
  .a3-title { font-size: 14px; }
  .a3-sq { width: 40px; height: 40px; }
  .a3-clipbar { gap: 4px; }
  .a3-clipbar b { min-width: 2.8em; }
  .a3-beta { display: none; }
  #a3-tabs button { font-size: 10px; }
  .a3-primary { padding: 0 12px; }
  .a3-chars { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .a3-moves, .a3-scenes, .a3-cams { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .a3-bar-track i { transition: none; } #a3-rec[aria-pressed="true"] .a3-ic, #a3-frec[aria-pressed="true"] .a3-ic { animation: none; } }
