:root {
  --bg: #FAFBFC;
  --panel: #FFFFFF;
  --ink: #0F2A44;
  --ink2: #3B4A5C;
  --ink3: #7A8694;
  --line: #E4E9EF;
  --line-2: #F1F4F8;
  --accent: #0066D6;
  --accent-soft: #E6F0FB;
  --marker: #FF5A5F;
  --marker-soft: #FFE9EA;
  --shadow-1: 0 1px 2px rgba(15, 42, 68, 0.04), 0 4px 12px rgba(15, 42, 68, 0.06);
  --shadow-2: 0 8px 28px rgba(15, 42, 68, 0.10);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body, #root {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(1200px 700px at 30% -20%, #EEF4FB 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #F5F1EB 0%, transparent 50%),
    var(--bg);
}

button { font-family: inherit; cursor: pointer; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  background: #F1F4F8;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink2);
}

/* App layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr 380px;
  min-height: 0;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand-text {
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  box-shadow: var(--shadow-1);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-tag { font-size: 11px; color: var(--ink3); font-family: var(--mono); }

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.preset-row {
  display: flex; gap: 2px;
  background: #F1F4F8;
  border: 1px solid var(--line);
  padding: 3px;
  border-radius: 8px;
}
.preset-btn {
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink2);
  border-radius: 5px;
  font-weight: 500;
}
.preset-btn:hover { color: var(--ink); }
.preset-btn.on {
  background: var(--panel);
  color: var(--accent);
  box-shadow: var(--shadow-1);
  font-weight: 600;
}
.topbar-divider { width: 1px; height: 22px; background: var(--line); }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink2);
  display: grid; place-items: center;
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink3); }
.icon-btn.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Search */
.search-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 420px));
  max-width: 520px;
}
.search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  transition: all 0.15s;
}
.search-shell.search-open {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search-ic { color: var(--ink3); flex-shrink: 0; }
.search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--ink);
  font-family: var(--sans);
}
.search-input::placeholder { color: var(--ink3); }
.search-kbd {
  font-family: var(--mono); font-size: 11px;
  background: #F1F4F8; padding: 2px 6px; border-radius: 4px; color: var(--ink3);
}
[data-theme="dark"] .search-kbd {
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  max-height: 360px;
  overflow-y: auto;
  z-index: 100;
  padding: 4px;
}
.sd-row {
  display: grid;
  grid-template-columns: 60px 160px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.sd-row-hov { background: var(--accent-soft); }
.sd-id {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  text-align: center;
}
.sd-name { font-weight: 600; color: var(--ink); }
.sd-short { color: var(--ink3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px 12px;
}
.sb-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; color: var(--ink3); padding: 0 8px 8px;
}
.sb-group { margin-bottom: 12px; }
.sb-group-title {
  font-size: 11px; font-weight: 600; color: var(--ink2);
  padding: 6px 8px;
  font-family: var(--mono);
}
.sb-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
  color: var(--ink);
  transition: all 0.12s;
}
.sb-item:hover { background: var(--line-2); }
.sb-item-sel { background: var(--accent-soft); color: var(--accent); }
.sb-item-id {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: var(--marker);
  min-width: 32px;
}
.sb-item-sel .sb-item-id { color: var(--accent); }
.sb-item-name { flex: 1; }
.sb-bil {
  font-family: var(--mono); font-size: 9px;
  background: #F1F4F8; padding: 1px 5px; border-radius: 3px;
  color: var(--ink3);
}
.sb-foot {
  margin-top: 24px; padding: 10px 8px;
  font-size: 11px; color: var(--ink3);
  font-family: var(--mono);
  border-top: 1px solid var(--line);
}
.sb-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: #00A36C; margin-right: 6px;
}

/* Stage */
.stage { position: relative; min-width: 0; min-height: 0; }
.scene-mount { position: absolute; inset: 0; }
.scene-mount canvas { display: block; }
.label-layer {
  position: absolute; inset: 0;
  pointer-events: none;
}
.lbl {
  position: absolute;
  top: 0; left: 0;
  transform: translate(0,0);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  pointer-events: auto;
  cursor: pointer;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 8px;
  margin-top: -8px;
  white-space: nowrap;
  transition: opacity 0.2s, color 0.15s, background 0.15s;
  box-shadow: 0 1px 2px rgba(15,42,68,0.06);
}
[data-theme="dark"] .lbl {
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.3);
}
.lbl:hover, .lbl-hov {
  background: var(--marker-soft);
  color: var(--marker);
  border-color: var(--marker);
}
.lbl-sel {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0,102,214,0.35);
}
.lbl-id { letter-spacing: 0.02em; }

.stage-overlay-tl {
  position: absolute;
  top: 16px; left: 16px;
  pointer-events: none;
}
.hint {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--ink2);
  font-family: var(--mono);
  display: flex; gap: 8px; align-items: center;
}
.hint-key {
  font-weight: 700;
  color: var(--ink);
  background: #F1F4F8;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 2px;
}
.hint-sep { color: var(--ink3); }

/* Calibrate button & banner */
.calib-btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  font: 600 12px/1 Inter, sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.calib-btn:hover {
  border-color: var(--ink2);
  background: var(--surface-2, #f6f6f9);
}
.calib-btn.on {
  background: #FF5A5F;
  border-color: #FF5A5F;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 90, 95, 0.18);
}
.calib-btn.on:hover { background: #ff7378; }

.calibrate-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 12px;
  background: rgba(20, 22, 28, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 6px rgba(0,0,0,0.15);
  font: 12px/1.35 Inter, -apple-system, system-ui, sans-serif;
  z-index: 50;
  max-width: 540px;
}
.calibrate-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #FF5A5F;
  box-shadow: 0 0 0 0 rgba(255,90,95,0.6);
  animation: calib-pulse 1.4s ease-in-out infinite;
  flex: none;
}
@keyframes calib-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,90,95,0.55); }
  50%      { box-shadow: 0 0 0 7px rgba(255,90,95,0); }
}
.calibrate-text {
  display: flex; flex-direction: column; gap: 2px;
}
.calibrate-text strong {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #FF8A8E;
}
.calibrate-text span {
  color: rgba(255,255,255,0.82);
}
.calibrate-text b {
  color: #fff;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 600;
}
.calibrate-export {
  margin-left: 6px;
  padding: 6px 10px;
  background: #FF5A5F;
  border: none;
  border-radius: 6px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.calibrate-export:hover { background: #ff7378; }

/* Planes panel */
.planes-panel {
  position: absolute;
  bottom: 16px; left: 16px;
  width: 260px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow-1);
}
.planes-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; color: var(--ink3); padding: 4px 6px 8px;
}
.plane-item-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 6px;
  align-items: center;
  padding: 2px;
  border-radius: 8px;
  transition: background 0.12s;
}
.plane-item-row.selected { background: var(--accent-soft); }
.plane-vis {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--panel);
  font-size: 10px;
  line-height: 1;
  color: transparent;
  cursor: pointer;
  padding: 0;
  display: grid; place-items: center;
  transition: all 0.12s;
}
.plane-vis.on { color: #fff; }
.plane-vis:hover { transform: scale(1.08); }
.plane-name-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink2);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.plane-name-btn:hover { background: var(--line-2); }
.plane-item-row.selected .plane-name-btn { color: var(--accent); font-weight: 600; }
.plane-swatch {
  width: 14px; height: 3px; border-radius: 2px;
}
.plane-name { font-weight: 500; }
.plane-pts { font-family: var(--mono); font-size: 10px; color: var(--ink3); }

/* Dossier */
.dossier {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column;
  gap: 16px;
}
.dossier:empty::before {
  content: "Select a landmark to see its dossier";
  display: block;
  color: var(--ink3);
  font-size: 13px;
  font-style: italic;
  margin: 60px 8px;
}
.dos-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.dos-id-chip {
  font-family: var(--mono); font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  padding: 6px 10px; border-radius: 6px;
  font-size: 13px;
  align-self: center;
}
.dos-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.dos-sub { font-size: 11px; color: var(--ink3); font-family: var(--mono); margin-top: 2px; }
.dos-close {
  border: none; background: transparent; color: var(--ink3);
  font-size: 22px; line-height: 1; padding: 4px 8px;
  border-radius: 6px;
}
.dos-close:hover { background: var(--line-2); color: var(--ink); }

.dos-section { display: flex; flex-direction: column; gap: 6px; }
.dos-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--ink3);
}
.dos-body {
  margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink2);
  text-wrap: pretty;
}
.dos-tip {
  display: flex; gap: 10px;
  background: #FFF8E6;
  border: 1px solid #F5DCAA;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: #6B5418;
  line-height: 1.5;
}
.dos-tip-mark { color: #F5A623; font-weight: 700; }
.dos-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dos-chip {
  font-size: 11px;
  background: #F1F4F8;
  color: var(--ink2);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: var(--mono);
}
[data-theme="dark"] .dos-chip {
  background: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.dos-plane {
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
.dos-plane-head {
  display: flex; align-items: center; gap: 10px;
}
.dos-plane-name { font-weight: 600; font-size: 13px; flex: 1; }
.dos-plane-pts { font-family: var(--mono); font-size: 11px; color: var(--ink3); }
.dos-plane-toggle {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink2);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.dos-plane-toggle.on {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.dos-plane-desc {
  font-size: 12px; color: var(--ink3); line-height: 1.5; margin-top: 6px;
}

/* Ceph overlay */
.ceph-overlay-wrap {
  position: fixed; inset: 0;
  background: rgba(15,42,68,0.5);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 200;
  padding: 40px;
}
.ceph-overlay {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  max-width: 880px;
  width: 100%;
  overflow: hidden;
}
.ceph-head {
  display: flex; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.ceph-title { font-weight: 600; font-size: 14px; flex: 1; }
.ceph-close {
  border: none; background: transparent; color: var(--ink3);
  font-size: 22px; padding: 4px 8px; border-radius: 6px; line-height: 1;
}
.ceph-close:hover { background: var(--line-2); color: var(--ink); }
.ceph-svg { display: block; width: 100%; }
.ceph-foot {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--ink3);
  border-top: 1px solid var(--line);
  background: #F8FAFC;
}

/* Plane dossier */
.dos-id-chip-plane {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 6px;
}
.dos-plane-bar {
  display: inline-block;
  width: 14px; height: 3px; border-radius: 2px;
}
.dos-construct {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dos-construct-pt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  flex: 1;
  min-width: 0;
}
.dos-construct-pt:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dos-construct-id {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
}
.dos-construct-name {
  font-size: 11px;
  color: var(--ink3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.dos-construct-arrow {
  color: var(--ink3);
  font-size: 14px;
  flex-shrink: 0;
}
.dos-norms {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dos-norm {
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.dos-norm-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.dos-norm-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
}
.dos-norm-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}
.dos-norm-what {
  font-size: 11px;
  color: var(--ink3);
  margin-top: 4px;
  line-height: 1.4;
}
.dos-plane-actions {
  margin-top: 8px;
}
.dos-plane-toggle-big {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.dos-plane-name-btn {
  border: none;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.dos-plane-name-btn:hover { color: var(--accent); }

/* Advanced collapsible sections */
.dos-advanced {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dos-advanced-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ink3);
  margin-bottom: 4px;
  padding-left: 2px;
}
.dos-collapsible {
  border-radius: 8px;
  background: #FAFBFC;
  border: 1px solid var(--line);
  overflow: hidden;
  transition: background 0.12s;
}
.dos-collapsible.open {
  background: #fff;
}
.dos-collapsible-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--ink2);
}
.dos-collapsible-head:hover { background: var(--line-2); }
.dos-collapsible-chevron {
  font-size: 10px;
  color: var(--ink3);
  width: 12px;
  flex-shrink: 0;
}
.dos-collapsible-label {
  font-size: 12px;
  font-weight: 600;
}
.dos-collapsible-body {
  padding: 0 12px 12px 32px;
  font-size: 12.5px;
}
.dos-collapsible-body .dos-body {
  font-size: 12.5px;
  color: var(--ink2);
  line-height: 1.55;
}

[data-theme="dark"] {
  --bg: #0a0a1a;
  --panel: rgba(17, 24, 39, 0.76);
  --ink: #f8fafc;
  --ink2: #e2e8f0;
  --ink3: #94a3b8;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.06);
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --marker: #fb7185;
  --marker-soft: rgba(251, 113, 133, 0.16);
  --shadow-1: 0 16px 44px rgba(2, 6, 23, 0.42);
  --shadow-2: 0 30px 70px rgba(2, 6, 23, 0.54);
}

html, body, #root {
  color-scheme: light dark;
}

[data-theme="dark"] body {
  background:
    radial-gradient(1280px 720px at 0% -10%, rgba(59, 130, 246, 0.24), transparent 55%),
    radial-gradient(1080px 640px at 100% 0%, rgba(96, 165, 250, 0.12), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #16213e 100%);
}

.app {
  padding: 18px;
  gap: 16px;
}

.main {
  gap: 16px;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(320px, 380px);
}

.topbar, .sidebar, .stage, .dossier, .planes-panel, .ceph-overlay {
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.topbar {
  position: relative;
  margin: -18px -18px 0;
  padding: 12px 24px 12px 16px;
  background: var(--panel);
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.brand {
  min-width: 0;
}

.brand-name {
  font-size: 18px;
}

.brand-tag {
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0;
}

[data-theme="dark"] .preset-row {
  background: rgba(148, 163, 184, 0.14);
  border-color: var(--line);
}

[data-theme="dark"] .preset-btn {
  color: var(--ink2);
}

[data-theme="dark"] .preset-btn:hover {
  color: var(--ink);
}

[data-theme="dark"] .preset-btn.on {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #fff;
  box-shadow: 0 16px 30px rgba(59, 130, 246, 0.24);
}

.search-shell,
.search-dropdown,
.ceph-overlay,
.dos-construct-pt,
.dos-norm,
.dos-collapsible,
.dos-plane,
.ceph-foot {
  background: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .search-shell,
[data-theme="dark"] .search-dropdown,
[data-theme="dark"] .ceph-overlay,
[data-theme="dark"] .dos-construct-pt,
[data-theme="dark"] .dos-norm,
[data-theme="dark"] .dos-collapsible,
[data-theme="dark"] .dos-plane,
[data-theme="dark"] .ceph-foot {
  background: rgba(15, 23, 42, 0.9);
}

.sidebar, .stage, .dossier {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow-1);
}

.sidebar,
.stage {
  overflow: hidden;
}

.dossier {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dossier::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.stage {
  background:
    radial-gradient(1000px 460px at 50% 0%, rgba(96, 165, 250, 0.12), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.08)),
    rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .stage {
  background:
    radial-gradient(1000px 460px at 50% 0%, rgba(96, 165, 250, 0.18), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    rgba(10, 14, 30, 0.92);
}

.hint,
.planes-panel {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow-1);
}

[data-theme="dark"] .hint {
  background: rgba(15, 23, 42, 0.88);
  color: var(--ink2);
}

[data-theme="dark"] .hint-key {
  background: rgba(148, 163, 184, 0.16);
  color: var(--ink);
}

.lbl-locked,
.sd-row-locked,
.sb-item-locked,
.plane-item-row.locked,
.dos-plane-locked {
  opacity: 0.62;
}

.lbl-locked {
  color: var(--ink3);
}

[data-theme="dark"] .lbl-locked {
  opacity: 0.82;
  color: #cbd5e1;
}

.plane-vis.locked,
.plane-name-btn.locked,
.dos-plane-toggle.locked {
  cursor: pointer;
}

.plane-vis.locked,
.dos-plane-toggle.locked {
  color: var(--ink3);
}

.dos-plane-toggle.locked {
  border-style: dashed;
}

.upsell-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.64);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 500;
}

.upsell-modal {
  width: min(100%, 460px);
  padding: 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}

[data-theme="dark"] .upsell-modal {
  background: rgba(15, 23, 42, 0.96);
}

.upsell-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.upsell-title {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.upsell-body {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink2);
}

.upsell-target {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 12px/1 var(--mono);
}

.upsell-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.upsell-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink2);
  padding: 10px 14px;
  border-radius: 999px;
  font: 600 13px/1.1 var(--sans);
}

.upsell-btn-primary {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 16px 30px rgba(59, 130, 246, 0.24);
}

@media (max-width: 1080px) {
  .app {
    padding: 12px;
    gap: 12px;
  }

  .topbar {
    margin: -12px -12px 0;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 18px 12px 14px;
  }

  .search-wrap {
    order: 3;
    position: relative;
    left: auto;
    transform: none;
    width: 100%;
    max-width: none;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(58vh, 1fr) auto;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 10px;
  }

  .topbar,
  .sidebar,
  .stage,
  .dossier {
    border-radius: 20px;
  }

  .topbar {
    margin: -10px -10px 0;
    padding: 12px 16px;
    border-radius: 0;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-tag {
    display: none;
  }
}
