:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172026;
  background: #f4f6f7;
  letter-spacing: 0;
  --border: #cfd7dc;
  --muted: #63717a;
  --surface: #ffffff;
  --surface-alt: #eef2f3;
  --accent: #087f72;
  --accent-strong: #05645a;
  --danger: #b42318;
  --warning: #9a6700;
  --focus: #1d4ed8;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f6f7; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select, input, textarea { border: 1px solid var(--border); border-radius: 4px; }
button { min-height: 36px; padding: 7px 12px; background: var(--surface); cursor: pointer; }
button:hover { background: var(--surface-alt); }
button:disabled { cursor: not-allowed; opacity: .48; }
button.primary { color: white; background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent-strong); }
button.danger { color: var(--danger); border-color: #e6aaa5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

.app-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 28px; background: #1f2a30; color: white; border-bottom: 3px solid var(--accent); }
.app-header h1 { margin: 0; font-size: 22px; font-weight: 650; }
.status-line { margin: 5px 0 0; color: #c7d1d6; font-size: 13px; }
.header-actions, .inline-form, .toolbar, .dialog-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 0; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 12px 16px; background: transparent; white-space: nowrap; }
.tab.is-active { border-bottom-color: var(--accent); color: var(--accent-strong); font-weight: 650; }
main { width: min(1600px, 100%); margin: 0 auto; }
.view { display: none; padding: 24px 28px 40px; }
.view.is-active { display: block; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { padding: 10px 0; color: var(--muted); font-size: 13px; }
.toolbar input[type="search"] { width: min(360px, 100%); }
input[type="search"], select, textarea { padding: 8px 10px; background: var(--surface); color: inherit; }
.file-picker { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: pointer; }
.file-picker input { width: min(260px, 45vw); border: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
.wide table { min-width: 1200px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e2e7ea; text-align: left; vertical-align: top; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: #e8edef; color: #36454d; font-weight: 650; }
.column-filter { display: block; width: min(260px, 100%); margin-top: 6px; padding: 5px 7px; background: var(--surface); color: inherit; font-weight: 400; }
.column-filter.compact { display: inline-block; width: 180px; margin-top: 0; }
tbody tr:hover { background: #f7fafa; }
.check-column { width: 44px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.status { display: inline-block; min-width: 64px; padding: 2px 6px; border-radius: 3px; text-align: center; font-size: 12px; font-weight: 650; background: #e6f4f1; color: #08685e; }
.status.warning { background: #fff2cc; color: var(--warning); }
.status.danger { background: #fee4e2; color: var(--danger); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.empty-state { margin: 0; padding: 28px; text-align: center; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.preview-form { display: grid; gap: 14px; max-width: 960px; }
.preview-form label { display: grid; gap: 6px; color: #36454d; font-size: 13px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.preview-result { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 18px; }
.preview-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.preview-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.preview-columns section { min-width: 0; }
.preview-columns h3 { font-size: 15px; margin: 0 0 8px; }
pre { margin: 0; padding: 14px; min-height: 180px; max-height: 520px; overflow: auto; border: 1px solid var(--border); background: #182126; color: #e8eef1; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid #aebbc2; border-radius: 6px; }
dialog::backdrop { background: rgb(15 23 42 / 45%); }
.dialog-shell { display: grid; max-height: calc(100vh - 42px); }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dialog-heading h2 { margin: 0; font-size: 18px; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.dynamic-controls { display: grid; gap: 14px; padding: 18px 20px; overflow: auto; }
.control-section { display: grid; gap: 9px; padding-bottom: 14px; border-bottom: 1px solid #e5e9eb; }
.control-section h3 { margin: 0; font-size: 14px; }
.control-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr); gap: 14px; align-items: center; }
.control-row label { font-size: 13px; }
.control-row small { display: block; color: var(--muted); margin-top: 3px; }
.dialog-actions { justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(460px, calc(100vw - 40px)); padding: 12px 14px; border-radius: 4px; background: #1f2a30; color: white; box-shadow: 0 8px 28px rgb(15 23 42 / 22%); }
.toast.error { background: #7a271a; }
.editor-metadata { display: grid; grid-template-columns: 1fr 1.4fr .7fr 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.editor-metadata label, .st-editor-panel label { display: grid; gap: 5px; color: #36454d; font-size: 12px; }
.editor-metadata input, .st-editor-panel input { min-width: 0; padding: 8px 10px; background: var(--surface); }
.st-editor-grid { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(360px, 2fr) minmax(220px, .9fr); gap: 12px; align-items: stretch; }
.st-editor-panel { min-width: 0; min-height: 520px; padding: 14px; border: 1px solid var(--border); background: var(--surface); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-heading h3 { margin: 0; font-size: 14px; }
.prompt-list { display: grid; align-content: start; gap: 4px; max-height: 440px; overflow: auto; }
.prompt-list-item { display: grid; gap: 2px; width: 100%; min-height: 46px; text-align: left; }
.prompt-list-item small { color: var(--muted); }
.prompt-list-item.is-selected { border-color: var(--accent); background: #e6f4f1; }
.prompt-order-actions { display: flex; gap: 5px; margin-top: 10px; }
.prompt-order-actions button { flex: 1; padding-left: 5px; padding-right: 5px; }
.st-prompt-content { display: grid; align-content: start; gap: 10px; }
.st-generation-panel { display: grid; align-content: start; gap: 10px; }
.inline-check { display: flex !important; grid-template-columns: auto auto; align-items: center; }
.editor-live-preview { margin-top: 12px; }
.editor-live-preview pre { min-height: 220px; }
.source-offer { color: var(--muted); font-size: 12px; }
.source-offer a { color: var(--accent-strong); }
.system-profile-details { border: 1px solid var(--border); padding: 12px; background: var(--surface); }
.system-profile-details summary { cursor: pointer; font-weight: 650; }
.system-profile-details label { margin-top: 12px; }
.safety-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; color: var(--muted); font-size: 12px; }
.runtime-feature-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.runtime-feature-status-grid article { padding: 14px; border: 1px solid var(--border); background: var(--surface); }
.runtime-feature-status-grid h3 { margin: 0 0 7px; font-size: 13px; color: var(--muted); }
.runtime-feature-status-grid p { margin: 0; font-weight: 650; }
.runtime-feature-form { margin-bottom: 24px; padding: 16px; border: 1px solid var(--border); background: var(--surface); }

@media (max-width: 760px) {
  .app-header, .section-heading { align-items: stretch; flex-direction: column; }
  .app-header, .view { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 8px; }
  .header-actions button, .inline-form button { flex: 1; }
  .inline-form { align-items: stretch; }
  .file-picker { width: 100%; flex-direction: column; align-items: flex-start; }
  .file-picker input { width: 100%; }
  .field-grid, .preview-columns, .editor-metadata, .st-editor-grid, .runtime-feature-status-grid { grid-template-columns: 1fr; }
  .st-editor-panel { min-height: 0; }
  .control-row { grid-template-columns: 1fr; gap: 6px; }
}

/* Shared control language: quiet surfaces, clear focus, compact readable forms. */
:root {
  --border: #dce4e7;
  --muted: #61737d;
  --surface-alt: #f0f5f5;
  --accent: #087d75;
  --accent-strong: #09645e;
  --focus: #168c83;
  background: #f3f6f7;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
body { background: #f3f6f7; line-height: 1.55; }
button, input, select, textarea { border-radius: 8px; transition: border-color .15s, box-shadow .15s, background-color .15s; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  min-width: 0; max-width: 100%; padding: 10px 12px; background: var(--surface); color: #20343d;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select { min-height: 42px; }
input::placeholder, textarea::placeholder { color: #84949c; }
input:hover, select:hover, textarea:hover { border-color: #afc2c7; }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%2361737d' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
select:disabled { color: var(--muted); background-color: #f5f7f8; opacity: 1; }
textarea { resize: vertical; line-height: 1.65; }
button { min-height: 40px; padding: 9px 14px; font-size: 13px; font-weight: 600; color: #31464f; white-space: nowrap; }
button:hover { border-color: #adc0c5; }
button.primary { box-shadow: 0 2px 4px rgb(8 125 117 / 12%); }
.app-header { padding: 22px 32px; background: #20363f; border: 0; }
.app-header h1 { font-size: 21px; letter-spacing: -.5px; }
.header-actions { flex-shrink: 0; }
.app-header .header-actions > button:not(.primary) { background: #304852; border-color: #49616a; color: #e7f0f3; }
.tabs { padding: 6px 22px 0; gap: 4px; }
.tab { border-radius: 7px 7px 0 0; padding: 13px 17px; color: var(--muted); }
.tab.is-active { background: #eef7f5; }
.view { padding: 28px 32px 48px; }
.section-heading h2 { font-size: 23px; font-weight: 650; letter-spacing: -.5px; }
.section-heading p { max-width: 960px; line-height: 1.8; }
.section-heading { margin-bottom: 22px; }
.table-wrap, .empty-state, .st-editor-panel, .system-profile-details { border-radius: 10px; }
th { background: #edf2f3; padding-top: 13px; padding-bottom: 13px; }
.status { border-radius: 6px; padding: 4px 8px; font-size: 11px; line-height: 1.5; }
.status.warning { color: #8c651c; background: #fff5de; }
.runtime-feature-status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.runtime-feature-status-grid article { padding: 17px 18px; border-radius: 10px; }
.runtime-feature-status-grid article:nth-child(4) { grid-column: span 2; }
.runtime-feature-status-grid h3 { font-size: 12px; font-weight: 500; margin-bottom: 9px; }
.runtime-feature-status-grid p { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.runtime-feature-form { max-width: none; padding: 28px; border-radius: 12px; gap: 24px; box-shadow: 0 2px 4px rgb(32 54 63 / 2%); }
.form-intro { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 19px; border-bottom: 1px solid var(--border); }
.form-intro h3 { font-size: 20px; margin: 3px 0 0; }
.eyebrow { color: var(--accent-strong); font: 600 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1.4px; }
.policy-section { min-width: 0; margin: 0; padding: 20px 22px 22px; display: grid; gap: 16px; border: 1px solid var(--border); border-radius: 10px; }
.policy-section legend { padding: 0 8px; margin-left: -8px; font-size: 15px; font-weight: 650; color: #24414a; }
.policy-section label { font-size: 13px; font-weight: 500; }
.policy-section .inline-check { gap: 10px; min-height: 28px; font-weight: 400; }
.policy-section .inline-check input, .runtime-feature-form > .inline-check input {
  appearance: none; position: relative; flex: 0 0 36px; width: 36px; height: 21px; min-height: 0; margin: 0; border: 1px solid #b8c6cc; border-radius: 20px; background: #ccd7db; cursor: pointer;
}
.policy-section .inline-check input::before, .runtime-feature-form > .inline-check input::before { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgb(30 50 60 / 15%); transition: transform .15s; }
.policy-section .inline-check input:checked, .runtime-feature-form > .inline-check input:checked { background: var(--accent); border-color: var(--accent); }
.policy-section .inline-check input:checked::before, .runtime-feature-form > .inline-check input:checked::before { transform: translateX(15px); }
.policy-section .field-grid { gap: 18px; align-items: center; }
.policy-section .field-grid > .inline-check { align-self: center; }
.policy-section > .muted, .field-help, .section-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; font-weight: 400; }
.policy-section details { border-radius: 8px; padding: 14px 16px; background: #f5f8f9; }
.policy-section summary { color: #38535e; font-size: 13px; font-weight: 600; cursor: pointer; }
.policy-section details[open] { display: grid; gap: 12px; }
.policy-section details > label { margin-top: 14px; }
.policy-section details > button { margin: 12px 0; }
.optional-tag { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 4px; background: #eaf5f2; color: var(--accent-strong); font-size: 10px; vertical-align: middle; font-weight: 500; }
.judge-section { border-top: 3px solid #8dbdb6; }
.setup-flow { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 0; padding: 13px 16px; list-style: none; counter-reset: setup; background: #f1f7f6; border-radius: 8px; }
.setup-flow li { counter-increment: setup; display: flex; align-items: center; gap: 7px; font-size: 12px; color: #41635e; }
.setup-flow li::before { content: counter(setup); display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #bbd5d0; border-radius: 50%; font: 11px ui-monospace, monospace; }
.judge-connection { display: grid; gap: 8px; }
.label-with-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.inline-actions { display: flex; align-items: stretch; gap: 8px; }
.inline-actions input { flex: 1; width: 0; }
.credential-binding { margin: 0; color: var(--muted); font-size: 11px; }
.credential-binding:empty { display: none; }
.judge-model-picker { border-top: 1px solid var(--border); padding-top: 20px; display: grid; gap: 12px; }
.judge-model-picker .panel-heading { margin: 0; }
.judge-model-picker .panel-heading h3 { margin: 0 0 3px; font-size: 13px; }
.judge-model-picker .panel-heading button { color: var(--accent-strong); border-color: #a5cbc3; background: #f1f8f6; }
.judge-config-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 14px 16px; background: #f6f8f9; border-radius: 8px; }
.judge-config-summary p { display: grid; gap: 5px; margin: 0; min-width: 0; }
.judge-config-summary span { font-size: 11px; color: var(--muted); }
.judge-config-summary strong { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.form-save-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); padding-top: 20px; }
.form-save-bar strong { font-size: 13px; font-weight: 600; }
.form-save-bar p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
#view-runtime-features > h3 { font-size: 17px; margin: 30px 0 13px; }
#view-runtime-features > .muted { font-size: 12px; }
@media (min-width: 1300px) {
  .runtime-feature-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .form-intro, .runtime-feature-form > .muted, .form-save-bar { grid-column: 1 / -1; }
  .runtime-feature-form > .policy-section:nth-of-type(2) { grid-column: 1; }
  .runtime-feature-form > .judge-section { grid-column: 2; grid-row: 2 / span 2; }
}
@media (max-width: 760px) {
  .app-header { padding: 20px 16px; gap: 18px; }
  .tabs { padding-left: 8px; padding-right: 8px; }
  .tab { padding: 11px 13px; }
  .view { padding: 22px 16px 32px; }
  .section-heading h2 { font-size: 21px; }
  .runtime-feature-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-feature-status-grid article:nth-child(3) { grid-column: 1; }
  .runtime-feature-status-grid article:nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
  .runtime-feature-form { padding: 18px 14px; gap: 22px; }
  .policy-section { padding: 15px 13px; gap: 14px; }
  .form-intro { align-items: flex-start; }
  .form-intro h3 { font-size: 18px; }
  .setup-flow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .key-actions { flex-wrap: wrap; }
  .key-actions input { flex-basis: calc(100% - 64px); }
  #anti-judge-key-save { width: 100%; }
  .judge-model-picker .panel-heading { align-items: stretch; flex-direction: column; }
  .judge-config-summary { grid-template-columns: 1fr; }
  .form-save-bar { align-items: stretch; flex-direction: column; }
  .section-heading > .header-actions button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
