/* SPDX-FileCopyrightText: 2026 Brandon Honeycutt
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #16191d;
  --muted: #616b76;
  --accent: #2f6feb;
  --accent-text: #ffffff;
  --ok: #12855a;
  --ok-bg: #e6f5ee;
  --err: #c2352b;
  --err-bg: #fdeceb;
  --warn: #8a5a00;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --surface: #181c22;
    --border: #2b323b;
    --text: #e8ecf1;
    --muted: #97a2ae;
    --accent: #5b8dff;
    --accent-text: #0b1020;
    --ok: #4ad295;
    --ok-bg: #12291f;
    --err: #ff8079;
    --err-bg: #2c1615;
    --warn: #e0b050;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 46rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
code { font-size: .9em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.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;
}

/* header */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  padding-top: calc(.75rem + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
.bar a { display: inline-flex; align-items: center; min-height: 44px; }
.bar nav { display: flex; align-items: center; gap: 1rem; }
.bar nav a { text-decoration: none; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }

/* surfaces */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.centered { max-width: 22rem; margin: 3rem auto; }

/* forms */
label { display: block; font-weight: 500; margin: .9rem 0 .35rem; }
label:first-of-type { margin-top: 0; }
input[type=text], input[type=password] {
  width: 100%; padding: .7rem .8rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
}
input:focus-visible, button:focus-visible, summary:focus-visible, .picker:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button, .button {
  display: inline-block; padding: .7rem 1rem; font: inherit; font-weight: 500;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); text-decoration: none; text-align: center; cursor: pointer;
  min-height: 44px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
/* A submit that owns its own line goes full width. Scoped to direct form
   children so a .primary sitting inside a .row stays inline. */
form > button.primary { width: 100%; margin-top: 1rem; }
button.danger { color: var(--err); border-color: var(--err); }
/* Wrap rather than squeeze: the button keeps its natural width, so without a
   floor the input absorbs every bit of the shortfall and its placeholder gets
   clipped on narrow phones. Below the basis the button drops to its own line. */
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.wrap {
  display: grid;
  /* Wide enough for the longest label ("Revoke admin") to stay on one line;
     below that the grid drops to a single stacked column. */
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: .5rem;
  margin-top: .5rem;
  /* .row centres its children. Here that would hang a two-line button off its
     one-line neighbours; stretch keeps every button in a row the same height. */
  align-items: stretch;
}
.row.wrap > form { margin: 0; }
.row.wrap button { width: 100%; }
/* The lopsided grow ratio does two jobs: sharing a line, the input takes
   effectively all the slack so the button keeps its natural width; alone on a
   wrapped line, the button is the only thing that can grow, so it fills it. */
.row > input { flex: 100 1 9.5rem; min-width: 0; }
.row > button { flex: 1 1 auto; }
/* The label is the real target: tapping the text toggles the box, so give the
   whole row 44px rather than only enlarging the control. */
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; min-height: 44px; }
.check input { width: 1.25rem; height: 1.25rem; flex: none; }
.hint { font-size: .85rem; color: var(--muted); margin: .4rem 0 0; }
.inline-form { margin-top: 1rem; }

.alert { padding: .7rem .9rem; border-radius: 10px; font-size: .95rem; }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* upload */
.picker {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 2.5rem 1rem; margin: 0 0 1rem; text-align: center; cursor: pointer;
  background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--accent);
}
.picker-title { font-size: 1.05rem; font-weight: 600; }
.picker-sub { font-size: .85rem; color: var(--muted); font-weight: 400; }

.summary { margin-bottom: 1rem; }
.progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.counts { margin: .6rem 0; font-size: .9rem; color: var(--muted); }
#more { width: 100%; }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.file {
  display: grid; grid-template-columns: 1fr auto; gap: .15rem .75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .7rem .85rem;
}
.file-name { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.file-state { grid-column: 2; grid-row: 1 / span 2; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.file-meta { grid-column: 1; font-size: .8rem; color: var(--muted); }
.file.done .file-state { color: var(--ok); }
.file.skipped { opacity: .6; }
.file.failed { border-color: var(--err); }
.file.failed .file-state { color: var(--err); }

/* admin */
.stats { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0 0 .75rem; }
.stats div { margin: 0; }
.stats dt { font-size: .8rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.15rem; font-weight: 600; }
.users { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.user { border: 1px solid var(--border); border-radius: 10px; padding: .8rem; }
.user.off { opacity: .6; }
.user-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.user-name { font-weight: 600; }
.tag {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .15rem .4rem; border-radius: 999px; background: var(--ok-bg); color: var(--ok);
}
.tag.warn { background: var(--err-bg); color: var(--warn); }
.user p { margin: .25rem 0 .5rem; }
/* .9rem text is 21.6px tall, so .7rem of vertical padding brings the
   disclosure up to the 44px touch target the buttons use. Padding rather than
   a flex display, which would drop the marker triangle. */
details summary {
  cursor: pointer; color: var(--accent); font-size: .9rem;
  padding: .7rem 0; min-height: 44px;
}
/* Direct children only: forms inside a .row.wrap are grid items and take
   their spacing from the grid gap, not from a margin. */
details > form { margin-top: .5rem; }
