/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg: #f5f6fa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #131722;
  --text-2: #5b6478;
  --muted: #8b93a7;
  --border: #e3e6ef;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: rgba(79, 70, 229, .1);
  --danger: #dc2626;
  --ok: #059669;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .12);
  --radius: 16px;
  --radius-sm: 10px;
}

html[data-theme="dark"] {
  --bg: #0c0f16;
  --bg-soft: #12161f;
  --surface: #151a24;
  --surface-2: #1c222e;
  --text: #eef1f7;
  --text-2: #a9b2c4;
  --muted: #7b8598;
  --border: #262e3d;
  --primary: #7c8cff;
  --primary-2: #b28dff;
  --primary-soft: rgba(124, 140, 255, .14);
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em;
       background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.ok { color: var(--ok); }
.is-hidden { display: none !important; }

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }

/* ============================================================
   Top navigation
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-soft) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; gap: 20px; height: 62px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand__logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-size: 15px; font-weight: 800;
}

.tabs {
  display: flex; gap: 4px; padding: 4px; margin-left: 8px;
  background: var(--surface-2); border-radius: 12px;
}
.tab {
  padding: 7px 20px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--text-2); transition: all .18s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: all .18s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn--sm { width: auto; height: 26px; padding: 0 9px; font-size: 12px; border-radius: 8px; }

.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.user-chip__name { font-size: 13px; font-weight: 600; max-width: 90px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 13px; flex: 0 0 auto;
}
.avatar--lg { width: 62px; height: 62px; border-radius: 18px; font-size: 25px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  border: 1px solid transparent; border-radius: 11px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 10px 18px;
  transition: all .18s ease; white-space: nowrap;
}
.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .28);
}
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(79, 70, 229, .36); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn--lg { padding: 13px 26px; font-size: 15px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ============================================================
   Layout
   ============================================================ */
.main { flex: 1; padding: 36px 20px 56px; }
.page { animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card__title { font-size: 15px; font-weight: 700; }
.card__title--mt { margin-top: 22px; }

.section-title { font-size: 17px; font-weight: 700; margin: 34px 0 14px; }

/* Hero */
.hero { text-align: center; padding: 34px 0 8px; }
.pill {
  display: inline-block; padding: 5px 13px; border-radius: 999px; font-size: 12px;
  font-weight: 600; color: var(--primary); background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}
.hero h1 { font-size: clamp(28px, 5vw, 42px); font-weight: 800; letter-spacing: -.02em; margin: 18px 0 12px; }
.grad {
  background: linear-gradient(120deg, var(--primary), var(--primary-2), #ec4899);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__sub { color: var(--text-2); font-size: 16px; max-width: 560px; margin: 0 auto; }
.hero__cta { display: flex; gap: 12px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 34px; }
.stat { text-align: center; }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat__label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Feature cards */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.feature__icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-size: 20px; background: var(--primary-soft); margin-bottom: 12px;
}
.feature h3 { font-size: 15px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* Recent sign-up list */
.user-list { display: flex; flex-direction: column; }
.user-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row__name { font-weight: 600; font-size: 14px; }
.user-row__time { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ============================================================
   Forms
   ============================================================ */
.auth { display: flex; justify-content: center; padding-top: 18px; }
.auth__card { width: 100%; max-width: 420px; }
.auth__hint { margin: 16px 0 0; text-align: center; }

.segmented {
  display: flex; gap: 4px; padding: 4px; background: var(--surface-2);
  border-radius: 12px; margin-bottom: 22px;
}
.segmented__item {
  flex: 1; padding: 9px; border: none; background: transparent; cursor: pointer;
  border-radius: 9px; font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--text-2); transition: all .18s ease;
}
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%; padding: 11px 13px; font-family: inherit; font-size: 14px;
  color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: all .18s ease; resize: vertical;
}
.input::placeholder { color: var(--muted); }
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--surface);
}
.form__actions { display: flex; gap: 10px; margin-top: 2px; }

.alert {
  margin: 0; padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px;
  border: 1px solid transparent;
}
.alert.is-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.alert.is-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent);
  border-color: color-mix(in srgb, var(--ok) 28%, transparent); }

/* ============================================================
   Profile
   ============================================================ */
.profile { display: flex; flex-direction: column; gap: 18px; }
.profile__head { display: flex; align-items: center; gap: 18px; }
.profile__meta { min-width: 0; }
.profile__meta h1 { font-size: 22px; font-weight: 800; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.profile__meta p { margin: 2px 0 0; }
.profile__head .btn { margin-left: auto; }
.profile__grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }

.kv { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; }
.kv li { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 13.5px; }
.kv li:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

.token {
  margin-top: 10px; padding: 11px 13px; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--text-2);
  word-break: break-all; line-height: 1.5; max-height: 76px; overflow: auto;
}

/* ============================================================
   Modal and toast
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(8, 11, 18, .5); backdrop-filter: blur(3px); }
.modal__panel { position: relative; width: 100%; max-width: 380px; animation: pop .22s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal__close {
  position: absolute; top: 12px; right: 14px; border: none; background: transparent;
  font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer;
}
.modal__panel .form__actions { margin-top: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 200;
  animation: pop .2s ease;
}

.footer { border-top: 1px solid var(--border); padding: 20px 0; }

/* ============================================================
   Video generation
   ============================================================ */
.video-gate { display: flex; justify-content: center; padding-top: 18px; }
.video-gate .auth__card { text-align: center; }
.video-gate .feature__icon { margin: 0 auto 12px; }

.video-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }

.upload-box {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 26px 16px; cursor: pointer; text-align: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--bg-soft); transition: all .18s ease;
}
.upload-box:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-box.has-file { border-style: solid; border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 8%, transparent); }
.upload-box__icon { font-size: 26px; }
.upload-box__text { font-size: 14px; font-weight: 600; word-break: break-all; }
.upload-box__hint { font-size: 12px; }

.status-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.status-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.status-badge.is-pending { color: var(--text-2); background: var(--surface-2); }
.status-badge.is-pending::before { background: var(--muted); }
.status-badge.is-running { color: var(--primary); background: var(--primary-soft); }
.status-badge.is-running::before { background: var(--primary); animation: blink 1s infinite; }
.status-badge.is-completed { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.status-badge.is-completed::before { background: var(--ok); }
.status-badge.is-failed { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.status-badge.is-failed::before { background: var(--danger); }
@keyframes blink { 50% { opacity: .25; } }

.demo-badge {
  display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: #b45309;
  background: color-mix(in srgb, #f59e0b 16%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 40%, transparent);
}

.video-player { margin-top: 14px; }
.video-player video { width: 100%; border-radius: var(--radius-sm); background: #000;
  max-height: 320px; display: block; }
.video-player__caption { margin-top: 8px; font-size: 12.5px; color: var(--text-2);
  word-break: break-all; }

.task-list { display: flex; flex-direction: column; }
.task-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s ease;
}
.task-row:hover { background: var(--surface-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 9px; }
.task-row:last-child { border-bottom: none; }
.task-row__main { min-width: 0; flex: 1; }
.task-row__title { font-size: 14px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.task-row__sub { font-size: 12.5px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.task-row__side { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.task-row__time { font-size: 12px; color: var(--muted); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  .topbar__inner { height: auto; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; text-align: center; }
  .stats { grid-template-columns: 1fr; }
  .profile__grid { grid-template-columns: 1fr; }
  .video-grid { grid-template-columns: 1fr; }
  .brand__name { display: none; }
  .user-chip__name { max-width: 60px; }
}
