/* Reveo Diktofon — the four surfaces: the list, one recording, devices, login.
 *
 * app.css holds the shell and the shared primitives and must load first; every
 * colour, face and radius here comes from reveo-tokens.css through it. Split
 * off because one stylesheet for the whole product had grown past the point
 * where you can find a rule by scrolling. */

.filters {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 170px 140px 140px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.filters .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.filters label {
  font-size: var(--t-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-3);
}
.filters .actions {
  align-self: end;
  padding-bottom: 1px;
}

/* ── The list ────────────────────────────────────────────────────────────── */

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  /* `clip`, NOT `hidden`. `overflow: hidden` makes this element a scroll
   * container, and a sticky descendant then resolves its offset against THIS
   * box instead of the viewport — the column header rendered 56px down, on top
   * of the first row, with the page not scrolled at all. `clip` still rounds
   * the corners and is not a scrollport. */
  overflow: clip;
}

.list-head,
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px 76px 150px 168px;
  gap: 12px;
  padding: 10px 14px;
  align-items: start;
}

.list-head {
  font-size: var(--t-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
}

.row {
  position: relative;
  border-bottom: 1px solid var(--line);
  color: inherit;
  /* The border-left is the hover affordance, so the hit target and the
   * highlight are the same rectangle. */
  border-left: 3px solid transparent;
  padding-left: 11px;
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease);
}
.row:last-child {
  border-bottom: none;
}
.row:hover {
  background: var(--surface-hover);
  border-left-color: var(--brand);
}

/* The whole row opens the recording, but the row is NOT an <a>: it now holds a
 * «Hozir yuklash» button, and interactive content nested inside a link is
 * invalid markup that leaves a screen reader announcing one control containing
 * another. So the filename is the real link and an ::after overlay gives it the
 * row's rectangle; the button sits above the overlay on its own layer. */
.row-link {
  /* `block`, because the filename is now an <a> and `text-overflow: ellipsis`
   * does nothing on an inline box — a long name overflowed its column instead
   * of being trimmed. */
  display: block;
  color: inherit;
  font-weight: inherit;
}
.row-link:hover {
  text-decoration: none;
}
.row-link::after {
  content: '';
  position: absolute;
  inset: 0;
}
.row:focus-within {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* A row whose audio has not crossed yet. The tint is what makes the
 * manifest-first list readable at a glance: these rows are real and clickable,
 * and they are also not the same thing as a recording you can play. */
.row-ondevice {
  background: var(--amber-soft);
}
.row-ondevice:hover {
  background: var(--amber-soft);
  border-left-color: var(--amber);
}

.row-name {
  font-family: var(--font-m);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-snippet {
  color: var(--ink-2);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-snippet mark {
  background: var(--brand-soft-2);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}
/* One DOM for both layouts. `display: contents` lets the meta cells sit in the
 * row's own grid columns on a wide screen, and the same element becomes a
 * wrapping flex line on a phone — so there is no second markup path to keep in
 * step with the first. */
.row-meta {
  display: contents;
}

.row-when {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.row-dur {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.row-device {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The state cell carries the chip AND, mid-transfer, the bar. Stacked rather
 * than side by side so a row that starts uploading does not shove the chip out
 * of the column it shares with every other row. */
.row-state {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.row-progress {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-small);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.row-progress .progress {
  flex: 1;
  min-width: 46px;
}

/* Above the row-link overlay, or the click opens the recording instead of
 * asking the Mac for it. */
.row-fetch {
  position: relative;
  z-index: 1;
  align-self: start;
}

/* ── Detail ──────────────────────────────────────────────────────────────── */

.detail-head {
  margin-bottom: 14px;
}
.detail-head h1 {
  font-family: var(--font-m);
  font-size: 17px;
  font-weight: 600;
  margin: 4px 0 8px;
  word-break: break-all;
}
.backlink {
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.player {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.player audio {
  width: 100%;
  display: block;
}
.player-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin-top: 9px;
  color: var(--ink-2);
  font-size: var(--t-small);
}

/* The waiting room: a recording that is listed and not yet here. It sits where
 * the player sits, because that is where somebody looks to hear it, and it
 * answers the question they arrived with. */
.awaiting {
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.awaiting h2 {
  font-size: var(--t-h2);
  font-weight: 600;
  margin: 0 0 4px;
}
.awaiting p {
  margin: 0 0 12px;
  color: var(--ink-2);
  max-width: 62ch;
}
.awaiting .progress {
  margin-bottom: 8px;
}
.awaiting-figures {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--ink-3);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
}
.fact {
  background: var(--surface);
  padding: 9px 12px;
}
.fact dt {
  font-size: var(--t-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.fact dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.panel-head h2 {
  font-size: var(--t-h2);
  font-weight: 600;
  margin: 0;
}
.panel-head .spacer {
  margin-left: auto;
}
.panel-body {
  padding: 4px 0;
}

.turn {
  display: grid;
  grid-template-columns: 26px 62px minmax(0, 1fr);
  gap: 10px;
  padding: 6px 14px;
  align-items: start;
}
.turn:hover {
  background: var(--surface-hover);
}
.turn-speaker {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--on-brand);
  background: var(--ink-4);
}
/* Three hues, because a fourth speaker on a handheld recording is rare and
 * cycling is honest about that. All three are tokens; none is invented here. */
.turn-speaker[data-speaker='A'] {
  background: var(--brand);
}
.turn-speaker[data-speaker='B'] {
  background: var(--violet);
}
.turn-speaker[data-speaker='C'] {
  background: var(--tg);
}
.turn-time {
  background: none;
  border: none;
  padding: 2px 0 0;
  cursor: pointer;
  text-align: left;
  color: var(--ink-3);
  font-family: var(--font-m);
  font-size: 12px;
}
.turn-time:hover {
  color: var(--brand-ink);
  text-decoration: underline;
}
.turn-text {
  padding-top: 1px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.turn-current {
  background: var(--brand-soft);
}

/* ── Devices ─────────────────────────────────────────────────────────────── */

.dev-list .dev-row {
  display: grid;
  /* The action column is a FIXED width, not `auto`. A revoked device has no
   * button, and an auto column collapsing to zero lets the 1fr grow — which
   * slid every other column right and made one row in the list look
   * misaligned with the rest. */
  grid-template-columns: minmax(0, 1fr) 190px 130px 110px 100px;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.dev-list .dev-row:last-child {
  border-bottom: none;
}
.dev-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dev-sub {
  color: var(--ink-3);
  font-size: var(--t-small);
}

.token-box {
  margin-bottom: 14px;
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.token-box h2 {
  margin: 0 0 4px;
  font-size: var(--t-h2);
  color: var(--amber);
}
.token-value {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.token-value code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-m);
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  overflow-x: auto;
  white-space: nowrap;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Login ───────────────────────────────────────────────────────────────── */

.auth {
  max-width: 400px;
  margin: 8vh auto 0;
  padding: 0 16px;
}
.auth .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.auth h1 {
  font-size: var(--t-lede);
  font-weight: 600;
  margin: 0 0 6px;
}
.auth .lede {
  color: var(--ink-2);
  margin: 0 0 18px;
}
.auth .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.auth .field label {
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--ink-2);
}
.auth .btn {
  width: 100%;
  justify-content: center;
}
.auth .foot {
  margin-top: 14px;
  color: var(--ink-3);
  font-size: var(--t-small);
  text-align: center;
}

/* ── Responsive: the surfaces ────────────────────────────────────────────── */

@media (max-width: 900px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .filters .field:first-child {
    grid-column: 1 / -1;
  }
  .dev-list .dev-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
  }
}

@media (max-width: 720px) {
  /* The table stops being a table. Five columns at 375px is five columns of one
   * word each; stacked, the filename stays readable and everything else becomes
   * one wrapping meta line. */
  .list-head {
    display: none;
  }
  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 12px 11px;
  }
  .row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
    align-items: center;
    color: var(--ink-2);
    font-size: var(--t-small);
  }
  .row-meta > * {
    min-width: 0;
  }
  .row-state {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1 0 100%;
  }
  .turn {
    grid-template-columns: 24px minmax(0, 1fr);
    row-gap: 2px;
  }
  .turn-time,
  .turn-text {
    grid-column: 2;
  }
  .facts {
    grid-template-columns: 1fr 1fr;
  }
}
