/* =====================================================================
   Fresh Dash – drei Ebenen: Hintergrund, Karte, aktiver Zustand (Akzent)
   ===================================================================== */
:root {
  --bg: #0b0d13;
  --card: #121621;
  --raise: rgba(255, 255, 255, .04);
  --line: rgba(255, 255, 255, .07);
  --text: #eef1f7;
  --muted: #8b93a7;
  --accent: #a78bfa;
  --on-accent: #150e28;
  --r: 22px;
  --gap: clamp(12px, 1.25vw, 20px);
  --pad: clamp(16px, 1.6vw, 28px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Grundgerüst ---------- */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--gap);
  padding: var(--gap) var(--gap) 0;
}
.home, .page { grid-row: 1; grid-column: 1; min-height: 0; }

.home {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "today media" "apps apps";
}
.today { grid-area: today; }
.media { grid-area: media; }
.apps  { grid-area: apps; }

.home[data-view="kalender"] { grid-template: minmax(0, 1fr) / 1fr; grid-template-areas: "today"; }
.home[data-view="medien"]   { grid-template: minmax(0, 1fr) / 1fr; grid-template-areas: "media"; }
.home[data-view="kalender"] .media,
.home[data-view="kalender"] .apps,
.home[data-view="medien"] .today,
.home[data-view="medien"] .apps { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
  min-width: 0;
  min-height: 0;
}

.sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: clamp(10px, 1.4vh, 16px); min-width: 0; }
.sec-head h2 { font-size: clamp(18px, 1.5vw, 24px); font-weight: 600; }
.hico { display: flex; font-size: clamp(20px, 1.6vw, 26px); }
.status { margin-left: auto; color: var(--muted); font-size: .88rem; }

/* ---------- Uhr + Agenda ---------- */
.today { display: flex; flex-direction: column; }
.time {
  font-size: clamp(72px, 9vw, 150px);
  font-weight: 600;
  line-height: .95;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.sec { font-size: .3em; font-weight: 400; color: var(--muted); margin-left: .2em; letter-spacing: 0; }
.date { font-size: clamp(18px, 1.7vw, 28px); color: var(--muted); margin-top: 8px; }

.agenda {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  margin-top: clamp(14px, 2.4vh, 30px);
  padding-top: clamp(14px, 2.4vh, 30px);
  border-top: 1px solid var(--line);
}
.ev-list { flex: 1; min-height: 0; overflow: hidden; }

.ev {
  position: relative;
  display: flex; align-items: baseline; gap: clamp(16px, 2vw, 32px);
  padding: clamp(10px, 1.5vh, 16px) 0 clamp(10px, 1.5vh, 16px) 18px;
  border-bottom: 1px solid var(--line);
}
.ev.first::before {
  content: ""; position: absolute; left: 0; top: 24%; bottom: 24%;
  width: 4px; border-radius: 4px; background: var(--accent);
}
.ev-time {
  flex: none; min-width: 5.4em;
  font-size: clamp(17px, 1.35vw, 22px); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ev-title {
  min-width: 0;
  font-size: clamp(16px, 1.3vw, 21px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev-day { padding: 20px 0 6px; color: var(--accent); font-weight: 600; font-size: .95rem; }
.ev-day:first-child { padding-top: 0; }
.ev-empty { padding: 12px 0 12px 18px; color: var(--muted); font-size: clamp(16px, 1.2vw, 19px); }
.ev.next-up .ev-time { color: var(--muted); }

.home[data-view="kalender"] .today {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: var(--pad);
}
.home[data-view="kalender"] .agenda {
  margin-top: 0; padding-top: 0; border-top: 0;
  padding-left: var(--pad); border-left: 1px solid var(--line);
}
.home[data-view="kalender"] .ev-list { overflow-y: auto; scrollbar-width: none; }

/* ---------- Medien ---------- */
.media { display: flex; flex-direction: column; }

.seg {
  margin-left: auto;
  display: flex; padding: 4px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--raise);
}
.seg-btn { padding: 8px clamp(14px, 1.4vw, 24px); border-radius: 999px; font-size: clamp(14px, 1.1vw, 17px); }
.seg-btn.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.stage {
  position: relative; flex: 1; min-height: 140px;
  border-radius: 16px; overflow: hidden;
  background: #0e121b;
}
.stage-player, .stage-view { position: absolute; inset: 0; }
.stage-player > *, .stage-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.stage-view { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; pointer-events: none; }
.stage-view.solid { pointer-events: auto; }
.stage-view.veil { background: rgba(8, 10, 15, .6); color: var(--muted); font-size: clamp(15px, 1.2vw, 18px); }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-preview { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-view.dim .stage-preview { filter: brightness(.3) saturate(.6); }

/* Vorschaubild mit Ersatzbild darunter (Plattform-Symbol auf Farbverlauf) */
.stage-thumb, .ml-thumb, .pick-thumb {
  position: relative; overflow: hidden;
  display: grid; place-items: center;
  color: var(--plat);
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--plat) 26%, #0e121b), #0e121b 72%);
}
.stage-thumb { position: absolute; inset: 0; }
.stage-thumb svg { display: none; }            /* großer Play-Button reicht */
.stage-thumb img, .ml-thumb img, .pick-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.stage-play {
  position: relative; pointer-events: none;
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; font-size: 32px;
  background: rgba(10, 12, 18, .6); border: 1px solid rgba(255, 255, 255, .25);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px);
}
.stage-msg {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 20px; text-align: center;
  color: var(--text); font-size: clamp(16px, 1.3vw, 20px);
}
.stage-msg svg { font-size: 40px; color: var(--muted); }

.picker { width: 100%; height: 100%; padding: clamp(14px, 1.6vw, 24px); display: flex; flex-direction: column; gap: 14px; overflow: auto; scrollbar-width: none; }
.picker-title { color: var(--muted); font-size: clamp(15px, 1.15vw, 18px); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.pick {
  display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); background: var(--raise);
}
.pick-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; font-size: 30px; }
.pick-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.pick .plat { padding: 0 2px; }

.meta { display: flex; align-items: center; gap: 12px; margin-top: clamp(12px, 1.6vh, 18px); min-width: 0; }
.meta[hidden] { display: none; }
.meta-info { flex: 1; min-width: 0; }
.meta-title { font-size: clamp(18px, 1.5vw, 24px); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-sub { color: var(--muted); font-size: clamp(14px, 1.1vw, 17px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.plat { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.plat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--plat); }

.btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 10px;
  padding: clamp(11px, 1.5vh, 15px) clamp(16px, 1.5vw, 24px);
  border-radius: 14px;
  font-size: clamp(15px, 1.2vw, 19px); font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { border: 1px solid var(--line); background: var(--raise); }
.icon-btn {
  flex: none; width: 48px; height: 48px;
  display: grid; place-items: center; font-size: 22px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--raise);
}

.media-list { display: none; }
.home[data-view="medien"] .media {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(240px, 22vw, 340px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head head" "stage list" "meta list";
  column-gap: var(--pad);
}
.home[data-view="medien"] .sec-head { grid-area: head; }
.home[data-view="medien"] .stage { grid-area: stage; }
.home[data-view="medien"] .meta { grid-area: meta; }
.home[data-view="medien"] .media-list {
  grid-area: list;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0; overflow-y: auto; scrollbar-width: none;
}
.ml-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); background: var(--raise);
}
.ml-item.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ml-thumb { flex: none; width: 96px; aspect-ratio: 16 / 9; border-radius: 10px; font-size: 24px; }
.ml-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ml-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Programme ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: clamp(10px, 1vw, 16px); }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: clamp(92px, 13vh, 132px);
  border-radius: 16px; border: 1px solid var(--line); background: var(--raise);
  font-size: clamp(16px, 1.3vw, 21px); font-weight: 600;
  transition: transform .12s, background .12s;
}
.tile svg { font-size: clamp(30px, 2.6vw, 40px); }
.tile:active { background: rgba(255, 255, 255, .09); }
.tile { position: relative; }
.tile-note:empty { display: none; }
.tile-note { font-size: .74rem; font-weight: 600; color: #fbbf24; margin-top: -4px; }
.tile.missing svg { color: var(--muted); }

.ev-more {
  margin: 10px 0 0 18px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--raise);
  color: var(--accent); font-size: clamp(14px, 1.1vw, 16px); font-weight: 600;
}

.btn:active, .icon-btn:active, .seg-btn:active, .tile:active, .nav-btn:active, .ml-item:active, .pick:active, .ev-more:active {
  transform: scale(.96);
}

/* ---------- Eingebettete Seite ---------- */
.page { z-index: 2; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: #fff; }
.page[hidden] { display: none; }
.page iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ---------- Leiste unten ---------- */
.nav { display: flex; gap: 6px; padding: var(--gap) 0; border-top: 1px solid var(--line); }
.nav-btn {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: clamp(12px, 1.7vh, 18px) 10px;
  border-radius: 16px;
  font-size: clamp(15px, 1.25vw, 20px);
}
.nav-btn svg { font-size: 1.4em; }
.nav-btn + .nav-btn::before {
  content: ""; position: absolute; left: -3px; top: 25%; bottom: 25%;
  width: 1px; background: var(--line);
}
.nav-btn.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.nav-btn.on::before, .nav-btn.on + .nav-btn::before { opacity: 0; }

/* ---------- Ruhemodus ---------- */
.idle {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: #05060a;
}
.idle[hidden] { display: none; }
.idle-time {
  font-size: clamp(120px, 17vw, 280px); font-weight: 600; line-height: 1;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  color: rgba(238, 241, 247, .55);
}
.idle-date { font-size: clamp(20px, 2vw, 34px); color: rgba(139, 147, 167, .7); }
.idle-next { margin-top: 18px; font-size: clamp(18px, 1.6vw, 26px); color: color-mix(in srgb, var(--accent) 70%, transparent); }

/* ---------- Rückmeldung ---------- */
.toast {
  position: fixed; left: 50%; top: 28px; z-index: 15;
  transform: translateX(-50%);
  padding: 14px 22px; border-radius: 14px;
  background: #1d2230; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-weight: 600; pointer-events: none;
}
.toast[hidden] { display: none; }
.toast.warn { border-color: rgba(251, 191, 36, .45); color: #fde68a; }
.toast.show { animation: toast-in .22s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- Kompakt (wenig Höhe, z. B. höhere Skalierung) ---------- */
@media (max-height: 760px) {
  :root { --gap: 10px; --pad: 14px; }
  .time { font-size: clamp(56px, 7vw, 100px); }
  .date { font-size: 17px; margin-top: 4px; }
  .agenda { margin-top: 10px; padding-top: 10px; }
  .ev { padding-top: 7px; padding-bottom: 7px; }
  .sec-head { margin-bottom: 8px; }
  .tile { min-height: 74px; gap: 6px; font-size: 15px; }
  .tile svg { font-size: 26px; }
  .nav-btn { padding: 9px 8px; font-size: 15px; }
  .btn { padding: 9px 14px; font-size: 15px; }
  .stage-play { width: 64px; height: 64px; font-size: 26px; }
}
