/* Radflow viewer: dark reading-room layout (header toolbar, series browser, viewport grid, measurements panel). */
:root {
  --bg: #000;
  --panel: #0a0a0a;
  --panel-2: #121212;
  --top: #000;
  --line: #1e1e1e;
  --line-2: #303030;
  --text: #ededed;
  --muted: #8c8c8c;
  --icon: #d6d6d6;
  --accent: #8fd0f5;
  --accent-ink: #000;
  --hover: #1a1a1a;
  --warn: #f1c40f;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 13px/1.35 var(--sans); overflow: hidden; }
button { font: inherit; color: inherit; }
.rv { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* Header */
.rv-top { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 10px; background: var(--top); border-bottom: 1px solid var(--line); flex: none; min-width: 0; }
.rv-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: .01em; flex: none; }
.rv-mark { width: 18px; height: 18px; background: linear-gradient(135deg, #fff, var(--accent)); clip-path: polygon(0 0, 100% 0, 100% 62%, 62% 100%, 0 100%); }
.rv-study { display: flex; flex-direction: column; min-width: 0; max-width: 26vw; padding-left: 10px; border-left: 1px solid var(--line); }
.rv-study strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-study span { color: var(--muted); font-size: 11.5px; }
.rv-tools { flex: 1; display: flex; align-items: center; justify-content: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.rv-tools::-webkit-scrollbar { display: none; }
.rv-right { display: flex; align-items: center; gap: 4px; flex: none; }
.rv-tsep { width: 1px; height: 26px; background: var(--line-2); margin: 0 6px; flex: none; }

.rv-tb { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 1px; height: 38px; min-width: 38px; padding: 0 7px; border: 0; background: transparent; color: var(--icon); cursor: pointer; flex: none; }
.rv-tb:hover { background: var(--hover); color: #fff; }
.rv-tb.is-on { background: var(--accent); color: var(--accent-ink); }
.rv-tb.is-open { background: var(--hover); color: var(--text); }
.rv-tb.is-on.is-open { background: var(--accent); color: var(--accent-ink); }
.rv-tb[hidden] { display: none; }
.rv-ic { display: inline-flex; }
.rv-caret { display: inline-flex; padding: 0 0 0 2px; opacity: .85; align-self: stretch; align-items: center; }
.rv-tb.has-split .rv-caret { border-left: 1px solid transparent; margin-left: 2px; padding-left: 3px; }
.rv-tb.has-split:hover .rv-caret { border-left-color: var(--line-2); }

.rv-iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; font-weight: 600; font-size: 15px; }
.rv-iconbtn:hover { background: var(--hover); color: var(--text); }
.rv-badge { position: absolute; top: 3px; right: 2px; min-width: 15px; padding: 0 3px; background: var(--accent); color: var(--accent-ink); font-size: 10px; line-height: 15px; font-weight: 600; text-align: center; }
.rv-badge:empty { display: none; }

/* Menus */
.rv-menu { position: fixed; z-index: 50; min-width: 210px; max-height: 70vh; overflow: auto; padding: 4px 0; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 12px 32px rgba(0, 0, 0, .55); }
.rv-menu > button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 12px; border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); }
.rv-menu > button:hover { background: var(--hover); }
.rv-menu > button.is-on { color: var(--accent); }
.rv-menu > button .rv-ic { color: var(--icon); }
.rv-menu small { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.rv-menu kbd { display: inline-block; min-width: 18px; color: var(--muted); font: 11px var(--sans); }
.rv-menu kbd:last-child:not(:first-child) { margin-left: auto; text-align: right; }
.rv-mh { padding: 6px 12px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.rv-layoutmenu { min-width: 0; padding: 4px 8px 10px; }
.rv-lgrid { display: grid; grid-template-columns: repeat(3, 30px); gap: 3px; padding: 4px; }
.rv-lgrid button { width: 30px; height: 30px; border: 1px solid var(--line-2); background: transparent; cursor: pointer; }
.rv-lgrid button.is-hl { background: var(--accent); border-color: var(--accent); }

/* Body */
.rv-main { flex: 1; display: flex; min-height: 0; }
.rv-left, .rv-rightp { display: flex; flex-direction: column; background: var(--panel); min-height: 0; flex: none; }
.rv-left { width: 248px; border-right: 1px solid var(--line); }
.rv-rightp { width: 268px; border-left: 1px solid var(--line); }
.rv.hide-left .rv-left, .rv.hide-right .rv-rightp { display: none; }
.rv-ph { padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--line); flex: none; }
.rv-series, .rv-measlist { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.rv-empty { padding: 14px 12px; margin: 0; color: var(--muted); }
.rv-note { margin: 0; padding: 10px 12px; color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--line); }

.rv-studyblock > header { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 10px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.rv-studyblock > header strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-studyblock > header small { grid-column: 2; color: var(--muted); }
.rv-dot { width: 8px; height: 8px; margin-top: 5px; background: var(--accent); }
.rv-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
.rv-thumb { display: flex; flex-direction: column; gap: 5px; padding: 4px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; min-width: 0; }
.rv-thumb:hover { border-color: var(--line-2); background: var(--hover); }
.rv-thumb.is-shown .rv-thumb-img { outline: 1px solid var(--line-2); }
.rv-thumb.is-active { border-color: var(--accent); }
.rv-thumb-img { display: block; aspect-ratio: 1; background: #000; overflow: hidden; }
.rv-thumb-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.rv-thumb-txt { display: flex; flex-direction: column; min-width: 0; }
.rv-thumb-txt b { font-weight: 500; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-thumb-txt small { color: var(--muted); font-size: 11px; }
.rv-thumb-txt em { font-style: normal; color: var(--accent); }

/* Viewports */
.rv-grid { flex: 1; display: grid; gap: 1px; min-width: 0; min-height: 0; background: var(--line); padding: 0; }
.rv-vp { position: relative; background: #000; min-width: 0; min-height: 0; overflow: hidden; outline: 1px solid transparent; outline-offset: -1px; }
.rv-vp.is-active { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }
.rv-vp.is-drop { outline: 2px dashed var(--warn); outline-offset: -2px; }
.rv-el { position: absolute; inset: 0; touch-action: none; }
.rv-ov { position: absolute; inset: 0; pointer-events: none; color: #e9eefc; font-size: 12px; line-height: 1.35; text-shadow: 0 0 3px #000, 0 0 2px #000; font-variant-numeric: tabular-nums; }
.rv-tl, .rv-tr, .rv-bl, .rv-br { position: absolute; max-width: 46%; padding: 6px 8px; }
.rv-tl { top: 0; left: 0; } .rv-tr { top: 0; right: 0; text-align: right; } .rv-bl { bottom: 0; left: 0; } .rv-br { bottom: 0; right: 0; text-align: right; }
.rv-tl div:first-child { color: var(--accent); }
.rv-tl div, .rv-tr div, .rv-bl div, .rv-br div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-o { position: absolute; color: var(--warn); font-weight: 600; font-size: 13px; }
.rv-o-t { top: 6px; left: 50%; transform: translateX(-50%); } .rv-o-b { bottom: 6px; left: 50%; transform: translateX(-50%); }
.rv-o-l { left: 8px; top: 50%; transform: translateY(-50%); } .rv-o-r { right: 8px; top: 50%; transform: translateY(-50%); }
.rv-load { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 14px; background: rgba(0, 0, 0, .85); border: 1px solid var(--line-2); color: var(--text); text-shadow: none; max-width: 80%; text-align: center; }
.rv-load[hidden] { display: none; }
.rv-fatal { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: #000; color: var(--muted); }
.rv-btn { display: inline-block; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 500; }

/* Measurements */
.rv-meas { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.rv-meas:hover { background: var(--hover); }
.rv-mi { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.rv-mt { display: flex; flex-direction: column; min-width: 0; }
.rv-mt b { font-weight: 500; }
.rv-mt small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.rv-del { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; display: inline-flex; }
.rv-del:hover { color: #ff7b7b; }
.rv-del svg { width: 17px; height: 17px; }

.rv-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; max-width: min(560px, 92vw); padding: 10px 16px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
.rv-toast[hidden] { display: none; }

.rv-keys { max-width: 520px; width: 92vw; padding: 20px 22px; background: var(--panel); color: var(--text); border: 1px solid var(--line-2); }
.rv-keys::backdrop { background: rgba(0, 0, 0, .6); }
.rv-keys h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.rv-keys dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; margin: 0 0 12px; }
.rv-keys dt { color: var(--accent); }
.rv-keys dd { margin: 0; color: var(--text); }
.rv-keys p { color: var(--muted); margin: 0; }
.rv-keys-x { position: absolute; top: 8px; right: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Narrow screens: panels become drawers over the images. */
@media (max-width: 900px) {
  .rv-study { display: none; }
  .rv-logo { font-size: 0; gap: 0; }
  .rv-tools { justify-content: flex-start; }
  .rv-left, .rv-rightp { position: fixed; top: 52px; bottom: 0; z-index: 20; box-shadow: 0 0 30px rgba(0, 0, 0, .7); display: none; }
  .rv-left { left: 0; width: min(280px, 86vw); }
  .rv-rightp { right: 0; width: min(290px, 86vw); }
  .rv.show-left .rv-left, .rv.show-right .rv-rightp { display: flex; }
  .rv.hide-left.show-left .rv-left, .rv.hide-right.show-right .rv-rightp { display: flex; }
  .rv-tsep { margin: 0 2px; }
}

/* Study mode: the case panel (views/partials/viewer_case.php) */
.rv-casebtn { width: auto; gap: 6px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.rv-casebtn[aria-pressed="true"] { color: var(--accent); }
.rv-casep { display: flex; flex-direction: column; flex: none; width: 360px; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.rv.hide-case .rv-casep { display: none; }
.rc-top { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 4px; padding: 6px 6px; border-bottom: 1px solid var(--line); flex: none; }
.rc-title { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.rc-title strong { font-weight: 600; font-size: 14px; }
.rc-title small { color: var(--muted); font-size: 11.5px; }
.rc-nav { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; color: var(--icon); text-decoration: none; }
.rc-nav:hover { background: var(--hover); color: var(--text); }
.rc-nav.is-off { opacity: .25; pointer-events: none; }
.rc-scroll { flex: 1; overflow-y: auto; padding: 12px 14px 20px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.rc-scroll h3 { margin: 0 0 6px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.rc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.rc-chip { padding: 4px 9px; border: 1px solid var(--line-2); background: var(--panel-2); font-size: 12.5px; }
.rc-chip b { font-weight: 500; color: var(--muted); margin-right: 3px; }
.rc-hist { margin-bottom: 16px; }
.rc-hist p { margin: 0; line-height: 1.5; }
.rc-hist .rc-tip { margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.rc-read { margin-bottom: 16px; }
.rc-read label { display: block; }
.rc-read textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 96px; padding: 9px 10px; background: #000; color: var(--text); border: 1px solid var(--line-2); font: inherit; font-size: 13.5px; line-height: 1.45; }
.rc-read textarea:focus { outline: none; border-color: var(--accent); }
.rc-saved { margin: 4px 0 10px; color: var(--muted); font-size: 11.5px; }
.rc-reveal { width: 100%; padding: 10px; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.rc-reveal:hover { filter: brightness(1.08); }
.rc-reveal[hidden], .rc-answer[hidden], .rc-yours[hidden] { display: none; }
.rc-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rc-bar button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--line-2); background: transparent; color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.rc-bar button:hover { background: var(--hover); }
.rc-bar #rc-hide { margin-left: auto; color: var(--muted); }
.rc-sec { border: 1px solid var(--line); margin-bottom: 8px; background: var(--panel-2); }
.rc-sec summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; cursor: pointer; list-style: none; font-weight: 600; }
.rc-sec summary::-webkit-details-marker { display: none; }
.rc-sec summary::before { content: ''; width: 7px; height: 7px; margin-right: 4px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.rc-sec[open] summary::before { transform: rotate(45deg); }
.rc-sec summary span { flex: 1; }
.rc-say, .rc-bar #rc-sayall { color: var(--muted); }
.rc-say { display: inline-flex; padding: 4px; border: 0; background: transparent; cursor: pointer; }
.rc-say:hover, .rc-say.is-on, .rc-bar #rc-sayall.is-on { color: var(--accent); }
.rc-body { padding: 2px 12px 12px; line-height: 1.55; font-size: 13.5px; }
.rc-body p { margin: 0 0 8px; }
.rc-body ul, .rc-body ol { margin: 0 0 8px; padding-left: 18px; }
.rc-body li { margin-bottom: 4px; }
.rc-body a { color: var(--accent); }
.rc-body strong { color: #fff; font-weight: 600; }
.rc-dx { font-size: 15.5px; font-weight: 600; color: var(--accent); }
.rc-cert { color: var(--muted); font-size: 12.5px; }
.rc-yours { margin-top: 10px; padding: 8px 10px; border-left: 2px solid var(--line-2); background: #000; }
.rc-yours b { display: block; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.rc-yours p { margin: 0; white-space: pre-wrap; }
.rc-meas small { display: block; color: var(--muted); }
.rc-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rc-keys a { display: block; aspect-ratio: 1; background: #000; border: 1px solid var(--line); }
.rc-keys a:hover { border-color: var(--accent); }
.rc-keys img { width: 100%; height: 100%; object-fit: contain; display: block; }
.rc-credit { color: var(--muted); font-size: 11.5px; margin: 10px 0 0; }
.rc-full { display: inline-block; margin-top: 14px; color: var(--accent); font-size: 13px; }
@media (max-width: 1200px) { .rv.is-case .rv-left { width: 200px; } .rv-casep { width: 320px; } }
@media (max-width: 900px) {
  .rv-casebtn span { display: none; }
  .rv-casebtn { width: 36px; padding: 0; }
  .rv-casep { position: fixed; top: 52px; right: 0; bottom: 0; z-index: 21; width: min(380px, 92vw); box-shadow: 0 0 30px rgba(0, 0, 0, .7); display: none; }
  .rv.show-case .rv-casep { display: flex; }
}
