:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-soft: #182236;
  --line: rgba(180, 220, 210, 0.12);
  --text: #eef6f3;
  --muted: #93a4b0;
  --mint: #3ee0a0;
  --mint-dim: #1fa971;
  --danger: #ff5d73;
  --warn: #ffc857;
  --blue: #6ec6ff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --font: "Segoe UI", "Outfit", sans-serif;
  --display: Georgia, "Fraunces", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  height: auto;
  background: radial-gradient(1200px 700px at 10% -10%, #16324a 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #123528 0%, transparent 42%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: auto;
  overflow-x: hidden;
}

.svg-filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

button, input, select { font-family: inherit; }

.hidden { display: none !important; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 16px;
  gap: 14px;
}

.topbar, .stage, .bottombar, .panel, .modal-card, .sheet {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.brand h1 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.app-version {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--mint);
  background: rgba(62, 224, 160, 0.12);
  border: 1px solid rgba(62, 224, 160, 0.35);
  border-radius: 999px;
  padding: 3px 9px;
  line-height: 1.2;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.patient-bar label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.name-row {
  display: flex;
  gap: 8px;
}

.name-row input {
  flex: 1;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 14px;
  padding: 0 14px;
  font-size: 18px;
}

.name-row input:focus {
  outline: 2px solid rgba(62, 224, 160, 0.35);
}

.icon-btn, .btn {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  color: var(--text);
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s;
}

.icon-btn:hover, .btn:hover { transform: translateY(-1px); }
.icon-btn:active, .btn:active { transform: translateY(1px); }

.icon-btn {
  width: 48px;
  height: 48px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 18px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.btn {
  height: 48px;
  padding: 0 16px;
  font-weight: 600;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.btn.primary {
  background: linear-gradient(180deg, #5af0b4, var(--mint-dim));
  color: #062016;
  border: 0;
}

.btn.danger { background: var(--danger); color: white; border: 0; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.res-update-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.update-sw-btn {
  height: auto;
  min-height: 26px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(62, 224, 160, 0.08);
  color: var(--mint);
  font-size: 12px;
  font-weight: 600;
}

.status-chip.warn { background: rgba(255, 200, 87, 0.1); color: var(--warn); }
.status-chip.rec { background: rgba(255, 93, 115, 0.12); color: var(--danger); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.dot.pulse { animation: pulse 1.1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

.stage {
  display: grid;
  grid-template-columns: 1fr 92px 280px;
  gap: 14px;
  padding: 14px;
  min-height: 560px;
  overflow: auto;
}

.live-wrap {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-frame {
  position: relative;
  flex: 1;
  min-height: 280px;
  border-radius: 18px;
  overflow: hidden;
  background: #05080f;
  border: 3px solid #14532d;
}

.live-frame video {
  position: absolute;
  left: 0;
  top: 0;
  width: 320px;
  height: 180px;
  opacity: 0.02;
  pointer-events: none;
  z-index: 0;
}

.live-frame #liveCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  background: #05080f;
}

.live-frame.direct-preview video {
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  object-fit: contain;
  z-index: 1;
}

.live-frame.direct-preview #liveCanvas {
  display: none;
}

.live-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.cam-idle-warn {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.cam-idle-warn-card {
  text-align: center;
  color: #fff;
  background: rgba(18, 26, 43, 0.88);
  border: 2px solid var(--warn);
  border-radius: 16px;
  padding: 10px 22px 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.cam-idle-warn-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cam-idle-warn-count {
  margin-top: 2px;
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

.cam-power-btn {
  height: 28px;
  min-width: 0;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
  color: #062016;
  background: #1ebd78;
}

.cam-power-btn.cam-on {
  background: #1ebd78;
  color: #062016;
}

.cam-power-btn.cam-alert {
  height: 36px;
  padding: 0 12px;
  background: #ffc857;
  color: #2a1c00;
  border-color: rgba(255, 200, 87, 0.7);
  animation: pulse 1.1s infinite;
}

.cam-power-btn.cam-off {
  height: 32px;
  padding: 0 12px;
  background: #e23b52;
  color: #fff;
}

.cam-power-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.cam-power-btn.cam-alert .cam-power-label,
.cam-power-btn.cam-off .cam-power-label {
  font-size: 12px;
}

.cam-power-btn:hover { transform: translateY(-1px); }
.cam-power-btn:active { transform: translateY(1px); }

.adjust-panel {
  display: none;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.adjust-panel.open { display: grid; }

.adjust-title {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--mint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.adjust-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.adjust-actions .btn {
  min-width: 72px;
}

.slider-field label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.slider-field input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
}

.mid-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  padding-bottom: 12px;
}

.mid-tools .btn, .mid-tools .icon-btn {
  width: 100%;
  height: 44px;
}

.mid-tools .mirror-btn {
  height: auto;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.2;
  white-space: normal;
}

.mid-tools .mirror-btn.on {
  background: rgba(62, 224, 160, 0.18);
  border-color: var(--mint);
  color: var(--mint);
}

.zoom-box, .xy-box {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 6px;
  text-align: center;
}

.zoom-box span, .xy-box span {
  font-size: 11px;
  color: var(--muted);
}

.zoom-box input, .xy-box input {
  writing-mode: vertical-lr;
  direction: rtl;
  height: 120px;
  width: 36px;
  accent-color: var(--mint);
  margin: 8px auto;
}

.side-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  padding-bottom: 12px;
}

.capture-btn {
  height: 72px;
  border-radius: 18px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.capture-btn.photo {
  background: linear-gradient(180deg, #f4fff9, #d7fbe8);
  color: #08301f;
}

.capture-btn.video {
  background: #f7f7f7;
  color: #111;
}

.capture-btn.video.recording {
  background: var(--danger);
  color: white;
}

.thumbs {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.thumb {
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #071018;
  position: relative;
  cursor: pointer;
  min-height: 0;
}

.thumb.photo { border-color: #3ee0a0; }
.thumb.video { border-color: #6ec6ff; }
.thumb img, .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  background: rgba(0,0,0,0.55);
  padding: 3px 7px;
  border-radius: 999px;
}
.thumb video { pointer-events: none; }

.bottombar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
}

.bottombar b { color: var(--mint); font-weight: 600; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(10px);
  display: grid;
  align-items: start;
  justify-items: center;
  overflow: auto;
  z-index: 30;
  padding: 24px;
}

.modal-card {
  width: min(1100px, 100%);
  max-height: none;
  overflow: auto;
  padding: 22px;
  margin-bottom: 32px;
}

.modal-card.narrow { width: min(460px, 100%); }

.modal-card.narrow h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.modal-head .sec-back {
  width: auto;
  min-width: 160px;
  flex: 1;
}

.modal-head h2 {
  font-family: var(--display);
  font-size: 28px;
}

.db-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  min-height: 62vh;
}

.patient-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  max-height: 62vh;
}

.patient-item {
  text-align: left;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
}

.patient-item.active {
  border-color: var(--mint);
  background: rgba(62, 224, 160, 0.08);
}

.media-cols {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
}

.media-col h3 { margin-bottom: 8px; }
.media-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  max-height: 50vh;
  padding-right: 4px;
}

.media-row {
  display: grid;
  grid-template-columns: 28px 96px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  cursor: pointer;
}

.media-row.selected {
  border-color: var(--mint);
  background: rgba(62, 224, 160, 0.08);
}

.media-row.modified {
  border: 2px solid #3ee0a0;
  box-shadow: 0 0 0 1px rgba(62, 224, 160, 0.35);
}

.mod-tag {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #3ee0a0;
  color: #062016;
  font-size: 11px;
  font-weight: 700;
}

.orig-tag {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.guide-hint {
  color: #ff9f43;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cal-status {
  color: var(--mint);
  font-size: 12px;
  line-height: 1.4;
}

.media-row img {
  width: 96px;
  height: 68px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
}

.bio-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 16px;
  min-height: 78vh;
  min-width: 0;
}

.tool-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
  padding-bottom: 16px;
  min-width: 0;
  max-width: 100%;
}
.tool-stack .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  min-height: 42px;
  padding: 8px 10px;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.tool-stack.in-section .bio-sec:not(.open) { display: none; }
.tool-stack.in-section #bioHint,
.tool-stack.in-section > img { display: none; }
#bioBackBtn {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex !important;
}

.bio-sec {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid transparent;
  min-width: 0;
  max-width: 100%;
}
.bio-sec .sec-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px 12px;
  min-width: 0;
}
.bio-sec .sec-back,
#bioBackBtn,
.tool-stack .sec-back {
  background: #ffd166 !important;
  color: #111 !important;
  border: 2px solid #111 !important;
  font-weight: 800;
  min-height: 48px;
  pointer-events: auto !important;
  cursor: pointer;
  position: relative;
  z-index: 8;
  touch-action: manipulation;
}
.bio-sec .sec-body.hidden { display: none !important; }
.bio-sec.open .sec-btn { color: #062016; font-weight: 800; }
.bio-sec.open .sec-body label,
.bio-sec.open .sec-body .slider-field label {
  color: #163024;
}

.sec-modify { border-color: #3ee0a0; }
.sec-modify .sec-btn { background: #1a4a38; color: #b6ffe0; }
.sec-modify.open,
.sec-modify.open .sec-body {
  background: linear-gradient(180deg, #f3fff9 0%, #d4f8e8 55%, #b8efd8 100%);
}
.sec-modify.open .sec-btn { background: #3ee0a0; }
.sec-modify .sec-save { background: #1fa971; color: #fff; }

.sec-settings { border-color: #6ec6ff; }
.sec-settings .sec-btn { background: #16344a; color: #cceeff; }
.sec-settings.open,
.sec-settings.open .sec-body {
  background: linear-gradient(180deg, #f4fbff 0%, #d7efff 55%, #b9e0ff 100%);
}
.sec-settings.open .sec-btn { background: #6ec6ff; }
.sec-settings .sec-save { background: #2b8fd4; color: #fff; }

.sec-calibrate { border-color: #ff9f43; }
.sec-calibrate .sec-btn { background: #4a2e12; color: #ffd9b0; }
.sec-calibrate.open,
.sec-calibrate.open .sec-body {
  background: linear-gradient(180deg, #fff8f0 0%, #ffe2c2 55%, #ffd09a 100%);
}
.sec-calibrate.open .sec-btn { background: #ff9f43; }
.sec-calibrate .sec-save { background: #e67e22; color: #fff; }
.sec-calibrate .guide-hint, .sec-calibrate .cal-status { color: #9a4b00; }

.sec-comment { border-color: #ffd166; }
.sec-comment .sec-btn { background: #4a3d12; color: #ffe9a8; }
.sec-comment.open,
.sec-comment.open .sec-body {
  background: linear-gradient(180deg, #fffdf3 0%, #fff1c2 55%, #ffe38a 100%);
}
.sec-comment.open .sec-btn { background: #ffd166; }
.sec-comment .sec-save { background: #d4a017; color: #062016; }
.sec-comment .guide-hint { color: #9a6400; }

.bio-global {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.hint {
  color: var(--mint);
  font-size: 13px;
  line-height: 1.5;
  padding: 10px;
  border-left: 3px solid var(--mint);
}

#bioCanvas, #bioView {
  width: 100%;
  min-height: 70vh;
  height: 100%;
  background: #05080f;
  border-radius: 16px;
  cursor: crosshair;
}

.tool-stack label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-width: 0;
}

.color-swatch, .swatch {
  height: 36px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch.active, .swatch.active { border-color: white; }

#bioCanvas {
  width: 100%;
  min-height: 70vh;
  display: block;
  border-radius: 16px;
  background: #05080f;
  cursor: crosshair;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(920px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  z-index: 90;
  padding: 16px;
}

.keys {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.key {
  min-width: 52px;
  height: 48px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.key.wide {
  min-width: min(280px, 46vw);
  flex: 1;
  max-width: 420px;
}
.key.num {
  background: #1a2740;
  color: #ffc857;
}
.key.enter { background: var(--mint); color: #062016; }
.key.exit {
  min-width: min(220px, 42vw);
  height: 56px;
  background: #ff5d73;
  color: white;
  font-size: 20px;
  letter-spacing: 0.04em;
}

.kb-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  text-align: center;
}
.kb-head strong {
  font-size: 16px;
}
.kb-head span {
  font-size: 12px;
  color: var(--muted);
}
#kbBackBtn {
  background: #ffd166 !important;
  color: #111 !important;
  border: 2px solid #111 !important;
  font-weight: 800;
  min-height: 44px;
  width: 100%;
  margin-top: 8px;
}

.kb-preview {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 22px;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

.keys.kb-actions {
  margin-top: 12px;
  gap: 10px;
}

.toast-wrap {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #102033;
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--mint);
  box-shadow: var(--shadow);
}

.warn-pop {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 15, 0.5);
  pointer-events: none;
}

.warn-pop.hidden {
  display: none !important;
}

.warn-pop-card {
  background: #3a1520;
  color: #fff;
  border: 1px solid var(--danger);
  border-radius: 18px;
  padding: 22px 32px;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 32px));
}

.warn-pop.info .warn-pop-card {
  background: #102033;
  border-color: var(--mint);
}

.viewer img, .viewer video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 16px;
}

.res-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
}

.res-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 10px;
}

.res-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
}

.res-item.ok { border-color: var(--mint); }
.res-item.bad { color: var(--danger); }

.popover {
  position: fixed;
  right: 24px;
  top: 90px;
  width: 280px;
  max-height: min(50vh, 340px);
  overflow-y: auto;
  z-index: 50;
  padding: 6px;
  background: #fff;
  border: 2px solid #111;
  color: #111;
  border-radius: 10px;
}

.recover-pop {
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 8px;
}
.recover-sorts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.recover-sorts .recover-sort {
  height: 42px;
  margin: 0;
  text-align: center;
  font-weight: 800;
  background: #f2f2f2;
  color: #111;
  border: 2px solid #111;
  border-radius: 8px;
}
.recover-sorts .recover-sort.active {
  background: #3ee0a0;
  color: #062016;
}
.recover-list {
  overflow-y: auto;
  flex: 1;
  min-height: 72px;
}
.recover-pop .recover-item {
  height: auto;
  min-height: 42px;
  white-space: normal;
  line-height: 1.25;
  padding: 8px 10px;
}
.recover-empty {
  padding: 14px 10px;
  font-weight: 700;
  color: #333;
}

.popover button,
.popover .recover-item {
  width: 100%;
  text-align: left;
  margin: 0 0 4px;
  height: 34px;
  padding: 4px 10px;
  background: #fff;
  color: #111;
  border: 1px solid #111;
  border-radius: 6px;
  font-weight: 600;
}

.popover button:last-child,
.popover .recover-item:last-child {
  margin-bottom: 0;
}

.cam-pop {
  right: 16px;
  top: 86px;
  width: min(380px, calc(100vw - 28px));
}
.cam-pop .pop-title {
  font-weight: 800;
  padding: 6px 8px 8px;
  color: #111;
}
.cam-pop .recover-item {
  height: auto;
  min-height: 40px;
  white-space: normal;
  line-height: 1.25;
  padding: 8px 10px;
}
.cam-pop .recover-item.active {
  border-color: #1fa971;
  background: #e8fff4;
}
.cam-pop .cam-save-default {
  background: #3ee0a0;
  color: #062016;
  border-color: #062016;
  margin-top: 8px;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .topbar, .stage { grid-template-columns: 1fr; }
  .mid-tools, .side-tools {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    overflow: visible;
  }
  .zoom-box input, .xy-box input { writing-mode: horizontal-tb; direction: ltr; width: 100%; height: auto; }
  .bio-layout, .db-grid { grid-template-columns: 1fr; }
}
