:root {
  /* Light theme (default) */
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --text-dim: #57606a;
  --accent: #1a7f37;
  --on-accent: #ffffff;
  --success: #1a7f37;
  --error: #cf222e;
  --focus-ring: rgba(26, 127, 55, 0.3);
  --error-ring: rgba(207, 34, 46, 0.25);
  --flash: rgba(26, 127, 55, 0.16);
  --chip-active-bg: rgba(26, 127, 55, 0.1);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono",
    "Fira Code", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #9aa4b2;
  --accent: #3fb950;
  --on-accent: #0d1117;
  --success: #3fb950;
  --error: #ff7b72;
  --focus-ring: rgba(63, 185, 80, 0.25);
  --error-ring: rgba(255, 123, 114, 0.25);
  --flash: rgba(63, 185, 80, 0.18);
  --chip-active-bg: rgba(63, 185, 80, 0.08);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}
.wrap { max-width: 720px; margin-inline: auto; padding-inline: 24px; }
main.wrap { display: flex; flex-direction: column; gap: 64px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}
.dim { color: var(--text-dim); }

.skip-link {
  position: absolute; top: 0; left: 0; z-index: 10;
  transform: translateY(-200%);
  padding: 10px 16px; background: var(--accent); color: var(--on-accent);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  text-decoration: none; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { transform: translateY(0); }

header.wrap { padding-top: 40px; padding-bottom: 0; }
.wordmark {
  margin: 0; font-family: var(--mono); font-size: 18px; font-weight: 700;
  line-height: 1; display: flex; align-items: center; gap: 2px;
}
.wordmark .prompt { color: var(--text-dim); font-weight: 400; }
.wordmark .brand { color: var(--text); }
.wordmark .cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.tagline {
  margin: 12px 0 0; font-family: var(--mono); font-size: 13px;
  color: var(--text-dim); line-height: 1.4;
}
.header-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px;
  cursor: pointer; flex: 0 0 auto;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); }
.theme-icon { font-size: 13px; line-height: 1; }

.section-label {
  margin: 0 0 16px; font-family: var(--mono); font-size: 12px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); line-height: 1;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.field-label {
  display: block; margin: 0 0 8px; font-family: var(--mono);
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-dim); line-height: 1.2;
}

.input-row { display: flex; gap: 12px; align-items: stretch; }
.input-affix { position: relative; flex: 1 1 auto; min-width: 0; }
.input-affix::before {
  content: "$"; position: absolute; left: 16px; top: 50%;
  transform: translateY(-50%); color: var(--text-dim);
  font-family: var(--mono); font-size: 18px; pointer-events: none;
}
.cron-input {
  width: 100%; height: 52px; padding: 0 16px 0 40px; background: var(--bg);
  color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--mono);
  font-size: 18px; font-weight: 500; letter-spacing: 0.5px; line-height: 1.2;
}
.cron-input::placeholder { color: var(--text-dim); opacity: 1; }
.cron-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.cron-input[aria-invalid="true"] { border-color: var(--error); }
.cron-input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--error-ring);
}

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px; height: 52px;
  padding: 0 16px; background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; flex: 0 0 auto;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost .kbd-hint { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.btn-ghost.copied #copy-label { color: var(--success); }

.result {
  display: block; margin-top: 16px; min-height: 56px; padding-left: 12px;
  border-left: 3px solid var(--border);
}
.result .caret { margin-right: 8px; }
.result.is-ok {
  border-left-color: var(--accent); font-family: var(--sans);
  font-size: 20px; font-weight: 600; color: var(--text); line-height: 1.35;
}
.result.is-ok .caret { color: var(--accent); }
.result.is-empty {
  font-family: var(--sans); font-size: 15px; color: var(--text-dim); line-height: 1.4;
}
.result.is-error {
  border-left-color: var(--error); font-family: var(--mono);
  font-size: 15px; font-weight: 500; color: var(--error); line-height: 1.4;
}
.result.is-error .caret { color: var(--error); }
.result.flash { animation: flash 0.4s ease-out; }
@keyframes flash {
  0% { background: var(--flash); }
  100% { background: transparent; }
}

.hint {
  margin: 16px 0 0; font-family: var(--sans); font-size: 13px;
  color: var(--text-dim); line-height: 1.5;
}
.hint code,
.prose code,
.faq code,
.ref code {
  font-size: 12px; color: var(--text); background: var(--surface-2);
  padding: 1px 5px; border-radius: 4px;
}

.group-label {
  margin: 0 0 8px; font-family: var(--mono); font-size: 12px;
  color: var(--text-dim); letter-spacing: 0.5px;
}
.group-label + .chips { margin-bottom: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.chip:hover { border-color: var(--accent); border-left-color: var(--accent); background: var(--surface-2); }
.chip-name { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.3; }
.chip-cron { font-family: var(--mono); font-size: 12px; color: var(--text-dim); line-height: 1.3; }
.chip.is-active { border-left-color: var(--accent); background: var(--chip-active-bg); }

.segmented {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 24px; padding: 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.seg {
  flex: 1 1 auto; padding: 8px 12px; background: transparent; color: var(--text-dim);
  border: 0; border-radius: 4px; font-family: var(--sans); font-size: 14px;
  font-weight: 500; white-space: nowrap; cursor: pointer;
}
.seg:hover:not([aria-checked="true"]) { color: var(--text); background: var(--surface-2); }
.seg[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }

.wizard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.wfield { display: flex; flex-direction: column; }
.wfield[hidden] { display: none; }
.select {
  height: 44px; padding: 0 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 14px; cursor: pointer;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

.preview { display: flex; align-items: center; gap: 16px; margin-top: 24px; }
.preview-row {
  flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap;
  align-items: baseline; gap: 8px 12px; padding: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px;
}
.preview-cron { font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--text); }
.preview-desc { font-family: var(--sans); font-size: 13px; color: var(--text-dim); }
.btn-primary {
  flex: 0 0 auto; height: 44px; padding: 0 20px; background: var(--accent);
  color: var(--on-accent); border: 0; border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

footer.wrap { padding-top: 0; padding-bottom: 40px; }
footer p {
  margin: 0; text-align: center; font-family: var(--mono); font-size: 12px;
  color: var(--text-dim); line-height: 1.4;
}

.prose {
  margin: 0 0 20px; font-size: 15px; color: var(--text-dim); line-height: 1.7;
}
.prose:last-child { margin-bottom: 0; }
.table-scroll { overflow-x: auto; }
.table-scroll + .table-scroll { margin-top: 24px; }
.ref { width: 100%; border-collapse: collapse; font-size: 14px; }
.ref th, .ref td {
  padding: 10px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.ref th {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim);
  white-space: nowrap;
}
.ref td:first-child {
  font-family: var(--mono); color: var(--text); white-space: nowrap;
}
.ref tbody tr:last-child td { border-bottom: 0; }

.faq { display: flex; flex-direction: column; gap: 24px; }
.faq h3 {
  margin: 0 0 8px; font-family: var(--sans); font-size: 16px;
  font-weight: 600; color: var(--text); line-height: 1.4;
}
.faq p { margin: 0; font-size: 15px; color: var(--text-dim); line-height: 1.7; }

@media (max-width: 719px) {
  .wrap { padding-inline: 16px; }
  main.wrap { gap: 40px; }
  header.wrap { padding-top: 24px; }
  .card { padding: 16px; }
  .input-row { flex-wrap: wrap; }
  .btn-ghost { width: 100%; justify-content: center; }
  .btn-ghost .kbd-hint { display: none; }
  .wizard-grid { grid-template-columns: 1fr; }
  .preview { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; }
}
@media (pointer: coarse) {
  .chip, .seg { min-height: 44px; }
  .theme-toggle { min-height: 44px; }
  /* Under 16px iOS Safari zooms the page when a control takes focus. */
  .select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .wordmark .cursor { animation: none; }
  .result.flash { animation: none; }
  * { transition: none !important; }
}
