:root {
  color-scheme: light;
  --bg: #f7f8f6;
  --panel: #ffffff;
  --panel-soft: #fafbf9;
  --ink: #17201b;
  --muted: #68736d;
  --line: #d9dfd8;
  --line-strong: #c2cbc1;
  --accent: #236456;
  --accent-strong: #173f37;
  --accent-soft: #e7f0ed;
  --warn: #9d6718;
  --bad: #b3261e;
  --good: #1d6b49;
  /* 轨道上的柔和底色：差异高亮、不可信区灰底 */
  --bad-soft: #fdecea;
  --line-soft: #eef1ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.shell {
  width: min(1360px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.update-date {
  justify-self: end;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

/*
 * 顶栏右侧容器：把站点导航与更新日期并排放在同一侧。
 * 纯布局与外观调整，不涉及任何业务逻辑。
 */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 站点内两个页面的切换开关 */
.page-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
}

.page-switch a {
  padding: 6px 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.page-switch a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.page-switch a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.update-date span {
  font-weight: 650;
}

.update-date time {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 3.8vw, 40px);
  font-weight: 760;
}

h2 {
  font-size: 18px;
  font-weight: 740;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.controls {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.form-section,
.table-wrap,
.notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.form-section {
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.section-index {
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 100, 86, 0.12);
}

.field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

textarea {
  min-height: 172px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.45;
}

.flank-input {
  min-height: 70px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ee;
  padding: 4px;
  margin: 0 0 14px;
}

.tab {
  min-width: 0;
  min-height: 44px;
  font-size: 13px;
  line-height: 1.5;
  text-wrap: balance;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(23, 32, 27, 0.12);
}

.hidden {
  display: none;
}

.aa-picker {
  margin: 0 0 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.aa-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.aa-picker-head div {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-strong);
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

.mini-btn:hover,
.ghost:hover {
  border-color: var(--accent);
}

.aa-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.aa-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.aa-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.aa-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 750;
}

.aa-option.disabled {
  cursor: not-allowed;
  color: #99a39d;
  background: #f0f2ef;
}

.tab:focus-visible,
.aa-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.settings-grid .field {
  align-content: start;
  grid-template-rows: auto 44px 18px;
}

.settings-grid input {
  height: 44px;
}

.placeholder-note {
  visibility: hidden;
}

.compact {
  margin-bottom: 0;
}

.primary,
.ghost {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 11px 14px;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
}

.primary:hover {
  background: var(--accent-strong);
}

.primary:disabled {
  cursor: wait;
  background: #7b9790;
}

.ghost {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--accent-strong);
}

.ghost:disabled {
  cursor: not-allowed;
  color: #9aa4a0;
  background: #f4f6f3;
}

.status {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.status.error {
  color: var(--bad);
}

.status.ok {
  color: var(--good);
}

.status.warn {
  color: #8b5c00;
}

.results {
  min-width: 0;
  /* 与左侧 .controls 的区块间距保持一致：右侧也用同一套卡片语言
     （边框 + 圆角 + 白底 + 编号标题），区块之间留同样的呼吸感。 */
  display: grid;
  gap: 12px;
  align-content: start;
}

.result-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2ee;
  color: #44514a;
  font-size: 12px;
  font-weight: 760;
}

td {
  font-size: 13px;
}

.seq {
  max-width: 720px;
  color: #101713;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.mut {
  color: #b3261e;
  font-weight: 800;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 54px 16px;
}

.notes {
  margin-top: 14px;
  padding: 16px;
  color: var(--muted);
}

.rule-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.rule-list div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.rule-list div:first-child {
  padding-top: 0;
  border-top: 0;
}

.rule-list dt {
  color: var(--ink);
  font-weight: 760;
}

.rule-list dd {
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .result-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    display: grid;
  }

  .update-date {
    justify-self: start;
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .rule-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
