/* ── Light theme (default) ── */
:root {
  --bg: #fafafa;
  --bg-secondary: #f0f0f0;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: #e0e0e0;
  --border-strong: #FF6B00;
  --text: #111111;
  --text-muted: #666666;
  --accent: #FF6B00;
  --accent-hover: #e05e00;
  --header-bg: #111111;
  --header-text: #ffffff;
  --spinner-track: #e0e0e0;
  --btn-outline-hover: #fff3ec;
  --success-check-bg: #FF6B00;
  --success-check-color: #ffffff;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-secondary: #0d0d0d;
  --bg-card: #1a1a1a;
  --bg-input: #222222;
  --border: #2a2a2a;
  --border-strong: #FF6B00;
  --text: #f0f0f0;
  --text-muted: #888888;
  --accent: #FF6B00;
  --accent-hover: #ff8c33;
  --header-bg: #000000;
  --header-text: #ffffff;
  --spinner-track: #2a2a2a;
  --btn-outline-hover: #1f1105;
  --success-check-bg: #FF6B00;
  --success-check-color: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid #FF6B00;
}

header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #FF6B00;
}

.header-right { display: flex; align-items: center; gap: 12px; }

/* ── Lang toggle ── */
.lang-toggle {
  display: flex;
  border: 1px solid #FF6B00;
  border-radius: 4px;
  overflow: hidden;
}

.lang-toggle button {
  background: transparent;
  border: none;
  color: #aaa;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  transition: all 0.15s;
}

.lang-toggle button.active {
  background: #FF6B00;
  color: #ffffff;
}

.lang-toggle button:hover:not(.active) { color: #FF6B00; }

/* ── Theme toggle ── */
.theme-btn {
  background: transparent;
  border: 1px solid #FF6B00;
  border-radius: 4px;
  color: #aaa;
  width: 34px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.theme-btn:hover { border-color: #FF6B00; color: #FF6B00; }

.theme-icon-light,
.theme-icon-dark { line-height: 1; }

/* light mode: show sun, hide moon */
[data-theme="light"] .theme-icon-dark  { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

/* dark mode: show moon, hide sun */
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark  { display: inline; }

/* ── Layout ── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  transition: background 0.2s, border-color 0.2s;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #FF6B00;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Config grid ── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) { .config-grid { grid-template-columns: 1fr; } }

/* ── Controls grid ── */
.controls-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  align-items: end;
}

@media (max-width: 680px) { .controls-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .controls-grid { grid-template-columns: 1fr; } }

/* ── Fields ── */
.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}

.field input, .field select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-input);
  transition: border-color 0.15s, background 0.2s, color 0.2s;
  width: 100%;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: #FF6B00;
  box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.15);
}

.field input::placeholder { color: #aaa; }

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: 4px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: #FF6B00;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) { background: #e05e00; }

.btn-primary:disabled {
  background: #cccccc;
  color: #888;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-outline:hover { background: var(--btn-outline-hover); color: #FF6B00; }

.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ── Loading ── */
.loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px;
  color: var(--text-muted);
}

.loading.visible { display: flex; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--spinner-track);
  border-top-color: #FF6B00;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Success card ── */
.success-content {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.success-check {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FF6B00;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}

.success-text { flex: 1; min-width: 0; }

.success-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.success-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Progress bar ── */
.progress-track {
  width: 100%;
  max-width: 340px;
  height: 6px;
  background: var(--spinner-track);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #FF6B00;
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Error banner ── */
.error-banner {
  display: none;
  background: #1a0a00;
  color: #FF6B00;
  border: 1px solid #FF6B00;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
}

.error-banner.visible { display: block; }

/* ── Login screen ── */
#loginScreen {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
}

.login-card {
  display: flex;
  flex-direction: column;
  padding: 36px 32px;
}

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

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
  padding: 11px 20px;
  font-size: 14px;
}

/* ── User badge (header) ── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,107,0,0.12);
  border: 1px solid rgba(255,107,0,0.4);
  border-radius: 4px;
  padding: 4px 10px 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #FF6B00;
  max-width: 220px;
  overflow: hidden;
}

.user-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

#userNameLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: none;
  color: #FF6B00;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
  flex-shrink: 0;
}

.btn-logout:hover { opacity: 1; }

/* ── Session info bar ── */
.session-info {
  padding: 10px 16px;
  border-radius: 6px;
}

.session-info-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.session-url {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
