:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --panel-border: #262b36;
  --text: #e8eaf0;
  --text-dim: #9aa1b2;
  --accent: #e6483c;
  --accent-dim: #7a2b25;
  --ok: #3ecf8e;
  --warn: #e6b34c;
  --err: #ef5350;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100%;
}

body {
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

header img { width: 32px; height: 32px; border-radius: 8px; }
header h1 { font-size: 18px; margin: 0; font-weight: 600; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

[hidden] { display: none !important; }

/* --- manual input state --- */
#input-state label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.row { display: flex; gap: 8px; }

input[type="text"], input[type="url"], input[type="password"] {
  flex: 1;
  background: #0c0e12;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  min-width: 0;
}

input[type="text"]:focus, input[type="url"]:focus, input[type="password"]:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

button {
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  color: white;
  background: var(--accent);
  transition: opacity 0.15s ease;
}

button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
}

.hint { color: var(--text-dim); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.hint.error-text { color: var(--err); }

/* --- preview state --- */
.preview {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.preview .thumb {
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  background: #0c0e12;
  flex-shrink: 0;
}

.preview .meta { min-width: 0; flex: 1; }
.preview .meta .title {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 6px;
  overflow-wrap: break-word;
}
.preview .meta .channel { color: var(--text-dim); font-size: 13px; margin: 0; }

.save-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  font-size: 16px;
}

/* --- progress state --- */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #0c0e12;
  border: 1px solid var(--panel-border);
  font-size: 14px;
  margin-bottom: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.status-banner.active .status-dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.status-banner.done .status-dot { background: var(--ok); animation: none; }
.status-banner.error .status-dot { background: var(--err); animation: none; }
.status-banner.skipped .status-dot { background: var(--warn); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.terminal {
  background: #0a0b0e;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #c7ccd8;
  height: 46vh;
  min-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal .line.cmd { color: var(--ok); }
.terminal .line.warn { color: var(--warn); }
.terminal .line.err { color: var(--err); }

.progress-actions { margin-top: 14px; }

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 28px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 400;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover { color: var(--text); opacity: 1; }
