:root {
  color-scheme: dark;
  --bg: #071015;
  --bg-elevated: #0b171e;
  --panel: rgba(14, 27, 35, 0.92);
  --panel-2: #101f28;
  --line: rgba(157, 190, 202, 0.14);
  --line-strong: rgba(157, 190, 202, 0.25);
  --text: #edf7f7;
  --muted: #8298a2;
  --cyan: #38dec9;
  --cyan-soft: rgba(56, 222, 201, 0.13);
  --amber: #ffb84d;
  --blue: #5e8bff;
  --pink: #ef78ba;
  --red: #ff6b6b;
  --radius: 12px;
  --sidebar-width: 310px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; background: var(--bg); color: var(--text); }
body {
  background-image:
    radial-gradient(circle at 80% -10%, rgba(42, 151, 166, 0.14), transparent 35%),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 44px;
  flex: none;
  padding: 0 14px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 21, .88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { min-width: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-name { min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.brand strong { display: block; font-size: .9rem; letter-spacing: .01em; }
.brand small { min-width: 0; display: block; overflow: hidden; text-overflow: ellipsis; font-size: .6rem; color: var(--muted); }
.brand-mark { width: 27px; height: 27px; display: flex; align-items: flex-end; gap: 3px; padding: 4px; border: 1px solid rgba(56,222,201,.42); background: var(--cyan-soft); border-radius: 6px; }
.brand-mark span { width: 4px; background: var(--cyan); border-radius: 2px; box-shadow: 0 0 10px rgba(56,222,201,.5); }
.brand-mark span:nth-child(1) { height: 9px; }.brand-mark span:nth-child(2) { height: 18px; }.brand-mark span:nth-child(3) { height: 13px; }
.analysis-navigation { min-width: 0; display: flex; align-items: center; gap: 16px; }
.project-state { min-width: 0; flex: 1; color: var(--muted); font-size: .75rem; }
#sourceName { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions .btn { min-height: 28px; padding: 0 10px; gap: 5px; border-radius: 6px; font-size: .73rem; }
.analysis-details { position: relative; }
.analysis-details summary { list-style: none; user-select: none; }
.analysis-details summary::-webkit-details-marker { display: none; }
.analysis-details[open] summary { color: var(--cyan); border-color: var(--cyan); }
.analysis-details .metric-grid { position: absolute; top: calc(100% + 8px); right: 0; width: min(340px, calc(100vw - 24px)); padding: 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-elevated); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.analysis-details summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--sidebar-width) 9px minmax(0, 1fr); overflow: hidden; }
.panel { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.13); }
.left-panel { height: 100%; overflow-y: auto; overscroll-behavior: contain; border-width: 0 1px 0 0; border-radius: 0; scrollbar-color: rgba(56,222,201,.32) transparent; }
.workspace-resizer { position: relative; z-index: 8; width: 9px; height: 100%; cursor: col-resize; touch-action: none; outline: 0; background: rgba(7,16,21,.72); border-right: 1px solid var(--line); }
.workspace-resizer::before { content: ''; position: absolute; inset: 0 -4px; }
.workspace-resizer span { position: absolute; left: 3px; top: 50%; width: 3px; height: 54px; transform: translateY(-50%); border-radius: 3px; background: rgba(157,190,202,.22); transition: background .16s ease, box-shadow .16s ease; }
.workspace-resizer:hover span, .workspace-resizer:focus-visible span, .workspace-resizer.dragging span { background: var(--cyan); box-shadow: 0 0 12px rgba(56,222,201,.55); }
body.resizing-sidebar { cursor: col-resize; user-select: none; }
.panel-section { padding: 21px 20px; border-bottom: 1px solid var(--line); }
.section-kicker, .eyebrow { color: var(--cyan); font: 700 .66rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin: 7px 0 13px; }
.section-title-actions { display: flex; align-items: center; gap: 6px; }
.auto-detect-open { min-height: 27px; padding: 0 9px; color: var(--cyan); font-size: .67rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 2.4vw, 2.4rem); letter-spacing: -.035em; }
h2 { font-size: 1rem; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.chip { padding: 4px 8px; border: 1px solid var(--line); background: rgba(255,255,255,.025); color: var(--muted); border-radius: 999px; font-size: .72rem; }

.btn, .square-button, .icon-button, .segmented button, .tabs button {
  border: 0; cursor: pointer; transition: .18s ease; -webkit-tap-highlight-color: transparent;
}
.btn { min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: 8px; font-weight: 650; font-size: .82rem; }
.btn.primary { background: var(--cyan); color: #05201c; box-shadow: 0 6px 25px rgba(56,222,201,.13); }
.btn.primary:hover { background: #5de8d6; transform: translateY(-1px); }
.btn.ghost { color: #b9c8cd; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--line-strong); color: white; background: rgba(255,255,255,.06); }
.btn.full { width: 100%; margin-top: 14px; }
.btn.compact { min-height: 32px; padding: 0 11px; font-size: .75rem; }
.file-button input { display: none; }
kbd { padding: 2px 5px; color: rgba(5,32,28,.72); background: rgba(255,255,255,.28); border-radius: 4px; font: 600 .64rem ui-monospace, monospace; }
.icon-button { width: 27px; height: 27px; border-radius: 7px; color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.icon-button:hover { color: var(--cyan); border-color: rgba(56,222,201,.4); }

.dropzone { min-height: 104px; border: 1px dashed rgba(56,222,201,.28); border-radius: 10px; background: linear-gradient(145deg, rgba(56,222,201,.06), rgba(56,222,201,.015)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; color: #bdd1d5; }
.dropzone:hover, .dropzone.drag { border-color: var(--cyan); background: rgba(56,222,201,.09); }
.dropzone svg { width: 24px; fill: none; stroke: var(--cyan); stroke-width: 1.5; }
.dropzone strong { font-size: .82rem; }.dropzone span { font-size: .7rem; color: var(--muted); }
.encoding-row { margin-top: 8px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; color: var(--muted); font-size: .68rem; }
.encoding-row select { min-width: 0; height: 29px; padding: 0 7px; color: #a9bec4; background: #081218; border: 1px solid var(--line); border-radius: 6px; font: .66rem ui-monospace, monospace; outline: 0; }
.encoding-row select:focus { border-color: rgba(56,222,201,.5); }
.source-type-row { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 8px; margin-bottom: 9px; color: var(--muted); font-size: .68rem; }
.source-type-row select { min-width: 0; height: 32px; padding: 0 7px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 7px; font: .68rem ui-monospace, monospace; }
.source-config[hidden] { display: none !important; }
.source-config-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.source-config-head strong { font-size: .72rem; }.source-config-head span { color: var(--muted); font-size: .58rem; }
.live-source { margin-top: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.live-source-head, .serial-actions, .live-status { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.live-source-head > div { display: flex; align-items: center; gap: 7px; }
.live-source-head strong { font-size: .72rem; }
.live-source-head span { padding: 2px 6px; border-radius: 999px; background: rgba(56,222,201,.09); color: var(--muted); font-size: .58rem; }
.live-web-hint { margin-top: 7px; color: var(--muted); font-size: .62rem; line-height: 1.45; }
.serial-controls { margin-top: 8px; }
.serial-port-row { display: grid; grid-template-columns: 38px minmax(0,1fr); align-items: center; gap: 5px; color: var(--muted); font-size: .62rem; }
.websocket-url-row { display: grid; grid-template-columns: 52px minmax(0,1fr); align-items: center; gap: 5px; margin-top: 8px; color: var(--muted); font-size: .62rem; }
.websocket-url-row input { width: 100%; min-width: 0; height: 28px; padding: 0 7px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font: .62rem ui-monospace, monospace; }
.serial-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; margin-top: 6px; }
.serial-grid label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: .58rem; }
.serial-grid input, .serial-grid select, .serial-port-row select { width: 100%; min-width: 0; height: 28px; padding: 0 6px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.serial-actions { justify-content: flex-start; margin-top: 7px; }
.serial-actions .btn { height: 28px; padding: 0 9px; font-size: .62rem; }
.live-status { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line); color: var(--muted); font-size: .58rem; }
.live-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live-status span { flex: 1; }
.live-status code { font-size: .58rem; }
.live-status.connected i { background: var(--cyan); box-shadow: 0 0 0 3px rgba(56,222,201,.12); }
.live-status.error i { background: #ff6b6b; }
.field-label { display: block; margin-bottom: 7px; color: #a7bbc2; font-size: .75rem; }
textarea, .expression-row input { width: 100%; color: #dcebed; background: #081218; border: 1px solid var(--line-strong); outline: none; border-radius: 8px; }
textarea { padding: 11px; resize: vertical; min-height: 88px; font: .75rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea:focus, .expression-row input:focus { border-color: rgba(56,222,201,.56); box-shadow: 0 0 0 3px rgba(56,222,201,.07); }
.format-hints { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
code { color: #8de9dd; background: rgba(56,222,201,.08); border: 1px solid rgba(56,222,201,.13); border-radius: 4px; padding: 2px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.format-hints code { font-size: .66rem; }
.inline-message { margin-top: 10px; font-size: .7rem; }
.inline-message.success { color: var(--cyan); }.inline-message.error { color: var(--red); }
.prefix-section { margin-bottom: 13px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.prefix-section-head { padding: 0 4px; cursor: default; }
.prefix-section-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prefix-section-body { padding-top: 5px; }
.subsection-head { min-height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #a9c0c5; font-size: .68rem; }
.subsection-head small { color: #59717a; font-size: .6rem; }
.print-head { margin-bottom: 6px; }
.prefix-list { display: grid; gap: 7px; }
.prefix-card { border: 1px solid var(--line); border-radius: 8px; background: rgba(4,11,15,.25); }
.prefix-card.active-prefix { border-color: rgba(56,222,201,.38); box-shadow: inset 2px 0 0 var(--cyan); }
.prefix-card summary { min-height: 36px; padding: 0 9px; position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; color: #bdd0d4; cursor: pointer; font-size: .69rem; list-style: none; }
.prefix-card summary::-webkit-details-marker { display: none; }
.prefix-title-text { min-width: 0; overflow: hidden; font: 650 .69rem ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.prefix-title-editor { min-width: 0; width: 100%; padding: 3px 5px; color: #bdd0d4; background: #081218; border: 1px solid rgba(56,222,201,.48); border-radius: 5px; outline: 0; font: 650 .69rem ui-monospace, SFMono-Regular, Menlo, monospace; box-shadow: 0 0 0 3px rgba(56,222,201,.07); }
.prefix-card.editing-title .prefix-title-text { display: none; }
.prefix-card summary code { color: #6f8790; background: transparent; border: 0; padding: 0; font-size: .58rem; }
.prefix-card[open] summary { border-bottom: 1px solid var(--line); }
.prefix-details { padding: 9px; display: grid; gap: 8px; }
.prefix-actions-row, .prefix-none-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; }
.prefix-activate, .prefix-none, .prefix-apply-all, .prefix-none-all { min-height: 30px; padding: 0 9px; color: #8ea4ab; background: rgba(255,255,255,.018); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: .65rem; text-align: left; }
.prefix-activate:hover, .prefix-none:hover, .prefix-apply-all:hover, .prefix-none-all:hover { color: #dffffa; border-color: rgba(56,222,201,.35); }
.prefix-activate.active, .prefix-none.active { color: var(--cyan); background: var(--cyan-soft); border-color: rgba(56,222,201,.32); cursor: default; }
.prefix-none-row { margin-top: 7px; }
.prefix-none { width: 100%; }
.prefix-delete { justify-self: end; padding: 4px 7px; color: #8d7478; background: transparent; border: 0; cursor: pointer; font-size: .61rem; }
.prefix-delete:hover { color: var(--red); }
.compact-add { min-height: 30px; margin-top: 7px; }
.rule-list { display: grid; gap: 9px; }
.rule-card { padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(4,11,15,.3); }
.rule-card.selected { border-color: rgba(56,222,201,.48); background: linear-gradient(135deg, rgba(56,222,201,.09), rgba(4,11,15,.3)); box-shadow: inset 3px 0 0 var(--cyan), 0 0 0 2px rgba(56,222,201,.035); }
.rule-card-head { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 7px; cursor: pointer; list-style: none; }
.rule-card-head::-webkit-details-marker { display: none; }
.rule-card-head input[type="checkbox"] { accent-color: var(--cyan); }
.rule-title-control { min-width: 0; position: relative; }
.rule-toggle { width: 100%; min-width: 0; min-height: 30px; padding: 0 4px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; color: #cfe0e3; background: transparent; border: 0; cursor: pointer; text-align: left; }
.rule-toggle code { color: #6f8790; background: transparent; border: 0; padding: 0; font-size: .6rem; white-space: nowrap; }
.rule-title { overflow: hidden; font-size: .73rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.rule-title-editor:not([hidden]) { width: 100%; height: 30px; padding: 0 6px; position: absolute; inset: 0; z-index: 2; display: block; color: #cfe0e3; background: #081218; border: 1px solid rgba(56,222,201,.48); border-radius: 6px; outline: 0; font: 650 .73rem ui-monospace, SFMono-Regular, Menlo, monospace; box-shadow: 0 0 0 3px rgba(56,222,201,.07); }
.rule-details { display: none; padding: 8px 1px 2px; border-top: 1px solid var(--line); }
.rule-card[open] .rule-details { display: grid; gap: 7px; margin-top: 6px; }
.rule-detail-label { display: grid; gap: 5px; color: #6f8790; font-size: .62rem; }
.rule-detail-label small { color: #516a73; font-size: .58rem; }
.rule-detail-label input, .rule-detail-label select { width: 100%; min-height: 32px; padding: 0 8px; color: #cfe0e3; background: #081218; border: 1px solid var(--line-strong); border-radius: 7px; outline: 0; font: .68rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.rule-detail-label input:focus, .rule-detail-label select:focus { border-color: rgba(56,222,201,.56); box-shadow: 0 0 0 3px rgba(56,222,201,.07); }
.rule-name { width: 100%; min-width: 0; color: #cfe0e3; background: transparent; border: 0; border-bottom: 1px solid transparent; outline: 0; font-size: .73rem; font-weight: 650; }
.rule-name:focus { border-bottom-color: rgba(56,222,201,.45); }
.rule-delete { width: 25px; height: 25px; border: 0; border-radius: 6px; color: #70858d; background: transparent; cursor: pointer; }
.rule-delete:hover { color: var(--red); background: rgba(255,107,107,.08); }
.rule-actions { display: flex; align-items: center; }
.rule-visibility { width: 25px; height: 25px; padding: 0; border: 0; border-radius: 6px; color: #5f767e; background: transparent; cursor: pointer; font-size: .78rem; }
.rule-visibility.active { color: var(--cyan); }
.rule-visibility:hover:not(:disabled) { background: var(--cyan-soft); }
.rule-visibility:disabled { opacity: .25; cursor: default; }
.rule-move { width: 23px; height: 25px; padding: 0; border: 0; border-radius: 6px; color: #70858d; background: transparent; cursor: pointer; font-size: .68rem; }
.rule-move:hover { color: var(--cyan); background: var(--cyan-soft); }
.rule-move:disabled { opacity: .25; cursor: default; }
.rule-format { min-height: 70px; padding: 9px; font-size: .69rem; }
.rule-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #617983; font-size: .62rem; }
.rule-meta code { font-size: .6rem; }
.rule-config-disclosure { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.rule-config-summary { min-height: 31px; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; list-style: none; color: #a9c0c5; cursor: pointer; font-size: .66rem; }
.rule-config-summary::-webkit-details-marker { display: none; }
.rule-config-summary:hover { background: var(--cyan-soft); }
.rule-config-summary small { color: #617983; font-size: .58rem; }
.rule-config-disclosure[open] .rule-config-summary { border-bottom: 1px solid var(--line); }
.rule-config-body { padding: 8px; display: grid; gap: 7px; }
.rule-inline-fields, .prefix-inline-fields { margin-top: 3px; padding-top: 9px; border-top: 1px solid var(--line); }
.inline-fields-head { min-height: 25px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #a9c0c5; font-size: .67rem; }
.inline-fields-head small { color: #617983; font-size: .59rem; }
.inline-field-list { display: grid; gap: 4px; }
.add-rule-button { width: 100%; min-height: 34px; margin-top: 9px; border: 1px dashed var(--line-strong); border-radius: 8px; background: rgba(255,255,255,.018); color: #8fa5ad; cursor: pointer; font-size: .72rem; }
.add-rule-button:hover { color: var(--cyan); border-color: rgba(56,222,201,.4); background: var(--cyan-soft); }
.field-list { display: grid; gap: 6px; }
.field-scope { min-height: 31px; margin: -4px 0 8px; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #6f8790; background: rgba(4,11,15,.28); border: 1px solid var(--line); border-radius: 7px; font-size: .66rem; }
.field-scope strong { color: #a9c0c5; font-weight: 650; }
.field-scope button { padding: 3px 7px; color: var(--cyan); background: var(--cyan-soft); border: 0; border-radius: 5px; cursor: pointer; font-size: .63rem; }
.field-scope button:hover { background: rgba(56,222,201,.2); }
.field-item { min-height: 34px; padding: 2px 4px; display: grid; gap: 4px; border-radius: 7px; border: 1px solid transparent; }
.field-item:hover { background: rgba(255,255,255,.025); border-color: var(--line); }
.field-item.expanded { padding-bottom: 7px; background: rgba(255,255,255,.025); border-color: var(--line); }
.field-main { min-width: 0; display: flex; align-items: center; gap: 3px; }
.field-toggle { min-width: 0; min-height: 29px; padding: 0 4px; display: grid; grid-template-columns: 9px minmax(0,1fr) auto 15px; align-items: center; gap: 8px; flex: 1; color: #cfe0e3; background: transparent; border: 0; border-radius: 5px; cursor: pointer; text-align: left; }
.field-toggle:hover { background: var(--cyan-soft); }
.field-chevron { color: #6f8790; font-size: .8rem; text-align: center; transition: transform .16s ease; }
.field-item.expanded .field-chevron { transform: rotate(180deg); }
.field-options { display: none; padding: 6px 4px 0; gap: 6px; border-top: 1px solid var(--line); }
.field-item.expanded .field-options { display: grid; }
.field-subsection { min-width: 0; padding: 6px; display: grid; gap: 5px; background: rgba(7,17,23,.44); border: 1px solid rgba(94,126,136,.18); border-radius: 7px; }
.field-subtitle { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; line-height: 1.25; }
.field-subtitle strong { color: #bad0d5; font-size: .63rem; letter-spacing: .04em; }
.field-subtitle small { min-width: 0; color: #627b84; font-size: .55rem; white-space: normal; overflow-wrap: anywhere; }
.field-add { min-height: 26px; padding: 0 9px; justify-self: end; color: var(--cyan); background: var(--cyan-soft); border: 1px solid rgba(56,222,201,.22); border-radius: 6px; cursor: pointer; font-size: .62rem; font-weight: 700; }
.field-add:hover { background: rgba(56,222,201,.2); border-color: rgba(56,222,201,.45); }
.field-add-row { display: flex; align-items: end; justify-content: flex-end; gap: 7px; }
.field-plot-mode { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .58rem; }
.field-plot-mode select { min-width: 74px; height: 26px; padding: 0 22px 0 7px; font-size: .6rem; }
.field-remove { width: 25px; height: 25px; padding: 0; color: #70858d; background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: .88rem; }
.field-remove:hover { color: var(--red); background: rgba(255,107,107,.08); }
.field-color { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.field-name { font: .76rem ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; }
.field-type { font-size: .62rem; text-transform: uppercase; color: var(--muted); padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; }
.field-condition { display: grid; grid-template-columns: minmax(110px, 1fr) 46px 62px; align-items: center; gap: 5px; color: #5f767e; font-size: .59rem; }
.field-condition select, .field-condition input { min-width: 0; height: 25px; padding: 0 5px; color: #9fb3b9; background: #081218; border: 1px solid var(--line); border-radius: 5px; outline: 0; font: .61rem ui-monospace, monospace; }
.field-condition input:disabled { opacity: .36; }
.field-aggregate { display: grid; grid-template-columns: minmax(110px, 1fr) 72px; align-items: center; gap: 5px; }
.field-aggregate select, .field-aggregate input { min-width: 0; height: 25px; padding: 0 5px; color: #9fb3b9; background: #081218; border: 1px solid var(--line); border-radius: 5px; outline: 0; font: .59rem ui-monospace, monospace; }
.field-aggregate select:disabled, .field-aggregate input:disabled { opacity: .36; }
.field-aggregate label { min-width: 0; position: relative; }
.field-aggregate label input { width: 100%; padding-right: 22px; }
.field-aggregate label span { position: absolute; right: 6px; top: 6px; color: #607984; font: .56rem ui-monospace, monospace; pointer-events: none; }
.field-aggregate-keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.field-aggregate-keys label { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 3px; color: #718991; font: .57rem ui-monospace, monospace; }
.field-aggregate-keys select { min-width: 0; width: 100%; height: 25px; padding: 0 5px; color: #9fb3b9; background: #081218; border: 1px solid var(--line); border-radius: 5px; outline: 0; font: .57rem ui-monospace, monospace; }
.field-aggregate-keys select:disabled { opacity: .36; }
.field-aggregate-members { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px; color: #718991; font: .57rem ui-monospace, monospace; }
.field-aggregate-members span { white-space: normal; line-height: 1.2; }
.field-aggregate-members input { min-width: 0; width: 100%; height: 25px; padding: 0 6px; color: #9fb3b9; background: #081218; border: 1px solid var(--line); border-radius: 5px; outline: 0; font: .59rem ui-monospace, monospace; }
.field-aggregate-members input:disabled { opacity: .36; }
.derived-signal-list { display: grid; gap: 5px; margin-top: 12px; }
.derived-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.fields-section .derived-box { margin-top: 0; padding-top: 0; border-top: 0; }
.calculated-section { padding-block: 0; }
.calculated-details { padding-block: 13px; }
.calculated-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; }
.calculated-summary::-webkit-details-marker { display: none; }
.calculated-summary span { display: grid; gap: 3px; }
.calculated-summary b { color: var(--cyan); font: 700 .58rem ui-monospace, monospace; letter-spacing: .16em; }
.calculated-summary strong { color: var(--text); font-size: 1rem; }
.calculated-summary small { color: var(--muted); font-size: .64rem; white-space: nowrap; }
.calculated-body { padding-top: 12px; }
.expression-row { display: grid; grid-template-columns: 1fr 34px; gap: 7px; }
.expression-row input { height: 34px; padding: 0 9px; font: .72rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.square-button { border-radius: 8px; background: var(--cyan-soft); border: 1px solid rgba(56,222,201,.25); color: var(--cyan); font-size: 1.2rem; }
.square-button:hover { background: rgba(56,222,201,.2); }
.microcopy { display: block; margin-top: 6px; color: #627983; font-size: .66rem; }

.main-stage { min-width: 0; height: 100%; padding: 8px clamp(14px, 1.8vw, 26px) 14px; display: flex; flex-direction: column; overflow: hidden; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.metric { min-width: 0; }
.metric span { display: block; margin-bottom: 3px; color: var(--muted); font-size: .67rem; }
.metric strong { font: 650 .9rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.metric.accent strong { color: var(--cyan); }
.analysis-view-switch { width: max-content; margin: 0; flex: none; }
.analysis-view-switch button { min-width: 64px; padding: 5px 10px; font-size: .73rem; }
.chart-card, .data-card { min-height: 0; flex: 1; border-radius: var(--radius); overflow: hidden; }
.chart-card, .chart-dialog {
  --chart-surface: #0d1d25;
  --chart-background: #081218;
  --chart-border: #39525e;
  --chart-border-soft: rgba(157,190,202,.12);
  --chart-text: #d8e8ec;
  --chart-muted: #78939e;
  --chart-accent: #38dec9;
  --chart-accent-soft: rgba(56,222,201,.12);
  --chart-hover: rgba(157,190,202,.06);
  --chart-shadow: 0 2px 8px rgba(0, 0, 0, .08), 0 12px 28px rgba(0, 0, 0, .09);
  color: var(--chart-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.chart-card { container: chart / inline-size; display: flex; flex-direction: column; background: var(--chart-surface); border-color: var(--chart-border); box-shadow: var(--chart-shadow); }
.chart-toolbar { min-height: 44px; padding: 4px 12px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 1fr); align-items: center; gap: 6px 10px; border-bottom: 1px solid var(--chart-border-soft); }
.toolbar-groups { min-width: 0; display: flex; align-items: center; gap: 8px 14px; }
.toolbar-groups .segmented { flex-shrink: 0; }
.sync-hint { min-width: 0; color: var(--chart-muted); font-size: .63rem; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-hint b { color: var(--chart-text); font-weight: 500; }
.chart-actions { min-width: 0; grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
@container chart (min-width: 1250px) {
  .chart-toolbar { grid-template-columns: 520px minmax(240px, 1fr) max-content; }
  .chart-actions { grid-column: auto; }
}
@container chart (max-width: 560px) {
  .chart-toolbar { grid-template-columns: minmax(0, 1fr); }
  .range-row { min-width: 0; }
}
.chart-card .chart-actions .btn.ghost,
.chart-dialog .chart-dialog-actions .btn.ghost { min-height: 32px; padding: 0 11px; color: var(--chart-text); background: var(--chart-surface); border: 1px solid var(--chart-border); border-radius: 7px; box-shadow: none; font-size: 12px; font-weight: 500; transition: background .15s, border-color .15s; }
.chart-card .chart-actions .btn.ghost:hover,
.chart-dialog .chart-dialog-actions .btn.ghost:hover { color: var(--chart-accent); border-color: var(--chart-accent); background: var(--chart-hover); }
.chart-card .chart-actions .btn.active,
.chart-dialog .chart-dialog-actions .btn.active { color: var(--chart-accent); border-color: var(--chart-accent); background: var(--chart-accent-soft); }
.segmented, .tabs { display: flex; background: rgba(4,11,15,.55); border: 1px solid var(--line); padding: 3px; border-radius: 8px; }
.segmented button, .tabs button { min-height: 27px; padding: 0 10px; color: var(--muted); background: transparent; border-radius: 5px; font-size: .7rem; }
.segmented button.active, .tabs button.active { color: #dffffa; background: rgba(56,222,201,.12); box-shadow: inset 0 0 0 1px rgba(56,222,201,.12); }
.chart-toolbar .segmented { background: var(--chart-background); border-color: var(--chart-border-soft); }
.chart-toolbar .segmented button { min-height: 28px; padding: 0 12px; color: var(--chart-muted); font-size: 12px; font-weight: 500; }
.chart-toolbar .segmented button.active { color: var(--chart-accent); background: var(--chart-accent-soft); box-shadow: none; }
.view-compose { min-height: 40px; padding: 5px 10px 5px 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; border-bottom: 1px solid var(--chart-border-soft); }
.legend { min-width: 0; flex: 1; display: flex; align-items: center; flex-wrap: nowrap; gap: 7px; overflow-x: auto; scrollbar-width: thin; }
.legend-entry { min-width: 0; max-width: 100%; flex: none; display: inline-flex; align-items: stretch; overflow: hidden; border: 1px solid transparent; border-radius: 6px; background: var(--chart-hover); }
.legend-item { min-width: 0; min-height: 29px; max-width: 100%; padding: 0 9px; flex: 1; display: flex; align-items: center; gap: 7px; text-align: left; color: var(--chart-text); background: transparent; border: 0; border-radius: 0; cursor: pointer; font: .7rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.legend-name { min-width: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-item:hover { background: var(--chart-hover); }
.legend-item.selected { color: var(--chart-accent); background: var(--chart-accent-soft); }
.legend-details { flex: none; padding: 6px 14px; border-bottom: 1px solid var(--chart-border-soft); color: var(--chart-muted); background: var(--chart-hover); overflow-wrap: anywhere; font: .68rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.legend-line { flex: none; width: 17px; height: 2px; border-radius: 2px; background: var(--series-color); box-shadow: none; }
.legend-line.points { width: 7px; height: 7px; margin: 0 5px; border-radius: 50%; }
.legend-mode { flex: none; width: 27px; padding: 0; color: var(--chart-muted); background: transparent; border: 0; border-left: 1px solid var(--chart-border-soft); cursor: pointer; font: .62rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.legend-mode:hover { color: var(--chart-accent); background: var(--chart-hover); }
.legend-remove { flex: none; width: 25px; padding: 0; color: var(--chart-muted); background: transparent; border: 0; border-left: 1px solid var(--chart-border-soft); cursor: pointer; font-size: .8rem; }
.legend-remove:hover { color: var(--red); background: rgba(239,68,68,.08); }
.chart-card button:focus-visible,
.chart-dialog button:focus-visible { outline: 2px solid var(--chart-accent); outline-offset: 2px; }
.view-compose-actions { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.view-compose-actions span { color: var(--chart-muted); font-size: .62rem; }
.view-compose-actions button { min-height: 28px; padding: 0 8px; color: var(--chart-text); background: var(--chart-surface); border: 1px solid var(--chart-border); border-radius: 6px; cursor: pointer; font-size: .64rem; }
.view-compose-actions button:hover:not(:disabled) { color: var(--chart-accent); border-color: var(--chart-accent); background: var(--chart-hover); }
.view-compose-actions button:disabled { opacity: .5; cursor: default; }
.chart-wrap { min-width: 0; min-height: 0; flex: 1; position: relative; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: linear-gradient(180deg, var(--chart-background), var(--chart-surface)); scrollbar-width: thin; scrollbar-color: var(--chart-border) var(--chart-background); }
.chart-wrap::-webkit-scrollbar { width: 10px; }
.chart-wrap::-webkit-scrollbar-track { background: var(--chart-background); }
.chart-wrap::-webkit-scrollbar-thumb { border: 3px solid var(--chart-background); border-radius: 8px; background: var(--chart-border); }
.chart-wrap::-webkit-scrollbar-thumb:hover { background: var(--chart-muted); }
#chartCanvas { width: 100%; height: auto; display: block; cursor: grab; touch-action: none; }
#chartCanvas.dragging { cursor: grabbing; }
#chartCanvas.crop-mode { cursor: crosshair; }
#chartCanvas.zoom-select-mode,
#chartCanvas.zoom-selecting { cursor: crosshair; }
#chartCanvas.title-hover { cursor: pointer; }
.axis-label { position: absolute; color: var(--chart-muted); font: .6rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; pointer-events: none; }
.y-label { left: 13px; top: 50%; transform: rotate(-90deg) translateX(-50%); transform-origin: left top; }
.x-label { right: 20px; bottom: 11px; }
.chart-tooltip { position: absolute; z-index: 4; min-width: 180px; max-width: min(360px, calc(100% - 16px)); padding: 12px 14px; border: 1px solid var(--chart-border); background: var(--chart-surface); border-radius: 10px; box-shadow: 0 3px 8px rgba(15,23,42,.06), 0 12px 28px rgba(15,23,42,.15); color: var(--chart-text); font: 12px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; pointer-events: none; }
.tooltip-point-name { max-width: 100%; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; line-height: 1.45; }
.tooltip-point-value { margin: 5px 0 8px; color: var(--chart-text); font-size: 23px; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; overflow-wrap: anywhere; }
.tooltip-point-value + .tooltip-point-meta { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--chart-border-soft); }
.tooltip-point-meta { color: var(--chart-muted); font-size: 12px; overflow-wrap: anywhere; }
.tooltip-point-label { margin-top: 7px; color: var(--chart-muted); font-size: 11px; }
.tooltip-point-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--chart-muted); font-size: 12px; }
.tooltip-point-row > :last-child { min-width: 0; color: var(--chart-text); text-align: right; overflow-wrap: anywhere; }
.crop-editor { padding: 8px 14px 7px; border-top: 1px solid rgba(56,222,201,.2); background: linear-gradient(180deg, rgba(56,222,201,.045), rgba(4,11,15,.18)); }
.crop-editor[hidden] { display: none; }
.crop-editor-head, .crop-editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.crop-editor-head > div:first-child { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.crop-editor-head strong { color: var(--text); font-size: .68rem; }
.crop-editor-head span, .crop-editor-foot { color: var(--muted); font-size: .56rem; }
.crop-editor-head > div:last-child { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.crop-editor-head button { min-height: 24px; padding: 0 7px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-size: .58rem; }
.crop-editor-head button:hover, .crop-editor-head button.active { color: var(--cyan); border-color: rgba(56,222,201,.42); background: var(--cyan-soft); }
.crop-trim-row { display: grid; grid-template-columns: 145px minmax(120px,1fr) 145px; align-items: center; gap: 10px; margin-top: 7px; }
.crop-timecode { min-width: 0; display: flex; align-items: baseline; gap: 7px; font: .59rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.crop-timecode span { color: var(--muted); }
.crop-timecode strong { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.crop-timecode.end { justify-content: flex-end; }
.crop-timeline { position: relative; height: 30px; user-select: none; touch-action: none; cursor: pointer; }
.crop-track { position: absolute; inset: 8px 0; border: 1px solid var(--line-strong); border-radius: 5px; background: repeating-linear-gradient(90deg, rgba(56,222,201,.08) 0 1px, transparent 1px 10%), var(--panel-2); }
.crop-shade { position: absolute; top: 8px; bottom: 8px; z-index: 1; background: rgba(1,7,10,.58); pointer-events: none; }
.crop-shade-left { left: 0; border-radius: 5px 0 0 5px; }
.crop-shade-right { right: 0; border-radius: 0 5px 5px 0; }
.crop-selection { position: absolute; top: 4px; bottom: 4px; z-index: 2; min-width: 12px; border: 1px solid rgba(56,222,201,.75); border-radius: 5px; background: rgba(56,222,201,.14); box-shadow: inset 0 0 12px rgba(56,222,201,.08); cursor: grab; }
.crop-selection.dragging { cursor: grabbing; }
.crop-selection-grip { position: absolute; inset: 0 14px; display: flex; align-items: center; justify-content: center; color: rgba(56,222,201,.7); font-size: .62rem; letter-spacing: .12em; pointer-events: none; }
.crop-handle { position: absolute; top: -3px; bottom: -3px; width: 13px; padding: 0; z-index: 3; border: 0; border-radius: 4px; background: var(--cyan); box-shadow: 0 0 10px rgba(56,222,201,.35); cursor: ew-resize; }
.crop-handle.start { left: -7px; }
.crop-handle.end { right: -7px; }
.crop-handle i { position: absolute; left: 5px; top: 7px; bottom: 7px; width: 2px; border-left: 1px solid rgba(4,20,22,.6); border-right: 1px solid rgba(255,255,255,.5); }
.crop-editor-foot { margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.range-row { min-width: 240px; min-height: 28px; display: grid; grid-template-columns: 28px minmax(120px, 1fr) 28px; align-items: center; gap: 0 8px; color: var(--chart-muted); font: 10px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
.range-labels { display: none; }
.range-labels span { min-width: 0; max-width: 50%; }
.range-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.range-row span:last-child { text-align: right; }
.zoom-step { width: 28px; height: 24px; padding: 0; color: var(--chart-text); background: var(--chart-surface); border: 1px solid var(--chart-border); border-radius: 5px; font: 16px/1 system-ui, sans-serif; cursor: pointer; }
.zoom-step:hover:not(:disabled) { color: var(--chart-accent); border-color: var(--chart-accent); background: var(--chart-hover); }
.zoom-step:disabled { opacity: .4; cursor: default; }
input[type="range"] { accent-color: var(--cyan); }
.range-row input[type="range"] { min-width: 0; width: 100%; margin: 0; accent-color: var(--chart-accent); }
.chart-help { margin-top: 0; padding: 2px 16px 10px; color: var(--chart-muted); text-align: center; font-size: 12px; line-height: 1.5; }
.chart-help.selected { color: var(--chart-accent); }

.data-card { display: flex; flex-direction: column; }
.data-head { min-height: 61px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.data-head h2 { margin-top: 4px; }
.tabs button span { display: inline-flex; min-width: 17px; height: 17px; align-items: center; justify-content: center; margin-left: 4px; background: rgba(255,255,255,.06); border-radius: 8px; font-size: .6rem; }
.table-wrap { min-height: 0; flex: 1; overflow: auto; }
.table-navigator { position: sticky; left: 0; min-width: min(100%, 780px); min-height: 45px; padding: 7px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: rgba(7,17,22,.96); }
.table-page-actions, .line-jump, .line-jump label { display: flex; align-items: center; gap: 7px; }
.table-navigator button { min-height: 28px; padding: 0 9px; color: #9fb3b9; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 6px; font-size: .66rem; }
.table-navigator button:disabled { opacity: .35; }
.table-page-actions span, .line-jump label { color: #6e8790; font-size: .65rem; }
.line-jump input { width: 120px; min-height: 28px; padding: 0 8px; color: #d5e5e8; background: #081319; border: 1px solid var(--line); border-radius: 6px; font: .68rem ui-monospace, monospace; }
.load-more-log { position: sticky; left: 0; width: 100%; min-width: min(100%, 780px); min-height: 34px; color: #79ddd0; background: rgba(56,222,201,.045); border: 0; border-bottom: 1px solid rgba(56,222,201,.14); font: 650 .67rem ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer; }
.load-more-log:hover { background: rgba(56,222,201,.09); color: #bafff7; }
.selected-log { position: sticky; left: 0; min-width: min(100%, 780px); padding: 9px 13px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; border-bottom: 1px solid rgba(56,222,201,.2); background: rgba(56,222,201,.055); }
.selected-log span { color: var(--cyan); white-space: nowrap; font-size: .67rem; }
.selected-log code { overflow: hidden; color: #b9cccf; text-overflow: ellipsis; white-space: nowrap; font-size: .68rem; }
tbody tr[data-row-index] { cursor: pointer; }
tbody tr.selected-row td { color: #eafffc; background: rgba(56,222,201,.11); box-shadow: inset 0 1px rgba(56,222,201,.16), inset 0 -1px rgba(56,222,201,.16); }
table { width: 100%; border-collapse: collapse; font-size: .74rem; }
th { position: sticky; top: 0; z-index: 2; text-align: left; color: #7f969f; background: #0d1a21; font: 650 .65rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
th, td { height: 38px; padding: 0 14px; border-bottom: 1px solid rgba(157,190,202,.08); white-space: nowrap; }
td { color: #b8c9ce; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
tbody tr:hover td { background: rgba(56,222,201,.025); color: #eafffc; }
td:first-child, th:first-child { color: #58727c; width: 48px; }
.raw-view { min-height: 0; flex: 1; overflow: auto; background: rgba(3,10,13,.34); }
.raw-navigator { position: sticky; top: 0; z-index: 3; min-height: 42px; padding: 0 13px; display: flex; align-items: center; justify-content: space-between; color: #789099; background: rgba(7,17,22,.97); border-bottom: 1px solid var(--line); font-size: .66rem; }
.raw-navigator small { color: #55707b; font-size: .6rem; }
.raw-line { width: 100%; min-width: max-content; min-height: 29px; padding: 0; display: grid; grid-template-columns: 70px minmax(700px, 1fr); align-items: center; color: #9cb1b7; background: transparent; border: 0; border-bottom: 1px solid rgba(157,190,202,.045); cursor: pointer; text-align: left; font: .7rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.raw-line:hover { color: #e6f3f4; background: rgba(56,222,201,.035); }
.raw-line.selected { color: #eafffc; background: rgba(56,222,201,.11); box-shadow: inset 3px 0 0 var(--cyan); }
.raw-line > span { padding-right: 12px; color: #506b75; text-align: right; user-select: none; }
.raw-line code { padding: 0 14px; color: inherit; background: transparent; border: 0; white-space: pre; }
.empty-view { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: .76rem; }
.empty-view strong { color: #bcd0d4; font-size: .84rem; }.empty-icon { color: var(--cyan); font-size: 1.4rem; }

dialog { width: min(480px, calc(100vw - 32px)); color: var(--text); background: #0d1a21; border: 1px solid var(--line-strong); border-radius: 13px; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,5,8,.7); backdrop-filter: blur(5px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
dialog p { color: #9eb1b7; font-size: .82rem; line-height: 1.6; }
.chart-dialog { width: calc(100vw - 32px); max-width: none; height: calc(100vh - 32px); max-height: none; margin: 16px; padding: 16px; overflow: hidden; color: var(--chart-text); background: var(--chart-surface); border-color: var(--chart-border); }
.auto-detect-dialog { width: min(820px, calc(100vw - 32px)); max-width: none; max-height: min(840px, calc(100vh - 32px)); padding: 16px; overflow: hidden; }
.auto-detect-dialog[open] { display: flex; flex-direction: column; }
.auto-detect-dialog .dialog-head { flex: none; margin-bottom: 8px; }
.auto-detect-intro { flex: none; margin-bottom: 10px; }
.auto-detect-intro code { color: var(--cyan); }
.auto-detect-summary { flex: none; min-height: 34px; padding: 8px 10px; color: #9eb5ba; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 7px; font-size: .7rem; line-height: 1.45; }
.auto-detect-prefix { flex: none; margin-top: 9px; }
.auto-detect-search { flex: none; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--text); font-size: .75rem; }
.auto-detect-search input { flex: 1; min-width: 180px; padding: 8px 10px; color: var(--text); background: var(--bg-elevated); border: 1px solid var(--line-strong); border-radius: 6px; }
.auto-detect-search input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.auto-detect-search-status { flex: none; margin-top: 6px; color: var(--muted); font-size: .7rem; }
.auto-detect-keyword-note { flex: none; margin: 6px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.auto-detect-prefix-card { padding: 10px 11px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 9px; align-items: start; color: #a9c0c5; background: var(--cyan-soft); border: 1px solid rgba(56,222,201,.25); border-radius: 8px; font-size: .7rem; }
.auto-detect-prefix-card input { margin-top: 3px; accent-color: var(--cyan); }
.auto-detect-prefix-card strong { color: var(--text); }
.auto-detect-prefix-card code { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
.auto-detect-prefix-card small { grid-column: 2; color: var(--muted); }
.auto-detect-results { min-height: 120px; margin-top: 9px; padding-right: 3px; display: grid; gap: 8px; overflow-y: auto; }
.auto-detect-empty { padding: 32px 15px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 8px; text-align: center; font-size: .74rem; }
.auto-candidate { padding: 10px 11px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px 9px; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: rgba(4,11,15,.28); }
.auto-candidate > input[type="checkbox"] { accent-color: var(--cyan); }
.auto-candidate-name { min-width: 0; height: 30px; padding: 0 8px; color: var(--text); background: #081218; border: 1px solid var(--line-strong); border-radius: 6px; outline: 0; font: 650 .72rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.auto-candidate-name:focus { border-color: rgba(56,222,201,.56); }
.auto-candidate-score { color: var(--cyan); font-size: .64rem; white-space: nowrap; }
.auto-candidate-format, .auto-candidate-fields, .auto-candidate-examples { grid-column: 2 / -1; min-width: 0; }
.auto-candidate-format { padding: 7px 8px; overflow-wrap: anywhere; font-size: .67rem; line-height: 1.5; }
.auto-candidate-fields { color: #789098; font-size: .63rem; }
.rule-tail-option { display: flex; align-items: flex-start; gap: 7px; color: var(--text); font-size: .72rem; }
.rule-tail-option input, .auto-candidate-tail input { accent-color: var(--cyan); margin: 2px 0 0; }
.rule-tail-option small { display: block; margin-top: 3px; color: var(--muted); font-size: .64rem; line-height: 1.5; }
.auto-candidate-tail { grid-column: 2 / -1; display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: .65rem; }
.auto-candidate-variants { grid-column: 2 / -1; min-width: 0; display: grid; gap: 5px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--cyan-soft); color: var(--muted); font-size: .65rem; line-height: 1.5; }
.auto-candidate-variants strong { color: var(--text); }
.auto-candidate-variants code { overflow-wrap: anywhere; }
.auto-candidate-variants button { justify-self: start; white-space: normal; }
.auto-candidate-examples { padding-top: 4px; display: grid; gap: 3px; border-top: 1px solid var(--line); color: #6f8790; font: .6rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.auto-candidate-examples span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-detect-footer { flex: none; padding-top: 11px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.history-dialog { width: min(680px, calc(100vw - 32px)); max-width: none; max-height: min(720px, calc(100vh - 32px)); padding: 16px; overflow: hidden; }
.history-dialog[open] { display: flex; flex-direction: column; }
.history-dialog .dialog-head { flex: none; margin-bottom: 8px; }
.history-list { min-height: 110px; margin-top: 10px; padding-right: 3px; display: grid; gap: 8px; overflow-y: auto; }
.history-empty { padding: 34px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 8px; text-align: center; font-size: .74rem; }
.history-item { padding: 10px 11px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: rgba(4,11,15,.28); }
.history-item strong { min-width: 0; overflow: hidden; color: var(--text); font: 650 .73rem ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.history-item small { color: var(--muted); font-size: .62rem; }
.history-actions { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 6px; }
.history-actions button { min-height: 29px; padding: 0 9px; color: #8fa5ad; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: .64rem; }
.history-actions .history-restore:hover { color: var(--cyan); border-color: rgba(56,222,201,.4); }
.history-actions .history-delete:hover { color: var(--red); border-color: rgba(255,107,107,.35); }
.history-footer { flex: none; padding-top: 10px; display: flex; justify-content: flex-end; }
.chart-dialog[open] { display: flex; flex-direction: column; }
.chart-dialog .dialog-head { flex: none; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; }
.chart-dialog .dialog-head .eyebrow { color: var(--chart-muted); font: 600 11px system-ui, sans-serif; letter-spacing: .08em; }
.chart-dialog .dialog-head h2 { margin-top: 4px; color: var(--chart-text); font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.chart-dialog .dialog-head > div:first-child { min-width: 0; }
.chart-dialog .dialog-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.chart-dialog .chart-dialog-actions .icon-button { color: var(--chart-text); border-color: var(--chart-border); background: var(--chart-surface); box-shadow: none; }
.chart-dialog-body { min-width: 0; min-height: 0; flex: 1; display: flex; overflow: hidden; border: 1px solid var(--chart-border); border-radius: 10px; background: var(--chart-background); }
.chart-dialog-body .chart-wrap { width: 100%; height: 100%; }
.chart-dialog-hint { flex: none; padding-top: 10px; color: var(--chart-muted); text-align: center; font-size: 12px; line-height: 1.5; }
.help-grid { display: grid; grid-template-columns: 120px 1fr; gap: 9px 12px; align-items: center; margin: 18px 0; font-size: .78rem; }
.help-dialog { width: min(1040px, calc(100vw - 32px)); max-width: none; height: min(860px, calc(100vh - 32px)); max-height: none; padding: 0; overflow: hidden; }
.help-dialog[open] { display: flex; flex-direction: column; }
.help-dialog-head { flex: none; margin: 0; padding: 16px 18px 13px; border-bottom: 1px solid var(--line); }
.help-dialog-head h2 { margin-top: 2px; }
.help-actions { display: flex; align-items: center; gap: 8px; }
.help-layout { min-height: 0; flex: 1; display: grid; grid-template-columns: 172px minmax(0, 1fr); }
.help-nav { min-height: 0; padding: 14px 10px; overflow-y: auto; border-right: 1px solid var(--line); background: rgba(7,18,24,.55); }
.help-nav a { display: block; padding: 7px 9px; color: var(--muted); border-radius: 6px; font-size: .7rem; text-decoration: none; }
.help-nav a:hover { color: var(--cyan); background: var(--cyan-soft); }
.help-content { min-height: 0; padding: 8px 28px 36px; overflow-y: auto; scroll-behavior: smooth; }
.help-content section { padding: 19px 0 21px; border-bottom: 1px solid var(--line); scroll-margin-top: 8px; }
.help-content section:last-child { border-bottom: 0; }
.help-content h3 { margin-bottom: 9px; color: var(--text); font-size: 1rem; }
.help-content h4 { margin: 15px 0 4px; color: var(--text); font-size: .78rem; }
.help-content p, .help-content li { color: #9eb1b7; font-size: .76rem; line-height: 1.72; }
.help-content p { margin: 7px 0; }
.help-content ul, .help-content ol { display: grid; gap: 4px; margin: 8px 0; padding-left: 20px; }
.help-content code { color: var(--cyan); font: .72rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.help-content pre { margin: 10px 0; padding: 11px 13px; overflow-x: auto; color: #c5d8dc; background: #071219; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; }
.help-content pre code { color: inherit; line-height: 1.65; }
.help-content .help-grid { grid-template-columns: minmax(120px, 180px) 1fr; margin: 11px 0; padding: 11px 13px; background: rgba(7,18,24,.42); border: 1px solid var(--line); border-radius: 8px; }
.help-note { margin: 10px 0 0; padding: 10px 12px; color: #9eb1b7; background: var(--cyan-soft); border-left: 3px solid var(--cyan); border-radius: 5px; font-size: .75rem; line-height: 1.55; }
.help-faq h4 + p { margin-top: 0; }
@media (max-width: 720px) {
  .help-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .help-dialog-head { padding: 12px; }
  .help-layout { grid-template-columns: 1fr; }
  .help-nav { display: flex; gap: 3px; padding: 7px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .help-nav a { flex: none; }
  .help-content { padding: 4px 16px 26px; }
  .help-actions .btn { display: none; }
}
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 14px; background: #e9fffb; color: #09231f; border-radius: 8px; font-size: .78rem; font-weight: 650; opacity: 0; pointer-events: none; transition: .22s ease; box-shadow: 0 12px 35px rgba(0,0,0,.35); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .topbar { gap: 10px; }
  .analysis-navigation { gap: 10px; }
  .top-actions .theme-toggle { min-width: 28px; }
  .top-actions .theme-toggle span:last-child { display: none; }
}
@media (max-width: 720px) {
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .topbar { height: auto; min-height: 44px; padding: 6px 10px; grid-template-columns: minmax(0, 1fr) max-content; gap: 5px 8px; }
  .brand-mark { display: none; }.brand strong { font-size: .8rem; }.brand-name { gap: 5px; }
  .top-actions { grid-column: 2; grid-row: 1; gap: 4px; }.top-actions .btn { padding: 0 6px; font-size: .68rem; }
  .analysis-navigation { grid-column: 1 / -1; grid-row: 2; gap: 10px; }
  .project-state { font-size: .68rem; }
  .analysis-details { position: static; }.analysis-details .metric-grid { top: calc(100% + 4px); right: 10px; width: min(340px, calc(100% - 20px)); }
  .workspace { flex: none; display: block; overflow: visible; }.left-panel { height: auto; overflow: visible; border-right: 0; }.workspace-resizer { display: none; }.panel-section { padding: 17px 16px; }
  .main-stage { height: auto; overflow: visible; padding: 14px 12px 32px; }
  .chart-card, .data-card { min-height: 520px; flex: none; }
  .chart-toolbar { align-items: stretch; flex-direction: column; gap: 8px; padding: 10px; }.toolbar-groups { align-items: stretch; flex-direction: column; }.toolbar-groups .segmented button { flex: 1; }.chart-actions .btn { flex: 1; }
  .view-compose { align-items: stretch; flex-direction: column; }.view-compose-actions { justify-content: space-between; }.view-compose-actions span { display: none; }
  .chart-wrap { height: 330px; flex: none; }.data-head { align-items: flex-start; flex-direction: column; gap: 10px; padding: 12px; }
  .range-row { min-width: 0; flex: none; width: 100%; }
  .crop-trim-row { grid-template-columns: 1fr; gap: 3px; }
  .crop-timecode.end { justify-content: flex-start; }
  .crop-editor-head { align-items: flex-start; }
  .crop-editor-head > div:first-child span { display: none; }
  .table-wrap, .raw-view { max-height: 430px; }
  .tabs { width: 100%; }.tabs button { flex: 1; }
  .table-navigator { align-items: stretch; flex-direction: column; }.line-jump { justify-content: space-between; }.selected-log { grid-template-columns: 1fr; gap: 4px; }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f7;
  --bg-elevated: #ffffff;
  --panel: rgba(255, 255, 255, .96);
  --panel-2: #f7fafb;
  --line: rgba(38, 72, 83, .13);
  --line-strong: rgba(38, 72, 83, .24);
  --text: #14262d;
  --muted: #657b83;
  --cyan: #078f82;
  --cyan-soft: rgba(7, 143, 130, .10);
  --amber: #c97908;
  --blue: #356fd6;
  --pink: #c44b8d;
  --red: #d94b4b;
}
html[data-theme="light"] .chart-card,
html[data-theme="light"] .chart-dialog {
  --chart-surface: #ffffff;
  --chart-background: #f7fafb;
  --chart-border: #c5d2d7;
  --chart-border-soft: rgba(45,75,86,.12);
  --chart-text: #263f48;
  --chart-muted: #617880;
  --chart-accent: #078f82;
  --chart-accent-soft: rgba(7,143,130,.12);
  --chart-hover: rgba(34,70,80,.035);
  --chart-shadow: 0 2px 8px rgba(15, 23, 42, .025), 0 12px 28px rgba(15, 23, 42, .045);
  color: var(--chart-text);
  background: var(--chart-surface);
  border-color: var(--chart-border);
  box-shadow: var(--chart-shadow);
}
html[data-theme="light"] .chart-card.panel { box-shadow: var(--chart-shadow); }
html[data-theme="light"] body {
  background-image:
    radial-gradient(circle at 82% -10%, rgba(41, 154, 165, .10), transparent 34%),
    linear-gradient(rgba(37, 70, 80, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 70, 80, .035) 1px, transparent 1px);
}
html[data-theme="light"] .topbar { background: rgba(255,255,255,.88); box-shadow: 0 1px 12px rgba(32,65,75,.045); }
html[data-theme="light"] .panel { box-shadow: 0 18px 50px rgba(48,76,85,.08); }
html[data-theme="light"] .workspace-resizer { background: #edf2f4; }
html[data-theme="light"] .brand-mark { border-color: rgba(7,143,130,.34); }
html[data-theme="light"] .brand-mark span, html[data-theme="light"] .status-dot { box-shadow: 0 0 8px rgba(7,143,130,.35); }
html[data-theme="light"] .btn.primary { color: #ffffff; background: #078f82; box-shadow: 0 6px 22px rgba(7,143,130,.16); }
html[data-theme="light"] .btn.primary:hover { background: #087e74; }
html[data-theme="light"] .btn.ghost { color: #40575f; background: rgba(255,255,255,.76); }
html[data-theme="light"] .btn.ghost:hover { color: #173038; background: #ffffff; }
html[data-theme="light"] kbd { color: rgba(255,255,255,.9); background: rgba(0,0,0,.14); }
html[data-theme="light"] .icon-button { background: #f7fafb; }
html[data-theme="light"] .dropzone { color: #29454e; background: linear-gradient(145deg, rgba(7,143,130,.075), rgba(255,255,255,.72)); }
html[data-theme="light"] .field-label,
html[data-theme="light"] .subsection-head,
html[data-theme="light"] .inline-fields-head,
html[data-theme="light"] .field-scope strong { color: #405a63; }
html[data-theme="light"] textarea,
html[data-theme="light"] .expression-row input,
html[data-theme="light"] .encoding-row select,
html[data-theme="light"] .rule-detail-label input,
html[data-theme="light"] .rule-detail-label select,
html[data-theme="light"] .field-condition select,
html[data-theme="light"] .field-condition input,
html[data-theme="light"] .field-aggregate select,
html[data-theme="light"] .field-aggregate input,
html[data-theme="light"] .field-aggregate-keys select,
html[data-theme="light"] .field-aggregate-members input,
html[data-theme="light"] .line-jump input { color: #203941; background: #ffffff; }
html[data-theme="light"] .field-subsection { background: rgba(255,255,255,.58); border-color: rgba(54,89,99,.14); }
html[data-theme="light"] code { color: #087f74; background: rgba(7,143,130,.07); border-color: rgba(7,143,130,.13); }
html[data-theme="light"] .prefix-card,
html[data-theme="light"] .rule-card { background: rgba(247,250,251,.92); }
html[data-theme="light"] .prefix-card summary,
html[data-theme="light"] .rule-toggle,
html[data-theme="light"] .rule-name,
html[data-theme="light"] .rule-config-summary,
html[data-theme="light"] .field-toggle { color: #29434c; }
html[data-theme="light"] .prefix-title-text { color: #29434c; }
html[data-theme="light"] .prefix-title-editor,
html[data-theme="light"] .rule-title-editor:not([hidden]) { color: #29434c; background: #ffffff; }
html[data-theme="light"] .prefix-activate,
html[data-theme="light"] .prefix-none,
html[data-theme="light"] .prefix-apply-all,
html[data-theme="light"] .prefix-none-all,
html[data-theme="light"] .add-rule-button { color: #5e747c; background: rgba(241,246,247,.72); }
html[data-theme="light"] .prefix-activate:hover,
html[data-theme="light"] .prefix-none:hover,
html[data-theme="light"] .prefix-apply-all:hover,
html[data-theme="light"] .prefix-none-all:hover { color: #086f66; }
html[data-theme="light"] .rule-card.selected { background: linear-gradient(135deg, rgba(7,143,130,.09), rgba(255,255,255,.96)); }
html[data-theme="light"] .field-item:hover { background: rgba(34,70,80,.035); }
html[data-theme="light"] .segmented,
html[data-theme="light"] .tabs { background: #edf3f4; }
html[data-theme="light"] .segmented button.active,
html[data-theme="light"] .tabs button.active { color: #075f57; background: rgba(7,143,130,.12); }
html[data-theme="light"] .table-navigator,
html[data-theme="light"] .raw-navigator { background: rgba(248,251,252,.98); }
html[data-theme="light"] .raw-view { background: rgba(247,250,251,.72); }
html[data-theme="light"] th { color: #536b74; background: #eef3f4; }
html[data-theme="light"] td { color: #3d555e; }
html[data-theme="light"] tbody tr:hover td,
html[data-theme="light"] tbody tr.selected-row td { color: #123138; }
html[data-theme="light"] .selected-log code { color: #405a63; }
html[data-theme="light"] .raw-line { color: #536b73; }
html[data-theme="light"] .raw-line:hover,
html[data-theme="light"] .raw-line.selected { color: #17343b; }
html[data-theme="light"] .empty-view strong { color: #38525b; }
html[data-theme="light"] dialog { background: #ffffff; box-shadow: 0 30px 90px rgba(34,65,74,.22); }
html[data-theme="light"] dialog::backdrop { background: rgba(26,45,52,.36); }
html[data-theme="light"] dialog p { color: #586f77; }
html[data-theme="light"] .help-nav { background: rgba(236,245,246,.78); }
html[data-theme="light"] .help-content p,
html[data-theme="light"] .help-content li { color: #526a72; }
html[data-theme="light"] .help-content pre { color: #29454e; background: #f3f8f8; }
html[data-theme="light"] .help-content .help-grid { background: #f6fafa; }
html[data-theme="light"] .help-note { color: #42616a; }
html[data-theme="light"] .auto-detect-summary { color: #536b73; background: #f7fafb; }
html[data-theme="light"] .auto-candidate { background: #fbfdfd; }
html[data-theme="light"] .auto-candidate-name { color: #17343b; background: #ffffff; }
html[data-theme="light"] .history-item { background: #fbfdfd; }
html[data-theme="light"] .toast { color: #ffffff; background: #173b42; box-shadow: 0 12px 30px rgba(34,65,74,.22); }
.theme-toggle { min-width: 76px; }
#chartCanvas.y-axis-hover,
#chartCanvas.y-axis-dragging { cursor: ns-resize; }

html[data-theme] .chart-toolbar .segmented button.active { color: var(--chart-accent); background: var(--chart-accent-soft); box-shadow: none; }
.chart-card .crop-editor { background: var(--chart-background); border-color: var(--chart-border); }
.chart-card .crop-editor-head strong { color: var(--chart-text); font: 600 12px system-ui, sans-serif; }
.chart-card .crop-editor-head span, .chart-card .crop-editor-foot { color: var(--chart-muted); font-size: 11px; }
.chart-card .crop-editor-head button { min-height: 28px; padding: 0 9px; color: var(--chart-text); background: var(--chart-surface); border-color: var(--chart-border); font-size: 11px; }
.chart-card .crop-editor-head button.active, .chart-card .crop-editor-head button:hover { color: var(--chart-accent); border-color: var(--chart-accent); background: var(--chart-accent-soft); }
.chart-card .crop-track { border-color: var(--chart-border); background: var(--chart-surface); }
.chart-card .crop-selection { border-color: var(--chart-accent); background: var(--chart-accent-soft); box-shadow: none; }
.chart-card .crop-selection-grip { color: var(--chart-accent); }
.chart-card .crop-handle { background: var(--chart-accent); box-shadow: none; }
.chart-card .crop-timecode { font: 11px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.chart-card .crop-timecode strong { color: var(--chart-text); }

@media (max-width: 980px) {
  .chart-toolbar .toolbar-groups { flex: 1 1 100%; }
  .chart-actions { justify-content: flex-start; }
  .view-compose .legend { flex-basis: 100%; }
}
@media (max-width: 720px) {
  .chart-toolbar { padding: 10px 12px; }
  .view-compose { padding: 10px 12px; flex-wrap: nowrap; }
  .view-compose .legend { width: 100%; flex-basis: auto; }
  .legend-entry { max-width: 100%; }
  .chart-actions .btn { min-width: 90px; }
  .chart-help { padding-right: 12px; padding-left: 12px; }
  .chart-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); margin: 8px; padding: 12px; }
  .chart-dialog .dialog-head > div:first-child { max-width: 100%; }
  .chart-dialog-actions { width: 100%; }
}
