:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0 0);
  --surface-strong: oklch(0.945 0 0);
  --ink: oklch(0.16 0.008 220);
  --muted: oklch(0.46 0.012 220);
  --faint: oklch(0.62 0.008 220);
  --border: oklch(0.89 0.006 220);
  --border-strong: oklch(0.79 0.008 220);
  --button: oklch(0.16 0.008 220);
  --button-ink: oklch(1 0 0);
  --primary: oklch(0.65 0.1 200);
  --primary-soft: oklch(0.94 0.035 200);
  --success: oklch(0.49 0.12 158);
  --success-soft: oklch(0.95 0.035 158);
  --danger: oklch(0.55 0.19 25);
  --danger-soft: oklch(0.96 0.025 25);
  --warning: oklch(0.58 0.13 78);
  --focus: oklch(0.59 0.13 200);
  --skeleton: oklch(0.93 0 0);
  --radius-sm: 8px;
  --radius-md: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-sticky: 20;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.105 0 0);
  --surface: oklch(0.145 0 0);
  --surface-strong: oklch(0.19 0 0);
  --ink: oklch(0.96 0.004 220);
  --muted: oklch(0.72 0.008 220);
  --faint: oklch(0.56 0.008 220);
  --border: oklch(0.25 0.004 220);
  --border-strong: oklch(0.35 0.006 220);
  --button: oklch(0.96 0.004 220);
  --button-ink: oklch(0.12 0 0);
  --primary: oklch(0.72 0.105 200);
  --primary-soft: oklch(0.22 0.035 200);
  --success: oklch(0.72 0.13 158);
  --success-soft: oklch(0.2 0.035 158);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.21 0.04 25);
  --warning: oklch(0.75 0.13 78);
  --focus: oklch(0.72 0.105 200);
  --skeleton: oklch(0.21 0 0);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 64px;
  padding: 0 28px;
  background: color-mix(in oklch, var(--bg) 90%, transparent);
  border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
  backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 620; letter-spacing: -0.015em; text-decoration: none; }
.brand-mark { display: inline-flex; width: 25px; height: 25px; color: var(--button); }
.brand-mark svg { width: 100%; height: 100%; }
.brand-mark path { stroke: var(--button-ink); }
.brand-mark circle { fill: var(--button-ink); }

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}
.icon-button:hover { background: var(--surface-strong); }
.icon-button:active { transform: scale(0.96); }
.theme-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }

main { width: min(920px, calc(100% - 48px)); margin: 0 auto; padding: 74px 0 56px; }
.intro { margin-bottom: 32px; }
.intro h1 { margin: 0 0 8px; font-size: 34px; font-weight: 650; line-height: 1.18; letter-spacing: -0.035em; text-wrap: balance; }
.intro p { max-width: 65ch; margin: 0; color: var(--muted); font-size: 16px; text-wrap: pretty; }

.setup-panel { padding: 25px; background: var(--surface); border-radius: var(--radius-md); }
.section-heading, .results-header, .form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h2 { margin: 0; font-size: 16px; font-weight: 640; letter-spacing: -0.012em; }
.privacy-note { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.privacy-note svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }

form { margin-top: 22px; }
.protocol-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend, .field > span:first-child { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 560; }
.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-strong); border-radius: 10px; }
.segmented-control label { min-width: 0; cursor: pointer; }
.segmented-control input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented-control span { display: grid; min-height: 36px; padding: 6px 12px; place-items: center; color: var(--muted); border-radius: 7px; font-size: 13px; font-weight: 530; text-align: center; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.segmented-control input:checked + span { background: var(--bg); color: var(--ink); }
.segmented-control input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.form-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-top: 18px; }
.field { min-width: 0; }
input { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--bg); color: var(--ink); border: 1px solid var(--border-strong); border-radius: 10px; outline: none; transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease); }
input::placeholder { color: var(--muted); opacity: 1; }
input:hover { border-color: color-mix(in oklch, var(--border-strong) 70%, var(--ink)); }
input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 22%, transparent); }
input[aria-invalid="true"] { border-color: var(--danger); }
.input-with-action { position: relative; display: block; }
.input-with-action input { padding-right: 58px; }
.input-action { position: absolute; top: 5px; right: 5px; min-width: 48px; height: 34px; padding: 0 8px; background: transparent; color: var(--muted); border: 0; border-radius: 6px; font-size: 12px; cursor: pointer; }
.input-action:hover { background: var(--surface); color: var(--ink); }

.form-actions { margin-top: 20px; }
.form-actions p { margin: 0; color: var(--muted); font-size: 12px; }
code { padding: 2px 5px; background: var(--surface-strong); border-radius: 5px; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.93em; }
.primary-button, .secondary-button, .test-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 590; cursor: pointer; transition: opacity 160ms var(--ease), transform 160ms var(--ease), background-color 160ms var(--ease); }
.primary-button { min-width: 122px; background: var(--button); color: var(--button-ink); border: 0; }
.primary-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 160ms var(--ease); }
.primary-button:hover svg { transform: translateX(2px); }
.primary-button:active, .secondary-button:active, .test-button:active { transform: scale(0.98); }
button:disabled { opacity: 0.48; cursor: not-allowed; transform: none !important; }
.secondary-button, .test-button { background: transparent; border: 1px solid var(--border-strong); }
.secondary-button:hover, .test-button:hover { background: var(--surface); }
.test-button { min-height: 34px; padding: 6px 11px; font-size: 13px; }

.message { margin-top: 16px; padding: 11px 13px; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); font-size: 13px; }
.message.is-info { color: var(--ink); background: var(--primary-soft); }

.results-section { margin-top: 46px; }
.results-header { align-items: flex-end; }
.results-header h2 { font-size: 19px; }
.results-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.results-tools { display: flex; align-items: center; gap: 10px; }
.search-field { position: relative; display: block; width: 190px; }
.search-field svg { position: absolute; top: 50%; left: 11px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.5; transform: translateY(-50%); pointer-events: none; }
.search-field input { min-height: 40px; padding: 8px 10px 8px 34px; }

.empty-state { display: grid; min-height: 270px; margin-top: 18px; place-items: center; align-content: center; color: var(--muted); border-top: 1px solid var(--border); text-align: center; }
.empty-state p { margin: 15px 0 2px; color: var(--ink); font-weight: 590; }
.empty-state > span { font-size: 13px; }
.empty-glyph { display: flex; align-items: flex-end; gap: 5px; width: 42px; height: 34px; padding: 7px; border: 1px solid var(--border-strong); border-radius: 9px; }
.empty-glyph span { display: block; flex: 1; background: var(--faint); border-radius: 2px 2px 1px 1px; }
.empty-glyph span:nth-child(1) { height: 35%; }
.empty-glyph span:nth-child(2) { height: 75%; }
.empty-glyph span:nth-child(3) { height: 52%; }

.model-list { margin-top: 18px; border-top: 1px solid var(--border); }
.model-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 18px; align-items: center; min-height: 66px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.model-name { min-width: 0; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 530; text-overflow: ellipsis; white-space: nowrap; }
.model-status { display: inline-flex; min-width: 92px; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; background: var(--faint); border-radius: 50%; }
.model-status[data-status="testing"] .status-dot { background: var(--primary); animation: pulse 1s ease-in-out infinite; }
.model-status[data-status="success"] { color: var(--success); }
.model-status[data-status="success"] .status-dot { background: var(--success); }
.model-status[data-status="error"] { color: var(--danger); }
.model-status[data-status="error"] .status-dot { background: var(--danger); }
.model-status[data-status="hidden"] { display: none; }
.model-row.is-filtered { display: none; }

.skeleton-row { display: grid; grid-template-columns: 1fr 90px 64px; gap: 18px; align-items: center; min-height: 66px; border-bottom: 1px solid var(--border); }
.skeleton-row span { display: block; height: 12px; background: var(--skeleton); border-radius: 5px; animation: shimmer 1.4s ease-in-out infinite alternate; }
.skeleton-row span:nth-child(1) { width: min(52%, 320px); }
.skeleton-row span:nth-child(2) { width: 70px; }
.skeleton-row span:nth-child(3) { height: 32px; }

footer { display: flex; align-items: center; justify-content: space-between; width: min(920px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0 36px; color: var(--faint); border-top: 1px solid var(--border); font-size: 12px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--ink); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes shimmer { from { opacity: 0.55; } to { opacity: 1; } }

@media (max-width: 700px) {
  .site-header { padding: 0 18px; }
  main { width: min(100% - 32px, 920px); padding-top: 52px; }
  .form-grid { grid-template-columns: 1fr; }
  .results-header { align-items: flex-start; flex-direction: column; }
  .results-tools { width: 100%; }
  .search-field { flex: 1; width: auto; }
  footer { width: min(100% - 32px, 920px); }
}

@media (max-width: 520px) {
  .intro h1 { font-size: 29px; }
  .setup-panel { padding: 20px 16px; }
  .segmented-control { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .primary-button { width: 100%; }
  .results-tools { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .secondary-button { width: 100%; }
  .model-row { grid-template-columns: minmax(0, 1fr) auto; gap: 9px 12px; padding: 13px 2px; }
  .model-status { min-width: 0; justify-self: end; }
  .test-button { grid-column: 1 / -1; width: 100%; }
}

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