:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-border: #262b36;
  --text: #e8eaed;
  --text-dim: #9aa2b1;
  --accent: #5b8cff;
  --accent-hover: #4472e8;
  --good: #3ecf8e;
  --warn: #e8b339;
  --bad: #e8546a;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
}

.hero-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin-bottom: 12px;
  box-shadow: 0 0 0 1px var(--panel-border);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.banner {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.5;
}

.banner-warn {
  background: rgba(232, 179, 57, 0.12);
  border: 1px solid rgba(232, 179, 57, 0.35);
  color: #f0cb6e;
}

.hidden { display: none !important; }

.steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.step-head h2 {
  margin: 0;
  font-size: 17px;
  flex: 1;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-help {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}

.step-help code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.chapter-select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.chapter-select:hover,
.chapter-select:focus {
  border-color: var(--accent);
  outline: none;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  font-size: 12.5px;
}

.btn-ghost:hover {
  color: var(--text);
}

.status {
  margin-left: 12px;
  font-size: 13.5px;
  color: var(--text-dim);
}

.status.good { color: var(--good); }
.status.bad { color: var(--bad); }

.advanced {
  margin-top: 14px;
  font-size: 13px;
}

.advanced summary {
  cursor: pointer;
  color: var(--text-dim);
  user-select: none;
}

.advanced-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

.advanced-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.advanced-body select,
.advanced-body input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
}

.checkbox-row:has(input:disabled) {
  opacity: 0.5;
}

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

.progress-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-label {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.log {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.footer {
  text-align: center;
  margin-top: 32px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.footer a {
  color: var(--text-dim);
}

.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  max-width: 460px;
  width: calc(100% - 40px);
  padding: 24px;
  font-size: 14px;
  line-height: 1.5;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.modal p {
  margin: 0 0 14px;
  color: var(--text-dim);
}

.modal ol {
  margin: 0;
  padding-left: 1.3em;
}

.modal li + li,
.modal li > ul {
  margin-top: 8px;
}

.modal ul {
  margin: 0;
  padding-left: 1.3em;
}

.modal code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.modal code.block {
  display: block;
  margin: 6px 0;
  padding: 6px 8px;
  overflow-x: auto;
}

.modal a {
  color: var(--accent);
}

.modal-error-detail {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.modal-error-detail code {
  word-break: break-word;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
