:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --card: #fff;
  --input: #f8faf9;
  --line: #e1e7e3;
  --text: #17271e;
  --muted: #4d6054;
  --green: #24734d;
  --green-hover: #195b3c;
  --red: #b72d3b;
  --sans: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 500 16px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button, select, input { accent-color: var(--green); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.shell { width: min(1040px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 32px; }
.topbar { min-height: 76px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 24px; font-weight: 700; }
.brand-icon { color: var(--green); font-size: 26px; }
.mode-tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.mode-tab { padding: 10px 2px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 500; }
.mode-tab:hover { color: var(--text); }
.mode-tab.is-active { color: var(--green); border-bottom-color: var(--green); font-weight: 700; }
.settings-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; padding: 18px 0; }
.settings-model { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-width: 0; }
.settings-model label { font-size: 14px; color: var(--muted); }
select, .rule input[type=text] { min-width: 0; color: var(--text); background: var(--card); border: 1px solid #ccd6cf; border-radius: 6px; padding: 7px 10px; }
.settings-model select { max-width: 100%; font-size: 15px; }
.model-hint { font-size: 14px; color: var(--muted); }
.rules-help-btn { padding: 7px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--green); font-size: 14px; white-space: nowrap; }
.rules-help-btn:hover, .rules-help-btn[aria-expanded=true] { background: #edf5f0; border-color: #b7ccbf; }
.rules-meta { color: var(--muted); }
.tab-panel { display: none; margin-top: 14px; }
.tab-panel.is-active { display: block; }
.monitor-card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.panel + .panel, .monitor-card + .panel { margin-top: 14px; }
.monitor-head, .monitor-heading, .panel-title, .lights-title, .events-title, .rules-popover-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.monitor-heading { justify-content: flex-start; flex-wrap: wrap; }
h2, h3 { margin: 0; color: var(--text); font-size: 18px; font-weight: 700; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 4px 9px; background: #f0f3f1; color: var(--muted); font-size: 13px; }
.status-pill i, .live-dot { width: 6px; height: 6px; border-radius: 50%; background: #9aa79f; flex-shrink: 0; }
.status-pill.busy { color: var(--green); background: #eaf5ee; }
.status-pill.busy i { background: var(--green); }
.status-pill.alert { color: var(--red); background: #fff0f1; }
.status-pill.alert i { background: var(--red); }
.start-button, .scan-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 7px 16px; border: 1px solid var(--green); border-radius: 6px; background: var(--green); color: white; font-size: 15px; font-weight: 600; white-space: nowrap; }
.start-button:hover:not(:disabled), .scan-button:hover:not(:disabled) { background: var(--green-hover); }
.start-button.stopping { background: #fff; color: var(--red); border-color: #e0b7bb; }
.start-button.stopping:hover:not(:disabled) { background: #fff0f1; }
.button-symbol { font-size: 12px; }
.monitor-main { margin-top: 16px; padding: 13px 15px; background: var(--input); border: 1px solid #eaf0ec; border-radius: 7px; }
.listen-visual { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.listen-visual.is-listening .live-dot { background: var(--green); }
.listen-visual.is-alert .live-dot { background: var(--red); }
.transcript { margin-top: 7px; min-height: 42px; max-height: 220px; overflow: auto; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.lights-title { flex-wrap: wrap; margin-bottom: 15px; }
.response-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; }
.toggle-row { display: flex; align-items: center; gap: 7px; cursor: pointer; position: relative; }
.toggle-copy { color: var(--muted); font-size: 14px; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle { width: 28px; height: 16px; border-radius: 20px; background: #aab6ae; position: relative; flex-shrink: 0; transition: background .15s; }
.toggle::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fff; position: absolute; left: 2px; top: 2px; transition: transform .15s; }
.toggle-row input:checked + .toggle { background: var(--green); }
.toggle-row input:checked + .toggle::after { transform: translateX(12px); }
.toggle-row input:focus-visible + .toggle { outline: 2px solid var(--green); outline-offset: 3px; }
.reset-button, .clear-button, .add-button { padding: 5px 11px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); font-size: 14px; }
.reset-button:hover, .clear-button:hover, .add-button:hover { background: #f0f6f2; color: var(--green); border-color: #b7ccbf; }
.alarm-display { display: flex; align-items: center; justify-content: center; gap: 42px; min-height: 190px; padding: 20px 24px; }
.alarm-lamp { position: relative; display: grid; place-items: center; flex-shrink: 0; width: 136px; height: 136px; border-radius: 50%; border: 7px solid #e7f0e9; background: radial-gradient(circle at 32% 24%, #fff 0, #f0f8f1 38%, #cbded0 100%); color: #7b8e81; font-size: 58px; font-weight: 750; line-height: 1; box-shadow: 0 0 0 1px #cbded0, 0 12px 26px #2c6b4017, inset 0 -4px 12px #4c8c5c14; }
.alarm-lamp::before { content: ""; position: absolute; inset: 10px; border: 1px solid #bed6c5; border-radius: 50%; box-shadow: inset 0 2px 7px #3f795118, 0 1px 0 #ffffffb8; }
.alarm-lamp::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #a4d3ae, #568b65 70%, #427450); border: 2px solid #edf7ef; box-shadow: 0 0 0 6px #ffffff9c, 0 0 19px #74ad8273; }
.alarm-copy { min-width: 0; max-width: 620px; }
.alarm-copy h2 { font-size: 30px; font-weight: 700; }
.alarm-copy p { margin: 8px 0 0; overflow-wrap: anywhere; }
#alarmWords { font-size: 20px; font-weight: 600; }
#alarmDescription { color: var(--muted); font-size: 14px; font-weight: 400; }
.lights-panel { transition: background .2s, border-color .2s; }
.lights-panel.is-alarming { border-color: #e86565; background: #fff5f5; box-shadow: 0 0 0 2px #dc303014; }
.is-alarming .alarm-lamp { color: white; border-color: #ffc8c8; background: radial-gradient(circle at 35% 25%, #ff9292, #e4303a 55%, #b31522); animation: alarm-pulse 1.2s ease-in-out infinite; }
.is-alarming .alarm-lamp::before, .is-alarming .alarm-lamp::after { display: none; }
.is-alarming .alarm-copy h2, .is-alarming #alarmWords { color: #b91c2b; }
.light-foot { display: flex; justify-content: flex-end; margin-top: 10px; color: var(--muted); font-size: 13px; }
#lastTrigger { overflow-wrap: anywhere; }
@keyframes alarm-pulse {
  0%, 100% { box-shadow: 0 0 0 7px #f0474724, 0 0 28px #e4303a55; filter: brightness(.9); }
  50% { box-shadow: 0 0 0 16px #f0474714, 0 0 48px #e4303a88; filter: brightness(1.12); }
}
.events-title { margin-bottom: 8px; }
.events-panel { margin-top: 14px; }
.event-list { max-height: 208px; overflow: auto; }
.event-row { display: grid; grid-template-columns: 66px 8px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 10px 0; border-top: 1px solid #edf0ee; font-size: 14px; }
.event-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.event-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--event-color); }
.event-name { overflow-wrap: anywhere; }
.event-source { display: inline-block; margin-right: 6px; padding: 1px 5px; border-radius: 4px; background: #eef3ef; color: var(--muted); font-size: 12px; font-weight: 600; }
.event-detail { color: var(--muted); }
.event-action { font-size: 13px; color: var(--muted); white-space: nowrap; }
.empty-state { padding: 13px 0; font-size: 14px; color: var(--muted); }
.panel-title { margin-bottom: 16px; }
.heading-note { font-size: 14px; color: var(--muted); }
.file-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.file-pick { position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px; border: 1px dashed #bdccc2; border-radius: 6px; background: var(--input); cursor: pointer; }
.file-pick:hover { border-color: var(--green); }
.file-pick:focus-within { outline: 2px solid var(--green); outline-offset: 3px; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick-label { flex-shrink: 0; padding: 4px 9px; border: 1px solid var(--line); border-radius: 4px; background: white; font-size: 14px; }
#fileName { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }
.file-status { margin-top: 12px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.file-status.is-busy { color: var(--green); }
.file-status.is-error { color: var(--red); }
.file-status.is-ok { color: var(--text); }
.file-transcript { margin-top: 18px; padding: 15px; background: var(--input); border: 1px solid var(--line); border-radius: 6px; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.file-hits { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.file-hit { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; max-width: 100%; padding: 6px 10px; border: 1px solid color-mix(in srgb, var(--hit) 40%, #e1e7e3); background: color-mix(in srgb, var(--hit) 8%, white); border-radius: 5px; font-size: 14px; overflow-wrap: anywhere; }
.file-hit b { font-weight: 600; }
.file-hit small { font-size: 13px; color: var(--muted); }
.file-segment-list { width: 100%; min-width: 0; margin-top: 6px; }
.file-segment { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.file-segment time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.rules-popover { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; background: #1a302740; padding: 20px; }
.rules-popover-card { width: min(580px, 100%); min-width: 0; max-height: 80vh; overflow: auto; background: white; border: 1px solid var(--line); border-radius: 10px; padding: 20px; box-shadow: 0 16px 60px #172b2326; }
.rules-popover-head { margin-bottom: 16px; }
.rules-popover-actions { display: flex; align-items: center; gap: 12px; }
.add-button { color: var(--green); }
.rules-close { border: 0; background: transparent; color: var(--muted); font-size: 23px; width: 28px; height: 28px; line-height: 1; }
.rules-close:hover { color: var(--red); }
.rule-head, .rule { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 65px 22px; gap: 8px; align-items: center; }
.rule-head { padding-bottom: 8px; color: var(--muted); font-size: 14px; border-bottom: 1px solid var(--line); }
.rule { padding: 8px 0; border-bottom: 1px solid #edf0ee; }
.rule input[type=text], .rule select { width: 100%; font-size: 14px; }
.rule input::placeholder { color: var(--muted); }
.rule-color { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.rule input[type=color] { width: 24px; height: 24px; padding: 1px; border: 1px solid #ccd6cf; border-radius: 4px; background: white; cursor: pointer; }
.delete-rule { border: 0; background: transparent; font-size: 18px; color: var(--muted); padding: 0; }
.delete-rule:hover { color: var(--red); }
.toast { position: fixed; bottom: 24px; left: 50%; z-index: 30; transform: translate(-50%, 8px); max-width: calc(100% - 32px); padding: 10px 16px; border: 1px solid #d0dbd4; border-radius: 7px; background: white; box-shadow: 0 5px 24px #213b291a; color: var(--text); font-size: 15px; overflow-wrap: anywhere; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 900px) {
  .settings-model { flex: 1 1 100%; }
}
@media (max-width: 540px) {
  .shell { width: calc(100% - 28px); }
  .topbar { min-height: 66px; }
  .brand { font-size: 20px; gap: 7px; }
  .settings-model { gap: 8px; }
  .model-hint { flex-basis: 100%; }
  .monitor-card, .panel { padding: 15px 14px; }
  .monitor-head { align-items: flex-start; }
  .monitor-heading { display: grid; gap: 6px; }
  .status-pill { font-size: 12px; }
  .monitor-main { padding: 12px; }
  .lights-title { gap: 12px; }
  .response-controls { width: 100%; gap: 12px; }
  .reset-button { margin-left: auto; }
  .alarm-display { flex-direction: column; gap: 24px; padding: 24px 6px 12px; text-align: center; }
  .alarm-lamp { width: 120px; height: 120px; }
  .alarm-copy h2 { font-size: 26px; }
  .light-foot { justify-content: center; }
  .event-row { grid-template-columns: 62px 6px minmax(0, 1fr); gap: 7px; }
  .event-action { grid-column: 3; }
  .file-controls { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .file-segment { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .heading-note { font-size: 13px; }
  .rules-popover { padding: 12px; }
  .rules-popover-card { padding: 14px; }
  .rule-head, .rule { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 52px 18px; gap: 5px; }
  .rule input[type=text], .rule select { padding: 7px 3px; font-size: 13px; }
  .rule-color { gap: 2px; font-size: 11px; }
  .rule input[type=color] { width: 20px; height: 22px; flex-shrink: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .is-alarming .alarm-lamp { box-shadow: 0 0 0 7px #f0474724, 0 0 28px #e4303a55; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
