:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #eeede7;
  --ink: #24231f;
  --ink-2: #56544c;
  --muted: #6b685d;
  --line: #e7e5dc;
  --line-strong: #d9d6ca;
  --accent: #5f7c61;
  --accent-deep: #42584a;
  --accent-soft: #e6ece1;
  --ok: #4f9d6b;
  --danger: #b0594b;
  --shadow-sm: 0 1px 2px rgba(36, 35, 31, 0.05), 0 4px 12px rgba(36, 35, 31, 0.05);
  --font-display: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-body: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

a { color: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.brand__mark svg { width: 36px; height: 36px; display: block; }

.brand__word {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__word strong {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.brand__word small {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 22px;
}

.back {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.back:hover { color: var(--accent-deep); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(79, 157, 107, 0.14);
}

.main {
  flex: 1;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 72px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero { max-width: 760px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

.eyebrow__rule {
  width: 34px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.hero__title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(25px, 5vw, 40px);
  font-weight: 700;
  line-height: 1.05;
}

.hero__lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-2);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel__title {
  margin: 0;
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  text-transform: uppercase;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel__actions { display: inline-flex; gap: 8px; }

.panel__body { padding: 20px; }

.panel__body--flush { padding: 12px 16px; }

/* 模式与周期分段控件 */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented--small .segmented__item {
  padding: 6px 14px;
  font-size: 12px;
}

.segmented__item {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  padding: 8px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}

.segmented__item[aria-selected='true'] {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
}

.mode-fields { margin-top: 16px; }

.fields-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.fields-row--3 { margin-bottom: 8px; }

.field { display: block; margin: 0; }

.field--inline .field__label { margin-bottom: 6px; }

.field__label {
  display: block;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 6px;
}

.field__label b {
  font-family: var(--font-mono);
  color: var(--accent-deep);
}

.field__control {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}

.field__control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(95, 124, 97, 0.14);
}

.field__control input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 11px 14px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  outline: none;
}

.field__unit {
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  padding: 11px 34px 11px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b685d' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(95, 124, 97, 0.14);
}

/* 比例预设 chips、单位下拉、字段小注 */
.ratio-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-2);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.unit-select {
  appearance: auto;
  border: none;
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  outline: none;
}

.unit-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 0;
}

.field__note {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

/* 输入:输出 手动输入组 */
.ratio-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}

.ratio-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(95, 124, 97, 0.14);
}

.ratio-group input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  background: none;
  padding: 11px 10px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  text-align: center;
  outline: none;
}

.ratio-colon {
  font-family: var(--font-mono);
  color: var(--muted);
  padding: 0 2px;
}

/* 模型 API 开放性标注 */
.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 7px;
  font-size: 10px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
  white-space: nowrap;
}

.tag--api {
  border: 1px solid var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.tag--own {
  border: 1px solid #a47735;
  color: #a47735;
  background: transparent;
}

.hint--padded {
  margin: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

/* 厂商行 */
.providers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.provider {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(200px, 1fr) minmax(200px, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 10px 12px;
  transition: opacity 180ms ease, border-color 180ms ease;
}

.provider--off { opacity: 0.55; }

.provider--on { border-color: var(--line-strong); }

.provider__check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-width: 0;
}

.provider__check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}

.provider__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider__sub {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider .select { padding-top: 9px; padding-bottom: 9px; font-size: 13px; }

/* 结果 */
.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.results-meta > span { font-size: 13px; color: var(--ink-2); }

.results-meta .select { width: auto; padding-top: 7px; padding-bottom: 7px; font-size: 12px; }

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td { border-bottom: none; }

.table td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tr.is-best td { background: var(--accent-soft); }

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.06em;
  vertical-align: 1px;
}

.cell-title { font-weight: 600; white-space: nowrap; }

.cell-title .warn { color: #a47735; margin-left: 4px; }

.cell-sub {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.cell-note {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  max-width: 260px;
}

.chart { width: 100%; height: 420px; margin-top: 18px; }

.footer {
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.8;
  background: var(--bg);
}

@media (max-width: 860px) {
  .provider {
    grid-template-columns: 1fr 1fr;
  }

  .provider__check { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .main { padding-top: 32px; }

  .topbar__meta .clock { display: none; }
}

@media (max-width: 560px) {
  .provider { grid-template-columns: 1fr; }

  .topbar__meta .status { display: none; }
}

@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;
  }
}
