/**
 * DECT Mesh Visualizer — iOS / Apple Human Interface–inspired UI
 */

:root {
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #636366;
  --text-tertiary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.12);
  --separator-strong: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.12);
  --accent: #007aff;
  --accent-pressed: #0062cc;
  --accent-tint: rgba(0, 122, 255, 0.12);
  --green: #34c759;
  --red: #ff3b30;
  --indigo: #5856d6;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-float: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 480px;
}

/* ——— Sidebar ——— */

.sidebar {
  width: 360px;
  min-width: 300px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 0.5px solid var(--separator-strong);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.8) inset;
}

.sidebar-header {
  padding: calc(20px + var(--safe-top)) 22px 18px;
  border-bottom: 0.5px solid var(--separator);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.brand-icon {
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0, 122, 255, 0.25));
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.brand-tagline {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.sidebar-lead {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 32em;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--separator-strong) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--separator-strong);
  border-radius: 100px;
}

.panel {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 16px 16px 18px;
  margin-bottom: 12px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-sm);
}

.panel--last {
  margin-bottom: 0;
}

.section-title {
  margin: 0 0 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

/* ——— Inputs ——— */

textarea.input-json {
  width: 100%;
  min-height: 148px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  resize: vertical;
  background: #f2f2f7;
  transition: box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

textarea.input-json::placeholder {
  color: var(--text-tertiary);
}

textarea.input-json:hover {
  background: #ebedf0;
}

textarea.input-json:focus {
  outline: none;
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--accent);
}

/* ——— Buttons ——— */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s var(--ease), background 0.15s var(--ease), opacity 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

.btn-primary:hover {
  background: #0077ed;
}

.btn-primary:active {
  background: var(--accent-pressed);
}

.btn-secondary {
  background: var(--fill);
  color: var(--accent);
}

.btn-secondary:hover {
  background: rgba(120, 120, 128, 0.16);
}

.btn-secondary:active {
  background: rgba(120, 120, 128, 0.22);
}

.btn-block {
  flex: 1;
  min-width: 0;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.btn-row--equal {
  gap: 8px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 12px;
}

.file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.btn-file {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--separator-strong);
  font-weight: 600;
}

.btn-file:hover {
  background: #f9f9fb;
}

/* ——— iOS-style switches ——— */

.toggle-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ios-switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 0.5px solid var(--separator);
}

.ios-switch:last-of-type {
  border-bottom: none;
  padding-bottom: 2px;
}

.ios-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.ios-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border-radius: 100px;
  background: #e9e9eb;
  transition: background 0.25s var(--ease);
  margin-top: 1px;
}

.ios-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s var(--ease);
}

.ios-switch-input:checked + .ios-switch-track {
  background: var(--green);
}

.ios-switch-input:checked + .ios-switch-track .ios-switch-thumb {
  transform: translateX(20px);
}

.ios-switch-input:focus-visible + .ios-switch-track {
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.ios-switch-label {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
  padding-top: 2px;
}

/* ——— Stats ——— */

.stats {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.stats-body strong {
  color: var(--text);
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: #f2f2f7;
  border-radius: 100px;
  min-height: 1.5em;
}

.warnings {
  margin-top: 10px;
}

.warning-item {
  font-size: 0.8125rem;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background: rgba(255, 149, 0, 0.1);
  border: 0.5px solid rgba(255, 149, 0, 0.35);
  color: #8e4b10;
}

.warning-item.severe {
  background: rgba(255, 59, 48, 0.08);
  border-color: rgba(255, 59, 48, 0.35);
  color: #c41e16;
}

.sidebar-footer {
  padding: 12px 22px calc(14px + var(--safe-bottom));
  border-top: 0.5px solid var(--separator);
  background: rgba(250, 250, 252, 0.8);
}

.sidebar-footer-text {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ——— Main graph area ——— */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  padding: 14px 14px 14px 10px;
  background: linear-gradient(165deg, #e8eaf0 0%, #f2f2f7 45%, #ebebf0 100%);
}

.graph-chrome {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-float), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

.graph-stage {
  flex: 1;
  min-height: 200px;
  background: radial-gradient(ellipse 120% 80% at 50% 20%, #fafbfd 0%, #f5f6fa 50%, #eef0f5 100%);
  position: relative;
}

.floorplan-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}

#network {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.graph-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 7;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(16px);
  border-radius: 12px;
  border: 0.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-sm);
}

.graph-tool-btn {
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  background: rgba(242, 242, 247, 0.95);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.12s var(--ease);
}

.graph-tool-btn:hover {
  background: #e5e5ea;
}

.graph-tool-btn:active {
  transform: scale(0.96);
}

.graph-tool-hint {
  padding: 0 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  user-select: none;
}

.graph-tool-btn--help {
  font-size: 0.95rem;
  font-weight: 700;
}

.graph-path-status {
  flex: 1 1 140px;
  min-width: 0;
  max-width: min(220px, 34vw);
  padding: 4px 8px;
  margin: 0;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
  font-family: inherit;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  cursor: default;
  appearance: none;
  -webkit-appearance: none;
}

.graph-path-status--actionable {
  cursor: pointer;
  transition: transform 0.12s var(--ease), box-shadow 0.15s var(--ease);
}

.graph-path-status--actionable:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.graph-path-status--actionable:active {
  transform: scale(0.98);
}

.graph-path-status--muted {
  color: var(--text-tertiary);
  font-weight: 500;
}

.graph-path-status--ok {
  color: #1a6b32;
  background: rgba(52, 199, 89, 0.12);
  border-color: rgba(52, 199, 89, 0.25);
}

.graph-path-status--warn {
  color: #8e4b10;
  background: rgba(255, 149, 0, 0.12);
  border-color: rgba(255, 149, 0, 0.28);
}

.graph-path-detail-wrap {
  position: absolute;
  top: 52px;
  left: 14px;
  right: 14px;
  z-index: 6;
  pointer-events: none;
}

.graph-path-detail-wrap--interactive {
  pointer-events: auto;
  cursor: pointer;
}

.graph-path-detail-wrap[hidden] {
  display: none !important;
}

.graph-path-detail {
  margin: 0;
  padding: 8px 11px;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: #5c3d12;
  background: rgba(255, 248, 235, 0.94);
  border: 0.5px solid rgba(255, 149, 0, 0.32);
  border-radius: 11px;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  max-height: 4.5rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.graph-path-detail-wrap--cycle .graph-path-detail {
  color: #4a2d5c;
  background: rgba(245, 240, 255, 0.94);
  border-color: rgba(175, 82, 222, 0.35);
}

.graph-path-detail-wrap--stalled .graph-path-detail {
  color: #5c2a28;
  background: rgba(255, 241, 240, 0.94);
  border-color: rgba(255, 59, 48, 0.28);
}

.help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.help-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 220;
  width: min(420px, calc(100vw - 28px));
  max-height: min(78vh, 580px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 0.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-float), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.help-sheet[hidden] {
  display: none !important;
}

.help-sheet-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.help-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 0.5px solid var(--separator);
}

.help-sheet-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.help-sheet-close {
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-secondary);
  background: rgba(242, 242, 247, 0.9);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.help-sheet-close:hover {
  background: #e5e5ea;
}

.help-sheet-body {
  padding: 14px 18px 20px;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.help-sheet-lead {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text);
}

.help-dl {
  margin: 0 0 16px;
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  gap: 6px 14px;
  align-items: baseline;
}

.help-dl dt {
  margin: 0;
}

.help-dl dd {
  margin: 0;
}

.help-list {
  margin: 0;
  padding-left: 1.15rem;
}

.help-list li {
  margin: 6px 0;
}

kbd {
  display: inline-block;
  padding: 3px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(242, 242, 247, 0.95);
  border-radius: 6px;
  border: 0.5px solid var(--separator);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

body.help-sheet-open {
  overflow: hidden;
}

body.sync-reconcile-open {
  overflow: hidden;
}

.reconcile-sheet {
  width: min(520px, calc(100vw - 28px));
  max-height: min(86vh, 640px);
}

.reconcile-sheet-head {
  align-items: flex-start;
}

.reconcile-head-text {
  flex: 1;
  min-width: 0;
}

.reconcile-sheet-head .help-sheet-close {
  flex-shrink: 0;
  margin-top: 2px;
}

.reconcile-stats {
  margin: 5px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  line-height: 1.35;
}

.help-sheet-body.reconcile-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  padding-bottom: 16px;
}

.reconcile-lead {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.reconcile-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.reconcile-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.reconcile-filter input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.reconcile-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reconcile-list-wrap {
  flex: 1;
  min-height: 140px;
  max-height: min(42vh, 320px);
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 12px;
  border: 0.5px solid var(--separator);
  background: rgba(242, 242, 247, 0.5);
  -webkit-overflow-scrolling: touch;
}

.reconcile-list {
  display: flex;
  flex-direction: column;
}

.reconcile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.8125rem;
  border-bottom: 0.5px solid var(--separator);
  transition: background 0.12s var(--ease);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.reconcile-row:last-child {
  border-bottom: none;
}

.reconcile-row:hover {
  background: rgba(255, 255, 255, 0.65);
}

.reconcile-row--hidden {
  display: none;
}

.reconcile-cb {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.reconcile-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text);
}

.reconcile-nums {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.reconcile-arrow {
  opacity: 0.55;
  font-size: 0.75rem;
}

.reconcile-delta {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.reconcile-delta--high {
  color: #c41e16;
}

.reconcile-delta--low {
  color: #0a66d4;
}

.reconcile-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 0.5px solid var(--separator);
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 200;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  border-radius: 14px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.app-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.app-toast--error {
  border-color: rgba(255, 59, 48, 0.35);
  background: rgba(255, 245, 245, 0.96);
}

.app-toast--ok {
  border-color: rgba(52, 199, 89, 0.35);
}

.input-feedback {
  min-height: 1.25em;
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-tertiary);
}

.input-feedback--ok {
  color: #1a6b2c;
}

.input-feedback--err {
  color: #c41e16;
}

.edge-filter {
  margin-bottom: 14px;
}

.edge-filter-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.segmented {
  display: flex;
  padding: 3px;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 10px;
  gap: 2px;
}

.segmented-item {
  flex: 1;
  position: relative;
  cursor: pointer;
  text-align: center;
}

.segmented-item input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.segmented-item span {
  display: block;
  padding: 8px 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented-item input:checked + span {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.segmented-item input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint-text {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.hint-text--compact {
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.92;
}

.version-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
}

.version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--separator);
  font-size: 0.8125rem;
}

.version-item:last-child {
  border-bottom: none;
}

.version-item-meta {
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}

/* Legend — floating glass card */

.legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 5;
  max-width: min(280px, calc(100% - 32px));
  padding: 12px 14px 14px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-radius: var(--radius-lg);
  border: 0.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.legend-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}

.legend-row--text {
  font-size: 0.8125rem;
}

.legend-heatmap-bar {
  width: 28px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, hsl(240, 68%, 52%), hsl(0, 68%, 52%));
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

.floorplan-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.floorplan-opacity-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

#floorplan-opacity {
  width: 100%;
  accent-color: var(--accent);
}

.legend-line {
  width: 32px;
  height: 0;
  flex-shrink: 0;
  border-top: 3px solid var(--green);
  border-radius: 2px;
}

.legend-line.weak {
  border-top-style: dashed;
  border-top-color: var(--red);
}

.legend-line--next {
  border-top-width: 4px;
  border-top-color: #00a854;
}

.legend-line--next.weak {
  border-top-style: dashed;
  border-top-color: var(--red);
}

.legend-line--bridge {
  border-top-width: 4px;
  border-top-style: solid;
  border-top-color: #ff9500;
}

.legend-line--syncpath {
  border-top-width: 4px;
  border-top-style: dashed;
  border-top-color: #bf5af2;
}

.legend-line--uplink-cycle {
  border-top-width: 4px;
  border-top-style: dashed;
  border-top-color: #ff375f;
}

.sync-tree-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-sync-tree-undo {
  font-size: 0.8125rem;
  padding: 8px 12px;
  background: rgba(142, 142, 147, 0.1);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
}

.legend-divider {
  height: 0.5px;
  background: var(--separator);
  margin: 10px 0 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot--master {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.25);
}

.legend-dot--sync {
  background: var(--accent);
  opacity: 0.9;
}

.legend-dot--critical {
  background: #ffb340;
  box-shadow: 0 0 0 2px #ff9500;
}

.export-hint {
  margin-bottom: 10px;
}

/* Hover tooltip */

.tooltip-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 6;
  max-width: min(340px, calc(100% - 32px));
  padding: 14px 16px 16px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.tooltip-panel.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tooltip-signal {
  margin: 0;
}

.tooltip-signal-group {
  margin-top: 12px;
}

.tooltip-signal-group:first-child {
  margin-top: 0;
}

.tooltip-signal-heading {
  margin: 0 0 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.tooltip-list--nested {
  margin: 0;
  padding-left: 18px;
}

.tooltip-signal-empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.tooltip-list {
  margin: 0;
  padding-left: 18px;
}

.tooltip-list li {
  margin: 5px 0;
}

.tooltip-list li.strong {
  color: #1a6b2c;
}

.tooltip-list li.weak {
  color: #c41e16;
}

/* ——— Responsive ——— */

/* ——— Project layout: topbar + bases panel ——— */

.app--project {
  flex-direction: column;
}

.app-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px calc(10px + var(--safe-top));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 0.5px solid var(--separator);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-back {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.topbar-back:hover {
  text-decoration: underline;
}

.topbar-title-input {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: #f2f2f7;
  color: var(--text);
}

.topbar-title-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.save-status {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  min-width: 5em;
  text-align: right;
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.app-body-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.app-body-row {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.preview-banner {
  flex-shrink: 0;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(255, 149, 0, 0.12) 0%, rgba(255, 204, 0, 0.08) 100%);
  border-bottom: 0.5px solid rgba(255, 149, 0, 0.35);
}

.preview-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 100%;
}

.preview-banner-text {
  font-size: 0.8125rem;
  color: var(--text);
  line-height: 1.4;
}

.preview-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.sim-grid {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px 10px;
  align-items: center;
  margin-bottom: 12px;
}

.sim-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sim-select,
.sim-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.8125rem;
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}

.analysis-suggestions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--separator);
  background: rgba(255, 255, 255, 0.65);
}

.suggestion-card--severe {
  border-color: rgba(255, 59, 48, 0.35);
  background: rgba(255, 59, 48, 0.06);
}

.suggestion-card--warn {
  border-color: rgba(255, 149, 0, 0.4);
  background: rgba(255, 149, 0, 0.07);
}

.suggestion-card--info {
  border-color: rgba(0, 122, 255, 0.3);
  background: rgba(0, 122, 255, 0.06);
}

.suggestion-card--ok {
  border-color: rgba(52, 199, 89, 0.35);
  background: rgba(52, 199, 89, 0.06);
}

.suggestion-title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.suggestion-detail {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.main-wrap {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
}

.bases-panel {
  width: 300px;
  min-width: 260px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  border-left: 0.5px solid var(--separator-strong);
}

.bases-panel-header {
  padding: 16px 16px 10px;
  border-bottom: 0.5px solid var(--separator);
}

.bases-panel-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.bases-panel-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.sync-rows {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 20px;
}

.sync-row {
  margin-bottom: 14px;
  border-radius: 12px;
  transition: box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.sync-row--flash {
  animation: dect-sync-row-flash 1.2s var(--ease) 1;
}

@keyframes dect-sync-row-flash {
  0%,
  100% {
    box-shadow: none;
    background: transparent;
  }
  15%,
  45% {
    box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.45), 0 6px 20px rgba(10, 132, 255, 0.12);
    background: rgba(10, 132, 255, 0.06);
  }
}

.sync-row-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.sync-row-stations {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-station {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #f2f2f7;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--separator);
}

.sync-station-name {
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--text);
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

.sync-level-input {
  width: 52px;
  flex-shrink: 0;
  padding: 6px 8px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--separator-strong);
}

.sync-level-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.btn-sm {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-danger {
  background: rgba(255, 59, 48, 0.12);
  color: #c41e16;
}

.btn-danger:hover {
  background: rgba(255, 59, 48, 0.2);
}

/* Login & projects list */

.login-body,
.projects-body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(165deg, #e8eaf0 0%, #f2f2f7 50%, #ebebf0 100%);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 28px 24px 26px;
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow-float);
}

.brand--login {
  margin-bottom: 20px;
}

.login-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 0.875rem;
  color: #c41e16;
  background: rgba(255, 59, 48, 0.08);
  border-radius: var(--radius-md);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-input {
  padding: 10px 12px;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: #f2f2f7;
  color: var(--text);
}

.login-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.login-submit {
  margin-top: 6px;
  width: 100%;
}

.projects-wrap {
  width: 100%;
  max-width: 720px;
}

.projects-storage-pill {
  margin: 0 0 12px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(10, 132, 255, 0.1);
  border-radius: 100px;
  display: inline-block;
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.projects-msg {
  margin: 0 0 14px;
  font-size: 0.875rem;
}

.projects-msg--ok {
  color: #1a6b2c;
}

.projects-msg--err {
  color: #c41e16;
}

.projects-new {
  margin-bottom: 14px;
}

.projects-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.projects-name-input {
  flex: 1;
  min-width: 180px;
}

.projects-filter-wrap {
  margin-bottom: 12px;
}

.projects-filter-input {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
}

.projects-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.projects-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--separator);
}

.projects-item:last-child {
  border-bottom: none;
}

.projects-link {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.projects-link:hover {
  color: var(--accent);
}

.projects-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.projects-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.projects-action-form {
  display: inline;
}

.projects-empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.virtual-hint {
  margin: 12px 0 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.virtual-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #b35a00;
  background: rgba(255, 179, 64, 0.25);
  border-radius: 4px;
  vertical-align: middle;
}

.sync-station--virtual {
  border-style: dashed;
  border-color: rgba(179, 90, 0, 0.45);
  background: rgba(255, 179, 64, 0.08);
}

.legend-diamond {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  background: #ffb340;
  border: 1px solid #e67e00;
  transform: rotate(45deg);
  border-radius: 2px;
}

@media (max-width: 960px) {
  .app:not(.app--project) {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  .app-body {
    flex-direction: column;
  }

  .app-body-row {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 0.5px solid var(--separator-strong);
    max-height: none;
  }

  .main-wrap {
    flex-direction: column;
  }

  .bases-panel {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 0.5px solid var(--separator-strong);
    max-height: 50vh;
  }

  .main {
    padding: 10px;
    min-height: 45vh;
  }

  .graph-chrome {
    min-height: 360px;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }

  .btn:active:not(:disabled) {
    transform: none;
  }
}
