:root {
  --bg: #0d0d0e;
  --panel: #151517;
  --panel-2: #1b1b1e;
  --line: #2a2a2e;
  --text: #ececea;
  --dim: #8d8d92;
  --accent: #f0b429;
  --accent-ink: #1a1405;
  --ok: #5fcf8a;
  --bad: #ff6b5e;
  --mono: 'DM Mono', ui-monospace, Menlo, monospace;
  --sans: 'Bricolage Grotesque', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--mono); font-size: 13px; letter-spacing: .04em; display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.account { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--dim); }
.account img { width: 26px; height: 26px; border-radius: 50%; }

.banner { margin: 12px 24px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); font-size: 14px; }
.banner.error { border-color: var(--bad); color: var(--bad); }

.panes {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 16px 24px;
}
/* Stacked on narrow screens: each pane keeps a usable height and the pane area scrolls. */
@media (max-width: 860px) { .panes { grid-template-columns: 1fr; grid-auto-rows: max-content; overflow: auto; } .panes > .pane { height: max(420px, 70vh); } }

.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pane-head { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 18px 6px; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
.meta { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 18px 12px; border-bottom: 1px solid var(--line); }
.pane-body { flex: 1; overflow: auto; min-height: 0; }

input[type=search], input[type=text], select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: 13px var(--mono); min-height: 40px;
}
input[type=search] { flex: 1; min-width: 120px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { font-size: 13px; color: var(--dim); display: flex; gap: 6px; align-items: center; }

.btn {
  font: 500 13px var(--mono); border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 0 14px; min-height: 44px; cursor: pointer;
}
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--dim); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--bad); color: #1d0907; border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; }

.empty { padding: 48px 24px; text-align: center; color: var(--dim); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 17px; }
.empty .btn { margin-top: 14px; }

.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { position: sticky; top: 0; background: var(--panel); text-align: left; font: 400 11px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: .06em; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.list td { padding: 9px 12px; border-bottom: 1px solid #202024; vertical-align: middle; }
.list tr:hover td { background: #19191c; }
.list tr.sel td { background: #2a2310; }
.list tr.off td { opacity: .45; }
.list .num { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.list .name { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .name small { display: block; color: var(--dim); font: 11px var(--mono); }
.list input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.list .chk { width: 42px; }
.list .act { width: 1%; white-space: nowrap; text-align: right; }
.folder-row { cursor: pointer; }
.folder-row .name::before { content: '▸ '; color: var(--accent); }
.tag { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; color: var(--dim); margin-left: 6px; }
.more { padding: 14px; text-align: center; }

.crumbs { flex: 1; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font: 13px var(--mono); min-width: 0; }
.crumbs button { background: none; border: 0; color: var(--dim); font: inherit; cursor: pointer; padding: 8px 4px; min-height: 36px; }
.crumbs button:hover { color: var(--text); }
.crumbs button.here { color: var(--accent); }
.crumbs .sep { color: var(--line); }

.space { height: 3px; background: var(--line); margin: 0 18px 4px; border-radius: 2px; overflow: hidden; }
.space > div { height: 100%; background: var(--accent); }

/* Transfer dock */
.dock { border-top: 1px solid var(--line); background: var(--panel); padding: 12px 24px; max-height: 45vh; overflow: auto; }
.dock-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dock-row .grow { flex: 1; min-width: 200px; }
.dock-row strong { font-weight: 600; }
.dock .meta { display: block; }
.jobs { margin-top: 12px; display: grid; gap: 6px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 160px 92px; gap: 12px; align-items: center; font-size: 13px; }
.item .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .st { font: 12px var(--mono); text-align: right; color: var(--dim); }
.item .st.done { color: var(--ok); }
.item .st.failed { color: var(--bad); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); transition: width .3s; }
.bar.done > div { background: var(--ok); }
.err { grid-column: 1 / -1; color: var(--bad); font: 12px var(--mono); }
.cleanup { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 10px; background: #1d1807; }
.cleanup p { margin: 0 0 10px; }
.cleanup .row { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) { .item { grid-template-columns: 1fr 70px; } .item .bar { display: none; } }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog h3 { margin: 0 0 8px; }
dialog p { color: var(--dim); margin: 0 0 18px; }
dialog input[type=text] { width: 100%; margin: 6px 0 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.file-row { cursor: pointer; }
.list .name .open { all: unset; display: block; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.list .name .open:focus-visible { outline: 2px solid var(--accent); }
.folder-row .name .open { display: inline; }
.file-row:hover .open { color: var(--accent); text-decoration: underline; }

/* Choosing a source */
.source-cards { display: flex; flex-direction: column; gap: 12px; padding: 24px 18px; }
.source-cards p { margin: 0 0 4px; }
.source-card { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; }
.source-card:hover, .source-card:focus-visible { border-color: var(--accent); }
.source-card strong { font-size: 17px; }
.source-card span { color: var(--dim); font-size: 13px; }
.sources { display: flex; gap: 6px; padding: 0 18px 12px; }
.sources button { min-height: 36px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--dim); font: 13px var(--mono); cursor: pointer; }
.sources button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.photo-actions { display: flex; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.picking { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.picking .grow { flex: 1; }
.picking p { margin: 4px 0 8px; display: block; }
.picking a { color: var(--accent); font-size: 13px; }

/* File viewer: fills the window */
dialog.viewer { width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--bg); overflow: hidden; }
dialog.viewer[open] { display: flex; flex-direction: column; }
.v-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.v-title { flex: 1; min-width: 160px; }
.v-title h3 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-tools { display: flex; align-items: center; gap: 8px; }
.v-tools input { width: 62px; min-height: 36px; text-align: right; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font: 13px var(--mono); }
.viewer .btn.small { min-height: 36px; display: inline-flex; align-items: center; white-space: nowrap; }
.v-body { position: relative; flex: 1; min-height: 0; }
.v-stage { position: absolute; inset: 0; }
.v-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 64px; text-align: center; color: var(--dim); pointer-events: none; }
.v-center .btn { pointer-events: auto; }
.v-center h4 { margin: 0; color: var(--text); font-size: 17px; }
.v-spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: v-spin .8s linear infinite; }
@keyframes v-spin { to { transform: rotate(360deg); } }
.v-image { position: absolute; inset: 0; display: flex; overflow: auto; padding: 16px 64px; }
.v-image img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.v-image.zoomed { padding: 0; }
.v-image.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
.v-pdf { position: absolute; inset: 0; overflow: auto; background: #202023; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(21,21,23,.88); color: var(--text); font-size: 22px; cursor: pointer; }
.v-nav.prev { left: 10px; }
.v-nav.next { right: 22px; }
.v-nav:disabled { display: none; }
@media (max-width: 640px) {
  .v-head { padding: 8px 10px; }
  /* Row 1: name and Close. Row 2: tools and Download. */
  .v-title { min-width: calc(100% - 100px); }
  .v-close { order: 1; }
  .v-tools { order: 2; flex: 1; gap: 6px; }
  .viewer .v-head a.btn { order: 3; }
  .viewer .btn.small { padding-left: 9px; padding-right: 9px; font-size: 12px; }
  .v-image { padding: 8px; }
  .v-center { padding: 24px; }
  .v-nav { top: auto; bottom: 14px; transform: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
