:root {
  color-scheme: dark;
  --bg: #0e1117;
  --surface: #151a22;
  --surface-2: #1b2230;
  --surface-3: #222b3a;
  --ink: #edf2f8;
  --muted: #9aa6b6;
  --line: #303a4a;
  --soft: #202838;
  --accent: #34c177;
  --danger: #ef4444;
  --danger-bg: #7f1d1d;
  --danger-hover: #991b1b;
  --warning: #f9c74f;
  --link: #7ab7ff;
  --control: #111722;
  --control-hover: #273244;
  --focus: #60a5fa;
  --active: #123052;
  --active-ink: #d7ebff;
  --success-soft: #11281d;
  --success-ink: #8cf0b7;
  --surface-top: #121821;
  --surface-table-head: #111721;
  --surface-deep: #0c1119;
  --surface-bottom: #07090d;
  --line-strong: #46566d;
  --placeholder: #6f7d90;
  --control-height: 44px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

a { color: var(--link); text-decoration: none; }
button, input, select {
  font: inherit;
}
button, .tool-btn, .tool-link {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.2;
  box-sizing: border-box;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
button:hover, .tool-link:hover { background: var(--control-hover); border-color: var(--line-strong); }
button:disabled,
input:disabled,
select:disabled {
  opacity: .55;
  cursor: not-allowed;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: var(--surface-top);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  color: var(--ink);
  font-size: 23px;
  font-weight: 750;
  line-height: 1;
}
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav span {
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wide { max-width: 1200px; margin: 36px auto; padding: 0 24px; }
.log-wide { max-width: min(1600px, calc(100vw - 48px)); }
.narrow { max-width: 720px; margin: 48px auto; padding: 0 24px; }
.muted { color: var(--muted); }
.notice { color: var(--accent); }
.error { color: var(--danger); }

.player-shell {
  height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding-bottom: 64px;
  overflow: hidden;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}
.app-menu {
  position: relative;
  display: flex;
  align-items: center;
}
.app-menu summary {
  width: 40px;
  height: 36px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  display: inline-grid;
  place-content: center;
  gap: 4px;
  cursor: pointer;
  list-style: none;
}
.app-menu summary::-webkit-details-marker {
  display: none;
}
.app-menu summary span {
  width: 16px;
  height: 2px;
  background: var(--ink);
  border-radius: 999px;
}
.app-menu[open] summary,
.app-menu summary:hover {
  background: var(--control-hover);
  border-color: var(--line-strong);
}
.app-menu nav {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  padding: 6px;
}
.app-menu nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 5px;
  color: var(--ink);
  font-weight: 650;
}
.app-menu nav a:hover {
  background: var(--surface-2);
}
#liveBtn {
  margin-left: auto;
}
.current-system {
  min-width: 0;
  max-width: min(44vw, 560px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 20px;
  font-weight: 750;
}
#filterLabel {
  margin-left: 8px;
  color: #06120b;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 13px;
}
.tool-link {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  min-height: 36px;
}
.active-tool {
  border-color: var(--focus);
  color: var(--active-ink);
  background: var(--active);
}

.player-grid {
  display: grid;
  grid-template-columns: minmax(480px, 1fr) 360px;
  min-height: 0;
  overflow: hidden;
}
.call-list {
  overflow: auto;
  border-right: 1px solid var(--line);
  min-height: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}
td:first-child,
th:first-child,
td:nth-child(2),
th:nth-child(2) {
  width: 42px;
  text-align: center;
}
th {
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-table-head);
  position: sticky;
  top: 0;
  z-index: 1;
}
tr.selected td {
  background: var(--success-soft);
  color: var(--success-ink);
}
.play-dot {
  color: var(--accent);
  font-size: 18px;
}
.unplayed-dot {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.row-play-btn {
  position: relative;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  border: 1px solid #244461;
  background: #102033;
  color: var(--success-ink);
  font-size: 13px;
  line-height: 1;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(122, 183, 255, .08);
}
.row-play-btn:hover {
  background: #17304a;
  border-color: #37658d;
}
.row-play-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #04130b;
}
.row-play-btn.unplayed::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -25px 0 0 23px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.star-btn {
  border: 0;
  background: transparent;
  color: #727f91;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}
.star-btn:hover {
  background: #3a2d10;
  color: #ffd36e;
}
.star-btn.starred {
  color: var(--warning);
}
.star-btn.large {
  width: 38px;
  min-height: 38px;
  font-size: 28px;
}
.call-detail {
  padding: 22px;
}
.detail-title {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
}
.call-detail h2 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 18px;
}
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
.meta-grid strong {
  display: block;
  font-size: 42px;
  font-weight: 500;
}
.small-lines {
  margin-top: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.bottom-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 110px 54px 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--surface-bottom);
  color: var(--ink);
  padding: 8px 14px;
  min-height: 64px;
  border-top: 1px solid #1f2937;
  box-shadow: 0 -12px 28px rgba(0,0,0,.28);
}
.bottom-player button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
#playPause {
  width: 50px;
  min-height: 42px;
  padding: 0;
  border-radius: 8px;
  background: #123052;
  border-color: #32669b;
  color: #ffffff;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(122, 183, 255, .14);
}
#playPause:hover {
  background: #16416f;
  border-color: #4b83bd;
}
#playPause.is-playing {
  background: var(--accent);
  border-color: var(--accent);
  color: #04130b;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .22);
}
.bottom-player button.active-tool {
  background: var(--active);
  border-color: var(--focus);
  color: var(--active-ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.bottom-player #autoplay.autoplay-on {
  background: #14261f;
  border-color: #2c8c62;
  color: #bdf7d7;
  box-shadow: inset 0 0 0 1px rgba(52, 193, 119, .18);
}
.bottom-player a { color: var(--ink); }
#nowPlaying small {
  display: none;
}
.waveform {
  position: relative;
  height: 38px;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--surface-deep);
  border-left: 2px solid #667085;
  border-right: 1px solid #293241;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  --progress: 0%;
}
.waveform:hover {
  border-color: var(--line-strong);
}
.wave-bars {
  position: absolute;
  inset: 4px 0;
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
}
.wave-progress {
  position: absolute;
  inset: 0;
  width: 100%;
  overflow: hidden;
  clip-path: inset(0 calc(100% - var(--progress)) 0 0);
  will-change: clip-path;
}
.wave-progress .wave-bars {
  width: 100%;
}
.wave-bar {
  flex: 1 1 0;
  height: calc(var(--h) * 1%);
  min-height: 2px;
  border-radius: 2px;
  background: #475569;
  opacity: .78;
}
.waveform-loading .wave-bar {
  opacity: .36;
}
.wave-played .wave-bar {
  background: #f43f5e;
  opacity: 1;
}
.wave-marker {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: #cbd5e1;
  opacity: .72;
  z-index: 2;
}
.load-more {
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  width: min(620px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  padding: 0;
  box-shadow: 0 18px 60px rgba(0,0,0,.28);
  overflow: hidden;
}
dialog::backdrop { background: rgba(0,0,0,.72); }
dialog h2 { margin: 0; padding: 22px; border-bottom: 1px solid var(--line); }
dialog form > menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-table-head);
}
.tabs {
  display: flex;
  padding: 22px 22px 0;
  max-width: 100%;
  overflow-x: auto;
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs button, .tabs a {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  min-width: 86px;
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: 0;
}
.tabs button:focus-visible,
.tabs a:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 2px var(--focus);
}
.tabs .active, .tabs button.active {
  background: var(--surface-3);
  font-weight: 700;
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.choice-box {
  margin: 16px 22px;
  min-height: 190px;
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.datetime-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 22px;
}
.choice {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  min-height: 44px;
  color: var(--ink);
}
.choice.selected {
  background: var(--surface-3);
  box-shadow: inset 3px 0 0 var(--accent);
  color: #d8ffe8;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  overflow-wrap: anywhere;
}
dialog .check { margin: 0 22px 18px; }
.dialog-check {
  display: inline-flex;
  max-width: calc(100% - 44px);
}
.dialog-check input {
  width: auto;
  min-height: 0;
  flex: 0 0 auto;
}
.dialog-check span {
  overflow-wrap: anywhere;
}

.login-layout {
  max-width: 1040px;
  margin: 60px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 72px;
}
.login-layout h1 { font-size: 36px; margin-bottom: 12px; }
.login-form button[type="submit"] {
  justify-self: start;
  margin-top: 4px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--surface);
}
.stack {
  display: grid;
  gap: 14px;
}
.stack > button {
  justify-self: start;
  align-self: start;
}
label:not(.check) {
  display: grid;
  gap: 6px;
  font-weight: 650;
}
input:not([type="checkbox"]), select {
  min-height: var(--control-height);
  height: var(--control-height);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  width: 100%;
  background: var(--control);
  color: var(--ink);
}
input::placeholder {
  color: var(--placeholder);
}
input[type="file"] {
  padding: 7px 10px;
}
input[type="file"]::file-selector-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 5px 10px;
  margin-right: 10px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  min-height: var(--control-height);
  height: var(--control-height);
  line-height: 1.25;
  padding: 9px 38px 9px 10px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--control);
  display: inline-grid;
  place-content: center;
  margin: 0;
  flex: 0 0 auto;
}
input[type="checkbox"]::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: transparent;
}
input[type="checkbox"]:checked::after {
  background: var(--accent);
}
input[type="checkbox"]:checked {
  border-color: var(--accent);
}
pre {
  white-space: pre-wrap;
  background: var(--surface-deep);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}
.log-view {
  max-height: 65vh;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}
.log-panel {
  padding: 18px;
}
.log-view-large {
  min-height: 560px;
  max-height: calc(100vh - 290px);
  white-space: pre;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.admin-tabs {
  border-bottom: 2px solid var(--line);
  margin-bottom: 18px;
}
.admin-tabs a.active {
  border-bottom: 3px solid var(--accent);
  margin-bottom: -2px;
}
.sub-tabs {
  padding: 0;
  margin: -4px 0 18px;
}
.sub-tabs a {
  min-width: 140px;
}
.admin-section-grid {
  align-items: stretch;
}
.page-action {
  margin: 14px 0 22px;
}
.system-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-weight: 700;
}
.system-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.system-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 650;
}
.system-pill:hover {
  background: var(--control-hover);
  border-color: var(--line-strong);
}
.system-pill.active {
  border-color: var(--accent);
  background: var(--success-soft);
  color: var(--success-ink);
}
.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.form-grid {
  display: grid;
  gap: 12px;
}
.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.tool-link.compact {
  min-height: 30px;
  padding: 5px 10px;
  justify-content: center;
}
.chip-form {
  display: inline-flex;
}
.chip-button {
  border-radius: 999px;
  min-height: 28px;
  padding: 4px 10px;
  background: var(--surface-2);
  color: var(--ink);
}
.permission-card-grid {
  display: grid;
  gap: 14px;
}
.permission-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-table-head);
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}
.permission-card-name {
  display: grid;
  gap: 10px;
}
.permission-card-name button,
.permission-card-actions button {
  justify-self: start;
}
.permission-card-body h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
}
.permission-card-actions {
  display: flex;
  justify-content: flex-end;
}
.two-col, .three-col, .stats {
  display: grid;
  gap: 18px;
  margin-bottom: 22px;
}
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--surface);
}
.stats strong { font-size: 42px; display: block; }
.admin-table th { position: static; }
.admin-table {
  min-width: 720px;
}
.admin-table td {
  vertical-align: middle;
}
.card-grid, .activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
  gap: 18px;
  align-items: stretch;
}
.system-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  display: grid;
  gap: 10px;
  min-height: 180px;
}
.system-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.system-card h2 {
  margin: 0;
  font-size: 21px;
}
.system-card p {
  margin: 0;
}
.system-card-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-self: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 14px;
}
.group-top {
  grid-template-columns: minmax(280px, 420px);
}
.group-management {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.group-management > .panel {
  min-width: 0;
  overflow: hidden;
}
.group-list {
  table-layout: fixed;
  min-width: 0;
}
.group-list a {
  display: block;
  color: var(--ink);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-list th,
.group-list td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-list th:last-child,
.group-list td:last-child {
  width: 110px;
  text-align: right;
}
.group-list .active-row td {
  background: #132033;
  border-left: 3px solid var(--accent);
}
.group-editor {
  min-width: 0;
  overflow: hidden;
}
.group-editor-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.group-editor-grid h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--muted);
}
.group-add-form {
  align-items: end;
}
.group-add-form label {
  flex: 1 1 320px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  align-content: flex-start;
}
.chips span,
.chip-form button {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 13px;
  min-height: 0;
}
.chip-form {
  margin: 0;
}
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 4px 0;
}
.inline-form .check {
  width: auto;
  margin-right: 8px;
}
.inline-form input[type="password"],
.inline-form input[name="name"] {
  width: min(280px, 100%);
}
.danger {
  background: var(--danger-bg);
  color: var(--ink);
  border-color: var(--danger);
}
.danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger);
}
.activity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}
.activity-card h2 {
  font-size: 17px;
  min-height: 44px;
}
.spark {
  height: 130px;
  border-radius: 8px;
  background:
    linear-gradient(to top, rgba(220,38,38,.86) var(--h), rgba(127,29,29,.24) var(--h)),
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(255,255,255,.16) 26px 27px);
}
.activity-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

@media (max-width: 820px) {
  :root {
    --control-height: 42px;
  }
  .topbar {
    padding: 0 12px;
  }
  .topbar nav {
    gap: 10px;
    font-size: 14px;
  }
  .wide,
  .narrow,
  .log-wide {
    max-width: 100%;
    margin: 22px auto;
    padding: 0 14px;
  }
  .player-shell {
    height: auto;
    min-height: calc(100vh - 56px);
    overflow: visible;
    padding-bottom: 108px;
  }
  .player-grid,
  .login-layout,
  .two-col,
  .three-col,
  .stats,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }
  .player-grid {
    overflow: visible;
    min-height: auto;
  }
  .call-list {
    border-right: 0;
    max-height: 58vh;
    min-height: 320px;
  }
  .call-detail {
    border-top: 1px solid var(--line);
    padding: 16px;
  }
  .call-detail h2 {
    font-size: 22px;
  }
  .meta-grid strong {
    font-size: 34px;
  }
  .toolbar {
    gap: 8px;
    padding: 8px 10px;
  }
  .toolbar #filterBtn {
    flex: 0 1 auto;
  }
  .current-system {
    flex: 1 1 220px;
    max-width: none;
    font-size: 18px;
  }
  .tool-link {
    display: none;
  }
  th, td {
    padding: 9px 8px;
  }
  td:first-child,
  th:first-child,
  td:nth-child(2),
  th:nth-child(2) {
    width: 34px;
  }
  .star-btn {
    width: 28px;
    min-height: 28px;
  }
  .datetime-grid {
    grid-template-columns: 1fr;
  }
  .login-layout {
    margin: 32px auto;
    gap: 24px;
  }
  .login-layout h1 {
    font-size: 30px;
  }
  .panel {
    padding: 16px;
  }
  .group-management,
  .group-editor-grid,
  .permission-card {
    grid-template-columns: 1fr;
  }
  .permission-card-actions {
    justify-content: flex-start;
  }
  .admin-tabs,
  .sub-tabs {
    padding: 0;
    margin-left: -2px;
    padding-bottom: 2px;
  }
  .admin-tabs a,
  .sub-tabs a {
    min-width: auto;
    flex: 0 0 auto;
    padding: 0 12px;
  }
  .admin-table {
    display: block;
    overflow-x: auto;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
  }
  .admin-table thead,
  .admin-table tbody {
    display: table;
    width: 100%;
    min-width: 720px;
  }
  .inline-form input[type="password"],
  .inline-form input[name="name"] {
    width: 100%;
  }
  .bottom-player {
    grid-template-columns: minmax(96px, auto) 48px minmax(46px, auto) auto;
    grid-template-rows: auto 32px;
    gap: 8px;
    min-height: 96px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-player button {
    min-height: 38px;
  }
  .waveform {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 32px;
  }
  #nowPlaying {
    justify-self: end;
  }
  #downloadLink {
    justify-self: end;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: auto;
    min-height: 48px;
    align-items: flex-start;
    padding-top: 12px;
    padding-bottom: 10px;
    gap: 8px;
  }
  .topbar nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    line-height: 1.2;
  }
  .brand {
    padding-top: 1px;
    font-size: 21px;
  }
  .player-shell {
    min-height: calc(100vh - 68px);
    padding-bottom: 76px;
  }
  .toolbar {
    display: grid;
    grid-template-columns: 42px minmax(116px, auto) minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    min-height: 82px;
    padding: 8px 10px;
  }
  .toolbar .tool-btn,
  .toolbar .tool-link {
    width: auto;
    justify-content: center;
  }
  .toolbar #filterBtn {
    min-width: 0;
    padding: 6px 8px;
    white-space: nowrap;
  }
  #liveBtn {
    margin-left: 0;
  }
  .current-system {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-basis: auto;
    max-width: none;
    font-size: 17px;
    line-height: 1.15;
  }
  #filterLabel {
    display: inline-block;
    max-width: 86px;
    padding: 2px 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
  }
  .app-menu summary {
    width: 40px;
    height: 38px;
  }
  .player-grid {
    display: block;
  }
  .call-list {
    max-height: none;
    min-height: 0;
    height: calc(100vh - 226px);
    overflow: auto;
  }
  .call-detail {
    display: none;
  }
  .call-list table,
  .call-list tbody,
  .call-list tr,
  .call-list td {
    display: block;
  }
  .call-list thead {
    display: none;
  }
  .call-list tr {
    position: relative;
    min-height: 66px;
    padding: 9px 58px 9px 88px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .call-list tr.selected {
    background: var(--success-soft);
  }
  .call-list tr.selected td {
    background: transparent;
  }
  .call-list td {
    border: 0;
    padding: 0;
  }
  .call-list td:first-child {
    position: absolute;
    left: 10px;
    top: 18px;
    width: 30px;
  }
  .call-list .star-btn {
    color: #8fa0b5;
    background: #101722;
    border: 1px solid #26364b;
  }
  .call-list .star-btn.starred {
    color: var(--warning);
    border-color: rgba(249, 199, 79, .45);
    background: rgba(249, 199, 79, .08);
  }
  .call-list td:nth-child(2) {
    position: absolute;
    left: 44px;
    top: 18px;
    width: 30px;
  }
  .call-list td:nth-child(3) {
    position: absolute;
    left: auto;
    right: 14px;
    top: 22px;
    width: 40px;
    text-align: right;
    font-weight: 750;
    color: var(--muted);
    font-size: 13px;
  }
  .call-list td:nth-child(3)::after {
    content: "s";
  }
  .call-list td:nth-child(4) {
    min-width: 0;
    padding-right: 0;
    font-size: 16px;
    font-weight: 750;
    line-height: 1.2;
  }
  .call-list td:nth-child(4)::after {
    content: attr(data-time);
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
  }
  .call-list th:nth-child(5),
  .call-list td:nth-child(5) {
    display: none;
  }
  .meta-grid {
    gap: 10px;
  }
  .meta-grid strong {
    font-size: 30px;
  }
  dialog {
    width: calc(100vw - 18px);
    max-width: calc(100vw - 18px);
  }
  dialog h2,
  dialog form > menu {
    padding-left: 16px;
    padding-right: 16px;
  }
  .tabs {
    padding: 16px 16px 0;
  }
  .choice-box {
    margin: 14px 16px;
  }
  dialog .check {
    margin-left: 16px;
    margin-right: 16px;
  }
  .bottom-player {
    grid-template-columns: 48px minmax(76px, auto) minmax(72px, 1fr) auto 38px;
    grid-template-rows: 42px;
    gap: 8px;
    min-height: 60px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }
  #autoplay {
    grid-column: 2;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }
  #playPause {
    grid-column: 1;
    grid-row: 1;
    width: 48px;
    min-height: 42px;
    border-radius: 10px;
  }
  #nowPlaying {
    grid-column: 4;
    grid-row: 1;
    align-self: center;
    justify-self: end;
    min-width: 36px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    text-align: right;
    line-height: 1.05;
  }
  #nowPlaying small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
  }
  .waveform {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    display: block;
    height: 8px;
    min-width: 0;
    overflow: hidden;
    background: #2b4059;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
  }
  .waveform .wave-bars,
  .waveform .wave-marker {
    display: none;
  }
  .waveform::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 100%;
    background: var(--accent);
    border-radius: inherit;
    clip-path: inset(0 calc(100% - var(--progress)) 0 0);
  }
  #downloadLink {
    grid-column: 5;
    grid-row: 1;
    display: inline-grid;
    place-items: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    justify-self: end;
    align-self: center;
    overflow: hidden;
    border: 1px solid #26364b;
    border-radius: 999px;
    background: #102033;
    color: var(--accent);
    font-size: 0;
    text-decoration: none;
  }
  #downloadLink::before {
    content: "↓";
    font-size: 22px;
    line-height: 1;
    transform: translateY(-1px);
  }
  .log-view-large {
    min-height: 420px;
    max-height: calc(100vh - 260px);
  }
}
