/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0a0f1e;
  --bg-2:      #0d1424;
  --surface:   #111827;
  --surface-2: #1a2236;
  --border:    #1e2d4a;
  --border-2:  #253556;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.2);
  --text:      #e8edf8;
  --text-2:    #a8b5cc;
  --muted:     #6b7a99;
  --error:     #ef4444;
  --error-bg:  rgba(239, 68, 68, 0.1);
  --success:   #22c55e;
  --warning:   #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);

  --radius-card:   14px;
  --radius-btn:    9px;
  --radius-input:  9px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px var(--border);
  --shadow-btn:  0 1px 3px rgba(0,0,0,0.3);

  --font: -apple-system, "SF Pro Display", "SF Pro Text", BlinkMacSystemFont,
          "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Code", monospace;

  --transition: 0.18s ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Login page layout ─────────────────────────────────────────────────────── */
body.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59,130,246,0.12) 0%, transparent 70%),
    var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 28px;
}

/* ── App header ────────────────────────────────────────────────────────────── */
.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.logout-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 0;
  transition: color var(--transition);
}
.logout-link:hover { color: var(--text-2); }
.logout-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 32px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.card-desc {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 18px;
}

/* ── TikTok login status ──────────────────────────────────────────────────── */
.tiktok-auth-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 24px;
  padding: 10px 12px;
}

.tiktok-auth-dot {
  background: var(--muted);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(107, 122, 153, 0.15);
  flex: 0 0 auto;
  height: 8px;
  margin-top: 4px;
  width: 8px;
}

.tiktok-auth-status.is-valid {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.tiktok-auth-status.is-valid .tiktok-auth-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.tiktok-auth-status.is-invalid,
.tiktok-auth-status.is-not-configured {
  background: var(--error-bg);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.tiktok-auth-status.is-invalid .tiktok-auth-dot,
.tiktok-auth-status.is-not-configured .tiktok-auth-dot {
  background: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.tiktok-auth-status.is-unknown {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}

.tiktok-auth-status.is-unknown .tiktok-auth-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* ── Form fields ───────────────────────────────────────────────────────────── */
.field {
  text-align: left;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

input[type="password"],
input[type="url"] {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

input[type="password"]::placeholder,
input[type="url"]::placeholder {
  color: var(--muted);
}

input[type="password"]:focus,
input[type="url"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input:focus-visible {
  outline: none;
}

/* ── Input group (URL + button inline) ────────────────────────────────────── */
.input-group {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.input-group input[type="url"] {
  flex: 1;
  min-width: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 18px;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  -webkit-appearance: none;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-h);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-btn);
}

.btn-primary:disabled {
  background: var(--muted);
}

.btn-full { width: 100%; margin-top: 4px; }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner-wrap {
  display: none;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 24px;
}

.spinner-wrap.visible {
  display: flex;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Result box ────────────────────────────────────────────────────────────── */
.result-box {
  margin-top: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.result-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-badge {
  background: var(--accent-glow);
  border: 1px solid rgba(59,130,246,0.3);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 1px 6px;
}

#transcript-text {
  width: 100%;
  min-height: 200px;
  max-height: 500px;
  resize: vertical;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.7;
  outline: none;
  padding: 16px;
}

.copy-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

.copy-btn.copied {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.3);
  color: var(--success);
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 20px;
  padding: 10px 14px;
  text-align: left;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}

p.error {
  color: #fca5a5;
  background: var(--error-bg);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 8px;
  font-size: 0.875rem;
  margin-top: 20px;
  padding: 12px 16px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 32px 20px 64px; }
  .card { padding: 28px 24px; }
}

@media (max-width: 520px) {
  .card { padding: 24px 20px; }
  .login-card { padding: 32px 24px; }
  .input-group { flex-direction: column; }
  .input-group .btn { width: 100%; }
  .header-inner { padding: 12px 16px; }
  .main-content { padding: 24px 16px 60px; }
  .copy-btn { padding: 8px 16px; }
  #transcript-text { min-height: 140px; }
}
