/* RecTool dashboard. Mobile-first; light and dark follow the device setting. No external fonts. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #15181d;
  --muted: #586170;
  --border: #dde1e7;
  --border-strong: #b8c0cc;
  --focus: #2f5bd3;

  --primary: #2f5bd3;
  --primary-hover: #244bb5;
  --on-primary: #ffffff;
  --danger: #c22a2a;
  --danger-hover: #a52020;
  --on-danger: #ffffff;
  --live: #d92d20;

  /* Status tones: text on soft background, plus a solid accent. */
  --neutral-fg: #4b5563;  --neutral-bg: #eceff3;  --neutral-accent: #8a94a3;
  --progress-fg: #1f4bb8; --progress-bg: #e5edff; --progress-accent: #2f5bd3;
  --live-fg: #b42318;     --live-bg: #fde8e6;     --live-accent: #d92d20;
  --success-fg: #17663d;  --success-bg: #e2f5ea;  --success-accent: #1f8a52;
  --warning-fg: #8a5300;  --warning-bg: #fff3d6;  --warning-accent: #d98a00;
  --danger-fg: #a61f1f;   --danger-bg: #fde7e7;   --danger-accent: #c22a2a;

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f26;
    --surface-2: #242b34;
    --text: #e8ecf1;
    --muted: #a0aab8;
    --border: #2d3540;
    --border-strong: #46515f;
    --focus: #8fb0ff;

    --primary: #7aa2ff;
    --primary-hover: #9bb9ff;
    --on-primary: #0b1328;
    --danger: #ff6b63;
    --danger-hover: #ff8a84;
    --on-danger: #1f0807;
    --live: #ff6b63;

    --neutral-fg: #c3cad4;  --neutral-bg: #2a313b;  --neutral-accent: #8a94a3;
    --progress-fg: #b3c8ff; --progress-bg: #1d2a4a; --progress-accent: #7aa2ff;
    --live-fg: #ffb4ae;     --live-bg: #3d1a18;     --live-accent: #ff6b63;
    --success-fg: #9fe0bb;  --success-bg: #15301f;  --success-accent: #4cc283;
    --warning-fg: #ffd58a;  --warning-bg: #36280c;  --warning-accent: #f0a92e;
    --danger-fg: #ffb4ae;   --danger-bg: #3a1716;   --danger-accent: #ff6b63;

    --shadow: none;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }

a { color: var(--primary); text-underline-offset: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* Page headings get focus from the router only to announce the new page; they are not controls. */
[tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* ---------- header ---------- */

/* Second header row for people who signed in with Zoom: their name + "Disconnect Zoom". */
.topbar__account {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--gutter) 6px;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.topbar__user { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.bots-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}

.bots-chip__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--neutral-accent);
}
.bots-chip[data-live="true"] .bots-chip__dot {
  background: var(--live);
  animation: pulse 1.6s ease-in-out infinite;
}

/* ---------- global notice ---------- */

.notice {
  position: fixed;
  left: 50%;
  top: 12px;
  z-index: 50;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
  transform: translate(-50%, -150%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.notice--visible { transform: translate(-50%, 0); opacity: 1; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn--secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--secondary:hover:not(:disabled) { border-color: var(--border-strong); }

.btn--danger { background: var(--danger); color: var(--on-danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn--small { min-height: 44px; padding: 0 12px; font-size: 0.9375rem; }
.btn--block { width: 100%; }

/* ---------- cards, banners ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card__title { margin-bottom: 12px; }
.card > :last-child { margin-bottom: 0; }

.card--warning { background: var(--warning-bg); border-color: var(--warning-accent); color: var(--warning-fg); }

.banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: 16px;
}
.banner--error { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-accent); }
.banner--info { background: var(--progress-bg); color: var(--progress-fg); border-color: var(--progress-accent); }

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

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

.field { margin-bottom: 16px; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}
.optional { font-weight: 400; color: var(--muted); }

.hint {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

input[type="text"],
input[type="password"] {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* 16px stops iOS from zooming in on focus */
}
input::placeholder { color: var(--muted); opacity: 0.8; }
input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
input[aria-invalid="true"] { border-color: var(--danger-accent); }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1 1 auto; min-width: 0; }

.field-error,
.form-error {
  margin: 6px 0 0;
  color: var(--danger-fg);
  font-size: 0.9375rem;
  font-weight: 600;
}
.form-error { margin: 0 0 12px; }
.field-error:empty,
.form-error:empty,
.form-success:empty { display: none; }

.form-success {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--success-bg);
  color: var(--success-fg);
  font-weight: 600;
}
.form-success a { color: inherit; }

/* ---------- badges & live marker ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge--neutral  { background: var(--neutral-bg);  color: var(--neutral-fg); }
.badge--progress { background: var(--progress-bg); color: var(--progress-fg); }
.badge--live     { background: var(--live-bg);     color: var(--live-fg); }
.badge--success  { background: var(--success-bg);  color: var(--success-fg); }
.badge--warning  { background: var(--warning-bg);  color: var(--warning-fg); }
.badge--danger   { background: var(--danger-bg);   color: var(--danger-fg); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--live-fg);
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
}
.live__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

/* ---------- login ---------- */

.login {
  min-height: calc(100vh - 2 * var(--gutter));
  min-height: calc(100dvh - 2 * var(--gutter));
  display: flex;
  align-items: center;
  justify-content: center;
}
.login__card { width: 100%; max-width: 400px; padding: 24px; }
.login__zoom { margin-bottom: 8px; }
.login__zoom .hint { margin-top: 8px; }
.login__admin-title {
  margin: 20px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 1rem;
  color: var(--muted);
}

.login__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 16px;
}

/* ---------- meetings page ---------- */

.meetings-layout { display: grid; gap: 8px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}
.section-head h2 { margin: 0; font-size: 1.25rem; }

.meeting-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.meeting-item {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 14px 44px 14px 16px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}
.meeting-item:hover { border-color: var(--border-strong); }
.meeting-item__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 2px; }
.meeting-item__title { font-weight: 700; font-size: 1.0625rem; overflow-wrap: anywhere; }
.meeting-item__meta { color: var(--muted); font-size: 0.9375rem; overflow-wrap: anywhere; }
.meeting-item__status { font-size: 0.9375rem; }
.meeting-item__chevron {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.75rem;
  line-height: 1;
  color: var(--muted);
}
.is-new .meeting-item { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* ---------- meeting page ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-bottom: 4px;
  font-weight: 600;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.detail__head { margin-bottom: 16px; }
.detail__title { overflow-wrap: anywhere; margin-bottom: 4px; }
.detail__head p { margin: 0; }

.status-card {
  --tone-accent: var(--neutral-accent);
  --tone-fg: var(--text);
  border-left: 6px solid var(--tone-accent);
}
.status-card[data-tone="progress"] { --tone-accent: var(--progress-accent); }
.status-card[data-tone="live"]     { --tone-accent: var(--live-accent); --tone-fg: var(--live-fg); }
.status-card[data-tone="success"]  { --tone-accent: var(--success-accent); --tone-fg: var(--success-fg); }
.status-card[data-tone="warning"]  { --tone-accent: var(--warning-accent); --tone-fg: var(--warning-fg); }
.status-card[data-tone="danger"]   { --tone-accent: var(--danger-accent); --tone-fg: var(--danger-fg); }

.status-card__row { display: flex; align-items: flex-start; gap: 12px; }
.status-card__dot {
  flex: none;
  width: 12px; height: 12px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--tone-accent);
}
.status-card[data-tone="live"] .status-card__dot { animation: pulse 1.6s ease-in-out infinite; }
.status-card__text { flex: 1 1 auto; min-width: 0; }
.status-card__label { margin: 0 0 4px; font-size: 1.25rem; font-weight: 700; color: var(--tone-fg); }
.status-card__hint { margin: 0; color: var(--muted); }
.status-card__detail { margin: 12px 0 0; overflow-wrap: anywhere; }
.status-card__detail:empty { display: none; }
.status-card__actions { margin-top: 16px; }
.status-card__actions .btn { width: 100%; }
.status-card__message { margin: 12px 0 0; font-weight: 600; }
.status-card__message:empty { display: none; }

.notes { margin: 0; padding-left: 20px; }
.notes li + li { margin-top: 4px; }

.recordings { list-style: none; margin: 0; padding: 0; }
.recording {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.recording:first-child { border-top: 0; padding-top: 4px; }
.recording:last-child { padding-bottom: 0; }
.recording__title { margin: 0 0 2px; }
.recording__meta { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.recording__notes { margin: 8px 0 0; padding-left: 20px; color: var(--warning-fg); font-size: 0.9375rem; }
.recording__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recording__actions .btn { flex: 1 1 100%; }

.facts { margin: 0 0 12px; display: grid; gap: 8px; }
.facts__row { display: grid; grid-template-columns: 8.5rem 1fr; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0 0 12px; padding: 0; }
.timeline__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.timeline__item:last-child { border-bottom: 0; }
.timeline__time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline__text { overflow-wrap: anywhere; }
.timeline__empty { padding: 8px 0; }

/* ---------- dialog ---------- */

.dialog {
  width: min(28rem, calc(100vw - 2 * var(--gutter)));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.dialog::backdrop { background: rgb(0 0 0 / 55%); }
.dialog__title { font-size: 1.25rem; }
.dialog__actions { display: flex; flex-wrap: wrap-reverse; gap: 8px; margin-top: 16px; }
.dialog__actions .btn { flex: 1 1 100%; }

/* ---------- loading ---------- */

.loading-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 0;
  color: var(--muted);
}
.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { max-width: 32rem; margin: 48px auto; text-align: center; }

/* ---------- wider screens ---------- */

@media (min-width: 600px) {
  .card { padding: 20px 24px; }
  .recording { grid-template-columns: 1fr auto; align-items: center; }
  .recording__actions { justify-content: flex-end; }
  .recording__actions .btn { flex: 0 0 auto; }
  .status-card__actions .btn { width: auto; }
  .dialog__actions { flex-wrap: nowrap; justify-content: flex-end; }
  .dialog__actions .btn { flex: 0 0 auto; }
}

@media (min-width: 960px) {
  h1 { font-size: 1.75rem; }
  .meetings-layout {
    grid-template-columns: minmax(340px, 400px) 1fr;
    gap: 24px;
    align-items: start;
  }
  .section-head { margin-top: 0; }
  .detail { max-width: 760px; margin: 0 auto; }
}

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

@media (forced-colors: active) {
  .badge, .bots-chip, .meeting-item, .card { border: 1px solid CanvasText; }
  .live__dot, .bots-chip__dot, .status-card__dot { forced-color-adjust: none; }
}
