:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #5f6873;
  --line: #e2e5ea;
  --accent: #1f5fd1;
  --accent-text: #ffffff;
  --accent-soft: #e8f0fd;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --in: #1a7f4b;
  --out: #8a5a00;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --surface: #181b20;
    --text: #e9ecf0;
    --muted: #9aa3ae;
    --line: #2a2f37;
    --accent: #7aa7f7;
    --accent-text: #0f1114;
    --accent-soft: #1c2738;
    --danger: #f2a39d;
    --danger-soft: #3a1c1a;
    --in: #6fd3a0;
    --out: #e4b860;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ---- top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.spacer {
  flex: 1;
}

.who {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ---- layout ---- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

h2 {
  margin: 32px 0 12px;
  font-size: 16px;
}

.sub {
  margin: 0 0 20px;
  color: var(--muted);
}

/* ---- buttons and fields ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.btn.small {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 13px;
}

.btn.link {
  border-color: transparent;
  background: none;
  color: var(--accent);
  padding-left: 0;
  padding-right: 0;
}

label {
  display: block;
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 600;
}

input[type='email'],
input[type='password'],
input[type='text'],
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
}

.notice.error {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.login {
  max-width: 400px;
  margin: 8vh auto 0;
  padding: 28px;
}

.login .btn.primary {
  width: 100%;
  margin-top: 20px;
}

.login .switch {
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* ---- summary tiles ---- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.tile {
  padding: 14px 16px;
}

.tile .label {
  color: var(--muted);
  font-size: 13px;
}

.tile .value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ---- tables ---- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 32px 0 12px;
}

.toolbar h2 {
  margin: 0;
}

.toolbar select {
  width: auto;
  min-width: 220px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tr.playing td {
  background: var(--accent-soft);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

td.actions .btn + .btn {
  margin-left: 6px;
}

.primary-cell {
  font-weight: 600;
}

.secondary {
  color: var(--muted);
  font-size: 13px;
}

.dir {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.dir.in {
  color: var(--in);
}

.dir.out {
  color: var(--out);
}

.dir.unknown {
  color: var(--muted);
}

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.more {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

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

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.player .title {
  min-width: 0;
  flex: 0 1 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.player audio {
  flex: 1;
  min-width: 0;
  height: 40px;
}

/* ---- small screens: each row becomes a card ---- */

@media (max-width: 720px) {
  .topbar {
    padding: 10px 14px;
  }

  .page {
    padding: 16px 14px 150px;
  }

  thead {
    display: none;
  }

  tr {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
  }

  tbody tr:last-child {
    border-bottom: 0;
  }

  td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: 0;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    text-align: left;
  }

  td.actions {
    justify-content: flex-end;
    padding-top: 8px;
  }

  td.actions::before {
    content: none;
  }

  .player {
    flex-wrap: wrap;
    padding: 8px 14px;
  }

  .player .title {
    flex: 1 1 auto;
  }

  .player audio {
    flex: 1 1 100%;
    order: 3;
  }
}
