:root {
  --color-canvas: #f3f1ec;
  --color-background-primary: #ffffff;
  --color-background-secondary: #f6f5f2;
  --color-background-info: #1d4ed8;
  --color-background-selected: #eef3ff;
  --color-success-soft: #e7f6ee;
  --color-danger-soft: #fdecec;
  --color-info-soft: #e8efff;
  --color-text-primary: #1c1917;
  --color-text-secondary: #78716c;
  --color-text-info: #1d4ed8;
  --color-text-success: #2ba471;
  --color-text-danger: #d54941;
  --color-text-anti: #ffffff;
  --color-border-secondary: #d6d3d1;
  --color-border-tertiary: #e7e5e4;
  --color-mask: rgba(28, 25, 23, 0.4);
  --color-tabbar: rgba(255, 255, 255, 0.72);
  --shadow-card: 0 1px 2px rgba(28, 25, 23, 0.04), 0 10px 28px rgba(28, 25, 23, 0.06);
  --shadow-lift: 0 10px 24px rgba(28, 25, 23, 0.12);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --glow-a: rgba(29, 78, 216, 0.55);
  --glow-b: rgba(196, 122, 18, 0.42);
  --glow-c: rgba(14, 138, 154, 0.4);
  --glow-d: rgba(107, 79, 216, 0.38);
  --grid-dot: rgba(28, 25, 23, 0.16);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --subtitle-1: #1d4ed8;
  --subtitle-2: #2ba471;
  --subtitle-3: #d54941;
  --subtitle-4: #c47a12;
  --subtitle-5: #6b4fd8;
  --subtitle-6: #0e8a9a;
  --subtitle-7: #c45c26;
  --subtitle-8: #3d6b4f;
  --subtitle-9: #b43d6e;
  --subtitle-10: #3a5f8a;
  --subtitle-11: #7a4e2d;
  --subtitle-12: #4a6fa5;
  --subtitle-13: #1f7a4d;
  --subtitle-14: #a33b3b;
  --subtitle-15: #5c4d8a;
  --subtitle-16: #2f6f6f;
}

html { color-scheme: light; }

html[data-theme="night"] {
  color-scheme: dark;
  --color-canvas: #12110f;
  --color-background-primary: #1c1b19;
  --color-background-secondary: #262421;
  --color-background-info: #3b82f6;
  --color-background-selected: #1c2c4a;
  --color-success-soft: #13281f;
  --color-danger-soft: #3a1d1b;
  --color-info-soft: #1a2744;
  --color-text-primary: #f4f1ea;
  --color-text-secondary: #a8a29e;
  --color-text-info: #93c5fd;
  --color-text-success: #4ade80;
  --color-text-danger: #f0a8a4;
  --color-text-anti: #ffffff;
  --color-border-secondary: #4a453f;
  --color-border-tertiary: #34312c;
  --color-mask: rgba(0, 0, 0, 0.62);
  --color-tabbar: rgba(38, 36, 33, 0.92);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 10px 24px rgba(0, 0, 0, 0.45);
  --glow-a: rgba(59, 130, 246, 0.55);
  --glow-b: rgba(196, 122, 18, 0.38);
  --glow-c: rgba(45, 212, 191, 0.32);
  --glow-d: rgba(167, 139, 250, 0.4);
  --grid-dot: rgba(244, 241, 234, 0.14);
}

html.theme-animate body,
html.theme-animate .panel,
html.theme-animate .card,
html.theme-animate .persona-strip,
html.theme-animate .studio-main,
html.theme-animate .table-card,
html.theme-animate .login-card,
html.theme-animate .shell,
html.theme-animate .sidenav,
html.theme-animate .tabbar,
html.theme-animate .theme-switch,
html.theme-animate .theme-option,
html.theme-animate .confirm-card,
html.theme-animate input,
html.theme-animate textarea,
html.theme-animate select {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--color-canvas);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
}

body.home { background: transparent; }
body.home::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1.4px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 18%, #000 15%, transparent 72%);
}
.canvas-lights { display: none; }
body.home .canvas-lights {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
body.home .canvas-lights span {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
body.home .canvas-lights span:nth-child(1) {
  top: -8%;
  left: -6%;
  width: 42vw;
  height: 42vw;
  background: radial-gradient(circle, var(--glow-a), transparent 68%);
  animation-name: orb-a;
  animation-duration: 18s;
}
body.home .canvas-lights span:nth-child(2) {
  top: -14%;
  right: -8%;
  width: 36vw;
  height: 36vw;
  background: radial-gradient(circle, var(--glow-b), transparent 70%);
  animation-name: orb-b;
  animation-duration: 24s;
}
body.home .canvas-lights span:nth-child(3) {
  bottom: -18%;
  left: 28%;
  width: 48vw;
  height: 40vw;
  background: radial-gradient(circle, var(--glow-c), transparent 70%);
  animation-name: orb-c;
  animation-duration: 28s;
}
body.home .canvas-lights span:nth-child(4) {
  top: 28%;
  left: 38%;
  width: 24vw;
  height: 24vw;
  background: radial-gradient(circle, var(--glow-d), transparent 68%);
  animation-name: orb-d;
  animation-duration: 16s;
}
body.home > header,
body.home > main { position: relative; z-index: 1; }

a { color: var(--color-text-info); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-text-info);
  outline-offset: 2px;
}

h1, .title {
  margin: 0;
  font-size: 22px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.muted { color: var(--color-text-secondary); }
.ok { color: var(--color-text-success); }
.danger { color: var(--color-text-danger); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--color-canvas);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2rem 1.5rem;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--color-background-info);
  color: var(--color-text-anti);
  font-size: 16px;
  font-weight: 560;
  line-height: 56px;
  text-align: center;
}

.logo.small {
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 8px;
  font-size: 12px;
  line-height: 28px;
}

.login-card .sub {
  margin: 4px 0 0;
  color: var(--color-text-secondary);
}

.login-card form { margin-top: 20px; text-align: left; }

.alert {
  margin: 0 0 12px;
  color: var(--color-text-danger);
  text-align: left;
}

label { display: block; margin: 12px 0 6px; color: var(--color-text-secondary); }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  background: var(--color-background-primary);
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="file"]:hover,
textarea:hover,
select:hover {
  border-color: var(--color-border-secondary);
}

textarea { min-height: 96px; resize: vertical; }

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.check { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--color-text-primary); }
.check input { width: auto; }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-info);
}

.btn-block {
  width: 100%;
  margin-top: 16px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--color-background-info);
  color: var(--color-text-anti);
  transition: transform 160ms ease-out, filter 160ms ease-out;
}
.btn-block:active { transform: translateY(1px); }

.btn-block:hover { text-decoration: none; filter: brightness(0.96); }

.center-note { margin: 16px 0 0; text-align: center; color: var(--color-text-secondary); }

ul { margin: 0; padding: 0; list-style: none; }
.pad { padding: 10px 12px; }
.pad-lg { padding: 16px 12px; }

.page { max-width: 720px; margin: 0 auto; padding: 24px 16px; }
.page .lead { margin: 8px 0 0; color: var(--color-text-secondary); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: transparent;
}
.topbar-end { display: flex; align-items: center; gap: 12px; }
.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--color-tabbar);
  box-shadow: var(--shadow-card);
}
.theme-option {
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  background: transparent;
  color: var(--color-text-secondary);
}
.theme-option[aria-pressed="true"] {
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-card);
}

.brand { display: flex; align-items: center; gap: 8px; color: var(--color-text-primary); font-weight: 500; }
.brand:hover { text-decoration: none; }

.shell {
  display: flex;
  min-height: calc(100vh - 32px);
  margin: 16px;
  overflow: hidden;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}

.sidenav {
  width: 180px;
  flex: none;
  padding: 12px 8px;
  background: var(--color-background-secondary);
}

.sidenav a {
  display: block;
  margin-bottom: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--color-text-primary);
}

.sidenav a:hover { text-decoration: none; background: var(--color-background-primary); }
.sidenav a.selected {
  background: var(--color-background-info);
  color: var(--color-text-anti);
}
.sidenav a.selected:hover { text-decoration: none; }

.sidenav form { margin-top: 12px; padding: 0 10px; }

.main { flex: 1; padding: 20px; min-width: 0; }

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.card {
  padding: 1rem;
  border-radius: 12px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}

.card .label { color: var(--color-text-secondary); }
.card .value { margin: 4px 0 0; font-size: 15px; font-weight: 500; }

.table-card {
  margin-top: 16px;
  overflow: hidden;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 12px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}

.studio-main .table-card,
.panel .table-card { box-shadow: none; }
.console-table table { min-width: 640px; }
.console-table th,
.console-table td { white-space: nowrap; }
.console-table .wrap { white-space: normal; min-width: 16em; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 400; color: var(--color-text-secondary); }
tr + tr td { border-top: 0.5px solid var(--color-border-tertiary); }

.ops { display: flex; gap: 10px; align-items: center; }
.ops form { margin: 0; }
.ops button { padding: 0; border: 0; background: none; }
.ops .link { color: var(--color-text-info); }
.ops .danger { color: var(--color-text-danger); }

.message { margin: 0 0 12px; color: var(--color-text-danger); }

@media (max-width: 720px) {
  .shell { display: block; }
  .sidenav { width: auto; }
  .cards { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}

.page.workbench { max-width: 1180px; }
.actions.flush { margin-top: 0; }

.panel {
  margin-top: 16px;
  padding: 18px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}

.panel h2,
.record h2 { margin: 0; font-size: 16px; font-weight: 560; }
.hint { margin: 4px 0 0; color: var(--color-text-secondary); font-size: 12px; }
.course-key-note { display: block; margin-top: 4px; color: var(--color-text); font-size: 13px; line-height: 1.4; }
.course-key-note:empty { display: none; }
.field { margin-top: 12px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.course-create-actions {
  position: sticky;
  top: 8px;
  z-index: 2;
  align-items: center;
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}
.count { margin: 4px 0 0; text-align: right; }

.btn-solid,
.btn-ghost,
.btn-danger {
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
}

.btn-solid {
  border: 0;
  background: var(--color-background-info);
  color: var(--color-text-anti);
  transition: transform 160ms ease-out, filter 160ms ease-out;
}

.btn-solid:active { transform: translateY(1px); }

.btn-ghost {
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-primary);
  color: var(--color-text-info);
}

.btn-danger {
  border: 0;
  background: transparent;
  color: var(--color-text-danger);
}

a.btn-solid,
a.btn-ghost {
  display: inline-block;
  text-decoration: none;
}

a.btn-solid:hover,
a.btn-ghost:hover {
  text-decoration: none;
}

.empty { margin: 0; padding: 48px 12px; text-align: center; color: var(--color-text-secondary); }

.tabs { position: relative; }
.tabs > input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.tabbar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  border: 0;
  border-radius: 12px;
  background: var(--color-tabbar);
  box-shadow: var(--shadow-card);
}
.tabbar label {
  display: inline-block;
  margin: 0;
  padding: 8px 14px;
  border-radius: 8px;
  border-bottom: 0;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background-color 180ms ease-out, color 180ms ease-out, box-shadow 180ms ease-out;
}
.tabbar label:hover {
  background: transparent;
  color: var(--color-text-primary);
}

.tab { display: none; }

.tabs.is-switching > .tab { view-transition-name: tab-panel; }

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}
::view-transition-old(tab-panel) {
  animation: 160ms var(--ease-out) both tab-leave;
}
::view-transition-new(tab-panel) {
  animation: 180ms var(--ease-out) both tab-enter;
}

#tab-personas:checked ~ .tabbar label[for="tab-personas"],
#tab-studio:checked ~ .tabbar label[for="tab-studio"],
#tab-course:checked ~ .tabbar label[for="tab-course"],
#make-audio:checked ~ .tabbar label[for="make-audio"],
#make-avatar:checked ~ .tabbar label[for="make-avatar"],
#make-clip:checked ~ .tabbar label[for="make-clip"] {
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
  color: var(--color-text-primary);
  font-weight: 560;
}

#tab-personas:checked ~ .tab-personas,
#tab-studio:checked ~ .tab-studio,
#tab-course:checked ~ .tab-course,
#make-audio:checked ~ .make-audio,
#make-avatar:checked ~ .make-avatar,
#make-clip:checked ~ .make-clip { display: block; }

.studio-video-shared { display: none; margin-top: 16px; }
#make-avatar:checked ~ .studio-video-shared,
#make-clip:checked ~ .studio-video-shared { display: block; }

.persona-strip {
  display: none;
  margin-top: 16px;
  padding: 10px 12px 8px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}
#tab-studio:checked ~ .persona-strip,
#tab-course:checked ~ .persona-strip { display: block; }
.persona-find { margin-top: 0; }
.persona-find input { width: min(320px, 100%); }
.persona.is-filtered,
.persona-card.is-filtered { display: none; }
.persona-strip .persona-list {
  height: auto;
  min-width: 0;
  max-width: 100%;
  margin-top: 10px;
  padding: 2px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  display: flex;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-secondary) var(--color-background-secondary);
}
.persona-strip .persona {
  flex: 0 0 92px;
  width: 92px;
  align-items: center;
  text-align: center;
}
.persona-strip .persona-name { width: 100%; font-size: 12px; }
.persona-strip .persona-list::-webkit-scrollbar { width: auto; height: 8px; }

.studio {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.persona-pane,
.studio-main {
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  padding: 12px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
}

.persona-list {
  height: 420px;
  margin-top: 12px;
  padding-right: 4px;
  overflow-y: scroll;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-content: start;
  scrollbar-width: auto;
  scrollbar-color: var(--color-border-secondary) var(--color-background-secondary);
}

.persona-list::-webkit-scrollbar { width: 10px; }
.persona-list::-webkit-scrollbar-track {
  background: var(--color-background-secondary);
  border-radius: 8px;
}
.persona-list::-webkit-scrollbar-thumb {
  background: var(--color-border-secondary);
  border: 2px solid var(--color-background-secondary);
  border-radius: 8px;
}

.persona-list .empty { padding: 28px 8px; grid-column: 1 / -1; }

.persona {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
  color: var(--color-text-primary);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease-out, box-shadow 180ms ease-out, border-color 180ms ease-out, background-color 180ms ease-out;
}

.persona:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.persona-face {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  pointer-events: none;
  background: var(--color-background-secondary);
}

.persona-making {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  text-align: center;
  color: var(--color-text-secondary);
}

.persona-prep-label { margin: 0; }

.persona-prep-track {
  width: min(160px, 80%);
  height: 4px;
  overflow: hidden;
  background: var(--color-background-secondary);
  border-radius: 8px;
}

.persona-prep-bar {
  width: 0;
  height: 100%;
  background: var(--color-background-info);
  transition: width 180ms ease-out;
}

.persona-prep-track.is-waiting .persona-prep-bar {
  width: 36%;
  animation: prep-slide 1.4s ease-in-out infinite;
}

.persona:disabled { cursor: default; }

.persona-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint.danger { color: var(--color-text-danger); }
.notice { margin: 0 0 12px; color: var(--color-text-success); }

.persona-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.persona-gallery:not(:has(.persona-card)) { display: none; }

.persona-card {
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  overflow: hidden;
  background: var(--color-background-primary);
  box-shadow: var(--shadow-card);
  transition: transform 180ms ease-out, box-shadow 180ms ease-out;
}

.persona-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.persona-card .persona-face { aspect-ratio: 4 / 3; border-radius: 0; }
.persona-card .meta { padding: 10px 12px 12px; }
.persona-card h3 { margin: 0; font-size: 13px; font-weight: 500; }
.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.card-actions form { margin: 0; }
.card-actions .btn-ghost,
.card-actions .btn-danger { margin-top: 0; padding: 6px 10px; }

.persona.selected {
  border-color: var(--color-background-info);
  background: var(--color-background-selected);
}

.studio-main > .hint { margin: 0 0 4px; }
.record { margin-top: 16px; }
.record h2 { margin: 0; }
.record .table-card { margin-top: 0; }
.record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.record .record-head h2 { margin: 0; }
.record-head > .hint { margin: 0; }
.record-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.record-date-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--color-text-secondary);
}
.record-tools input[type="date"],
.record-tools select { width: auto; }
.record-tip { margin: 0 0 8px; }
.record-pager { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.record-page { color: var(--color-text-secondary); }
.record-pager button:disabled,
#course-watch-apply:disabled,
#course-watch-render:disabled,
#course-create:disabled { opacity: 0.45; cursor: not-allowed; }
.upload-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 0 100%;
  color: var(--color-text-secondary);
  font-size: 13px;
}
.upload-progress[hidden] { display: none; }
.upload-progress-track {
  width: 160px;
  height: 4px;
  overflow: hidden;
  background: var(--color-background-secondary);
  border-radius: 8px;
}
.upload-progress-bar {
  width: 0;
  height: 100%;
  background: var(--color-background-info);
  transition: width 180ms ease-out;
}
.upload-progress.is-waiting .upload-progress-bar {
  width: 36%;
  animation: prep-slide 1.4s ease-in-out infinite;
}
.record .pick,
.pick-col { width: 28px; }
.record .pick input,
.pick-col input { width: auto; margin: 0; }
.record-ops { display: flex; flex-wrap: wrap; gap: 8px; }
#course-record-list table { table-layout: auto; }
#course-record-list th:nth-child(3),
#course-record-list td:nth-child(3) { width: 7.5rem; }
#course-record-list th:nth-child(5),
#course-record-list td:nth-child(5) { width: 28rem; }
#audio-records td:nth-child(4),
#audio-records td:nth-child(5),
#audio-records td:last-child { white-space: nowrap; }
#audio-records td:last-child { width: 1%; }
#audio-records .record-ops { flex-wrap: nowrap; }
#audio-records .record-ops .btn-ghost,
#audio-records .record-ops .btn-danger { padding: 6px 10px; }
#course-videos td:nth-child(4) { white-space: nowrap; }
#course-record-list .record-ops .btn-ghost,
#course-record-list .record-ops .btn-danger { padding: 6px 10px; }
#course-record-list td:nth-child(2),
#course-record-list .course-status { overflow-wrap: anywhere; }
.course-error {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  margin-top: 4px;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.page-stopped {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--color-mask);
}
.page-stopped .confirm-card h1 { margin-bottom: 8px; }
.page-stopped .muted { margin: 0; }

.confirm-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--color-mask);
  animation: mask-in 180ms ease-out;
}
.confirm-layer[hidden] { display: none; }
.confirm-card {
  width: min(360px, 100%);
  padding: 16px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
  animation: card-in 180ms ease-out;
}
.confirm-card p { margin: 0; }
.confirm-card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 500; }
.confirm-card .actions { margin-top: 16px; }
.original-card { width: min(480px, 100%); }
.original-card textarea { min-height: 120px; }
.inner .tabbar { margin-top: 8px; }

.preview {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 0.5px solid var(--color-border-tertiary);
}

.preview audio,
.preview video { width: 100%; margin-top: 8px; }
.clip-error { display: block; margin-top: 4px; }
#audio-preview-wrap { margin-top: 12px; padding-top: 0; border-top: 0; }
#audio-preview-wrap[hidden] { display: none; }
#audio-preview-wrap audio { margin-top: 0; }
.btn-solid.is-busy { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 720px) {
  .studio { grid-template-columns: 1fr; }
  .persona-gallery { grid-template-columns: 1fr 1fr; }
  .layout-board { grid-template-columns: 1fr; }
  .film-pair { grid-template-columns: 1fr; }
  #audio-records .record-ops { flex-wrap: wrap; }
  #audio-records td:last-child { white-space: normal; }
}

.stage-wrap { display: flex; justify-content: center; align-items: flex-start; margin-top: 12px; }
.layout-board {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 12px 20px;
  align-items: start;
  margin-top: 12px;
}
.layout-board .stage-wrap { margin-top: 0; }
.stage {
  position: relative;
  overflow: hidden;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  background: var(--color-background-secondary);
}
.stage-tag {
  position: absolute;
  z-index: 0;
  top: 8px;
  left: 10px;
  color: var(--color-text-secondary);
  font-size: 12px;
  pointer-events: none;
}
.float-box {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: 8px;
  background: var(--color-background-primary);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.float-box * { pointer-events: none; }
.float-box.is-dragging { z-index: 4; cursor: grabbing; }
.float-box[hidden] { display: none; }
.ppt-box {
  z-index: 1;
  overflow: hidden;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
.ppt-box.has-slide .ppt-label { display: none; }
.avatar-box {
  z-index: 2;
  right: 4%;
  bottom: 4%;
  width: 22%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
}
.avatar-box.has-still { background: transparent; }
#avatar-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
#course-avatar-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.course-order { margin-left: 6px; }
.course-proof-card { width: min(880px, 100%); max-height: 80vh; overflow: auto; }
.course-watch-layer { z-index: 40; }
.course-render-layer { z-index: 50; }
.play-layer { z-index: 60; }
.play-card {
  width: min(960px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.play-video {
  width: 100%;
  max-height: 70vh;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
}
.course-watch-card {
  width: min(960px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.watch-scroll { flex: 1 1 auto; overflow: auto; min-height: 0; }
.film-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: start;
}
.film-slot .actions { margin-top: 8px; }
.film-player {
  display: block;
  width: 100%;
  max-height: 132px;
  margin-top: 8px;
  object-fit: contain;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
}
.film-player[hidden] { display: none; }
.layout-form { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.layout-form label { display: inline-flex; align-items: center; margin: 0; }
.layout-ratios { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.layout-pair { gap: 8px; color: var(--color-text-secondary); white-space: nowrap; }
.layout-pair select { width: auto; min-width: 88px; padding: 4px 8px; }
.layout-rows { display: flex; flex-direction: column; gap: 8px; }
.layout-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.layout-name { flex: 0 0 48px; color: var(--color-text-primary); }
.layout-cell { gap: 6px; color: var(--color-text-secondary); font-size: 12px; white-space: nowrap; }
.layout-cell input[type="number"] { width: 72px; padding: 4px 6px; }
.watch-player {
  display: block;
  flex: 0 0 auto;
  align-self: center;
  width: min(100%, 720px);
  height: auto;
  max-height: 30vh;
  margin: 12px auto 0;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  background: var(--color-background-secondary);
}
.watch-player[hidden] { display: none; }
a.btn-ghost { display: inline-flex; align-items: center; font: inherit; line-height: 1.2; }
a.btn-ghost:hover { text-decoration: none; }
a.btn-ghost[hidden] { display: none; }
.proof-nav { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.proof-nav .hint { margin: 0; }
.proof-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.proof-shot { width: 100%; height: auto; border: 0.5px solid var(--color-border-tertiary); border-radius: 8px; }
.proof-options { display: flex; flex-direction: column; gap: 8px; }
.proof-options .field { margin-top: 0; }
.proof-options .hint { margin: 0; }
.proof-script { display: block; width: 100%; min-height: 140px; margin-top: 4px; }
.proof-axis { display: flex; width: 100%; height: 14px; margin: 4px 0 8px; }
.proof-block {
  flex: 1 1 0;
  height: 14px;
  min-width: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
}
.proof-block:first-child { border-radius: 8px 0 0 8px; }
.proof-block:last-child { border-radius: 0 8px 8px 0; }
.proof-block:only-child { border-radius: 8px; }
.proof-block:hover,
.proof-block:focus-visible { outline: 2px solid var(--color-text-primary); outline-offset: 1px; }
.proof-preview { margin: 0 0 8px; min-height: 1.6em; }
.proof-line { display: flex; flex-direction: row; align-items: flex-start; gap: 8px; }
.proof-swatch { width: 10px; height: 10px; margin-top: 6px; border-radius: 8px; flex: 0 0 auto; }
.proof-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.proof-time { margin: 0; color: var(--color-text-secondary); font-size: 12px; }
.proof-line p { margin: 0; }
.caption-box {
  z-index: 3;
  left: 12%;
  bottom: 8%;
  width: 76%;
  min-height: 28px;
  padding: 4px 8px;
  text-align: center;
}
.proof-effect-row { display: flex; align-items: flex-end; gap: 8px; }
.proof-effect-row .field { flex: 1 1 auto; margin-top: 0; }
.caption-tools[hidden],
#layout-panel[hidden] { display: none; }
input[type="range"] { width: 100%; padding: 0; }

.choice { display: block; margin-top: 8px; }
.choice input { width: auto; margin-right: 6px; }

.settings-form { max-width: 720px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 12px; }
.user-actions form { margin: 0; }
.user-actions .field { margin-top: 0; }
.user-layer { z-index: 25; }
.user-sheet {
  width: min(560px, 100%);
  max-height: min(80vh, 760px);
  overflow: auto;
}
.quota-fields[hidden] { display: none; }
.quota-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.quota-line .choice { margin: 0; }
.quota-line input[type="number"] { width: 8em; }
.vip-term[hidden],
[data-access][hidden] { display: none; }

body.is-preview #audio-form .choice,
body.is-preview #audio-form .field,
body.is-preview #audio-form .actions,
body.is-preview #clip-form .choice,
body.is-preview #clip-form .field,
body.is-preview #clip-form .actions,
body.is-preview .btn-solid,
body.is-preview .btn-danger,
body.is-preview .audio-fill,
body.is-preview .clip-fill,
body.is-preview .clip-redo,
body.is-preview .avatar-redo,
body.is-preview #course-form .field,
body.is-preview #course-form .actions,
body.is-preview .course-proof,
body.is-preview .course-retry,
body.is-preview .course-delete {
  display: none;
}

tr.nested td:first-child { padding-left: 28px; }

.current-persona {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--color-background-secondary);
}
.current-face {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 8px;
  background: var(--color-border-tertiary) center / cover no-repeat;
}
.current-face[hidden] { display: none; }
.current-face img,
.current-face video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.current-kicker { display: block; color: var(--color-text-secondary); font-size: 12px; line-height: 1.3; }
.current-name { display: block; font-weight: 560; }

.more { margin-top: 8px; }
.more summary {
  width: fit-content;
  color: var(--color-text-info);
  font-size: 12px;
  cursor: pointer;
}
.more summary:hover { text-decoration: underline; }

.upload-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.upload-row .field {
  margin-top: 12px;
  padding: 12px;
  border: 0.5px dashed var(--color-border-secondary);
  border-radius: 12px;
  background: var(--color-background-secondary);
}
.upload-row .file-name { margin-top: 8px; }

.clip-status-label,
.course-status-label {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-background-secondary);
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  transition: background-color 180ms ease-out, color 180ms ease-out;
}
.record-row[data-status="succeeded"] .clip-status-label,
.record-row[data-status="succeeded"] .course-status-label {
  background: var(--color-success-soft);
  color: var(--color-text-success);
}
.record-row[data-status="failed"] .clip-status-label,
.record-row[data-status="failed"] .course-status-label,
.record-row[data-status="expired"] .clip-status-label,
.record-row[data-status="expired"] .course-status-label {
  background: var(--color-danger-soft);
  color: var(--color-text-danger);
}
.record-row[data-status="queued"] .clip-status-label,
.record-row[data-status="queued"] .course-status-label,
.record-row[data-status="aligning"] .course-status-label,
.record-row[data-status="matching"] .course-status-label,
.record-row[data-status="rendering"] .clip-status-label,
.record-row[data-status="rendering"] .course-status-label,
.record-row[data-status="grabbing"] .clip-status-label,
.record-row[data-live="1"] .clip-status-label,
.record-row[data-live="1"] .course-status-label {
  background: var(--color-info-soft);
  color: var(--color-text-info);
}

.persona-card.is-new { animation: tab-in 200ms ease-out; }

@keyframes tab-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes orb-a {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  25% { transform: translate3d(18vw, 6vh, 0) scale(1.08); }
  50% { transform: translate3d(10vw, 22vh, 0) scale(0.94); }
  75% { transform: translate3d(-8vw, 12vh, 0) scale(1.12); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes orb-b {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  25% { transform: translate3d(-8vw, 16vh, 0) scale(1.1); }
  50% { transform: translate3d(-22vw, 8vh, 0) scale(0.9); }
  75% { transform: translate3d(-10vw, -6vh, 0) scale(1.06); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes orb-c {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  25% { transform: translate3d(12vw, -8vh, 0) scale(1.06); }
  50% { transform: translate3d(-14vw, -16vh, 0) scale(0.92); }
  75% { transform: translate3d(-18vw, -4vh, 0) scale(1.1); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes orb-d {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  25% { transform: translate3d(-12vw, 8vh, 0) scale(1.16); }
  50% { transform: translate3d(6vw, 16vh, 0) scale(0.86); }
  75% { transform: translate3d(16vw, -4vh, 0) scale(1.08); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes tab-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes tab-leave {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-6px); }
}
@keyframes mask-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes card-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes prep-slide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(280%); }
}

@media (max-width: 720px) {
  .upload-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  ::view-transition-old(tab-panel),
  ::view-transition-new(tab-panel) { animation: none; }
  .persona:hover:not(:disabled),
  .persona-card:hover { transform: none; }
}
