:root {
  --bg-1: #f2efdf;
  --bg-2: #d3e2d6;
  --surface: #fffdf4;
  --surface-strong: #f6f8f1;
  --text: #15211d;
  --muted: #60726a;
  --accent: #0a6a5b;
  --accent-strong: #0f816f;
  --line: #cad9ce;
  --danger: #a53131;
  --shadow: 0 14px 26px rgb(16 54 43 / 10%);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

.texture-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.48;
  background:
    radial-gradient(circle at 8% 10%, rgb(255 255 255 / 80%), transparent 34%),
    radial-gradient(circle at 92% 90%, rgb(7 103 90 / 25%), transparent 32%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 1.4rem));
  margin: 0.8rem auto 1.2rem;
}

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

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.login-card {
  width: min(470px, 100%);
  margin: 10vh auto 0;
  padding: 1.5rem;
}

.login-card h1,
.topbar h1 {
  margin: 0.2rem 0 0;
  font-size: 1.9rem;
}

.login-card p {
  margin: 0.35rem 0 1rem;
  color: var(--muted);
}

form {
  display: grid;
  gap: 0.55rem;
}

input,
button,
select {
  font: inherit;
}

input,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0.62rem 0.72rem;
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.6rem 0.82rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

button:hover {
  background: var(--accent-strong);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  background: #2f4c45;
}

.error-text {
  min-height: 1.2rem;
  color: var(--danger);
}

.app {
  display: grid;
  gap: 0.78rem;
}

.topbar {
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(68px, 1fr));
  background: #dce8e1;
  border-radius: 12px;
  padding: 0.2rem;
  gap: 0.2rem;
}

.tab {
  background: transparent;
  color: #26443d;
  border-radius: 10px;
  min-width: 68px;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.toolbar {
  padding: 0.7rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.6rem;
}

.toolbar-field {
  display: grid;
  gap: 0.25rem;
}

.toolbar-field label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 0.78rem;
}

.panel {
  min-height: 68vh;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.micro-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.scroll-list {
  display: grid;
  gap: 0.45rem;
  overflow: auto;
}

.category-btn {
  width: 100%;
  text-align: left;
  background: #e8f0eb;
  color: #203a34;
}

.category-btn.active {
  background: var(--accent);
  color: #fff;
}

.category-overview {
  margin-top: 0.62rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.62rem;
  display: grid;
  gap: 0.42rem;
}

.category-overview h3 {
  margin: 0;
  font-size: 0.78rem;
  color: #4b655d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.group-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e6f0ea;
  color: #28433d;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
}

.streams {
  align-content: start;
}

.stream-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
}

.stream-item.playing {
  border-color: #6ca798;
  box-shadow: inset 0 0 0 1px rgb(11 118 101 / 25%);
}

.stream-play-zone {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0.52rem;
}

.stream-play-zone:hover {
  background: #eef5f0;
}

.stream-badge {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: #dde9e2;
  color: #2d4f46;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.stream-name {
  font-size: 0.93rem;
  line-height: 1.25;
  word-break: break-word;
}

.play-hint {
  font-size: 0.74rem;
  color: #2a4c44;
  background: #d8e8df;
  border-radius: 999px;
  padding: 0.2rem 0.56rem;
}

.fav-btn {
  align-self: center;
  margin: 0 0.48rem 0 0;
  min-width: 42px;
  background: #385951;
}

.fav-btn.active {
  background: #ab7d11;
}

.track-grid {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.52rem;
}

.player-actions {
  margin-top: 0.58rem;
}

.player-actions button {
  width: 100%;
}

.track-field {
  display: grid;
  gap: 0.2rem;
}

.track-field span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

video {
  width: 100%;
  border-radius: 14px;
  min-height: 228px;
  max-height: 56vh;
  background: #0b1110;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

#streams-meta {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
}

#now-playing {
  margin-top: 0.6rem;
  white-space: pre-wrap;
}

.epg-panel {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem;
  background: #f1f7f3;
}

.epg-panel h3 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
}

.epg-list {
  display: grid;
  gap: 0.4rem;
}

.epg-row {
  display: grid;
  gap: 0.14rem;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #d7e4dc;
  padding: 0.45rem 0.5rem;
}

.epg-row.is-now {
  border-color: #6ca798;
  background: #ecf8f3;
}

.epg-time {
  font-size: 0.72rem;
  color: #44655b;
  font-weight: 700;
}

.epg-title {
  font-size: 0.86rem;
  font-weight: 600;
}

.epg-desc {
  font-size: 0.8rem;
  color: #5f756d;
}

#toggle-categories-btn,
#load-more-btn {
  margin-top: 0.55rem;
}

@media (max-width: 1140px) {
  .workspace {
    grid-template-columns: 240px minmax(280px, 1fr);
  }

  .player-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 780px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
  }

  .actions .secondary {
    margin-left: auto;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
    max-height: 46vh;
  }

  .stream-play-zone {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .stream-badge {
    width: 34px;
    height: 34px;
    font-size: 0.65rem;
  }

  .play-hint {
    font-size: 0.7rem;
  }

  .track-grid {
    grid-template-columns: 1fr;
  }
}
