/* The accent is only ever used to mean "this is on the phone": the left rail
   on a row, the progress bar, the storage gauge. It is not decoration. */
:root {
  --paper: #ffffff;
  --fill: #f4f6f3;
  --line: #e4e8e4;
  --ink: #16211c;
  --muted: #6f7a74;
  --pine: #1e6b4e;
  --alert: #b23a48;
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
img { display: block; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: 4px; }

[hidden] { display: none !important; }

.shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  border-inline: 1px solid var(--line);
}

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 24px;
}

/* -------------------------------------------------------------- sign in */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px;
}

.gate-card { width: min(360px, 100%); }
.gate-card h1 { font-size: 30px; font-weight: 620; letter-spacing: -0.025em; margin: 0 0 4px; }
.gate-note { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

.gate-card label { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 6px; }

.gate-card input {
  width: 100%;
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 13px 15px;
  min-height: var(--tap);
}
.gate-card input:focus { background: var(--paper); border-color: var(--line); outline: none; }
.gate-card input:focus-visible { border-color: var(--pine); }

.solid {
  width: 100%;
  margin-top: 24px;
  min-height: var(--tap);
  background: var(--ink);
  color: var(--paper);
  border-radius: 11px;
  padding: 12px 22px;
  font-weight: 600;
}
.solid:disabled { opacity: 0.45; cursor: default; }

.error { color: var(--alert); font-size: 13px; margin: 10px 0 0; }

/* ------------------------------------------------------------- masthead */

h1 {
  font-size: 30px;
  font-weight: 620;
  letter-spacing: -0.025em;
  margin: 30px 0 4px;
}

.sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.sub b { font-weight: 600; color: var(--ink); }

.paste {
  width: 100%;
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 13px 15px;
  min-height: var(--tap);
}
.paste::placeholder { color: var(--muted); }
.paste:focus { background: var(--paper); border-color: var(--line); outline: none; }
.paste:focus-visible { border-color: var(--pine); }

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

.chips {
  display: flex;
  gap: 8px;
  margin: 18px -20px 6px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* --------------------------------------------------------------- groups */

.group {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin: 30px 0 2px;
}

.rows { list-style: none; margin: 0; padding: 0; }

/* The left rail is the whole idea: a solid pine edge means the file is on
   this phone. Scanning the list tells you what survives losing signal,
   before you read a single word. */
.row {
  display: flex;
  gap: 13px;
  width: 100%;
  text-align: left;
  align-items: center;
  padding: 12px 0 12px 13px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  min-height: var(--tap);
}
.row.here { border-left-color: var(--pine); }
.row:active { background: var(--fill); }

.art {
  flex: none;
  width: 76px;
  aspect-ratio: 16 / 10;
  border-radius: 7px;
  background: var(--fill);
  position: relative;
  overflow: hidden;
}
.art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.art .len {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: rgba(22, 33, 28, 0.72);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  padding: 0 4px;
  border-radius: 3px;
}
.art.audio { display: grid; place-items: center; }
.art.audio::after {
  content: "";
  width: 15px; height: 15px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--fill), inset 0 0 0 5px var(--muted);
}

.text { flex: 1; min-width: 0; }
.title {
  font-size: 15px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 3px; }
.meta .warn { color: var(--alert); }

.get {
  flex: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.get svg { stroke: var(--pine); }

/* ---------------------------------------------------------------- queue */

.job { padding: 16px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.job-top { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.job-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-pct { font-size: 14px; color: var(--pine); flex: none; }
.job.failed .job-pct { color: var(--alert); }
.bar { display: block; height: 2px; background: var(--line); border-radius: 2px; margin-top: 11px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pine); transition: width 0.4s linear; }
.job-note { display: block; font-size: 13px; color: var(--muted); margin-top: 8px; }
.job.failed .job-note { color: var(--alert); }

/* A save into OPFS reports on the row itself, in the same pine. */
.row .bar { margin-top: 7px; }

/* ------------------------------------------------------------- settings */

.field { padding: 18px 0; border-bottom: 1px solid var(--line); }
.field-name { font-size: 15px; }
.field-note { font-size: 13px; color: var(--muted); margin-top: 3px; max-width: 34ch; }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }

.gauge { height: 6px; background: var(--fill); border-radius: 3px; margin: 14px 0 8px; overflow: hidden; }
.gauge i { display: block; height: 100%; width: 0; background: var(--pine); transition: width 0.4s ease; }

.switch { flex: none; width: 46px; height: 27px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: var(--paper); transition: transform 0.18s; }
.switch[aria-checked="true"] { background: var(--pine); }
.switch[aria-checked="true"]::after { transform: translateX(19px); }
.switch:disabled { cursor: default; }

.danger { color: var(--alert); font-size: 15px; padding: 18px 0; min-height: var(--tap); }

/* Only an administrator sees this row, so it has to look like a way in. */
#users-open { width: 100%; text-align: left; min-height: var(--tap); }
.chevron { flex: none; color: var(--muted); font-size: 20px; line-height: 1; }

/* ----------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper);
}
.tab {
  flex: 1;
  padding: 11px 0 13px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.tab svg { stroke: currentColor; fill: none; stroke-width: 1.6; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab .count {
  position: absolute;
  transform: translate(16px, -3px);
  background: var(--pine);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  min-width: 15px;
  border-radius: 8px;
  padding: 0 4px;
}

/* --------------------------------------------------------------- sheets */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 28, 0.32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.sheet {
  width: min(460px, 100%);
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  padding: 8px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 84dvh;
  overflow-y: auto;
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes rise { from { transform: translateY(18px); } }

.grab { width: 34px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 18px; }

.sheet h2 { font-size: 19px; font-weight: 620; letter-spacing: -0.015em; margin: 0 0 3px; }
.sheet p.lede { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.option {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  min-height: var(--tap);
}
.option:last-of-type { border-bottom: none; }
.option-size { color: var(--muted); font-size: 14px; }
.option-name { font-size: 16px; }

.sheet-label { font-size: 13px; color: var(--muted); margin: 20px 0 0; }
.sheet-label:first-of-type { margin-top: 0; }

.act {
  width: 100%;
  text-align: left;
  padding: 15px 0;
  font-size: 16px;
  border-bottom: 1px solid var(--line);
  min-height: var(--tap);
}
.act.warn { color: var(--alert); }
.act:last-child { border-bottom: none; }

.spinner { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: 14px; padding: 24px 0 8px; }
.spinner i {
  flex: none;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--pine);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sheet .error { padding-bottom: 8px; }

.sheet-input { display: block; margin-top: 18px; }
.sheet-input span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.sheet-input input {
  width: 100%;
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 13px 15px;
  min-height: var(--tap);
}
.sheet-input input:focus { background: var(--paper); border-color: var(--line); outline: none; }
.sheet-input input:focus-visible { border-color: var(--pine); }

.sheet-switch { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 22px; }
.sheet-switch .field-note { margin-top: 3px; }

/* --------------------------------------------------------------- player */

.dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: var(--fill);
}
.dock-top { display: flex; align-items: center; gap: 12px; }
.dock-title { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock button { color: var(--muted); font-size: 14px; }
.dock audio { width: 100%; height: 34px; }
.play-glyph { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; }
.play-glyph svg { fill: #fff; }

/* Video gets the whole screen: a phone has no room for a stage and a list. */
.stage {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.stage-inner { width: min(720px, 100%); padding: 0 20px; }
.stage-head { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
.stage-title { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-head button { color: var(--muted); font-size: 14px; min-height: var(--tap); }
.stage video { width: 100%; max-height: 62dvh; background: #000; border-radius: 10px; }
.stage-meta { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

.empty { color: var(--muted); font-size: 14px; padding: 40px 0; max-width: 32ch; }

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