:root {
  --bg0: #071316;
  --bg1: #0c1f24;
  --bg2: #113137;
  --panel: rgba(8, 20, 24, 0.9);
  --stroke: rgba(169, 236, 226, 0.22);
  --text: #ebf8f5;
  --muted: #98b6b0;
  --accent: #5df0c1;
  --accent2: #66beff;
  --warn: #f3be74;
  --danger: #f07a81;
  --ok: #66e3a1;
  --font-main: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
body * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable="true"],
.selectable-text,
.selectable-text * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

html,
body {
  margin: 0;
  background: var(--bg0);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font-main);
  letter-spacing: 0.01em;
  background: radial-gradient(circle at 12% 12%, #153640, transparent 36%),
    radial-gradient(circle at 88% 8%, #203b43, transparent 31%),
    linear-gradient(150deg, var(--bg0), var(--bg1) 52%, var(--bg2));
}

body.overlay-lock {
  overflow: hidden;
}

.bg-noise {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.07;
  pointer-events: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
  backdrop-filter: blur(10px);
  background: rgba(7, 19, 22, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar > .brand-row,
.topbar > .header-actions,
.topbar > .status-row,
.topbar > .update-banner {
  max-width: 1220px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  min-width: 34px;
  max-width: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  padding: 3px;
  object-fit: contain;
}

.badge {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-size: clamp(20px, 4vw, 28px);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 10px;
  cursor: pointer;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.header-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.header-actions.hidden-controls {
  display: none;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.status-row span {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 10px;
}

.update-banner {
  border-radius: 12px;
  border: 1px solid rgba(243, 190, 116, 0.45);
  background: rgba(50, 37, 11, 0.52);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 14px 14px 124px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: enter 200ms ease;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.compact {
  margin-bottom: 6px;
}

h2 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(19px, 3vw, 25px);
}

h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
}

.head-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.head-icon.small {
  width: 16px;
  height: 16px;
}

.subline {
  color: var(--muted);
  font-size: 13px;
}

.module {
  display: none;
  margin-top: 12px;
  gap: 9px;
  flex-direction: column;
}

.module.active {
  display: flex;
}

.module-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

label {
  color: var(--muted);
  font-size: 13px;
}

input[type="number"],
input[type="text"],
textarea,
select,
input[type="range"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(5, 11, 14, 0.72);
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input[type="range"] {
  appearance: none;
  height: 8px;
  padding: 0;
  background: linear-gradient(90deg, var(--accent), rgba(93, 240, 193, 0.15));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0c1f22;
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 13px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #041113;
  font-weight: 700;
}

.btn-emphasis {
  font-size: 15px;
  padding: 12px 16px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-ghost[aria-pressed="true"] {
  background: rgba(93, 240, 193, 0.18);
  border-color: rgba(93, 240, 193, 0.64);
}

.segmented {
  display: grid;
  gap: 8px;
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.segmented button.active {
  border-color: rgba(93, 240, 193, 0.68);
  background: rgba(93, 240, 193, 0.2);
}

.signal-state {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 9px 11px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr 115px;
  gap: 10px;
  align-items: center;
}

.inline-input.compact {
  grid-template-columns: auto 88px;
  align-items: center;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.divider {
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.result {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.04);
}

.result.ok {
  border-color: rgba(102, 227, 161, 0.55);
  color: var(--ok);
}

.result.bad {
  border-color: rgba(240, 122, 129, 0.55);
  color: var(--danger);
}

.polarity-result {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
  padding: 14px 14px;
  min-height: 110px;
}

.polarity-sign {
  font-size: clamp(38px, 8vw, 62px);
  font-weight: 800;
  line-height: 1;
}

.polarity-main {
  font-size: clamp(21px, 4.4vw, 33px);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.05;
}

.polarity-sub {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.polarity-result.ok {
  background: rgba(35, 96, 74, 0.22);
}

.polarity-result.bad {
  background: rgba(111, 39, 49, 0.22);
}

.polarity-measure-wrap {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  transform-origin: center;
  transition: transform 180ms ease;
}

.polarity-measure-wrap.flipped {
  transform: rotate(180deg);
}

.polarity-measure-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#polarityFlipBtn {
  min-width: 120px;
}

.polarity-level {
  display: grid;
  gap: 8px;
}

.polarity-meter-wrap {
  height: 11px;
}

.polarity-meter-bar {
  transition: width 140ms linear;
  background: linear-gradient(90deg, #ef4444 0%, #f3be74 45%, #5df0c1 100%);
}

.signal-state.ok {
  border-color: rgba(102, 227, 161, 0.5);
  color: var(--ok);
}

.signal-state.warn {
  border-color: rgba(243, 190, 116, 0.52);
  color: var(--warn);
}

.signal-state.bad {
  border-color: rgba(240, 122, 129, 0.5);
  color: var(--danger);
}

#syncPanel {
  display: grid;
  gap: 10px;
}

.sync-peer-list {
  display: grid;
  gap: 8px;
}

.sync-peer-empty {
  color: var(--muted);
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}

.sync-peer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
}

.sync-peer-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-peer-item.connected {
  border-color: rgba(102, 227, 161, 0.6);
  background: rgba(36, 95, 73, 0.26);
}

.sync-manual {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
}

.sync-manual summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.sync-qr-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.sync-qr-image {
  width: min(72vw, 250px);
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #fff;
}

.sync-scan-wrap {
  display: grid;
  gap: 8px;
}

.sync-scan-video {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.analyzer-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analyzer-controls {
  display: grid;
  gap: 10px;
}

.analyzer-profile-control {
  display: grid;
  gap: 6px;
}

.analyzer-profile-control label {
  font-size: 12px;
  color: var(--muted);
}

.analyzer-profile-info {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  color: rgba(215, 236, 228, 0.7);
  font-family: var(--font-mono);
}

.analyzer-actions {
  display: block;
}

.analyzer-corner-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: inline-flex;
}

.analyzer-corner-btn {
  width: 46px;
  min-width: 46px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  background: rgba(5, 11, 14, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

.analyzer-corner-btn svg {
  width: 17px;
  height: 17px;
}

.analyzer-corner-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.24);
}

.analyzer-curve-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.icon-only-btn {
  width: 46px;
  min-width: 46px;
  height: 42px;
  padding: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.canvas-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #03070a;
}

canvas {
  width: 100%;
  height: min(52vh, 440px);
  display: block;
  touch-action: none;
}

.overlay-canvas-wrap {
  height: 100%;
  min-height: 0;
  position: relative;
}

.overlay-visual {
  position: absolute;
  inset: 0;
  transform-origin: center;
  transition: transform 180ms ease;
}

.overlay-canvas-wrap.rotated .overlay-visual {
  transform: rotate(180deg);
}

.overlay-canvas-wrap canvas {
  height: 100%;
  max-height: none;
}

.peak-badge {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 10px;
  border-radius: 999px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid rgba(243, 190, 116, 0.6);
  background: rgba(24, 16, 3, 0.82);
  color: var(--warn);
  pointer-events: none;
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
}

.peak-main {
  font-size: 12px;
  line-height: 1.05;
}

.peak-note {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  line-height: 1;
  color: rgba(228, 232, 232, 0.85);
}

.peak-note-name {
  letter-spacing: 0.04em;
}

.peak-note-sign {
  color: rgba(230, 235, 234, 0.2);
  opacity: 0.62;
  min-width: 7px;
  text-align: center;
}

.peak-note-sign.active.near {
  color: rgba(114, 235, 170, 0.92);
  opacity: 1;
}

.peak-note-sign.active.far {
  color: rgba(245, 102, 114, 0.96);
  opacity: 1;
}

.peak-note.hit .peak-note-name {
  color: rgba(114, 235, 170, 0.96);
}

.marker-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.marker-tag {
  position: absolute;
  transform: translateX(-50%);
  border-radius: 999px;
  min-width: 108px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  border: 1px solid rgba(102, 190, 255, 0.75);
  background: rgba(8, 40, 60, 0.92);
  color: #a8dbff;
  white-space: nowrap;
}

.marker-tag.pending {
  border-color: rgba(243, 190, 116, 0.88);
  background: rgba(44, 28, 6, 0.94);
  color: #ffd89b;
}

.marker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.marker-empty {
  color: var(--muted);
  font-size: 13px;
}

.marker-chip {
  border: 1px solid rgba(102, 190, 255, 0.45);
  background: rgba(16, 54, 74, 0.55);
  color: #dff4ff;
  border-radius: 999px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.marker-chip-x {
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.meta-row span {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  padding: 4px 9px;
}

.level-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.level-controls {
  display: grid;
  gap: 10px;
}

.level-calibration-control {
  display: grid;
  gap: 6px;
}

.converter-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tuner-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tuner-controls {
  display: grid;
  gap: 10px;
}

.tuner-field {
  display: grid;
  gap: 6px;
}

.tuner-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tuner-target-chip {
  border: 1px solid rgba(102, 190, 255, 0.45);
  background: rgba(16, 54, 74, 0.55);
  color: #dff4ff;
  border-radius: 999px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.tuner-target-chip.active {
  border-color: rgba(93, 240, 193, 0.82);
  background: rgba(93, 240, 193, 0.22);
  color: #c9ffe9;
}

.tuner-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tuner-meter-wrap {
  position: relative;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  height: 24px;
  overflow: hidden;
}

.tuner-meter-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  left: 50%;
  margin-left: -3px;
  border-radius: 4px;
  background: linear-gradient(180deg, #f3be74, #5df0c1);
  transition: left 120ms linear;
}

.tuner-meter-center {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.45);
}

.tuner-meter-scale {
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.tuner-meter-scale span:nth-child(2) {
  text-align: center;
}

.tuner-meter-scale span:last-child {
  text-align: right;
}

.converter-block {
  display: grid;
  gap: 10px;
}

.converter-stats {
  display: grid;
  gap: 8px;
}

.converter-stat {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.converter-stat strong {
  color: var(--text);
  font-size: 18px;
  font-family: var(--font-mono);
}

.converter-grid {
  display: grid;
  gap: 10px;
}

.converter-field {
  display: grid;
  gap: 6px;
}

.level-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kicker {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.big-num {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  font-size: clamp(20px, 4.2vw, 34px);
  font-weight: 700;
  text-align: center;
  font-family: var(--font-mono);
}

.meter-wrap {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  height: 14px;
  overflow: hidden;
}

.meter-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #5df0c1 55%, #f3be74 82%, #ef4444 100%);
}

.meter-scale {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.meter-scale span:nth-child(2),
.meter-scale span:nth-child(3) {
  text-align: center;
}

.meter-scale span:last-child {
  text-align: right;
}

.analyzer-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(2, 7, 9, 0.83);
  backdrop-filter: blur(6px);
  padding: calc(8px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(2, 7, 9, 0.83);
  backdrop-filter: blur(6px);
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.overlay-surface,
.settings-panel {
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(6, 17, 20, 0.96);
  padding: 14px;
}

.overlay-surface {
  height: 100%;
  position: relative;
  padding: 8px;
}

.overlay-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: auto;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.overlay-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 34px;
  padding: 0;
  font-size: 16px;
  border-radius: 9px;
  background: rgba(5, 11, 14, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

.overlay-control-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.24);
}

.overlay-icon-btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.7;
}

#overlayRotateBtn svg {
  width: 16px;
  height: 16px;
}

.fullscreen-icon .icon-collapse {
  display: none;
}

button[aria-pressed="true"] .fullscreen-icon .icon-expand {
  display: none;
}

button[aria-pressed="true"] .fullscreen-icon .icon-collapse {
  display: block;
}

.settings-panel {
  max-width: 560px;
  margin: 0 auto;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.settings-advanced {
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 10px;
}

.settings-advanced summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.settings-advanced summary::-webkit-details-marker {
  display: none;
}

.settings-advanced[open] summary {
  color: var(--text);
}

.settings-advanced-body {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.settings-row {
  display: grid;
  gap: 6px;
}

.settings-analyzer {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.settings-analyzer strong {
  font-size: 13px;
  color: var(--muted);
}

.settings-mobile-nav {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.settings-mobile-nav strong {
  font-size: 13px;
  color: var(--muted);
}

.mobile-nav-pin-list {
  display: grid;
  gap: 6px;
}

.mobile-nav-pin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
  cursor: pointer;
  position: relative;
}

.mobile-nav-pin-text {
  color: var(--text);
}

.mobile-nav-pin-check {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mobile-nav-pin-switch {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(120, 130, 138, 0.38);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: background 260ms cubic-bezier(0.22, 0.7, 0.22, 1),
    border-color 260ms cubic-bezier(0.22, 0.7, 0.22, 1),
    box-shadow 260ms cubic-bezier(0.22, 0.7, 0.22, 1);
  flex: 0 0 auto;
}

.mobile-nav-pin-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform 260ms cubic-bezier(0.22, 0.7, 0.22, 1),
    box-shadow 260ms cubic-bezier(0.22, 0.7, 0.22, 1);
  will-change: transform;
}

.mobile-nav-pin-check:checked + .mobile-nav-pin-switch {
  background: rgba(93, 240, 193, 0.36);
  border-color: rgba(93, 240, 193, 0.82);
  box-shadow: 0 0 0 3px rgba(93, 240, 193, 0.15);
}

.mobile-nav-pin-check:checked + .mobile-nav-pin-switch::after {
  transform: translateX(18px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
}

.mobile-nav-pin-item:active .mobile-nav-pin-switch::after {
  transform: translateX(0) scale(0.96);
}

.mobile-nav-pin-item:active .mobile-nav-pin-check:checked + .mobile-nav-pin-switch::after {
  transform: translateX(18px) scale(0.98);
}

.mobile-nav-pin-check:focus-visible + .mobile-nav-pin-switch {
  box-shadow: 0 0 0 3px rgba(102, 190, 255, 0.28);
}

.settings-contact {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
}

.settings-contact a {
  color: var(--accent);
}

.settings-contact-logos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.settings-contact-logos a {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-contact-logos img {
  display: block;
  width: auto;
  max-width: 120px;
  height: 24px;
  object-fit: contain;
}

.settings-mobile-copyright {
  display: none;
  margin-top: 6px;
  color: var(--muted);
}

.about {
  max-width: 1220px;
  margin: 6px auto 98px;
  padding: 0 14px;
}

.logo-links {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0;
  flex-wrap: wrap;
  justify-content: center;
}

.logo-links a {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-links img {
  display: block;
  width: auto;
  max-width: 176px;
  height: 42px;
  object-fit: contain;
}

.about a {
  color: var(--accent);
}

.about-meta {
  display: grid;
  gap: 4px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 919px), (hover: none) and (pointer: coarse) {
  .about {
    display: none;
  }

  .settings-mobile-copyright {
    display: block;
  }
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(5, 13, 16, 0.93);
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(10px);
}

.bottom-nav button {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  min-height: 52px;
  font-size: 12px;
  font-weight: 600;
}

.bottom-nav button.active {
  border-color: rgba(93, 240, 193, 0.7);
  background: rgba(93, 240, 193, 0.22);
}

.bottom-nav button.mobile-nav-hidden {
  display: none;
}

.mobile-nav-more-btn {
  display: none;
}

body.mobile-nav-mode .mobile-nav-more-btn {
  display: flex;
}

.mobile-nav-menu {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 44;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(5, 13, 16, 0.96);
  padding: 10px;
  display: grid;
  gap: 8px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

.mobile-nav-menu button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  min-height: 44px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
}

.mobile-nav-menu button.active {
  border-color: rgba(93, 240, 193, 0.7);
  background: rgba(93, 240, 193, 0.22);
}

.mobile-nav-menu-item-label {
  line-height: 1.2;
}

.nav-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

@media (min-width: 920px) {
  .topbar {
    padding: calc(12px + env(safe-area-inset-top)) 24px 14px;
  }

  .brand-row {
    align-items: center;
  }

  .header-actions {
    grid-template-columns: repeat(2, minmax(160px, 220px));
    justify-content: end;
  }

  .status-row {
    justify-content: flex-start;
  }

  .update-banner {
    max-width: 760px !important;
    margin-right: auto;
    margin-left: 0;
  }

  .bottom-nav {
    position: sticky;
    top: calc(84px + env(safe-area-inset-top));
    left: auto;
    right: auto;
    transform: none;
    width: min(1220px, calc(100% - 48px));
    margin: 10px auto 0;
    padding: 0;
    background: transparent;
    border-top: none;
    backdrop-filter: none;
    z-index: 24;
    border-radius: 0;
    grid-template-columns: repeat(6, 1fr);
  }

  .bottom-nav button {
    min-height: 48px;
    font-size: 13px;
    background: rgba(8, 20, 24, 0.85);
  }

  main {
    padding: 18px 24px 44px;
  }

  .panel {
    padding: 20px;
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .converter-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .converter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tuner-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analyzer-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .polarity-measure-actions {
    grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  }

  .about {
    padding: 0 24px;
    margin-bottom: 34px;
  }

  .logo-links {
    padding: 12px 0 24px;
  }

  .mobile-nav-menu,
  .mobile-nav-more-btn {
    display: none !important;
  }
}

@media (orientation: landscape) and (max-height: 580px) {
  .topbar {
    position: relative;
  }

  main {
    padding-top: 12px;
  }

  canvas {
    height: min(68vh, 350px);
  }

  .overlay-canvas-wrap canvas {
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
