/* imvault — a compact dark theme. */

:root {
  --bg: #101216;
  --bg-elev: #171a21;
  --bg-elev-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #6ea8fe;
  --accent-strong: #4d8ef7;
  --danger: #f2707a;
  --ok: #6ee7a8;
  --warn: #f5c168;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; color: var(--text); }

.muted { color: var(--muted); }
.warn { color: var(--warn); }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.25rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}

.brand {
  display: inline-flex; align-items: center; gap: .45rem;
  font-weight: 700; letter-spacing: -.02em; font-size: 1.1rem;
  color: var(--text); text-decoration: none;
}
.brand img { display: block; flex: none; }

.nav { display: flex; align-items: center; gap: 1rem; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: .92rem; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.btn { color: var(--text); }
.nav a.btn.primary { color: #0b1220; }

.who { color: var(--muted); font-size: .92rem; border-left: 1px solid var(--border); padding-left: 1rem; }

.page {
  flex: 1;
  width: 100%; max-width: var(--maxw);
  margin: 0 auto; padding: 1.5rem 1.25rem 3rem;
}

.foot {
  display: flex; justify-content: space-between; gap: 1rem;
  max-width: var(--maxw); width: 100%;
  margin: 0 auto; padding: 1rem 1.25rem 2rem;
  color: var(--muted); font-size: .82rem;
}

/* ---------- primitives ---------- */

.btn {
  display: inline-block;
  padding: .45rem .85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit; font-size: .9rem;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: #262b36; text-decoration: none; }
.btn.small { padding: .3rem .6rem; font-size: .82rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b1220; font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: #47282d; background: #241a1d; }
.btn.danger:hover { background: #33222a; }

.link {
  background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; cursor: pointer;
  text-decoration: underline;
}
label.link { cursor: pointer; }

.badge {
  display: inline-block;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem; line-height: 1.5;
}
.badge.private { color: var(--danger); border-color: #47282d; }
.badge.warn { color: var(--warn); border-color: #4a3b1e; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.stack { display: flex; flex-direction: column; gap: .85rem; }
.row { display: flex; align-items: center; gap: .55rem; }
.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; margin-top: .6rem; }
.inline-form input { flex: 1; min-width: 0; }

.flash {
  border-radius: 8px; padding: .65rem .9rem; margin: 0 0 1.1rem;
  border: 1px solid var(--border); background: var(--bg-elev);
}
.flash.ok { border-color: #23503a; color: var(--ok); }
.flash.err { border-color: #5a2b30; color: var(--danger); }
.flash ul { margin: .4rem 0 0; padding-left: 1.1rem; }

.empty {
  color: var(--muted); text-align: center;
  padding: 3rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius);
}

.section { margin-top: 2rem; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; }

.narrow { max-width: 420px; margin: 3rem auto 0; }
.center { text-align: center; }
.center .code { font-size: 3rem; font-weight: 700; color: var(--border); margin: 0; }

/* ---------- forms ---------- */

.btn.wide { display: block; width: 100%; text-align: center; }

label { display: block; color: var(--muted); font-size: .88rem; }
label.row { display: flex; align-items: center; }

input[type="text"], input[type="password"], input[type="email"], input:not([type]), select, textarea {
  display: block; width: 100%;
  margin-top: .3rem;
  padding: .5rem .7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
label.row > input[type="checkbox"] { margin: 0; width: auto; }
input[readonly] { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.search { display: flex; gap: .5rem; align-items: center; }
.search input { margin-top: 0; min-width: 220px; }

/* A group of mutually exclusive choices, rendered as a stack of labelled rows
   rather than a bare radio list so the explanation travels with the option. */
fieldset.choices {
  margin: 0;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
fieldset.choices legend { color: var(--muted); font-size: .82rem; padding: 0 .3rem; }
fieldset.choices label.row { align-items: flex-start; }
fieldset.choices label.row > input[type="radio"] { margin: .2rem 0 0; width: auto; }
fieldset.choices label.row span { font-size: .85rem; }
fieldset.choices p.muted { margin: .4rem 0 0; font-size: .8rem; }

/* The instance profiles: side by side where there is room, stacked when not. */
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .8rem; }
.profile {
  display: flex; flex-direction: column; gap: .4rem;
  padding: .8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.profile p { margin: 0; font-size: .82rem; }
.profile button { margin-top: auto; }

/* The three-way visibility control on a file page. */
.vis-control { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.vis-control > .muted { font-size: .82rem; }

/* Who shared a tile, on the instance feed. */
.card .meta .by { color: var(--accent); }

/* ---------- grid & cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .9rem;
}

.card {
  position: relative;
  margin: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .12s ease, transform .12s ease;
}
.card:hover { border-color: #3d4553; transform: translateY(-1px); }

.card .thumb {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1;
  background: #0b0d11;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Play affordance for clips, which show a still poster frame in grids. */
.card .play {
  position: absolute;
  z-index: 1;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(10, 12, 16, .68);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: .95rem;
  padding-left: .2rem;
  pointer-events: none;
}

.card .caption { padding: .5rem .6rem .6rem; }
.card .name {
  display: block;
  color: var(--text); font-size: .86rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .name:hover { text-decoration: none; color: var(--accent); }
.card .meta {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-top: .3rem; color: var(--muted); font-size: .74rem;
}

.card-action { position: absolute; top: .4rem; right: .4rem; opacity: 0; transition: opacity .12s ease; }
.card:hover .card-action, .card:focus-within .card-action { opacity: 1; }

.card .pick { position: absolute; top: .4rem; left: .4rem; z-index: 2; }
.card .pick input { width: auto; margin: 0; }

.icon {
  width: 1.6rem; height: 1.6rem;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(12, 14, 18, .85);
  color: var(--text); cursor: pointer; font-size: .8rem; line-height: 1;
}
.icon.danger:hover { background: #47282d; color: var(--danger); }

/* HTMX removal animation */
.htmx-swapping { opacity: 0; transform: scale(.96); transition: opacity .15s ease, transform .15s ease; }

/* ---------- pager ---------- */

.pager { display: flex; gap: .35rem; justify-content: center; margin: 1.75rem 0 0; flex-wrap: wrap; }
.page-link {
  padding: .3rem .65rem; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--muted); font-size: .85rem;
}
.page-link:hover { color: var(--text); text-decoration: none; }
.page-link.current { background: var(--accent); border-color: var(--accent); color: #0b1220; font-weight: 600; }

/* ---------- chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chips.large .chip { font-size: .9rem; padding: .35rem .7rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: .82rem;
}
.chip a { color: var(--text); }
.chip a:hover { color: var(--accent); text-decoration: none; }
.chip .count { color: var(--muted); font-size: .75rem; }
.chip form { display: flex; }
.chip-x {
  background: none; border: 0; padding: 0 .1rem;
  color: var(--muted); cursor: pointer; font-size: .9rem; line-height: 1;
}
.chip-x:hover { color: var(--danger); }

/* ---------- uploader ---------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.25rem 1rem;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.dropzone.over { border-color: var(--accent); background: #141a26; }
.drop-title { margin: 0; font-size: 1.05rem; font-weight: 600; }
.dropzone .muted { margin: .35rem 0 0; font-size: .88rem; }

.htmx-indicator { opacity: 0; transition: opacity .15s ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- detail page ---------- */

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 820px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
}

.preview {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  display: grid; place-items: center;
  min-height: 240px;
}
.preview img { max-width: 100%; max-height: 78vh; display: block; border-radius: 6px; }
.preview .player {
  width: 100%;
  max-height: 78vh;
  display: block;
  border-radius: 6px;
  background: #000;
}

.side { display: flex; flex-direction: column; gap: 1.1rem; }
.filename { font-size: 1.1rem; overflow-wrap: anywhere; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0; font-size: .88rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.block { border-top: 1px solid var(--border); padding-top: .9rem; }
.block h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.copy { margin-bottom: .5rem; }
.copy input { width: 100%; }

/* ---------- albums ---------- */

.album-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; margin-top: 1.5rem; }
.album-card {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .9rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.album-card:hover { border-color: #3d4553; text-decoration: none; }

/* The owner's settings live behind a disclosure, so an album page opens on its
   images rather than on a form. */
details.album-settings { margin-top: 2rem; }
details.album-settings > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: .9rem;
  padding: .2rem 0;
}
details.album-settings[open] > summary { margin-bottom: .6rem; }

/* The photograph's own description, closed until asked for. */
details.file-details { margin: 0 0 1rem; }
details.file-details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details.file-details[open] > summary { margin-bottom: .5rem; }
details.file-details .facts { margin: 0; }
details.file-details p.muted { margin: .6rem 0 0; font-size: .8rem; }

/* ---------- moderation ---------- */

.report-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }
.report-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.report-head p { margin: .45rem 0 0; }
.report-target { display: flex; gap: .8rem; align-items: center; }
.report-target .thumb { display: block; width: 96px; flex: none; }
.report-target .thumb img { display: block; width: 100%; border-radius: 8px; }

/* Reporting is a disclosure so it does not compete with the content. */
details.report-form { margin-top: 2rem; }
details.report-form > summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details.report-form[open] > summary { margin-bottom: .6rem; }

/* ---------- API keys ---------- */

table.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.keys th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .4rem .6rem;
  border-bottom: 1px solid var(--border);
}
table.keys td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.keys tr:last-child td { border-bottom: 0; }
table.keys code { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }

.chip .owner { color: var(--muted); font-size: .75rem; }

/* ---------- admin ---------- */

.subtabs { display: flex; gap: .5rem; align-items: center; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.stat {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .85rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value { font-size: 1.35rem; font-weight: 650; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }

.usage { display: flex; flex-direction: column; gap: .3rem; min-width: 150px; }
.usage-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.usage-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  min-width: 0;
}
.usage .muted { font-size: .78rem; white-space: nowrap; }

table.users td { vertical-align: top; }
table.users .inline-form { margin: 0; gap: .3rem; }
table.users .inline-form input { width: 6rem; margin: 0; padding: .3rem .5rem; }

.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.row-actions form { margin: 0; }
/* The role picker sits in the action column, where a full-width select would
   push every other control onto its own line. */
.row-actions select { width: auto; margin-top: 0; padding: .25rem .4rem; font-size: .82rem; }

/* Alpine renders after the document is parsed; hide anything it controls until
   then, so nothing flashes before it is initialised. */
[x-cloak] { display: none !important; }

/* ---------- modal ---------- */

/* A native <dialog>, so focus trapping and Escape come from the platform. */
dialog.modal {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.25rem;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
dialog.modal::backdrop {
  background: rgba(8, 10, 14, .72);
}
.modal p { margin: 0 0 .5rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1rem;
}

/* ---------- table filter ---------- */

.filter-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
}
.filter-row input[type="search"] {
  width: auto;
  min-width: 16rem;
  margin: 0;
}
.filter-row .muted { font-size: .82rem; }

.enrol { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-start; }
.enrol .qr { background: #fff; padding: .5rem; border-radius: 8px; }
.enrol > .stack { flex: 1; min-width: 16rem; }

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: .4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.recovery-codes code {
  padding: .35rem .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: .85rem;
}

.danger-zone { border-color: #47282d; }
.danger-zone h2 { color: var(--danger); }

.notice-link { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; }
.notice-link input { flex: 1; min-width: 0; margin: 0; }

/* Inline feedback for an admin action that failed, kept within its own row. */
.row-error-text {
  color: var(--danger);
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.key-reveal {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
  color: var(--ok);
}

pre.code {
  margin: 0;
  padding: .8rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88em;
  color: var(--accent);
}
