/* ═══════════════════════════════════════════════════════════════
   SpeakerCheck Touch — Style v2
   Design: Industrial-precision measurement tool
   Fonts: JetBrains Mono (data/mono) + Barlow (UI/labels)
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500;700&display=swap');

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Core palette — dark mode */
  --bg:          #09090c;
  --bg-mid:      #0f1014;
  --surface:     #14151b;
  --surface2:    #1c1d25;
  --border:      #252630;
  --border2:     #2e3040;

  /* Text */
  --text:        #dde0ed;
  --text-dim:    #8b90a8;
  --text-faint:  #464b60;

  /* Accent — amber/amber-gold for measurement feel */
  --accent:      #f5a524;
  --accent-dim:  rgba(245,165,36,.18);
  --accent-glow: rgba(245,165,36,.08);

  /* Status */
  --ok:          #30d158;
  --ok-dim:      rgba(48,209,88,.15);
  --warn:        #ff9f0a;
  --warn-dim:    rgba(255,159,10,.15);
  --bad:         #ff453a;
  --bad-dim:     rgba(255,69,58,.15);
  --blue:        #0a84ff;
  --blue-dim:    rgba(10,132,255,.15);

  /* Chart colors */
  --live-color:  #0a84ff;
  --ref-color:   #30d158;
  --diff-color:  #f5a524;

  /* Spacing */
  --r:           10px;
  --r-sm:        6px;
  --gap:         10px;

  /* Font */
  --ff-ui:       'Barlow', sans-serif;
  --ff-data:     'JetBrains Mono', monospace;

  /* Header */
  --header-h:    60px;
}

/* Light theme */
:root.light {
  --bg:          #f0f1f5;
  --bg-mid:      #e8e9ef;
  --surface:     #ffffff;
  --surface2:    #f4f5f9;
  --border:      #d8dae6;
  --border2:     #c8cad8;
  --text:        #1a1b22;
  --text-dim:    #5a6075;
  --text-faint:  #9ca0b0;
  --accent-glow: rgba(245,165,36,.05);
}

html { height: 100%; }

body {
  font-family: var(--ff-ui);
  font-size: 14px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
body.app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Countdown Overlay ─────────────────────────────────────── */
#countdownOverlay {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 9999; pointer-events: none;
}
#countdownOverlay.active { display: flex; }
#countdownOverlay::after {
  content: attr(data-s);
  font-family: var(--ff-data);
  font-size: 25vmin; font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 60px rgba(245,165,36,.4);
  letter-spacing: -.05em;
}

/* ── Toast ─────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 20px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  display: none; z-index: 99999;
  max-width: 84vw;
  font-family: var(--ff-data);
  font-size: 13px;
  letter-spacing: .02em;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  animation: toastIn .2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(8px); }
}
#toast.ok  { border-color: var(--ok);  color: var(--ok); }
#toast.err { border-color: var(--bad); color: var(--bad); }

/* ═══════════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════════ */
header {
  position: sticky; top: 0; z-index: 100;
  min-height: var(--header-h);
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  flex-wrap: wrap;
  align-content: center;
  padding: 10px 12px;
  gap: 8px;
  overflow: visible;
  scrollbar-width: none;
}
body.app-shell header {
  flex: 0 0 auto;
}
header::-webkit-scrollbar { display: none; }

/* Logo / title */
.sc-logo {
  display: flex; align-items: center; gap: 8px;
  margin-right: 8px;
  flex-shrink: 0;
}
.sc-logo img {
  height: 28px; width: auto;
  opacity: .9;
}
.sc-logo-text {
  font-family: var(--ff-data);
  font-size: 13px; font-weight: 500;
  letter-spacing: .04em;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Separator */
.ctl-sep {
  width: 1px; height: 28px;
  background: var(--border2);
  flex-shrink: 0;
  margin: 0 4px;
}

/* Control groups */
.ctrl-group {
  display: flex; align-items: center; gap: 5px;
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}

/* ── Buttons ────────────────────────────────────────────────── */
button {
  font-family: var(--ff-ui);
  font-size: 13px; font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 0 14px;
  height: 36px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
}
body.app-shell button {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
}
button:hover  { background: var(--surface); border-color: var(--border2); }
button:active { transform: translateY(1px); opacity: .88; }

/* Primary action button */
button.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}
button.btn-primary:hover { background: #ffb63e; border-color: #ffb63e; }

/* Danger / stop */
button.btn-danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
}
button.btn-danger:hover { background: var(--bad-dim); }
button.btn-danger:disabled { opacity: .35; cursor: not-allowed; }

/* Active state (pink noise on, auto-pdf on, etc.) */
button.is-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Disabled */
button:disabled {
  opacity: .3; cursor: not-allowed;
  transform: none !important;
}

/* Icon-only buttons */
button.btn-icon {
  width: 36px; height: 36px; padding: 0;
  justify-content: center;
  font-size: 15px;
}
body.app-shell button.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
}

/* Ref select */
select {
  font-family: var(--ff-ui);
  font-size: 13px; font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 0 10px;
  height: 36px;
  cursor: pointer;
  outline: none;
  min-width: 160px;
  width: clamp(150px, 18vw, 220px);
  max-width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b90a8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: border-color .14s;
}
body.app-shell select {
  height: 44px;
  font-size: 14px;
}
select:focus { border-color: var(--accent); }

/* Pink level slider (compact, in-header) */
.pn-level-wrap {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--ff-data);
  font-size: 11px; color: var(--text-dim);
}
.pn-level-wrap input[type=range] {
  width: 80px; height: 20px;
  appearance: none; background: transparent; cursor: pointer;
}
body.app-shell .pn-level-wrap input[type=range] {
  height: 44px;
}
.pn-level-wrap input[type=range]::-webkit-slider-runnable-track {
  height: 4px; background: var(--border2); border-radius: 4px;
}
.pn-level-wrap input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg-mid);
}

/* ═══════════════════════════════════════════════════════════════
   MAIN LAYOUT
═══════════════════════════════════════════════════════════════ */
main {
  display: grid;
  grid-template-rows: auto auto auto;
  grid-template-columns: 1fr 320px;
  grid-template-areas:
    "status   status"
    "charts   sidebar"
    "protocol sidebar";
  gap: var(--gap);
  padding: var(--gap);
  max-width: 1800px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
  align-content: start;
  align-items: start;
}
body.app-shell main {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
}

/* ── Status bar ──────────────────────────────────────────────── */
.status-bar {
  grid-area: status;
  display: flex; align-items: center; gap: 12px;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--ff-data);
  font-size: 13px;
  letter-spacing: .02em;
  min-width: 0;
}
.status-bar .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  transition: background .3s;
}
.status-bar.is-ok   .status-dot { background: var(--ok);   box-shadow: 0 0 8px var(--ok); }
.status-bar.is-warn .status-dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.status-bar.is-bad  .status-dot { background: var(--bad);  box-shadow: 0 0 8px var(--bad); }
.status-bar.is-live .status-dot {
  background: var(--blue);
  animation: pulse-live 1s ease-in-out infinite;
}
@keyframes pulse-live {
  0%,100% { opacity: 1; box-shadow: 0 0 4px var(--blue); }
  50%      { opacity: .5; box-shadow: 0 0 12px var(--blue); }
}
#status {
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}
.verdict-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.verdict-copy strong {
  font-family: var(--ff-ui);
  font-size: 18px;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.workflow-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.workflow-step {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  background: var(--bg);
  font-family: var(--ff-data);
  font-size: 11px;
}
.workflow-step.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.status-bar.is-ok .verdict-copy strong { color: var(--ok); }
.status-bar.is-warn .verdict-copy strong { color: var(--warn); }
.status-bar.is-bad .verdict-copy strong { color: var(--bad); }
.status-bar.is-live .verdict-copy strong { color: var(--blue); }

.mobile-panel-nav {
  grid-area: mobile-nav;
  display: none;
  min-width: 0;
  min-height: 44px;
}
.mobile-panel-btn {
  justify-content: center;
  min-width: 0;
}
.mobile-panel-btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ── Charts ──────────────────────────────────────────────────── */
.charts-area {
  grid-area: charts;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}
body.app-shell .charts-area {
  height: 100%;
  overflow: hidden;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chart-card-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.chart-card-header h3 {
  font-family: var(--ff-ui);
  font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim);
}

.chart-legend {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  font-family: var(--ff-data);
  font-size: 10px; color: var(--text-dim);
}
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend .swatch {
  width: 18px; height: 2px; border-radius: 1px;
}
.swatch.live { background: var(--live-color); }
.swatch.ref  { background: var(--ref-color); }
.swatch.diff { background: var(--diff-color); }
.swatch.tol  { background: var(--text-faint); border: none; border-top: 2px dashed var(--text-faint); }

.chart-canvas-wrap {
  flex: 1 1 auto; padding: 8px;
  display: flex; align-items: stretch;
  min-height: 0;
  min-width: 0;
}
canvas {
  width: 100%;
  height: 280px;
  max-width: 100%;
  border-radius: var(--r-sm);
  background: var(--bg);
  display: block;
}

/* ── Protocol section ─────────────────────────────────────────── */
.protocol-area {
  grid-area: protocol;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  min-width: 0;
}
body.app-shell .protocol-area {
  padding: 12px;
}

.section-title {
  font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.proto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 10px;
}

.field {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.field label {
  font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim);
}
.field input[type=text] {
  font-family: var(--ff-data);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  outline: none;
  transition: border-color .14s;
  -webkit-user-select: text;
  user-select: text;
  min-width: 0;
}
body.app-shell .field input[type=text],
body.app-shell .new-ref-row input[type=text] {
  min-height: 44px;
  font-size: 14px;
}
.field input[type=text]:focus { border-color: var(--accent); }
.field input[type=text]::placeholder { color: var(--text-faint); }
.inline-action {
  display: flex;
  gap: 6px;
  min-width: 0;
}
.inline-action input {
  flex: 1 1 auto;
}
.inline-action button {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 0 12px;
}
.rentman-hint {
  min-height: 18px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.3;
}
.rentman-hint.is-ok { color: var(--ok); }
.rentman-hint.is-warn { color: var(--warn); }
.rentman-hint.is-bad { color: var(--bad); }

/* Sliders inside protocol */
.slider-field {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.slider-label-row {
  display: flex; justify-content: space-between; align-items: baseline;
}
.slider-label-row .lbl {
  font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim);
}
.slider-label-row .val {
  font-family: var(--ff-data);
  font-size: 13px; font-weight: 500;
  color: var(--accent);
}

input[type=range] {
  width: 100%; height: 34px;
  appearance: none; background: transparent; cursor: pointer;
}
body.app-shell input[type=range] {
  height: 44px;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--border2);
  border-radius: 4px;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 24px; height: 24px; margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
  transition: box-shadow .14s;
}
input[type=range]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Checkbox toggle */
.toggle-field {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  min-width: 0;
}
.toggle-field input[type=checkbox] { display: none; }
.toggle-pill {
  width: 46px; height: 26px;
  background: var(--border2);
  border-radius: 14px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-pill::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-dim);
  top: 4px; left: 4px;
  transition: transform .2s, background .2s;
}
.toggle-field input:checked + .toggle-pill { background: var(--accent-dim); border: 1px solid var(--accent); }
.toggle-field input:checked + .toggle-pill::after { transform: translateX(20px); background: var(--accent); }
.toggle-field .toggle-label {
  font-size: 12px; color: var(--text-dim);
  line-height: 1.3;
  min-width: 0;
}

/* Window select */
.window-field {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.window-btns {
  display: flex; gap: 4px;
  min-width: 0;
}
.window-btn {
  flex: 1;
  font-family: var(--ff-data);
  font-size: 12px; padding: 6px 0;
  min-height: 44px;
  text-align: center;
  justify-content: center;
  color: var(--text-dim);
}
.window-btn.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  display: flex; flex-direction: column; gap: var(--gap);
  min-width: 0;
  min-height: 0;
}
body.app-shell .sidebar,
body.app-shell .sidebar .card {
  height: 100%;
}
body.app-shell .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.app-shell .card-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint);
}
.card-body { padding: 12px 14px; }

/* Ref list */
#refList {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
body.app-shell #refList {
  flex: 1 1 auto;
  max-height: none;
}
#refList::-webkit-scrollbar { width: 4px; }
#refList::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

#refList li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color .14s;
  min-width: 0;
}
#refList li:hover { border-color: var(--border2); }
#refList li.selected { border-color: var(--accent); background: var(--accent-glow); }

.ref-info strong {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.ref-info .meta {
  font-family: var(--ff-data);
  font-size: 10px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ref-info {
  min-width: 0;
  flex: 1 1 auto;
}

.ref-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ref-actions button {
  height: 28px; padding: 0 8px; font-size: 11px;
}

/* New ref input row */
.new-ref-row {
  display: flex; gap: 6px; margin-bottom: 10px;
  min-width: 0;
}
.new-ref-row input[type=text] {
  flex: 1;
  min-width: 0;
  font-family: var(--ff-data);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color .14s;
}
.new-ref-row input:focus { border-color: var(--accent); }
.new-ref-row button { height: 32px; padding: 0 10px; font-size: 12px; }
body.app-shell .new-ref-row button { font-size: 13px; }
.reference-guide {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent-glow);
}
.reference-guide strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
}
.reference-guide span {
  font-size: 12px;
  color: var(--text-dim);
}

/* Import/export row */
.ref-io-row {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.ref-io-row button {
  height: 30px; padding: 0 10px; font-size: 12px;
}
.ref-io-row label.toggle-field {
  font-size: 11px; gap: 6px;
}
.ref-io-row .toggle-pill { width: 28px; height: 16px; }
.ref-io-row .toggle-pill::after { width: 10px; height: 10px; top: 3px; left: 3px; }
.ref-io-row input:checked + .toggle-pill::after { transform: translateX(12px); }

/* Hint */
.hint {
  font-size: 11px; color: var(--text-faint);
  line-height: 1.5; margin-top: 8px;
}
.hint code {
  font-family: var(--ff-data);
  font-size: 10px;
  background: var(--bg); padding: 1px 4px; border-radius: 3px;
  color: var(--text-dim);
}

/* ── Footer ──────────────────────────────────────────────────── */
footer.legal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px; color: var(--text-faint);
}
body.app-shell footer.legal-footer {
  flex: 0 0 auto;
  padding: 6px 12px;
  min-height: 28px;
}
footer.legal-footer a { color: var(--text-faint); text-decoration: none; }
footer.legal-footer a:hover { color: var(--text-dim); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 860px) {
  main,
  body.app-shell main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "status"
      "mobile-nav"
      "charts";
  }
  .mobile-panel-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .charts-area { grid-template-columns: 1fr; }
  body.app-shell main.mobile-panel-charts .charts-area {
    grid-area: charts;
    display: grid;
    height: 100%;
    overflow: hidden;
  }
  body.app-shell main.mobile-panel-charts .sidebar,
  body.app-shell main.mobile-panel-charts .protocol-area,
  body.app-shell main.mobile-panel-refs .charts-area,
  body.app-shell main.mobile-panel-refs .protocol-area,
  body.app-shell main.mobile-panel-protocol .charts-area,
  body.app-shell main.mobile-panel-protocol .sidebar {
    display: none;
  }
  body.app-shell main.mobile-panel-refs .sidebar,
  body.app-shell main.mobile-panel-protocol .protocol-area {
    grid-area: charts;
    display: flex;
    height: 100%;
    overflow: hidden;
  }
  body.app-shell main.mobile-panel-protocol .protocol-area {
    display: block;
    overflow: auto;
  }
}

@media (max-width: 760px) {
  :root { --header-h: 56px; }
  main { padding: 8px; gap: 8px; }
  .charts-area { grid-template-columns: 1fr; }
  header { align-items: flex-start; }
  .ctl-sep { display: none; }
  .ctrl-group { flex: 1 1 auto; }
  .pn-level-wrap { flex: 1 1 170px; }
  .pn-level-wrap input[type=range] { flex: 1 1 80px; }
  .status-bar { align-items: stretch; flex-direction: column; }
  .workflow-strip { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  body.app-shell header {
    padding: 6px;
    gap: 5px;
  }
  body.app-shell header .sc-logo {
    width: 44px;
    justify-content: center;
    margin-right: 0;
  }
  .sc-logo-text { display: none; }
  body.app-shell header .ctrl-group { gap: 4px; }
  body.app-shell header select {
    min-width: 128px;
    width: 128px;
    font-size: 12px;
  }
  body.app-shell header button {
    width: 44px;
    min-width: 44px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }
  body.app-shell header button::before {
    content: attr(data-short);
    font-size: 14px;
    line-height: 1;
  }
  body.app-shell header #btnLang::before,
  body.app-shell header #btnAutoPDF::before,
  body.app-shell header #btnExport::before,
  body.app-shell header #btnFit::before {
    font-family: var(--ff-data);
    font-size: 11px;
  }
  body.app-shell .pn-level-wrap {
    flex: 1 1 132px;
    min-width: 132px;
  }
  body.app-shell .pn-level-wrap > span:first-child { display: none; }
  body.app-shell .pn-level-wrap input[type=range] { flex: 1 1 70px; }
  button { padding: 0 10px; font-size: 12px; }
  body.app-shell .status-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  body.app-shell .verdict-copy strong { font-size: 16px; }
  body.app-shell #status { font-size: 12px; }
  body.app-shell .workflow-step {
    min-height: 26px;
    padding: 0 8px;
    font-size: 10px;
  }
  .proto-grid { grid-template-columns: 1fr; }
  .new-ref-row { flex-direction: column; }
  #refList li { align-items: flex-start; flex-direction: column; }
  .ref-actions { width: 100%; }
  .ref-actions button { flex: 1; justify-content: center; }
}
