:root {
  --bg: #0f1419;
  --card: #1a2230;
  --text: #f2f4f8;
  --muted: #9aa6b2;
  --accent: #e8a04a;
  --accent2: #6ec8ff;
  --danger: #ff6b6b;
  --ok: #5dcea0;
  --border: #2a3545;
  --radius: 12px;
  font-family: "Noto Sans CJK TC", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #24304a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  background: rgba(15, 20, 25, 0.85);
  z-index: 10;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand .logo {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7a6e);
  display: grid; place-items: center; font-weight: 700; color: #1a1008;
}
.brand small { display: block; color: var(--muted); font-size: 0.75rem; }
.user-bar { display: flex; gap: 0.75rem; align-items: center; color: var(--muted); }
main { max-width: 920px; margin: 0 auto; padding: 1.5rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 420px; margin: 3rem auto; }
h1 { font-size: 1.35rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.75rem; }
.error { color: var(--danger); min-height: 1.2em; }
label { display: block; margin: 0.85rem 0; font-size: 0.9rem; }
input, textarea, select {
  display: block; width: 100%; margin-top: 0.35rem;
  background: #0d1218; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.65rem 0.75rem; font: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
button, .button {
  appearance: none; border: none; cursor: pointer;
  background: #2a3548; color: var(--text);
  padding: 0.6rem 1rem; border-radius: 8px; font: inherit;
  text-decoration: none; display: inline-block;
}
button.primary, .button.primary { background: linear-gradient(135deg, var(--accent), #d47a2e); color: #1a1008; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--border); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.row.gap { gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.hidden { display: none !important; }
.linkback {
  background: none; color: var(--accent2); padding: 0; margin-bottom: 0.75rem;
}
.job-list { display: grid; gap: 0.75rem; margin-top: 1rem; }
.job-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem;
  cursor: pointer; transition: border-color 0.15s;
}
.job-item:hover { border-color: var(--accent); }
.job-item h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.badge {
  font-size: 0.75rem; padding: 0.2rem 0.55rem; border-radius: 999px;
  background: #2a3545; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.queued { background: #3a3a20; color: #e8d44a; }
.badge.running { background: #1a3a4a; color: var(--accent2); }
.badge.done { background: #1a3a2e; color: var(--ok); }
.badge.failed { background: #3a1a1a; color: var(--danger); }
.preview-box { margin: 1rem 0; }
.preview-box video {
  width: min(360px, 100%);
  aspect-ratio: 9/16;
  background: #000;
  border-radius: 8px;
  display: block;
  margin-bottom: 0.75rem;
}
.lines {
  background: #0d1218; border-radius: 8px; padding: 0.75rem 1rem;
  white-space: pre-wrap; color: var(--muted); font-size: 0.85rem;
  border: 1px solid var(--border); overflow: auto;
}
footer {
  text-align: center; padding: 2rem 1rem 3rem; color: var(--muted);
}
.success { color: var(--ok); min-height: 1.2em; }
.materials-panel {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #121820;
}
.materials-panel legend {
  padding: 0 0.4rem;
  color: var(--accent);
  font-weight: 600;
}
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  margin: 0.5rem 0 0.75rem; font-size: 0.85rem;
}
.breadcrumb button {
  background: transparent; border: none; color: var(--accent2);
  padding: 0.15rem 0.35rem; cursor: pointer; font: inherit;
}
.breadcrumb span.sep { color: var(--muted); }
.materials-browser {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  max-height: 280px;
  overflow: auto;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1218;
}
.mat-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem;
  cursor: pointer;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  background: #151c28;
  transition: border-color 0.15s, background 0.15s;
  word-break: break-all;
}
.mat-item:hover { border-color: var(--accent2); }
.mat-item.selected { border-color: var(--accent); background: #2a2418; color: var(--text); }
.mat-item .icon { font-size: 1.6rem; display: block; margin-bottom: 0.25rem; }
.mat-item img.thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px;
  display: block; margin-bottom: 0.25rem; background: #000;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: #243044; border: 1px solid var(--border);
  border-radius: 999px; padding: 0.25rem 0.55rem; font-size: 0.78rem;
}
.chip button {
  background: none; border: none; color: var(--danger);
  padding: 0; cursor: pointer; font-size: 0.9rem; line-height: 1;
}
.selected-chips { margin-top: 0.75rem; }
