/* RawViewer Web: neutral dark chrome so photos read correctly. */
:root {
  --bg: #1e1e20;
  --view-bg: #161618;
  --panel: #252528;
  --panel-2: #2c2c30;
  --line: #38383d;
  --text: #dcdcdf;
  --text-dim: #9a9aa2;
  --text-faint: #6e6e76;
  --accent: #e8a33d;         /* amber: non-zero adjustments, UniWB badge */
  --accent-2: #f07a2a;       /* orange: UniWB not corrected */
  --sel: #3b5f8f;
  --sel-soft: rgba(80, 130, 200, 0.22);
  --focus: #6aa2ff;
  --thumbs-w: 220px;
  --folders-w: 240px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; }
/* the hidden menu and status bar drop out of the grid, so full screen has a single row */
#app.fullscreen { grid-template-rows: minmax(0, 1fr); }
#app.fullscreen #menubar, #app.fullscreen #status, #app.fullscreen .ribbon, #app.fullscreen .infopanel { display: none !important; }

/* ---------------- menu bar ---------------- */
#menubar { display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--line); height: 28px; user-select: none; position: relative; z-index: 50; }
.mtop { position: relative; }
.mtop > .mlabel { display: block; height: 100%; padding: 0 11px; line-height: 27px; border: 0; background: none; cursor: default; }
.mtop.open > .mlabel, .mtop > .mlabel:hover { background: var(--panel-2); }
.mdrop { position: absolute; top: 100%; left: 0; min-width: 270px; background: #2a2a2e; border: 1px solid #45454b; box-shadow: 0 8px 28px rgba(0,0,0,.5); padding: 4px 0; display: none; }
.mtop.open > .mdrop { display: block; }
.mitem { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 14px 5px 8px; border: 0; background: none; text-align: left; cursor: default; white-space: nowrap; }
.mitem:hover:not(:disabled), .mitem.kbd { background: var(--sel); }
.mitem:disabled { color: var(--text-faint); }
.mitem .mcheck { width: 16px; text-align: center; color: var(--accent); }
.mitem .mtext { flex: 1; }
.mitem .mkey { color: var(--text-dim); font-size: 12px; }
.msep { height: 1px; background: var(--line); margin: 4px 0; }
.mhead { padding: 4px 14px 2px 34px; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------------- workspace ---------------- */
#workspace { display: flex; min-height: 0; min-width: 0; position: relative; overflow: hidden; }
#thumbs { order: 1; width: var(--thumbs-w); }
#view { order: 3; flex: 1 1 0; min-width: 100px; position: relative; overflow: hidden; background: var(--view-bg); }
#info { order: 4; }
#folders { order: 5; width: var(--folders-w); }
/* thumbs on the right edge (outermost), folders on the left */
#workspace.thumbs-right #thumbs { order: 6; }
#workspace.folders-left #folders { order: 2; }
#workspace.thumbs-right.folders-left #folders { order: 0; }

.ribbon { position: relative; display: flex; flex-direction: column; background: var(--panel); min-width: 0; flex: none; }
#thumbs { border-right: 1px solid var(--line); }
#workspace.thumbs-right #thumbs { border-right: 0; border-left: 1px solid var(--line); }
#folders { border-left: 1px solid var(--line); }
#workspace.folders-left #folders { border-left: 0; border-right: 1px solid var(--line); }

.ribbon-header { display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px; border-bottom: 1px solid var(--line); background: var(--panel-2); user-select: none; cursor: grab; flex: none; }
.ribbon-header.dragging { cursor: grabbing; }
.rtitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.rbtn { border: 0; background: none; width: 24px; height: 22px; border-radius: 4px; cursor: pointer; color: var(--text-dim); flex: none; }
.rbtn:hover { background: #3a3a40; color: var(--text); }
.expand-folders { display: none; }
#thumbs.show-expand-left .expand-folders.left, #thumbs.show-expand-right .expand-folders.right { display: block; color: var(--accent); }

.splitter { position: absolute; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 5; }
#thumbs .splitter { right: -3px; }
#workspace.thumbs-right #thumbs .splitter { right: auto; left: -3px; }
#folders .splitter { left: -3px; }
#workspace.folders-left #folders .splitter { left: auto; right: -3px; }
.splitter:hover, .splitter.active { background: rgba(106,162,255,.35); }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }

.dock-hint { position: absolute; top: 0; bottom: 0; width: 80px; background: rgba(106,162,255,.18); border: 2px dashed rgba(106,162,255,.6); z-index: 40; pointer-events: none; }

/* ---------------- histogram ---------------- */
.hist { flex: none; padding: 6px 6px 4px; border-bottom: 1px solid var(--line); background: #202023; }
.hist-tools { display: flex; align-items: center; gap: 3px; margin-bottom: 4px; }
.hbtn { border: 1px solid #44444a; background: #2b2b2f; color: var(--text-faint); height: 20px; min-width: 22px; padding: 0 5px; border-radius: 3px; font-size: 11px; cursor: pointer; }
.hbtn.on { color: var(--text); background: #3a3a41; border-color: #5a5a62; }
.hbtn.ch.r.on { color: #ff8a80; } .hbtn.ch.g.on { color: #8fe39a; } .hbtn.ch.b.on { color: #8fb1ff; }
.hbtn.wb.on { color: #111; background: var(--accent); border-color: var(--accent); }
.hbtn:disabled { opacity: .35; cursor: default; }
.hsep { width: 6px; }
.hist-label { flex: 1; text-align: right; color: var(--text-faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-canvas { display: block; background: #121214; border: 1px solid #333338; }
.hist-clip { display: flex; justify-content: space-between; gap: 8px; color: var(--text-faint); font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.hist-clip .cr { color: #f29a92; } .hist-clip .cg { color: #9bd8a2; } .hist-clip .cb { color: #9bb6f2; }

/* ---------------- thumbnails ---------------- */
/* The scrollbar's space is always reserved: otherwise a list that just fits would flicker endlessly
   (scrollbar appears -> tiles narrower and shorter -> no scrollbar -> tiles wider and taller -> …). */
.thumb-scroll { flex: 1; overflow-y: scroll; overflow-x: hidden; scrollbar-gutter: stable; position: relative; outline: none; }
.thumb-scroll:focus-visible { box-shadow: inset 0 0 0 1px var(--focus); }
.thumb-spacer { position: relative; }
.tile { position: absolute; left: 6px; padding-top: 6px; cursor: pointer; }
.tile .frame { position: relative; background: #1a1a1c; border-radius: 3px; overflow: hidden; outline: 2px solid transparent; outline-offset: 1px; }
.tile canvas { display: block; }
.tile:hover .frame { outline-color: #4a4a52; }
.tile.current .frame { outline-color: var(--accent); }
.tile.current .tname { color: var(--text); }
.tile .tname { font-size: 11.5px; color: var(--text-dim); padding: 3px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 20px; }
.tile.unreadable { opacity: .35; }
.tile .tspin { position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #3a3a40; border-top-color: #77777f; animation: spin 0.9s linear infinite; }
.tile.loaded .tspin, .tile.failed .tspin { display: none; }
.tile.failed .frame::after { content: "⚠"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-faint); font-size: 22px; }

/* ---------------- photo view ---------------- */
#photo { position: absolute; left: 0; top: 0; display: block; outline: none; cursor: grab; touch-action: none; --view-bg: #161618; }
#photo.dragging { cursor: grabbing; }
.view-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-dim); pointer-events: none; padding: 24px; }
.view-msg .box { pointer-events: auto; max-width: 560px; }
.view-msg h1 { font-size: 22px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.view-msg p { margin: 6px 0; line-height: 1.5; }
.view-msg .err { color: #f0a0a0; }
.view-msg .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.btn { border: 1px solid #4a4a52; background: #2e2e33; padding: 7px 14px; border-radius: 5px; cursor: pointer; }
.btn:hover { background: #3a3a41; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 600; }
.btn.primary:hover { background: #f0b357; }
.view-msg .small { font-size: 12px; color: var(--text-faint); }
.view-msg kbd, .dlg kbd { font: 11px/1 ui-monospace, Consolas, monospace; background: #333338; border: 1px solid #4a4a52; border-bottom-width: 2px; border-radius: 3px; padding: 2px 5px; color: var(--text); }

.spinner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; background: rgba(20,20,22,.72); padding: 16px 20px 12px; border-radius: 10px; }
.spinner .ring { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.18); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.spinner[hidden] .ring { animation: none; }
.spinner .stext { color: var(--text); font-size: 12.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.drop-overlay { position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 12px; background: rgba(232,163,61,.08); display: grid; place-items: center; font-size: 16px; color: var(--text); pointer-events: none; z-index: 30; }

/* ---------------- info panel ---------------- */
.infopanel { width: 300px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
.info-body { flex: 1; overflow: auto; padding: 8px 10px 16px; }
.info-body table { width: 100%; border-collapse: collapse; }
.info-body th { text-align: left; font-weight: normal; color: var(--text-dim); vertical-align: top; padding: 3px 8px 3px 0; white-space: nowrap; width: 1%; }
.info-body td { padding: 3px 0; word-break: break-word; }
.info-body tr.sec th { padding-top: 12px; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.info-body .amber { color: var(--accent); font-weight: 600; }

/* ---------------- folder tree ---------------- */
.tree { flex: 1; overflow: auto; outline: none; padding: 4px 0 12px; user-select: none; }
.tree:focus-visible { box-shadow: inset 0 0 0 1px var(--focus); }
.tsection { padding: 8px 10px 3px; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.tempty { padding: 2px 12px 6px; color: var(--text-faint); font-size: 12px; line-height: 1.4; }
.trow { display: flex; align-items: center; gap: 4px; height: 24px; padding-right: 4px; cursor: default; white-space: nowrap; }
.trow:hover { background: rgba(255,255,255,.05); }
.trow.sel { background: var(--sel-soft); }
.tree:focus .trow.sel { background: var(--sel); }
.twist { width: 14px; height: 14px; flex: none; position: relative; cursor: pointer; }
.twist::before { content: ""; position: absolute; left: 4px; top: 3px; border: 4px solid transparent; border-left: 5px solid var(--text-dim); transition: transform .1s; transform-origin: 2px 4px; }
.twist.open::before { transform: rotate(90deg); }
.twist.none::before { display: none; }
.ticon { width: 16px; height: 12px; flex: none; border-radius: 2px; background: #c9a35a; position: relative; opacity: .85; }
.ticon::before { content: ""; position: absolute; left: 0; top: -3px; width: 7px; height: 4px; border-radius: 2px 2px 0 0; background: #c9a35a; }
.ticon.session { background: #7f95b8; } .ticon.session::before { background: #7f95b8; }
.trow.locked .ticon { opacity: .4; }
.tlabel { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.trow.locked .tlabel { color: var(--text-dim); font-style: italic; }
.tforget { border: 0; background: none; color: var(--text-faint); width: 18px; height: 18px; border-radius: 3px; cursor: pointer; visibility: hidden; flex: none; }
.trow:hover .tforget { visibility: visible; }
.tforget:hover { background: #4a3a3a; color: #f0a0a0; }

/* ---------------- status bar ---------------- */
#status { display: flex; flex-wrap: wrap; align-items: center; column-gap: 0; row-gap: 2px; padding: 3px 6px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; color: var(--text-dim); min-height: 28px; user-select: none; }
.sitem { padding: 0 9px; white-space: nowrap; border-right: 1px solid var(--line); line-height: 20px; }
.sitem:empty { display: none; }
.sitem.sright { margin-left: auto; border-right: 0; border-left: 1px solid var(--line); }
/* camera summary sits at the right end, next to the source / render time */
#sExif { margin-left: auto; border-right: 0; border-left: 1px solid var(--line); }
#sExif:not(:empty) ~ #sSource { margin-left: 0; }
#sPos { color: var(--text); max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.adjgroup { display: inline-flex; align-items: center; padding: 0 6px; border-right: 1px solid var(--line); }
.adjgroup.disabled, .wbgroup.disabled { opacity: .4; pointer-events: none; }
.wbgroup { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; }
#wbBtn { text-align: left; color: var(--text); }
/* status-bar buttons that open a popup menu: a small ▴ on the right */
.menubtn { position: relative; padding-right: 18px !important; }
.menubtn::after { content: ""; position: absolute; right: 6px; top: 7px; border: 4px solid transparent; border-bottom: 5px solid currentColor; border-top: 0; opacity: .7; }
.menubtn.open { background: var(--sel) !important; border-color: var(--sel) !important; color: var(--text) !important; }
.menubtn.down::after { border-bottom: 0; border-top: 5px solid currentColor; top: 8px; }
.hdrbtn { flex: none; height: 22px; padding: 0 8px; border: 1px solid #45454b; background: #2e2e33; border-radius: 3px; cursor: pointer; font-size: 12px; color: var(--text); }
.hdrbtn:hover { background: #3a3a41; }
.hdrbtn.filtered { background: rgba(232,163,61,.18); border-color: rgba(232,163,61,.6); color: var(--accent); font-weight: 600; }
.statuspop.down { box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.statuspop { position: fixed; z-index: 60; min-width: 220px; background: #2a2a2e; border: 1px solid #45454b; box-shadow: 0 -8px 28px rgba(0,0,0,.5); padding: 4px 0; border-radius: 4px; user-select: none; }
.statuspop .mswatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #55555c; flex: none; }
.zoomgroup { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; }
.zoomgroup.disabled { opacity: .4; pointer-events: none; }
#zoomBtn { text-align: left; color: var(--text); }
#zoomNote { color: var(--text-dim); padding-left: 2px; }
#zoomNote:empty { display: none; }
.av.kelvin.est { color: var(--text-dim); font-style: italic; }
.ksuf { color: var(--text-dim); margin-left: -2px; }
.adj { display: inline-flex; align-items: center; gap: 2px; }
.ab { width: 20px; height: 20px; border: 1px solid #45454b; background: #2e2e33; border-radius: 3px; cursor: pointer; line-height: 1; padding: 0; }
.ab:hover { background: #3c3c43; }
.an { padding: 0 3px 0 4px; }
.av { width: 40px; height: 20px; border: 1px solid transparent; background: transparent; color: var(--text); text-align: center; font: inherit; font-variant-numeric: tabular-nums; border-radius: 3px; padding: 0 4px; }
.av:hover { border-color: #45454b; }
.av:focus { outline: none; border-color: var(--focus); background: #18181b; }
.av.nonzero { color: var(--accent); font-weight: 700; }
.ssep { color: #4a4a52; padding: 0 6px; }
.sbtn { border: 1px solid #45454b; background: #2e2e33; border-radius: 3px; padding: 0 8px; height: 20px; cursor: pointer; }
.sbtn:disabled { opacity: .4; cursor: default; }
/* processing mode: Immediate / Delayed toggle and Apply */
.procgroup { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; }
#procBtn { color: var(--text); }
#procBtn.delayed { background: #2f4a6e; border-color: #4f78ad; }
#applyBtn.pending { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 700; }
#applyBtn.pending:hover { background: #f0b357; }
.sitem.sharpen { padding: 0 6px; }
/* Sharpen levels: light orange, orange, red */

#sharpenBtn.lv1 { background: #f7c98a; border-color: #f7c98a; color: #3a2610; font-weight: 700; }
#sharpenBtn.lv2 { background: #f0882e; border-color: #f0882e; color: #24140a; font-weight: 700; }
#sharpenBtn.lv3 { background: #d9362b; border-color: #d9362b; color: #fff; font-weight: 700; }
.badge { display: inline-block; padding: 0 7px; border-radius: 9px; line-height: 18px; font-size: 11.5px; }
.badge.grey { background: #34343a; color: var(--text-dim); }
.badge.amber { background: rgba(232,163,61,.18); color: var(--accent); border: 1px solid rgba(232,163,61,.5); }
.badge.orange { background: rgba(240,122,42,.18); color: #ff9a55; border: 1px solid rgba(240,122,42,.55); }
#sNote { color: #e6b866; }

/* ---------------- dialogs ---------------- */
.dlg { background: #26262a; color: var(--text); border: 1px solid #48484f; border-radius: 10px; padding: 0; min-width: 360px; max-width: min(720px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dlg::backdrop { background: rgba(0,0,0,.55); }
.dlg form { padding: 18px 20px 14px; }
.dlg-title { margin: 0 0 10px; font-size: 16px; }
.dlg-body { line-height: 1.5; max-height: 70vh; overflow: auto; }
.dlg-body p { margin: 6px 0; }
.dlg-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg table.keys { border-collapse: collapse; width: 100%; }
.dlg table.keys td { padding: 3px 10px 3px 0; vertical-align: top; }
.dlg table.keys td:first-child { white-space: nowrap; color: var(--text-dim); }
.dlg .danger { color: #ff9a8a; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3c3c42; border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* Fixed sizes: buttons and value boxes never change width as their labels and values change, so
   the controls after them don't shift. Sized for the longest label/value, with room for font differences. */
#procBtn, #applyBtn, #zoomBtn, #sharpenBtn, #wbBtn, #filterBtn, #adjReset { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#procBtn { width: 88px; }
#applyBtn { width: 88px; }
#zoomBtn { width: 66px; }
#sharpenBtn { width: 100px; }
#wbBtn { width: 150px; }
#filterBtn { width: 100px; }
#adjReset { width: 56px; }
.adj .av { width: 40px; }                  /* "-1.5" */
.adj[data-adj="ev"] .av { width: 62px; }   /* "+1.5 EV" */
.av.kelvin { width: 50px; }                /* "15000" */
.av.zoombox { width: 46px; }               /* "3200" */
