:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #14151a;
  --text-muted: #6b6f7b;
  --accent: #e0263f;
  --accent-contrast: #ffffff;
  --border: #e3e4e8;
  --live: #e0263f;
  --ok: #1fa463;
  --warn: #d98c00;
  --shadow: 0 10px 30px rgba(20, 21, 26, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0d0e12;
  --surface: #17181e;
  --text: #f3f4f6;
  --text-muted: #9599a6;
  --accent: #ff3b56;
  --accent-contrast: #ffffff;
  --border: #262832;
  --live: #ff3b56;
  --ok: #35d07f;
  --warn: #ffb648;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  transition: background 0.2s ease, color 0.2s ease;
}

.player {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
}

.public-password-gate {
  width: 100%;
  max-width: 400px;
}
.public-password-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 26px 22px 22px;
}
.public-password-card h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
  letter-spacing: 0.08em;
}
.public-password-card p {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
}
.public-password-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  padding: 12px 14px;
  font-size: 18px;
  text-align: center;
}
.public-password-error {
  min-height: 20px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand__name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

:root:not([data-theme="dark"]) .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }

.clock {
  text-align: center;
  font-size: 52px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.badge--onair { background: rgba(31,164,99,0.15); color: var(--ok); }
.badge--tech { background: rgba(217,140,0,0.15); color: var(--warn); }
.badge--offline { background: rgba(107,111,123,0.15); color: var(--text-muted); }

.listener-state {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.info-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.info-row {
  display: grid;
  grid-template-columns: minmax(110px, max-content) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  font-size: 14px;
}
.info-label {
  min-width: 0;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.info-value {
  min-width: 0;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.2;
}
#inStudio {
  white-space: normal;
}
.info-row--schedule {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.schedule-inline {
  width: 100%;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: start;
  column-gap: 10px;
  min-width: 0;
}
.schedule-list-public {
  width: min(68%, 280px);
  max-width: 68%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.schedule-inline__time {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 800;
  white-space: nowrap;
  text-align: right;
}
.schedule-inline__title {
  min-width: 0;
  max-width: 100%;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.15;
}

.test-broadcast-notice {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 140, 0, 0.34);
  border-radius: 14px;
  background: rgba(217, 140, 0, 0.12);
  color: var(--warn);
  line-height: 1.35;
}
.test-broadcast-notice strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}
.test-broadcast-notice span {
  font-size: 13px;
  font-weight: 700;
}

.message-overlay {
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(217,140,0,0.12);
  color: var(--warn);
  font-weight: 600;
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 14px 8px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn--live { color: var(--live); border-color: var(--live); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.listen-cta {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 10px;
}
.timeline__label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.timeline__current {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: -12px;
}
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 34px;
}

.quality-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quality-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }

.network-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(217,140,0,0.38);
  border-radius: 12px;
  background: rgba(217,140,0,0.12);
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
.network-notice__btn {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid rgba(217,140,0,0.48);
  border-radius: 10px;
  background: var(--surface);
  color: var(--warn);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.network-notice__btn:active { transform: scale(0.97); }

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.segmented__btn {
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.segmented__btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.legal-notice-btn {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(10px);
}
.legal-notice-btn:active {
  transform: translateX(-50%) scale(0.97);
}
.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
}
.legal-modal__card {
  width: min(560px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.legal-modal__card h2 {
  margin: 0;
  font-size: 18px;
}
.legal-modal__body {
  overflow: auto;
  padding-right: 2px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}
.legal-modal__body p {
  margin: 0 0 12px;
}
.legal-modal__body p:last-child {
  margin-bottom: 0;
}
.legal-modal__ok {
  align-self: stretch;
  min-height: 46px;
}

.public-maintenance {
  width: min(420px, 100%);
  padding: 24px;
  text-align: center;
}
.public-maintenance h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}
.public-maintenance p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.45;
}

@media (max-width: 520px) {
  body {
    align-items: stretch;
    justify-content: flex-start;
    overflow-y: auto;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(72px + env(safe-area-inset-bottom));
  }
  .clock { font-size: 42px; }
  .player {
    max-width: none;
    padding: 18px 14px 28px;
    border-radius: 18px;
    gap: 12px;
  }
  .public-password-gate {
    max-width: none;
    margin: auto 0;
  }
  .info-block {
    padding: 12px;
  }
  .info-row {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
    gap: 8px;
  }
  .info-label,
  .info-value {
    min-width: 0;
  }
  .info-label {
    overflow-wrap: anywhere;
  }
  .info-value {
    overflow-wrap: anywhere;
  }
  .info-row--schedule {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .schedule-list-public {
    width: 100%;
    max-width: none;
    align-items: stretch;
    gap: 7px;
  }
  .schedule-inline {
    grid-template-columns: minmax(72px, max-content) minmax(0, 1fr);
    column-gap: 8px;
  }
  .schedule-inline__title {
    line-height: 1.2;
  }
  .controls {
    gap: 8px;
  }
  .btn {
    padding-top: 12px;
    padding-bottom: 12px;
    padding-left: 6px;
    padding-right: 6px;
  }
  .network-notice {
    align-items: stretch;
    flex-direction: column;
  }
  .network-notice__btn {
    width: 100%;
  }
  .legal-modal {
    align-items: flex-end;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .legal-modal__card {
    max-height: min(680px, calc(100dvh - 24px - env(safe-area-inset-bottom)));
    border-radius: 18px;
    padding: 18px;
  }
  .legal-notice-btn {
    max-width: calc(100vw - 24px);
  }
}
