/* shadcn/ui-like look: zinc neutrals, bordered cards, small radius, system sans font. */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --destructive: #dc2626;
  --destructive-foreground: #fafafa;
  --ring: #a1a1aa;
  --brand: #d97757;
  --ok-bg: #dcfce7;  --ok-fg: #166534;
  --bad-bg: #fee2e2; --bad-fg: #991b1b;
  --run-bg: #fef3c7; --run-fg: #92400e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #0c0c0e;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --border: #27272a;
    --input: #3f3f46;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --destructive: #b91c1c;
    --ring: #52525b;
    --ok-bg: rgba(34, 197, 94, 0.15);  --ok-fg: #4ade80;
    --bad-bg: rgba(239, 68, 68, 0.15); --bad-fg: #f87171;
    --run-bg: rgba(245, 158, 11, 0.15); --run-fg: #fbbf24;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
main { width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted-foreground); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.error { color: var(--bad-fg); font-size: 13px; min-height: 1em; }
.center { align-self: center; }
.center-text { text-align: center; }

header { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px; }
header h1::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--brand);
  vertical-align: 1px;
}

.alert {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 13px;
  text-align: center;
}

/* card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-header { padding: 18px 18px 0; display: flex; flex-direction: column; gap: 4px; }
.card-header.row-between { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-header .muted { margin-top: 2px; }
.card-content { padding: 14px 18px 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 13px; font-weight: 500; margin-top: 4px; }
.form .btn { margin-top: 10px; }

dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
dt { color: var(--muted-foreground); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge.run { background: var(--run-bg); color: var(--run-fg); }
.badge.run::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 120ms ease, opacity 120ms ease;
}
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--primary); color: var(--primary-foreground); }
.btn.primary:hover { opacity: 0.9; }
.btn.destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn.destructive:hover { opacity: 0.9; }
.btn.outline { border-color: var(--input); background: var(--background); box-shadow: var(--shadow); }
.btn.outline:hover, .btn.ghost:hover { background: var(--muted); }
.btn.ghost { color: var(--muted-foreground); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming in on focus */
  box-shadow: var(--shadow);
}

/* switch */
.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--input);
  cursor: pointer;
  transition: background-color 150ms ease;
  touch-action: manipulation;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 150ms ease;
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }
/* a bigger invisible touch target around the small switch */
.switch::before { content: ""; position: absolute; inset: -12px; }

.btn:focus-visible, .switch:focus-visible, input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.confirm { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm .actions .btn { flex: 1; }

/* dialog (shadcn AlertDialog) */
dialog {
  width: min(calc(100vw - 32px), 400px);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { display: flex; flex-direction: column; gap: 8px; }
dialog h2 { font-size: 17px; }
dialog .actions { margin-top: 14px; }
@media (max-width: 480px) {
  dialog .actions { flex-direction: column-reverse; }
}

@media (prefers-reduced-motion: reduce) {
  .switch, .switch::after, .btn { transition: none; }
  .badge.run::before { animation: none; }
}
