  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: #1a1a1a;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #e0e0e0;
    position: relative;
  }

  /* ── Top bar ── */
  .topbar {
    height: 72px;
    background: #1e1e1e;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    align-items: center;
    padding: 0 8px 0 4px;
    gap: 0;
    flex-shrink: 0;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 2px;
  }
  .topbar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .topbar-icon:hover { background: rgba(255,255,255,0.08); }
  .topbar-icon svg { width: 22px; height: 22px; fill: currentColor; }
  /* Planet DDS logo: same 40x40 footprint, larger artwork, not interactive */
  .topbar-logo { cursor: default; }
  .topbar-logo:hover { background: transparent; }
  .topbar-logo svg { width: 21px; height: 35px; }
  .topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #bbb;
    margin-left: 4px;
  }
  .topbar-breadcrumb-sep { color: #555; font-size: 16px; font-weight: 300; }
  .topbar-breadcrumb-current { color: #e0e0e0; font-weight: 500; }
  .topbar-patient-name { color: #4da0ff; font-weight: 500; }
  .topbar-patient-edit { color: #888; font-size: 16px; vertical-align: middle; cursor: pointer; }
  .topbar-patient-edit:hover { color: #e0e0e0; }

  .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .topbar-badge-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .topbar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f44336;
    margin: 0 4px;
  }
  .topbar-location {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 4px 8px 4px 12px;
    font-size: 13px;
    color: #ccc;
    cursor: pointer;
    min-width: 160px;
  }
  .topbar-location svg { width: 18px; height: 18px; fill: currentColor; color: #888; margin-left: auto; }
  .topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #37474f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    color: #cfd8dc;
    cursor: pointer;
    margin-left: 4px;
  }

  /* ── User menu: profile / Settings list / Location Settings ── */
  .usermenu-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    display: none;
    z-index: 1100;
  }
  .usermenu-overlay.visible { display: block; }
  .usermenu-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: calc(100vw - 24px);
    background: #26282e;
    border-left: 1px solid #3a3a3a;
    box-shadow: -8px 0 28px rgba(0,0,0,0.5);
    overflow-y: auto;
  }
  .usermenu-screen { display: none; padding: 20px 0; }
  .usermenu-screen.active { display: block; }
  .usermenu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 16px;
  }
  .usermenu-title { font-size: 18px; font-weight: 600; color: #f0f0f0; }
  .usermenu-back, .usermenu-close { color: #ccc; cursor: pointer; font-size: 20px; }
  .usermenu-close { margin-left: auto; }
  .usermenu-back:hover, .usermenu-close:hover { color: #fff; }
  .usermenu-list { display: flex; flex-direction: column; }
  .usermenu-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #e6e6e6;
    cursor: pointer;
  }
  .usermenu-row:hover { background: rgba(255,255,255,0.06); }
  .usermenu-row .material-symbols-outlined { font-size: 20px; color: #cfd6e0; }
  .usermenu-row-nav .material-symbols-outlined { margin-left: auto; font-size: 18px; }
  .usermenu-divider { height: 1px; background: #3a3a3a; margin: 8px 20px; }

  /* Location Settings form */
  .locsettings-body { padding: 4px 20px 20px; }
  .locsettings-current { font-size: 13px; color: #ddd; margin-bottom: 16px; }
  .locsettings-field { margin-bottom: 18px; }
  .locsettings-label { font-size: 13px; color: #ccc; margin-bottom: 8px; }
  .locsettings-segment {
    display: flex;
    border: 1px solid #1976d2;
    border-radius: 4px;
    overflow: hidden;
  }
  .locsettings-opt {
    flex: 1;
    padding: 8px 0;
    background: transparent;
    border: none;
    border-left: 1px solid #1976d2;
    color: #cfd6e0;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
  }
  .locsettings-opt:first-child { border-left: none; }
  .locsettings-opt:hover { background: rgba(255,255,255,0.06); }
  .locsettings-opt.active { background: #1976d2; color: #fff; }
  .locsettings-opt:disabled { color: #666; cursor: default; }
  .locsettings-select {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid #1976d2;
    border-radius: 4px;
    color: #cfd6e0;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
  }
  .locsettings-select:hover { background: rgba(255,255,255,0.06); }
  .locsettings-save {
    width: 100%;
    margin-top: 8px;
    padding: 10px 0;
    background: #1976d2;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
  }
  .locsettings-save:hover { background: #1565c0; }

  /* Site Settings screen */
  .sitesettings-body { padding: 4px 20px 20px; }
  .sitesettings-field { margin-bottom: 18px; }
  .sitesettings-input-wrap { position: relative; }
  .sitesettings-input {
    width: 100%;
    padding: 8px 30px 8px 10px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #e6e6e6;
    font-family: inherit;
    font-size: 13px;
  }
  .sitesettings-input-clear, .sitesettings-input-more {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
  }
  .sitesettings-input-clear { right: 8px; }
  .sitesettings-input-more { right: 30px; }
  .sitesettings-stepper { display: flex; }
  .sitesettings-stepper-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid #555;
    border-right: none;
    border-radius: 4px 0 0 4px;
    color: #e6e6e6;
    font-family: inherit;
    font-size: 13px;
  }
  .sitesettings-stepper-btn {
    width: 32px;
    flex-shrink: 0;
    background: #1976d2;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .sitesettings-stepper-btn:hover { background: #1565c0; }
  .sitesettings-stepper-btn:last-child { border-radius: 0 4px 4px 0; }
  .sitesettings-stepper-btn .material-icons { font-size: 18px; }
  .sitesettings-checklist { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
  .sitesettings-checklist .clin-check { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
  .sitesettings-section-title { font-size: 13px; font-weight: 600; color: #e0e0e0; margin: 16px 0 14px; }

  /* Design Settings screen: experimental, off-by-default feedback flags */
  .designsettings-body { padding: 4px 20px 20px; }
  .designsettings-body .clin-check { display: flex; flex-direction: row-reverse; justify-content: flex-end; margin-bottom: 6px; }
  .design-flag-desc { font-size: 11px; color: #9aa1aa; line-height: 1.5; margin: 0 0 18px 23px; }

  /* ── Main layout ── */
  .layout {
    display: flex;
    flex: 1;
    overflow: hidden;
  }

  /* ── Study panel (thumbnails) ── */
  .study-panel {
    width: 168px;
    background: #141414;
    border-right: 1px solid #252525;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.2s ease;
  }
  /* Collapsed: panel fully hidden; the expand control lives at the bottom of the tool strip */
  body.panel-collapsed .study-panel { width: 0; border-right: none; }
  .study-search {
    padding: 8px 6px 4px;
    border-bottom: 1px solid #252525;
    flex-shrink: 0;
  }
  .study-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e1e1e;
    border: 1px solid #2e2e2e;
    border-radius: 4px;
    padding: 5px 8px;
    margin-bottom: 6px;
  }
  .study-search-input-wrap .material-icons { font-size: 15px; color: #555; flex-shrink: 0; }
  .study-search-input-wrap input {
    background: transparent;
    border: none;
    outline: none;
    color: #e0e0e0;
    font-size: 12px;
    width: 100%;
    font-family: inherit;
  }
  .study-search-input-wrap input::placeholder { color: #444; }
  .study-filter-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
  }
  .study-chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid #2e2e2e;
    color: #888;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
  }
  .study-chip:hover { border-color: #4a4a4a; color: #bbb; }
  .study-chip.active { background: #1a3a5c; border-color: #1976d2; color: #4da0ff; }

  .study-no-results {
    padding: 16px 8px;
    font-size: 12px;
    color: #555;
    text-align: center;
  }

  .study-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
  }
  .study-list::-webkit-scrollbar { width: 4px; }
  .study-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

  .study-card {
    background: #1e1e1e;
    border-radius: 4px;
    margin-bottom: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.1s;
    position: relative;
  }
  .study-card:hover { border-color: #3a3a3a; }
  .study-card.active { border-color: #1976d2; }

  .study-thumb {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
    background: #000;
  }
  .study-meta {
    padding: 4px 8px 6px;
    font-size: 11px;
    color: #888;
    line-height: 1.5;
  }
  .study-meta strong { display: block; color: #aaa; }

  .study-footer {
    height: 48px;
    border-top: 1px solid #252525;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 11px;
    color: #666;
    gap: 6px;
    flex-shrink: 0;
  }
  .study-footer-back {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #333;
    background: transparent;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: auto;
  }
  .study-footer-back svg { width: 14px; height: 14px; fill: currentColor; }

  /* ── Left tool strip ── */
  .tool-strip {
    width: 60px;
    background: #313339;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 6px;
    gap: 9px;
    flex-shrink: 0;
  }
  .tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
    flex-shrink: 0;
  }
  .tool-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
  .tool-btn.active { background: #4da0ff; color: #fff; border-radius: 5px; }
  .tool-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
  .tool-btn svg { width: 20px; height: 20px; fill: currentColor; }
  /* Rocket art has padding inside its 32 viewBox, so size it up to read like the Material icons */
  #rocketBtn svg { width: 24px; height: 24px; }
  .tool-divider { width: 100%; height: 1px; background: rgba(255,255,255,0.2); margin: 0; }

  /* Expand control shown only when the study panel is collapsed; pinned to the
     bottom of the tool strip, under the rocket icon */
  .panel-expand {
    display: none;
    margin-top: auto;
    margin-bottom: 9px;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: 1px solid #333;
    border-radius: 6px;
    background: transparent;
    color: #888;
    cursor: pointer;
    align-items: center;
    justify-content: center;
  }
  .panel-expand:hover { background: rgba(255,255,255,0.1); color: #fff; }
  .panel-expand svg { width: 14px; height: 14px; fill: currentColor; transform: rotate(180deg); }
  body.panel-collapsed .panel-expand { display: flex; }

  /* ── Canvas area ── */
  .canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #121212;
  }
  #mainCanvas { display: block; }

  /* ── Spot panel — floats in canvas, anchored top-left ── */
  .spot-panel {
    position: absolute;
    bottom: 80px;
    left: 260px;
    width: 228px;
    background: #242424;
    border: 1px solid #353535;
    border-radius: 6px;
    overflow: hidden;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 10;
  }
  .spot-panel.visible { display: block; }
  .panel-header {
    padding: 10px 14px 8px;
    border-bottom: 1px solid #353535;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .panel-title { font-size: 13px; font-weight: 500; color: #e0e0e0; letter-spacing: 0.01em; }
  .panel-actions { display: flex; align-items: center; gap: 2px; }
  .panel-action-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
  }
  .panel-action-btn:hover { background: rgba(255,255,255,0.08); color: #e0e0e0; }
  .panel-action-btn .material-icons { font-size: 16px; }
  .panel-body { padding: 14px 14px 6px; }
  .control-row { margin-bottom: 14px; }
  .control-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: none;
    letter-spacing: 0.04em;
  }
  .control-value {
    font-size: 11px;
    color: #bbb;
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    text-align: right;
    text-transform: none;
    letter-spacing: 0;
  }
  .slider-row { display: flex; align-items: center; gap: 6px; }
  .slider-btn {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 3px;
    border: 1px solid #444;
    background: #2e2e2e;
    color: #bbb;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    user-select: none;
  }
  .slider-btn:hover { background: #3a3a3a; color: #fff; }
  .slider-btn:active { background: #1976d2; border-color: #1976d2; color: #fff; }

  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(to right, #1976d2 50%, #444 50%);
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1976d2;
    cursor: pointer;
  }
  input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #1976d2;
    cursor: pointer;
    border: none;
  }
  .panel-footer {
    padding: 8px 14px 10px;
    border-top: 1px solid #353535;
  }
  .reset-btn {
    background: transparent;
    color: #90caf9;
    border: 1px solid #1976d2;
    border-radius: 4px;
    padding: 5px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
  }
  .reset-btn:hover { background: rgba(25,118,210,0.15); }
  .reset-btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }

  /* ── Upload series panel, dropped from the right toolbar's Import button ── */
  .upload-panel {
    position: absolute;
    top: 64px;
    right: 66px;
    width: 260px;
    background: #242424;
    border: 1px solid #353535;
    border-radius: 6px;
    overflow: hidden;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 20;
  }
  .upload-panel.visible { display: block; }
  .upload-panel .control-row:last-child { margin-bottom: 0; }
  .upload-optional { color: #666; font-weight: 400; text-transform: none; }
  .upload-file-btn {
    display: inline-flex;
    align-items: center;
    background: #2e2e2e;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #cfd6e0;
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
  }
  .upload-file-btn:hover { background: #363636; }
  .upload-file-list {
    margin-top: 6px;
    font-size: 11px;
    color: #999;
    line-height: 1.5;
    word-break: break-all;
  }
  .upload-hint { margin-top: 6px; font-size: 10.5px; color: #666; line-height: 1.4; }
  .upload-text-input {
    width: 100%;
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
    padding: 6px 8px;
  }
  .upload-text-input::placeholder { color: #666; }
  .upload-text-input:focus-visible { outline: 2px solid #4da0ff; outline-offset: 1px; }

  /* ── Right toolbar ── */
  .right-strip {
    width: 60px;
    background: #313339;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 6px;
    gap: 9px;
    flex-shrink: 0;
  }

  /* ── Status bar ── */
  /* ── Bottom toolbar ── */
  .bottombar {
    position: absolute;
    left: 169px;
    right: 0;
    bottom: 0;
    height: 48px;
    background: #313339;
    border-top: 1px solid #d1ccc7;
    display: none;
    align-items: center;
    justify-content: flex-start;
    padding-left: 12px;
    gap: 2px;
    /* Above the compare-view overlays (captions, labels, acceptability card)
       so it never gets covered when a card sits near the bottom edge. */
    z-index: 20;
  }
  .bottom-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .bottom-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
  .bottom-btn svg { width: 20px; height: 20px; fill: currentColor; }
  .tool-btn .material-icons,
  .bottom-btn .material-icons { font-size: 24px; }
  .tool-btn .material-symbols-outlined,
  .bottom-btn .material-symbols-outlined { font-size: 24px; }
  .bottom-btn.active { background: #1976d2; color: #fff; border-radius: 50%; }
  .bottom-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

  /* Flip control: a labelled pill (icon + text) rather than an icon-only
     circle, since "View Original"/"View Enhance" needs to read clearly on
     its own in the bottom toolbar. */
  .bottom-btn-labeled {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 17px;
    border: 1px solid #46484e;
    background: transparent;
    color: #aaa;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 8px;
  }
  .bottom-btn-labeled:hover { background: rgba(255,255,255,0.08); color: #fff; }
  .bottom-btn-labeled .material-symbols-outlined { font-size: 18px; }
  /* View Original and View Enhance intentionally look identical: same
     outline, no colour change between them, so the button reads as one
     consistent control rather than having a "more active" state. */

  /* Vertical divider between the icon row and the flip button */
  .bottombar-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.2); margin: 0 6px; flex-shrink: 0; }

  .cbct-card { position: relative; }

  /* ── CBCT canvas state ── */
  .cbct-canvas-state {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #111;
    z-index: 5;
  }
  .cbct-canvas-state.visible { display: flex; }
  .cbct-canvas-icon .material-symbols-outlined {
    font-size: 56px;
    color: #333;
    transition: color 0.3s;
  }
  @keyframes spin-cube {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
  .cbct-canvas-state.loading .cbct-canvas-icon .material-symbols-outlined {
    color: #1976d2;
    animation: spin-cube 1.2s linear infinite;
    display: inline-block;
  }
  .cbct-canvas-title { font-size: 16px; font-weight: 500; color: #888; }
  .cbct-canvas-desc { font-size: 13px; color: #555; text-align: center; line-height: 1.6; }
  .cbct-canvas-actions { display: flex; gap: 10px; margin-top: 8px; }
  .cbct-canvas-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
  .cbct-canvas-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 9px 18px;
    border-radius: 6px;
    border: 1px solid #1976d2;
    background: transparent;
    color: #4da0ff;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
  }
  .cbct-canvas-btn:hover { background: rgba(25,118,210,0.12); }
  .cbct-canvas-btn.primary { background: #1976d2; color: #fff; }
  .cbct-canvas-btn.primary:hover { background: #1565c0; }
  .cbct-canvas-btn .material-symbols-outlined { font-size: 16px; }


  /* ── Image caption + flag on canvas (tracks pan/zoom) ── */
  .canvas-caption {
    /* Positioned (via JS) to span the image's own left edge + width, so the
       text can centre on the image's true centre (via justify-content) while
       the flag pins to the box's right edge, under the image's right edge. */
    position: absolute;
    display: none;
    justify-content: center;
    padding: 6px 4px 4px;
    pointer-events: none; /* only the flag is interactive */
    z-index: 15;
  }
  .canvas-caption.visible { display: flex; }
  .canvas-caption-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
  }
  .cap-teeth { font-size: 12px; color: #ccc; text-align: center; }
  /* #8a8a8a (not the original #777) to clear WCAG AA's 4.5:1 contrast
     minimum for small text against the canvas's #121212 background. */
  .cap-date { font-size: 16px; color: #8a8a8a; text-align: center; }
  .cap-enhanced { font-size: 16px; color: #ccc; text-align: center; }
  .cap-enhanced-icon { width: 14px; height: 14px; fill: #4da0ff; vertical-align: -1px; margin-right: 4px; }
  /* Compare/enhance mode off: nothing is enhanced, so drop the "enhanced" label */
  body.enhance-off .cap-enhanced { display: none; }
  /* Flag pins to the caption box's right edge (i.e. under the image's right
     edge), out of flow, independent of the centred text's own width. */
  .canvas-caption .flag-btn {
    position: absolute;
    right: 4px;
    /* Aligned with the date line specifically (the caption's first visible
       row), not centred against the whole multi-line block. */
    top: 8px;
  }

  /* Single-image mode: plain stacked caption (matches the compare/overview
     captions). Positioned under the image via JS so it tracks pan/zoom. This
     is always the original (unenhanced) image, so its flag stays visible. */
  .canvas-caption.fixed { align-items: center; }
  .canvas-caption.fixed .cap-teeth,
  .canvas-caption.fixed .cap-date,
  .canvas-caption.fixed .cap-enhanced { white-space: nowrap; text-align: center; }

  .flag-btn {
    pointer-events: auto;
    flex-shrink: 0;
    width: 22px; height: 22px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #6a6a72;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.15s, background 0.15s;
    position: relative;
  }
  .flag-btn:hover { color: #ccc; background: rgba(255,255,255,0.08); }
  .flag-btn.flagged { color: #e05050; }
  .flag-btn.flagged:hover { color: #f06060; }
  .flag-btn .flag-tooltip {
    position: absolute;
    bottom: calc(100% + 7px);
    right: 0;
    background: #2a2a34;
    border: 1px solid #3a3a46;
    color: #ddd;
    font-size: 11px;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
  }
  .flag-btn:hover .flag-tooltip { opacity: 1; }

  /* ── Compare mode labels (fixed headers over each half) ── */
  .compare-labels {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    display: none;
    padding: 0;
    pointer-events: none;
    z-index: 16;
  }
  .compare-labels.visible { display: flex; }

  /* ── Series-overview banner: shown when Advanced Enhance previews are on ── */
  .series-preview-banner {
    position: absolute;
    top: 14px;
    left: 32px;
    display: none;
    align-items: center;
    gap: 10px;
    background: rgba(20,20,20,0.78);
    border: 1px solid #2c2c2c;
    border-radius: 6px;
    padding: 8px 14px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    pointer-events: none;
    z-index: 16;
    /* Matches .compare-label-pill's height, so the "top title" box reads as
       the same size whether it's the overview banner or the Enhanced/
       Original pill, regardless of 1 vs 2 lines of content. */
    min-height: 50px;
  }
  .series-preview-banner.visible { display: flex; }
  .series-preview-banner-icon { width: 16px; height: 16px; fill: #4da0ff; flex-shrink: 0; }
  .series-preview-banner-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .series-preview-banner-title { font-size: 12px; color: #cfd6e0; }

  /* Experimental (design-flag): breadcrumb badge shown while Advanced
     Enhance is active. See #flagStudyBannerToggle. */
  .advanced-study-badge {
    display: none;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
    background: transparent;
    border: 1px solid #2c4770;
    border-radius: 12px;
    padding: 3px 10px 3px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #cfd6e0;
    white-space: nowrap;
  }
  .advanced-study-badge.visible { display: inline-flex; }
  .advanced-study-badge-icon { width: 12px; height: 12px; fill: #4da0ff; flex-shrink: 0; }

  /* Experimental (design-flag): rocket-icon alternative to the flip pill.
     See #flagRocketFlipToggle. */
  #flipBtn.flip-hidden { display: none; }
  #flipRocketBtn { display: none; margin-left: 8px; }
  #flipRocketBtn.visible { display: flex; }
  #flipRocketBtn svg { fill: currentColor; }
  #flipRocketBtn.active { background: #1976d2; color: #fff; border-radius: 50%; }
  .series-preview-banner-sub { font-size: 11px; color: #9aa1aa; }
  .compare-label-icon { width: 14px; height: 14px; fill: #4da0ff; flex-shrink: 0; }
  .compare-label-col {
    width: 50%;
    box-sizing: border-box;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .compare-sub {
    display: block;
    text-align: left;
    font-size: 11px;
    line-height: 1.4;
    color: #9aa1aa;
  }
  .compare-label-col.hidden { display: none; }
  .compare-label-col.full { width: 100%; }

  /* One pill combining what you're looking at (left) and the flip control
     (right), matching the study-card convention of bundling related info
     into a single bordered unit rather than scattering separate elements. */
  .compare-label-pill {
    pointer-events: auto;
    display: flex;
    align-items: stretch;
    /* Matches .series-preview-banner's height, so 1-line (Enhanced) and
       2-line (Original) content both render as the same size box. */
    min-height: 50px;
    background: rgba(20,20,20,0.78);
    border: 1px solid #2c2c2c;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    overflow: hidden;
  }
  .compare-label-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #cfd6e0;
    padding: 5px 12px;
    white-space: nowrap;
  }
  .compare-label-text .material-symbols-outlined { font-size: 15px; color: #8b93a0; }
  /* When a pill also carries a sub-line (e.g. Original's diagnosis note),
     both live in one padded group inside the pill, matching the title+sub
     pattern already used by .series-preview-banner, rather than the sub
     floating below the pill as a separate element. */
  .compare-label-text-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 5px 12px;
  }
  .compare-label-text-group .compare-label-text { padding: 0; white-space: normal; }
  .compare-label-text-group .compare-sub { white-space: normal; }
  /* Advanced Enhance stands out with the brand blue throughout the pill */
  .compare-label-pill.enhanced { border-color: rgba(77,160,255,0.5); }
  .compare-label-pill.enhanced .compare-label-text { color: #cfe6ff; }
  .compare-label-pill.enhanced .compare-label-text .material-symbols-outlined { color: #4da0ff; }

  /* ── Full-height divider between the two compare panels ── */
  .compare-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: #3a3d44;
    display: none;
    pointer-events: none;
    z-index: 14;
  }
  .compare-divider.visible { display: block; }

  /* ── Prev/next image navigation (makes arrow-key cycling discoverable) ── */
  .img-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(20,20,20,0.6);
    color: #cfd6e0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 17;
  }
  .img-nav:hover { background: rgba(40,40,40,0.85); color: #fff; }
  .img-nav .material-icons { font-size: 22px; }
  .img-nav.visible { display: flex; }
  .img-nav-prev { left: 12px; }
  .img-nav-next { right: 12px; }

  /* Panel border emphasis retired: the label pill, icon, and expand-control
     tint already carry the brand-blue emphasis for Advanced Enhance. */
  .enhanced-panel-frame {
    display: none;
  }

  /* Image Quality bottom-bar button hidden per request; kept in the
     DOM/CSS in case it's wanted back. */
  #imageQualityBtnBottom {
    display: none;
  }

  /* ── Per-panel metadata captions in compare view ── */
  .compare-caption {
    /* Positioned (via JS) to span the panel's own left edge + width, so the
       text can centre on the panel's true centre (via justify-content) while
       the flag pins to the box's right edge, under the panel's right edge. */
    position: absolute;
    display: none;
    justify-content: center;
    white-space: nowrap;
    z-index: 16;
  }
  .compare-caption.visible { display: flex; }
  /* The flag reports a quality issue with the original capture, so it only
     appears on the Original caption, never on the Advanced Enhance one. */
  #compareCapEnhanced .flag-btn { display: none; }
  /* Flag pins to the caption box's right edge (i.e. under the panel's right
     edge), out of flow, independent of the centred text's own width. */
  .compare-caption .flag-btn {
    position: absolute;
    right: 4px;
    /* Aligned with the date line specifically (the caption's first visible
       row), not centred against the whole multi-line block. */
    top: 2px;
  }
  .compare-caption .canvas-caption-text {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  .compare-caption .cap-teeth,
  .compare-caption .cap-date,
  .compare-caption .cap-enhanced { white-space: nowrap; text-align: center; }

  /* Enhanced-panel acceptability control: notification-style card, bottom-right */
  .clin-notify {
    position: absolute;
    bottom: 64px;
    /* Centred under the Enhanced panel (its half spans 0-50%, so its centre
       is 25%), matching how the image and label are centred in that half. */
    left: 25%;
    transform: translateX(-50%);
    /* Two explicit layouts, chosen in JS by measuring real available width
       (see updateClinNotifyWide): stacked (question above, options below) at
       a fixed compact width when the panel is too narrow for one line, or
       "wide" (below) when there's room for everything on a single line.
       flex-wrap's own shrink-to-fit sizing was tried first and rejected: an
       auto-width wrapping flex container stretches to fill all available
       width even when wrapped content doesn't need it, so a narrow panel
       produced an unnecessarily wide 2-row card. Measuring and toggling an
       explicit class avoids that. */
    width: 270px;
    max-width: calc(50% - 56px);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    /* De-emphasised: neutral chrome like the other pills, rather than a
       glowing blue card competing with the Enhance/flip pill above. */
    background: rgba(20,20,20,0.85);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 9px 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 16;
  }
  /* Full screen (solo): no divider to avoid, so centre across the whole canvas */
  body.solo-view .clin-notify {
    left: 50%;
    max-width: calc(100% - 80px);
  }
  .clin-notify.visible { display: flex; }

  /* Applied via JS once measurement confirms the question and the Yes/No/Send
     Feedback row genuinely fit on one line (e.g. solo full-width view, or a
     wide-enough split panel). */
  .clin-notify.wide {
    width: auto;
    max-width: none;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    column-gap: 16px;
  }
  .clin-notify.wide .clin-question { white-space: nowrap; }

  .clin-question-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .clin-question {
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.3;
    color: #cfd6e0;
  }
  .clin-notify .clin-info { flex-shrink: 0; }

  .clin-options {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  /* Clinically-acceptable Yes/No radios */
  .clin-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: #cfd6e0;
    cursor: pointer;
    user-select: none;
  }
  .clin-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
  .clin-radio-dot {
    width: 14px;
    height: 14px;
    border: 1.5px solid #666;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
    flex-shrink: 0;
  }
  .clin-radio-dot::after {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #1976d2;
    opacity: 0;
    transition: opacity 0.15s;
  }
  .clin-radio input:checked + .clin-radio-dot { border-color: #1976d2; }
  .clin-radio input:checked + .clin-radio-dot::after { opacity: 1; }
  .clin-radio input:focus-visible + .clin-radio-dot { outline: 2px solid #4da0ff; outline-offset: 2px; }

  /* Send Feedback: only appears once a Yes/No selection has been made, inline
     with the radios (not its own row) to keep the card as short as possible */
  .clin-send-btn {
    display: none;
    margin-left: auto;
    white-space: nowrap;
    background: #1976d2;
    border: none;
    border-radius: 5px;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 10px;
    cursor: pointer;
  }
  .clin-send-btn:hover { background: #2087e8; }
  /* Sent: greyed out so it can't be spammed, until the answer changes */
  .clin-send-btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
  .clin-notify.has-selection .clin-send-btn { display: inline-flex; }

  /* Checkbox variant: single attestation + Send, one tight row. Simpler
     prototype stand-in for the Yes/No card above (see CLIN_VARIANT in
     viewer.js): no info icon yet, and the button is always shown rather
     than gated on a selection, since a checkbox has no "unanswered" state. */
  .clin-notify-checkbox {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    width: auto;
    gap: 10px;
  }
  .clin-notify-checkbox .clin-send-btn {
    display: inline-flex;
    background: transparent;
    border: 1px solid #3a3a3a;
    color: #cfd6e0;
  }
  .clin-notify-checkbox .clin-send-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

  .clin-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: #cfd6e0;
    cursor: pointer;
    user-select: none;
  }
  .clin-check input { position: absolute; opacity: 0; width: 0; height: 0; }
  .clin-box {
    width: 15px;
    height: 15px;
    border: 1.5px solid #666;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
  }
  .clin-box::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0;
    transition: opacity 0.15s;
  }
  .clin-check input:checked + .clin-box { background: #1976d2; border-color: #1976d2; }
  .clin-check input:checked + .clin-box::after { opacity: 1; }
  .clin-check input:focus-visible + .clin-box { outline: 2px solid #4da0ff; outline-offset: 2px; }

  .clin-info {
    background: transparent;
    border: none;
    color: #8b93a0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border-radius: 4px;
  }
  .clin-info:hover { color: #cfd6e0; background: rgba(255,255,255,0.08); }
  .clin-info .material-symbols-outlined { font-size: 18px; }

  /* Disclaimer modal */
  .disclaimer-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
  }
  .disclaimer-modal.visible { display: flex; }
  .disclaimer-box {
    width: 380px;
    max-width: calc(100vw - 48px);
    background: #242424;
    border: 1px solid #353535;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.6);
  }
  .disclaimer-title { font-size: 14px; font-weight: 500; color: #e0e0e0; margin-bottom: 10px; }
  .disclaimer-text { font-size: 12px; line-height: 1.6; color: #aaa; margin-bottom: 16px; }
  .disclaimer-actions { display: flex; justify-content: flex-end; }
  .disclaimer-close {
    background: #1976d2;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 7px 16px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
  }
  .disclaimer-close:hover { background: #1565c0; }

  /* ── Toast / snackbar ── */
  .toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #17233a;
    border: 1px solid #2c4770;
    color: #d7e2f4;
    font-size: 13px;
    padding: 10px 16px;
    border-radius: 22px;
    max-width: 520px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
  }
  .toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  .toast-icon { width: 16px; height: 16px; fill: #4da0ff; flex-shrink: 0; }
