:root {
  color-scheme: light;
  --navy: #123653;
  --navy-dark: #0b2941;
  --cyan: #007f8b;
  --cyan-light: #e7f5f6;
  --ink: #182733;
  --muted: #536675;
  --line: #d7e0e6;
  --surface: #ffffff;
  --background: #f3f6f8;
  --error: #a52727;
  --error-bg: #fff2f1;
  --success: #176b45;
  --warning: #805500;
  font-family: "Noto Sans CJK SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--background); color: var(--ink); line-height: 1.6; }
button, input, select { font: inherit; }
a { color: var(--cyan); }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: 1rem; top: -5rem; z-index: 20; padding: .6rem 1rem; background: var(--surface); }
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid #0098a8; outline-offset: 3px; }

.site-header { background: var(--navy); color: #fff; border-bottom: 4px solid #19a4ae; }
.header-inner, main, footer, .header-nav { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: 2rem 0 1.4rem; }
.eyebrow { margin: 0 0 .25rem; color: #9edce0; font-size: .78rem; letter-spacing: .13em; }
h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); line-height: 1.3; }
.subtitle { margin: .5rem 0 0; color: #d4e2eb; }
.engine-status { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; min-width: 340px; padding: .85rem 1rem; border: 1px solid #416078; border-radius: 6px; background: #173f5e; }
.engine-status strong, .engine-status span { display: block; }
#engine-detail { color: #d4e2eb; font-size: .85rem; }
.status-dot { width: .72rem; height: .72rem; border-radius: 50%; background: #a9bac6; }
.status-dot.online { background: #55d8b1; }
.status-dot.offline { background: #ff8d83; }
.status-dot.pending { background: #f1c96b; }
.header-nav { display: flex; gap: 1.7rem; padding-bottom: .8rem; }
.header-nav a { color: #e7f0f5; text-decoration: none; font-size: .92rem; }
.header-nav a:hover { text-decoration: underline; }

main { padding: 1.5rem 0 2.5rem; }
.section { margin-top: 1.25rem; padding: 1.6rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px rgba(19, 49, 70, .035); scroll-margin-top: 1rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.4rem; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.section-heading > div { display: flex; align-items: baseline; gap: .7rem; }
.section-heading h2 { margin: 0; color: var(--navy); font-size: 1.35rem; }
.section-heading p { margin: 0; max-width: 570px; color: var(--muted); font-size: .92rem; text-align: right; }
.section-index { color: var(--cyan); font-weight: 700; font-size: .85rem; letter-spacing: .08em; }
.section-note { margin: -.5rem 0 1rem; color: var(--muted); }

fieldset { min-width: 0; }
.mode-fieldset { border: 0; padding: 0; margin: 0; }
.mode-fieldset legend { margin-bottom: .7rem; font-weight: 700; color: var(--navy); }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.mode-card { position: relative; display: block; cursor: pointer; }
.mode-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-card-body { display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; height: 100%; padding: .9rem 1rem; background: #f8fafb; border: 1px solid var(--line); border-radius: 6px; transition: border-color .15s, background .15s; }
.mode-name { color: var(--navy); font-weight: 700; }
.mode-pla { color: var(--cyan); font-weight: 700; }
.mode-note { grid-column: 1 / -1; color: var(--muted); font-size: .86rem; }
.mode-card:hover .mode-card-body { border-color: #72aeb4; }
.mode-card input:checked + .mode-card-body { background: var(--cyan-light); border: 2px solid var(--cyan); padding: calc(.9rem - 1px) calc(1rem - 1px); }
.mode-card input:focus-visible + .mode-card-body { outline: 3px solid #0098a8; outline-offset: 3px; }
.mode-card input:disabled + .mode-card-body { opacity: .65; cursor: not-allowed; }

.parameter-panel { margin-top: 1.25rem; padding: 1rem; background: #f7f9fb; border-left: 3px solid var(--cyan); }
.parameter-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.parameter-header h3 { margin: 0; color: var(--navy); font-size: 1rem; }
.preset-group { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .55rem 1rem; border: 1px solid transparent; border-radius: 4px; cursor: pointer; text-decoration: none; font-weight: 650; line-height: 1.35; }
.button:disabled, .button.disabled { opacity: .52; cursor: not-allowed; pointer-events: none; }
.button-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.button-primary:hover:not(:disabled) { background: var(--navy-dark); }
.button-secondary { background: var(--surface); color: var(--navy); border-color: #91a7b6; }
.button-secondary:hover:not(:disabled) { background: #edf3f6; }
.button-quiet { min-height: 34px; background: transparent; color: #fff; border-color: #668096; }
.button-small { padding: .3rem .55rem; font-size: .82rem; }
.button-preset { min-height: 38px; padding: .35rem .65rem; background: var(--surface); color: var(--navy); border-color: var(--line); font-size: .86rem; }
.button-preset span { margin-left: .3rem; color: var(--muted); font-weight: 400; }
.parameter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-top: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-weight: 650; }
.field input, .field select { display: block; width: 100%; min-height: 44px; padding: .5rem .65rem; border: 1px solid #9bafbc; border-radius: 4px; background: var(--surface); color: var(--ink); }
.field input[readonly] { background: #e9eef1; color: var(--navy); font-weight: 700; }
.field input:disabled, .field select:disabled { color: #4c5d68; background: #e9eef1; opacity: 1; }
.field small { display: block; margin-top: .3rem; color: var(--muted); font-size: .8rem; }
.action-bar { display: flex; gap: 1.2rem; align-items: center; margin-top: 1.2rem; }
.action-buttons { display: flex; flex: 0 0 auto; gap: .6rem; }
.risk-note { margin: 0; color: var(--muted); font-size: .86rem; }
.run-state { display: flex; align-items: flex-start; gap: .8rem; margin-top: 1rem; padding: .8rem 1rem; background: var(--cyan-light); border: 1px solid #b8dadd; border-radius: 4px; }
.run-state strong, .run-state span { display: block; }
#run-state > div > span { font-size: .88rem; }
.spinner { flex: 0 0 auto; width: 1.25rem; height: 1.25rem; margin-top: .25rem; border: 3px solid #b5dadd; border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert { margin: 1rem 0; padding: .8rem 1rem; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert-error { color: var(--error); background: var(--error-bg); border: 1px solid #e7b6b1; }
.empty-state { padding: 1.2rem; background: #f7f9fa; border: 1px dashed #a9bac4; color: var(--muted); }
.result-meta { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 1rem; border: 1px solid var(--line); }
.result-meta > div { min-width: 0; padding: .7rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-meta > div:last-child { border-right: 0; }
.result-meta span, .result-meta strong { display: block; }
.result-meta span { color: var(--muted); font-size: .8rem; }
.result-meta strong { overflow-wrap: anywhere; }
.statistics-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; margin-bottom: .8rem; }
.statistics-toolbar label { color: var(--navy); font-weight: 650; }
.statistics-toolbar select { min-height: 40px; padding: .4rem .6rem; border: 1px solid #9bafbc; border-radius: 4px; background: var(--surface); }
.statistics-toolbar span { color: var(--muted); font-size: .88rem; }
.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { background: #eaf0f4; color: var(--navy); font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f5f9fa; }
td.pass { color: var(--success); font-weight: 700; }
td.fail { color: var(--error); font-weight: 700; }
td.unknown { color: var(--muted); }
.download-row { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.download-row span { color: var(--muted); font-size: .88rem; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.report-card { padding: 1.2rem; border: 1px solid var(--line); border-top: 3px solid var(--cyan); border-radius: 4px; }
.report-card h3 { margin: 0; color: var(--navy); }
.report-card p { min-height: 3.2em; color: var(--muted); }
.report-card a { margin-right: .8rem; }
.report-card span { display: block; margin-top: .7rem; color: var(--muted); font-size: .88rem; }
footer { padding: 0 0 2rem; color: var(--muted); font-size: .85rem; text-align: center; }

@media (max-width: 900px) {
  .header-inner { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .engine-status { width: 100%; min-width: 0; }
  .mode-grid { grid-template-columns: repeat(2, 1fr); }
  .parameter-grid { grid-template-columns: repeat(2, 1fr); }
  .parameter-header { align-items: flex-start; flex-direction: column; }
  .preset-group { justify-content: flex-start; }
  .result-meta { grid-template-columns: repeat(3, 1fr); }
  .result-meta > div { border-bottom: 1px solid var(--line); }
  .section-heading { align-items: flex-start; }
}

@media (max-width: 560px) {
  .header-inner, main, footer, .header-nav { width: min(100% - 24px, 1180px); }
  .header-inner { padding-top: 1.3rem; }
  .header-nav { gap: .8rem; overflow-x: auto; }
  .header-nav a { flex: 0 0 auto; }
  .engine-status { grid-template-columns: auto 1fr; }
  .engine-status button { grid-column: 2; justify-self: start; }
  .section { padding: 1rem; }
  .section-heading { flex-direction: column; gap: .7rem; }
  .section-heading p { text-align: left; }
  .mode-grid, .parameter-grid, .report-grid { grid-template-columns: 1fr; }
  .preset-group { display: grid; width: 100%; }
  .button-preset { justify-content: space-between; }
  .action-bar, .download-row { align-items: stretch; flex-direction: column; }
  .action-buttons { flex-wrap: wrap; }
  .result-meta { grid-template-columns: repeat(2, 1fr); }
  .report-card p { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation: none; }
}
