:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #697586;
  --line: #d9ded6;
  --accent: #146c5c;
  --accent-strong: #0d4f43;
  --warm: #b3541e;
  --shadow: 0 16px 38px rgba(31, 41, 51, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: #fffdf8;
}

.topbar h1,
.login-panel h1,
.now h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar p,
.now p {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 22px;
  padding: 24px clamp(18px, 4vw, 44px) 44px;
}

.program-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.program-item {
  width: 100%;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.program-item strong,
.program-item small,
.program-item em {
  display: block;
}

.program-item small,
.program-item em {
  color: var(--muted);
}

.program-item em {
  font-style: normal;
  white-space: nowrap;
}

.program-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.player-shell {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.now,
.repeat-panel,
.file-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.now {
  padding: 22px;
}

.kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--warm);
  font-size: 0.8rem;
  font-weight: 700;
}

audio {
  width: 100%;
  min-height: 44px;
}

.controls,
.repeat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.controls button,
.repeat-actions button,
.ghost {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover,
a:hover {
  filter: brightness(0.96);
}

.ghost,
.repeat-actions button,
.controls button {
  background: #ffffff;
  color: var(--accent-strong);
}

.repeat-panel {
  padding: 16px;
}

.repeat-panel p {
  margin: 10px 0 0;
  color: var(--muted);
}

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

table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

tr.selected td {
  background: #eef7f3;
}

.linklike {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
}

a {
  color: var(--accent-strong);
  font-weight: 700;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 380px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel form,
.login-panel label {
  display: grid;
  gap: 8px;
}

.login-panel form {
  margin-top: 20px;
  gap: 16px;
}

.login-panel span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.error {
  margin: 0;
  color: #a6362d;
}

@media (max-width: 760px) {
  body {
    background: #ffffff;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px 12px 28px;
  }

  .program-list {
    display: flex;
    margin: 0 -12px;
    padding: 0 12px 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .program-item {
    min-width: 220px;
    min-height: 68px;
    scroll-snap-align: start;
  }

  .player-shell {
    gap: 14px;
  }

  .now {
    padding: 16px;
    box-shadow: none;
  }

  .now h2 {
    font-size: 1.22rem;
    line-height: 1.25;
  }

  .now p {
    overflow-wrap: anywhere;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls button,
  .repeat-actions button {
    min-height: 44px;
    padding: 0 8px;
  }

  .repeat-panel {
    padding: 14px;
    box-shadow: none;
  }

  .repeat-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
  }

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

  tr.selected {
    border-color: var(--accent);
    box-shadow: inset 4px 0 0 var(--accent);
  }

  tr.selected td {
    background: #f7fffb;
  }

  .linklike {
    width: fit-content;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: #ffffff;
  }

  td a {
    width: fit-content;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 0 12px;
    text-decoration: none;
  }

  .empty {
    display: block;
    padding: 18px;
  }
}
