/* img: mobile first, dark around media. */
:root {
  --bg: #111; --fg: #eee; --muted: #9a9a9a; --card: #1c1c1c; --line: #2c2c2c;
  --accent: #4c9aff; --ok: #2e9d5b; --no: #c8453c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
main { max-width: 900px; margin: 0 auto; padding: 0 12px env(safe-area-inset-bottom); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 1rem 0; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .25rem; }
code { background: var(--card); padding: 0 4px; border-radius: 4px; }

nav.top { display: flex; gap: 18px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
nav.top form { margin-left: auto; }

button, .button {
  font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 16px; cursor: pointer; text-decoration: none; text-align: center;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.accept { background: var(--ok); border-color: var(--ok); color: #fff; }
button.reject { background: var(--no); border-color: var(--no); color: #fff; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .5; cursor: wait; }

input { font: inherit; width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: #000; color: var(--fg); }
label { display: block; color: var(--muted); }
label input { margin-top: 4px; color: var(--fg); }

.narrow { max-width: 480px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 12px; margin: 1rem 0; }
.danger { margin-top: 2.5rem; }
.notice { background: #18324f; padding: 8px 12px; border-radius: 8px; }
.error { background: #4f1c18; padding: 8px 12px; border-radius: 8px; }

.choices { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.choice { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; text-align: left; }
a.choice { padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--fg); text-decoration: none; }
.choice span { color: var(--muted); font-size: .9rem; }
.choice.current { border-color: var(--accent); }

/* The viewer fills the screen below the navigation. */
.viewer { display: flex; flex-direction: column; min-height: calc(100dvh - 50px); }
.bar { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; color: var(--muted); }
.stage {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: 50dvh;
  touch-action: pan-y pinch-zoom; user-select: none; transition: transform .15s ease, opacity .15s ease;
}
.stage img, .stage video { max-width: 100%; max-height: 70dvh; object-fit: contain; border-radius: 6px; }
.stage.dragging { transition: none; }
.meta { color: var(--muted); font-size: .9rem; text-align: center; margin: 6px 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 8px 0; }
.actions:has(> :nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }
.actions form, .actions button, .actions .button { width: 100%; }
.empty { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.sub { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .85rem; padding: 8px 0 14px; }

/* htmx request indicator (htmx's own inline styles are disabled by the CSP). */
.htmx-indicator { display: none; text-align: center; color: var(--muted); margin: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #4f1c18; color: #fff; padding: 10px 16px; border-radius: 8px; }

/* Album grid: square thumbnails, loaded as they scroll into view. */
.grid { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
.grid li { aspect-ratio: 1; }
.grid a, .grid img, .grid .tile { display: block; width: 100%; height: 100%; }
.grid img { object-fit: cover; border-radius: 3px; background: var(--card); }
.grid .tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: var(--card); border-radius: 3px; color: var(--fg); text-decoration: none; font-size: 1.6rem; }
.grid .tile small { font-size: .8rem; color: var(--muted); }
.grid .more { grid-column: 1 / -1; aspect-ratio: auto; text-align: center; color: var(--muted); padding: 16px; }

/* Album list with cover thumbnails. */
.choice.album { align-items: center; justify-content: flex-start; }
.choice.album img, .choice.album .cover { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; background: var(--line); }
.choice.album .text { display: flex; flex-direction: column; gap: 2px; }
.choice.album .text strong { color: var(--fg); }

/* Info panel under the media. */
.info { margin: 4px 0 12px; color: var(--muted); font-size: .9rem; }
.info summary { cursor: pointer; text-align: center; }
.info dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; color: var(--fg); overflow-wrap: anywhere; }
.prefetch { display: none; }

/* Casting: the button appears when a Chromecast is found; the bar is the
   remote control while a session runs. */
.count { display: inline-flex; align-items: center; gap: 8px; }
.cast-button { background: none; border: 0; padding: 4px; color: var(--muted); cursor: pointer; line-height: 0; }
.cast-button.on { color: var(--accent); }
.castbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--card); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: .9rem; }
.castbar .device { flex: 1; color: var(--muted); }
.castbar .device strong { color: var(--fg); }
.castbar input[type=range] { flex: 1 1 100%; order: 5; }
.castbar button { padding: 6px 12px; }
.castbar[hidden], .castbar [hidden] { display: none; }
