:root {
  --bg: #0d0f13;
  --panel: #161920;
  --panel-2: #1d212a;
  --line: #2a2f3b;
  --text: #e9ebf1;
  --muted: #98a1b3;
  --accent: #7c9bff;
  --accent-ink: #0a0f22;
  --ok: #4cc38a;
  --err: #ff7a7a;
  --warn: #f0b955;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 16px; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.error { color: var(--err); font-size: 14px; }

button, input, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 9px 14px;
}
button:hover { border-color: #3b4252; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.07); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--muted); }
button.link:hover { color: var(--text); }
button.danger:hover { border-color: var(--err); color: var(--err); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
}
input:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 120px; }
label { display: block; font-weight: 600; font-size: 14px; }
label input { margin-top: 6px; font-weight: 400; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

/* sign-in and password screens */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.auth .hint { display: block; margin-top: 4px; }
.row { display: flex; gap: 10px; }

/* app frame */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px;
  background: rgba(13, 15, 19, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; line-height: 20px; text-align: center;
}
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

/* create */
.create { max-width: 760px; margin: 0 auto; display: grid; gap: 14px; }
.create h2 { margin-bottom: 0; }
.under { display: flex; justify-content: space-between; gap: 12px; margin-top: -8px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.choice { position: relative; font-weight: 400; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.choice span.box {
  display: block;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 9px;
  padding: 8px 16px;
}
.cards .choice span.box { padding: 12px 14px; }
.choice input:checked + span.box { border-color: var(--accent); background: rgba(124, 155, 255, 0.1); }
.choice input:focus-visible + span.box { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .title { display: block; font-weight: 600; }
.choice .detail, .choice .time { display: block; color: var(--muted); font-size: 13px; }
.seed input { display: block; max-width: 220px; }
.seed .hint { margin-left: 6px; }
.estimate { color: var(--muted); font-size: 14px; }
.create button.primary { justify-self: start; padding: 11px 22px; }

/* library */
.library-head { display: flex; align-items: baseline; gap: 14px; }
.empty { color: var(--muted); padding: 48px 0; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.media { aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; }
.media video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.placeholder { width: 100%; padding: 0 22px; display: grid; gap: 8px; text-align: center; }
.placeholder .state { font-weight: 600; }
.placeholder .sub { color: var(--muted); font-size: 13px; min-height: 20px; }
.card[data-status="failed"] .state { color: var(--err); }
.card[data-status="cancelled"] .state { color: var(--muted); }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--line); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.card-body { padding: 14px 16px 16px; display: grid; gap: 8px; flex: 1; }
.prompt {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3;
  overflow: hidden; cursor: pointer; overflow-wrap: anywhere;
}
.prompt.open { display: block; }
.meta { color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; align-self: end; }
.actions button, .actions a {
  font-size: 13px; padding: 6px 11px; border-radius: 8px; text-decoration: none; color: inherit;
  border: 1px solid var(--line); background: var(--panel-2);
}
.actions a:hover { border-color: #3b4252; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); z-index: 10;
}

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 8px 14px; padding: 10px 16px; }
  .account { width: 100%; margin-left: 0; justify-content: space-between; }
  .page { padding: 18px 14px 48px; }
  .panel { padding: 18px; }
  .grid { grid-template-columns: 1fr; }
}
