:root {
  --bg: #f1f5f6;
  --bar: #202a58;
  --surface: #ffffff;
  --surface-soft: #f6f9fa;
  --border: #d7e2e4;
  --border-strong: #9bb6ba;
  --text: #202950;
  --muted: #5c7078;
  --faint: #7a8e95;
  --primary: #007f7c;
  --primary-hover: #006c69;
  --success: #78c83b;
  --success-text: #477d1d;
  --danger: #d94f5f;
  --warning: #d99a2b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
::selection { color: #202a58; background: #b8fa77; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.topbar { min-height: 72px; border-bottom: 1px solid #168a89; background: linear-gradient(115deg, #202a58 0%, #174964 62%, #0a8d89 135%); }
.topbar-inner { width: min(1080px, calc(100% - 40px)); min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-size: 14px; font-weight: 700; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; background: #b8fa77; color: #202a58; font-size: 18px; box-shadow: 0 8px 24px rgb(4 64 76 / 24%); }
.service-state { min-height: 32px; display: inline-flex; align-items: center; gap: 8px; color: #d8eeee; font-size: 13px; }
.service-state span { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.service-state[data-state="online"] span { background: var(--success); }
.service-state[data-state="offline"] span { background: var(--danger); }
.service-state strong { font-weight: 500; }

.shell { width: min(1080px, calc(100% - 40px)); margin: 40px auto 0; }
.text-input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #f8fbfb; color: var(--text); font-size: 14px; letter-spacing: 0; }
.text-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(0 167 162 / 14%); }
.server-mode .method-switch { grid-template-columns: repeat(3, 1fr); }
.input-panel, .run-panel { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 32px rgb(25 56 67 / 7%); }
.input-panel { padding: 22px; }
.section-heading, .run-heading, .form-actions, .label-row, .phase-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eyebrow, .run-state p, .success-result p { margin: 0 0 3px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 17px; line-height: 1.25; }
h2 { margin: 0; font-size: 14px; }
.ready-badge { padding: 6px 9px; border: 1px solid #9cdc62; border-radius: 6px; color: #477e1d; background: #effbe5; font-size: 11px; font-weight: 700; }

form { margin-top: 22px; }
.method-switch { width: min(540px, 100%); height: 34px; margin: 0 0 18px; padding: 3px; display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--border); border-radius: 7px; background: #edf3f4; }
.method-switch label { min-width: 0; cursor: pointer; }
.method-switch input { position: absolute; opacity: 0; pointer-events: none; }
.method-switch span { height: 26px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); font-size: 11px; }
.method-switch input:checked + span { color: #fff; background: var(--primary); }
.method-switch input:focus-visible + span { outline: 2px solid rgb(0 167 162 / 48%); outline-offset: 1px; }
.field + .field { margin-top: 18px; }
.label-row { margin-bottom: 8px; }
label { font-size: 12px; font-weight: 700; color: var(--text); }
.label-row > span { color: var(--faint); font-size: 12px; }
textarea { width: 100%; min-height: 96px; display: block; resize: vertical; padding: 11px 12px; border: 1px solid var(--border); border-radius: 7px; outline: none; background: #f8fbfb; color: var(--text); font-size: 13px; line-height: 1.45; transition: border-color 160ms ease, box-shadow 160ms ease; }
textarea::placeholder { color: #8b9ba0; }
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(0 167 162 / 14%); }
.field small { display: block; min-height: 20px; margin-top: 7px; color: var(--faint); font-size: 12px; }

.concurrency-row { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.concurrency-row div { display: flex; flex-direction: column; gap: 2px; }
.concurrency-row small { color: var(--faint); font-size: 11px; }
.concurrency-row input { width: 72px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #f8fbfb; color: var(--text); text-align: center; }
.concurrency-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(0 167 162 / 14%); }

.form-message { margin-top: 20px; padding: 11px 13px; border: 1px solid rgb(217 79 95 / 35%); border-radius: 6px; color: #a82f3e; background: rgb(217 79 95 / 7%); font-size: 13px; }
.form-actions { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-actions p { margin: 0; color: var(--faint); font-size: 12px; }
.start-button, .open-button, .copy-button, .stop-button { min-height: 44px; border-radius: 7px; font-weight: 700; transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease; }
.start-button { min-width: 128px; padding: 0 20px; border: 1px solid var(--primary); display: inline-flex; align-items: center; justify-content: center; gap: 9px; color: #fff; background: var(--primary); box-shadow: 0 7px 18px rgb(0 129 126 / 16%); }
.start-button:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.start-button:disabled { cursor: not-allowed; opacity: .55; }
.button-icon { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid currentColor; }

.run-panel { margin-top: 20px; overflow: hidden; }
.stop-button { min-width: 72px; padding: 0 14px; border: 1px solid var(--border-strong); color: var(--text); background: transparent; }
.stop-button:hover { border-color: var(--danger); color: #a82f3e; }
.task-list { display: grid; }
.task-item { padding: 13px 18px 15px; border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: 0; }
.task-item.is-success { padding-top: 12px; padding-bottom: 12px; }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.task-head-main { min-width: 0; display: flex; align-items: center; gap: 7px; }
.task-head strong { font-size: 12px; }
.copy-email { min-height: 22px; padding: 0 7px; flex: 0 0 auto; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted); background: transparent; font-size: 10px; }
.copy-email:hover { border-color: var(--primary); color: var(--primary); background: #eef9f8; }
.task-success-badge { padding: 3px 7px; border: 1px solid #9cdc62; border-radius: 5px; color: var(--success-text); background: #effbe5; font-size: 10px; font-weight: 700; }
.progress-track { height: 5px; margin: 0; overflow: hidden; border-radius: 3px; background: #dbe7e8; }
.progress-track span { width: 0; height: 100%; display: block; border-radius: inherit; background: var(--primary); transition: width 240ms ease, background 180ms ease; }
.progress-track[data-state="done"] span { background: var(--success); }
.progress-track[data-state="error"] span { background: var(--danger); }
.task-detail { margin: 8px 0 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.task-detail.is-error { color: #a82f3e; }
.task-result { width: 100%; min-width: 0; display: flex; align-items: center; gap: 10px; }
.task-item.is-success .task-result { margin-top: 7px; }
.task-result a, .task-result > span { min-width: 0; flex: 1 1 0; overflow: hidden; color: var(--success-text); font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.task-result a:visited { color: var(--success-text); }
.task-check .is-available { color: var(--success-text); }
.task-check .is-unavailable { color: #a82f3e; }
.task-result button { min-height: 28px; padding: 0 9px; flex: 0 0 auto; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--text); background: transparent; font-size: 11px; }
.result-card { display: grid; grid-template-columns: minmax(0, 1fr) 176px; align-items: stretch; gap: 22px; }
.result-info { min-width: 0; }
.result-card-actions { display: flex; gap: 8px; margin-bottom: 15px; }
.result-card-actions .result-open, .result-card-actions button { min-height: 34px; padding: 0 13px; display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; border-radius: 6px; font-size: 11px; font-weight: 700; text-decoration: none; }
.result-card-actions .result-open { border: 1px solid var(--primary); color: #fff; background: var(--primary); }
.result-card-actions .result-open:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.result-card-actions button:hover { border-color: var(--primary); background: #eef9f8; }
.result-link-block { min-width: 0; }
.result-link-block > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.result-link-block > a, .result-link-block > span:last-child { min-height: 38px; padding: 9px 11px; display: block; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; color: var(--primary); background: var(--surface-soft); font-size: 12px; font-weight: 600; line-height: 18px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.result-link-block > a:visited { color: var(--primary); }
.result-meta { margin: 14px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 20px; }
.result-meta div { min-width: 0; }
.result-meta dt { color: var(--faint); font-size: 10px; }
.result-meta dd { margin: 2px 0 0; overflow: hidden; color: var(--text); font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.result-qr-wrap { width: 176px; min-height: 176px; margin: 0; padding: 8px; display: grid; place-items: center; align-self: center; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.result-qr { width: 158px; height: 158px; display: block; object-fit: contain; image-rendering: pixelated; }
.result-qr-state { color: var(--faint); font-size: 10px; text-align: center; }
.result-qr-state.is-error { color: #a82f3e; }
.run-footer { padding: 10px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.run-footer .stop-button { min-height: 32px; font-size: 11px; }
.batch-actions { padding: 10px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 6; background: var(--surface); box-shadow: 0 4px 12px rgb(25 56 67 / 6%); }
.batch-actions[hidden] { display: none; }
.batch-action-button { min-height: 34px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--text); background: transparent; font-size: 12px; font-weight: 700; transition: border-color 160ms ease, color 160ms ease, opacity 160ms ease; }
.batch-action-button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.batch-action-button:disabled { cursor: not-allowed; opacity: .55; }
.batch-actions-hint { margin-left: auto; color: var(--faint); font-size: 11px; }

.error-result, .success-result { margin: 0 24px 24px; border-radius: 7px; }
.error-result { padding: 16px; border: 1px solid rgb(217 79 95 / 35%); background: rgb(217 79 95 / 7%); }
.error-result strong { color: #a82f3e; }
.error-result p { margin: 5px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.success-result { padding: 20px; border: 1px solid rgb(120 200 59 / 38%); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; background: #f3fbe9; }
.success-result[hidden] { display: none; }
.success-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #20320f; background: #aef16f; font-weight: 900; }
.result-copy { min-width: 0; }
.result-copy > a { display: block; overflow: hidden; color: #007f7c; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.result-copy dl { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 12px 0 0; }
.result-copy dl div { display: flex; gap: 6px; font-size: 12px; }
.result-copy dt { color: var(--faint); }
.result-copy dd { margin: 0; color: var(--muted); }
.result-actions { display: flex; gap: 8px; }
.open-button, .copy-button { padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.open-button { border: 1px solid var(--primary); color: #fff; background: var(--primary); }
.open-button:hover { background: var(--primary-hover); }
.copy-button { border: 1px solid var(--border-strong); color: var(--text); background: transparent; }
.copy-button:hover { border-color: var(--primary); background: #eef9f8; }

.site-footer { width: min(1080px, calc(100% - 40px)); margin: 24px auto; color: #789097; font-size: 12px; text-align: center; }
button:focus-visible, a:focus-visible { outline: 3px solid rgb(0 167 162 / 42%); outline-offset: 2px; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .topbar-inner, .shell, .site-footer { width: min(100% - 24px, 1080px); }
  .shell { margin-top: 20px; }
  .input-panel { padding: 20px 16px; }
  .ready-badge { display: none; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .start-button { width: 100%; }
  .run-heading, .phase-line { padding-left: 16px; padding-right: 16px; }
  .phase-line { align-items: flex-start; flex-direction: column; gap: 3px; }
  .phase-line code { max-width: 100%; }
  .task-item { padding-left: 16px; padding-right: 16px; }
  .result-card { grid-template-columns: 1fr; }
  .result-qr-wrap { width: min(176px, 100%); justify-self: start; }
  .error-result, .success-result { margin-left: 16px; margin-right: 16px; }
  .success-result { grid-template-columns: auto 1fr; }
  .result-actions { grid-column: 1 / -1; }
  .open-button, .copy-button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
