:root {
  --bg: #0f1419;
  --bg-elev: #171e26;
  --bg-soft: #1d2630;
  --border: #2a3542;
  --text: #e8eef5;
  --muted: #9aabbc;
  --accent: #5eb1ff;
  --accent-strong: #3b9aef;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --danger: #f07178;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(94, 177, 255, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(62, 207, 142, 0.1), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.page {
  width: min(860px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.25rem 0 3.5rem;
}

.header h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.lead {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.notice {
  margin: 1.25rem 0 1.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.08);
  border-radius: 12px;
  color: #f5df9a;
  font-size: 0.92rem;
}

.notice code,
.hint code,
.footer code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.05em 0.35em;
  border-radius: 4px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.field-label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

textarea,
input[type="text"],
input[type="number"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 12rem;
}

textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 177, 255, 0.2);
}

.options .field {
  margin-bottom: 1rem;
}

.options .field:last-of-type {
  margin-bottom: 0.35rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
}

.check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent-strong);
}

.inline-ms {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-ms input {
  width: 6.5rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.25rem 0 1rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  border-color: #3d4d60;
  background: #243040;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #4aa4f0, var(--accent-strong));
  border-color: transparent;
  color: #061018;
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #62b3f7, #4aa4f0);
}

.btn.danger {
  background: rgba(240, 113, 120, 0.12);
  border-color: rgba(240, 113, 120, 0.45);
  color: #ffc0c4;
}

.btn.ghost {
  background: transparent;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.65rem;
  font-weight: 600;
}

.state {
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.state.idle { color: var(--muted); }
.state.running {
  color: #9fd0ff;
  border-color: rgba(94, 177, 255, 0.45);
  background: rgba(94, 177, 255, 0.1);
}
.state.done {
  color: #9aefc4;
  border-color: rgba(62, 207, 142, 0.45);
  background: rgba(62, 207, 142, 0.1);
}
.state.stopped {
  color: #ffd28a;
  border-color: rgba(240, 180, 41, 0.45);
  background: rgba(240, 180, 41, 0.1);
}
.state.error {
  color: #ffb4b8;
  border-color: rgba(240, 113, 120, 0.45);
  background: rgba(240, 113, 120, 0.1);
}

.bar-track {
  height: 0.55rem;
  border-radius: 999px;
  background: #10161d;
  border: 1px solid var(--border);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b9aef, #3ecf8e);
  transition: width 0.2s ease;
}

.current-url {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}

.log-card h2 {
  margin-top: 0;
}

.log {
  margin: 0;
  max-height: 22rem;
  overflow: auto;
  padding: 0.75rem 0.85rem;
  background: #10161d;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c9d6e4;
}

.log .ok { color: var(--ok); }
.log .err { color: var(--danger); }
.log .info { color: var(--accent); }
.log .warn { color: var(--warn); }

.footer {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 1.25rem, 860px);
    padding-top: 1.5rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
