:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222c38;
  --line: #2c3744;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4aa3ff;
  --accent-2: #2bd4a7;
  --warn: #ffb84d;
  --err: #ff6b6b;
  --feratel-blue: #0a6ab8;
  --feratel-blue-dk: #074f8c;
  --feratel-yellow: #ffd21e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #16202c, var(--bg));
  color: var(--text);
  min-height: 100vh;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 28px;
  background: linear-gradient(135deg, var(--feratel-blue), var(--feratel-blue-dk));
  border-bottom: 3px solid var(--feratel-yellow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; }
h1 { margin: 0; font-size: 20px; letter-spacing: .3px; color: #fff; }
.sub { margin: 2px 0 0; color: rgba(255, 255, 255, .8); font-size: 13px; }

.powered { display: flex; align-items: center; gap: 14px; }
.feratel-chip {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 10px; padding: 8px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}
.feratel-chip img { height: 40px; display: block; }
.powered-by { color: rgba(255, 255, 255, .9); font-size: 13px; line-height: 1.3; }
.powered-by strong { display: block; color: var(--feratel-yellow); font-size: 15px; font-weight: 700; }
.logout-btn {
  width: auto; margin: 0; padding: 8px 14px; font-size: 13px; font-weight: 600;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .35);
  color: #fff; border-radius: 9px;
}
.logout-btn:hover { background: rgba(255, 255, 255, .22); }
main {
  display: grid; gap: 20px; padding: 24px 28px; max-width: 1200px; margin: 0 auto;
  grid-template-columns: 320px 1fr;
}
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 14px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); }
.controls { grid-row: span 2; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input, select {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-size: 14px;
}
button {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #2f7fe0);
  color: white; font-size: 15px; font-weight: 600; margin-top: 4px;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.voice-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.voice-row select { margin-top: 0; flex: 1; }
.voice-play {
  width: 42px; flex: 0 0 42px; height: 42px; margin-top: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); color: var(--accent);
}
.voice-play:not(:disabled):hover { border-color: var(--accent); }
.voice-hint { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.avatar-preview { margin: -8px 0 14px; }
.avatar-preview img {
  display: block; width: 100%; max-height: 240px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.avatar-preview-msg { font-size: 12px; color: var(--muted); }
button.secondary {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-size: 13px; font-weight: 500; padding: 9px;
}
button.secondary:hover { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; min-height: 16px; }
.hint.err { color: var(--err); }
.field-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }

.subhead {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); font-weight: 600; margin: 4px 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.subhead:not(:first-of-type) { margin-top: 20px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cam-preview {
  margin: 12px 0 4px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); overflow: hidden; min-height: 120px;
  display: grid; place-items: center;
}
.cam-preview img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.cam-placeholder { color: var(--muted); font-size: 12px; padding: 24px 16px; text-align: center; margin: 0; }

.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
.steps li {
  counter-increment: s; position: relative; padding: 10px 10px 10px 40px;
  border-radius: 8px; color: var(--muted); font-size: 14px; margin-bottom: 4px;
}
.steps li::before {
  content: counter(s); position: absolute; left: 8px; top: 50%;
  transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px;
}
.steps li.active { color: var(--text); background: var(--panel-2); }
.steps li.active::before { border-color: var(--accent); color: var(--accent); }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "✓"; background: #11271f; border-color: #1f5a4a; color: var(--accent-2); }
.steps li.error::before { content: "!"; background: #271414; border-color: #5a2424; color: var(--err); }
.log { font-size: 12px; color: var(--muted); margin-top: 12px; min-height: 18px;
  font-family: ui-monospace, monospace; }

.result-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
.result-media { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
#finalVideo { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px;
  border: 1px solid var(--line); }
.download { text-align: center; font-size: 13px; color: var(--accent);
  text-decoration: none; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.result-meta h3 { margin: 0 0 6px; font-size: 18px; }
.result-meta h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); }
.visual { color: var(--muted); font-size: 13px; font-style: italic; }

.archive { grid-column: 1 / -1; }
.archive-label { margin-bottom: 12px; }
.archive-empty { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.archive-media {
  display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin-top: 14px;
}
#archiveVideo { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px;
  border: 1px solid var(--line); }

/* ---- Login / Landingpage ---- */
.login-body {
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(10, 106, 184, .35), transparent),
    radial-gradient(1200px 600px at 70% 110%, #16202c, var(--bg));
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
  background: linear-gradient(135deg, var(--feratel-blue), var(--feratel-blue-dk));
  border: 1px solid var(--line); border-top: 4px solid var(--feratel-yellow);
  border-radius: 18px; padding: 36px 30px 30px; text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.login-chip { padding: 14px 22px; }
.login-chip img { height: 54px; }
.login-title { margin: 22px 0 2px; color: #fff; font-size: 24px; }
.login-powered { margin: 0 0 26px; color: rgba(255, 255, 255, .9); font-size: 14px; }
.login-powered strong { color: var(--feratel-yellow); font-weight: 700; }
.login-form { text-align: left; }
.login-label { color: rgba(255, 255, 255, .92); font-size: 13px; }
.login-form input {
  background: rgba(255, 255, 255, .96); color: #10202e; border: 0;
}
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 44px; box-sizing: border-box; }
.login-form .pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 32px; height: 32px; margin: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px;
  color: #44627a; cursor: pointer;
}
.login-form .pw-toggle:hover { color: #10202e; background: rgba(16, 32, 46, .08); filter: none; }
.login-form .pw-toggle:focus-visible { outline: 2px solid var(--feratel-yellow); outline-offset: 1px; }
.login-form button {
  background: var(--feratel-yellow); color: #1a1200; font-weight: 700; margin-top: 14px;
}
.login-form button:hover { filter: brightness(1.05); }
.login-form .hint { color: rgba(255, 255, 255, .85); text-align: center; }
.login-form .hint.err { color: #ffd9d9; }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .result-media { max-width: 280px; }
}
