:root {
  --bg: #0a0c10;
  --bg2: #10131a;
  --card: rgba(22, 26, 35, .78);
  --card-solid: #161a23;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .12);
  --text: #eef1f6;
  --muted: #8a93a6;
  --red: #e10600;
  --green: #22c55e;
  --yellow: #facc15;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --purple: #a855f7;
  --cyan: #22d3ee;
  --pink: #f43f5e;
  --slate: #94a3b8;
  --radius: 18px;
  --font: "Inter", "Segoe UI", "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(225, 6, 0, .16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(59, 130, 246, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); letter-spacing: -.02em; }
.muted { color: var(--muted); }

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 28px);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { height: 40px; width: auto; border-radius: 8px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, #ff2a1f, #a30400);
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(225, 6, 0, .35), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark span { font-weight: 900; font-style: italic; font-size: 20px; letter-spacing: -1px; }
.brand-text { min-width: 0; }
.brand-title { font-size: 22px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.brand-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-right { display: flex; align-items: center; gap: 10px; }
.now { font-family: var(--mono); font-size: 18px; color: var(--muted); padding: 0 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line2);
  font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
}
.badge .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.badge.live { background: rgba(225, 6, 0, .16); border-color: rgba(225, 6, 0, .55); color: #ffd7d5; }
.badge.live .dot { background: var(--red); box-shadow: 0 0 0 0 rgba(225,6,0,.7); animation: pulse 1.6s infinite; }
.badge.archive .dot { background: var(--blue); }
.badge.off { color: #fecaca; border-color: rgba(244, 63, 94, .4); }
.badge.off .dot { background: var(--pink); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(225,6,0,.7); }
  70% { box-shadow: 0 0 0 10px rgba(225,6,0,0); }
  100% { box-shadow: 0 0 0 0 rgba(225,6,0,0); }
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line2);
  display: grid; place-items: center; transition: background .2s, border-color .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg path:first-child { fill: currentColor; stroke: none; }
#fsBtn svg path:first-child { fill: none; stroke: currentColor; }
.icon-btn.on { border-color: rgba(34,197,94,.6); color: #bbf7d0; }
.icon-btn:not(.on) .wave { opacity: .25; }

.alert {
  padding: 12px 16px; border-radius: 12px; font-size: 14px;
  background: rgba(244, 63, 94, .12); border: 1px solid rgba(244, 63, 94, .35); color: #fecdd3;
}

/* ---------- Tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr 1.5fr;
  gap: 14px;
}
.tile {
  position: relative; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(14px);
  min-height: 118px;
  display: flex; flex-direction: column; gap: 8px;
}
.tile-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.tile-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.tile-value .muted { font-size: 20px; font-weight: 600; }
.tile-foot { margin-top: auto; font-size: 13px; }
.pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.07); border: 1px solid var(--line2);
  font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.pill.started { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.45); color: #bbf7d0; }
.pill.aborted { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.45); color: #fecaca; }

.progress { height: 6px; border-radius: 6px; background: rgba(255,255,255,.07); overflow: hidden; margin-top: auto; }
.progress .bar { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #ff3b30, var(--red)); transition: width .8s ease; }

/* Track-Status-Kachel */
.tile.track { --tc: var(--slate); transition: background .5s, border-color .5s, box-shadow .5s; }
.tile.track::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 160px at 0% 0%, color-mix(in srgb, var(--tc) 35%, transparent), transparent 70%);
  pointer-events: none;
}
.tile.track { border-color: color-mix(in srgb, var(--tc) 45%, transparent); }
.tile.track[data-status="1"] { --tc: var(--green); }
.tile.track[data-status="2"] { --tc: var(--yellow); }
.tile.track[data-status="4"],
.tile.track[data-status="6"],
.tile.track[data-status="7"] { --tc: var(--orange); }
.tile.track[data-status="5"] { --tc: var(--red); box-shadow: 0 0 40px rgba(225,6,0,.35); }
.tile.track[data-status="4"], .tile.track[data-status="5"] { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 46px color-mix(in srgb, var(--tc) 45%, transparent); } }
.track-main { position: relative; display: flex; align-items: center; gap: 16px; margin-top: 2px; }
.track-flag {
  width: 62px; height: 62px; border-radius: 16px; flex: none;
  background: color-mix(in srgb, var(--tc) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--tc) 60%, transparent);
  display: grid; place-items: center; color: var(--tc);
}
.track-flag svg { width: 34px; height: 34px; }
.track-text { font-size: 30px; font-weight: 900; text-transform: uppercase; letter-spacing: .02em; color: var(--tc); line-height: 1.05; }
.track-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.tile.track.dim { animation: none; box-shadow: none; }
.tile.track.dim .track-main { opacity: .6; }

/* Wetter */
.wx { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; margin-top: 4px; }
.wx > div { display: flex; flex-direction: column; }
.wx-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.wx-v { font-size: 18px; font-weight: 700; font-family: var(--mono); }

/* ---------- Feed ---------- */
.feed-wrap {
  flex: 1;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; backdrop-filter: blur(14px);
  display: flex; flex-direction: column; min-height: 0;
}
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.feed-title { display: flex; align-items: center; gap: 10px; }
.feed-title h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .01em; }
.count { font-family: var(--mono); font-size: 13px; padding: 3px 9px; border-radius: 999px; background: rgba(225,6,0,.18); color: #ffd1cf; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  cursor: pointer; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: transparent; border: 1px solid var(--line2); color: var(--muted);
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.chip.active { background: var(--text); color: #0a0c10; border-color: var(--text); }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.msg {
  --mc: var(--slate);
  display: grid; grid-template-columns: 92px 44px 1fr; align-items: center; gap: 14px;
  padding: 12px 14px 12px 12px;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line);
  border-left: 4px solid var(--mc);
  border-radius: 14px;
  transition: background .3s;
}
.msg:hover { background: rgba(255,255,255,.05); }
.msg.new { animation: slideIn .5s cubic-bezier(.2,.9,.3,1.2), flash 6s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
@keyframes flash { 0% { background: color-mix(in srgb, var(--mc) 28%, transparent); } 100% { background: rgba(255,255,255,.025); } }

.msg-time { display: flex; flex-direction: column; gap: 2px; }
.msg-time .t { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.msg-time .l { font-size: 12px; color: var(--muted); }
.msg-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--mc) 16%, transparent);
  color: var(--mc);
}
.msg-ico svg { width: 22px; height: 22px; }
.msg-body { min-width: 0; }
.msg-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.tag {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.06); color: var(--muted);
}
.tag.kind { background: color-mix(in srgb, var(--mc) 18%, transparent); color: var(--mc); }
.tag.drv { color: var(--text); background: rgba(255,255,255,.08); border-left: 3px solid var(--team, #888); }
.msg-text { font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: .01em; overflow-wrap: anywhere; }

.msg[data-kind="flag"][data-flag="GREEN"], .msg[data-kind="flag"][data-flag="CLEAR"] { --mc: var(--green); }
.msg[data-kind="flag"][data-flag="YELLOW"], .msg[data-kind="flag"][data-flag="DOUBLE YELLOW"] { --mc: var(--yellow); }
.msg[data-kind="flag"][data-flag="RED"] { --mc: var(--red); }
.msg[data-kind="flag"][data-flag="BLUE"] { --mc: var(--blue); }
.msg[data-kind="flag"][data-flag="CHEQUERED"] { --mc: #f8fafc; }
.msg[data-kind="flag"][data-flag="BLACK AND WHITE"] { --mc: #e2e8f0; }
.msg[data-kind="flag"][data-flag="BLACK AND ORANGE"] { --mc: #fb923c; }
.msg[data-kind="flag"][data-flag="BLACK"] { --mc: #64748b; }
.msg[data-kind="sc"] { --mc: var(--orange); }
.msg[data-kind="drs"] { --mc: var(--purple); }
.msg[data-kind="steward"] { --mc: var(--cyan); }
.msg[data-kind="steward"][data-penalty="1"] { --mc: var(--pink); }
.msg[data-kind="limits"] { --mc: #818cf8; }

.empty { display: none; flex: 1; place-items: center; text-align: center; color: var(--muted); padding: 50px 0; gap: 14px; }
.empty.show { display: grid; }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.08); border-top-color: var(--red);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; padding: 0 4px; }

/* ---------- Responsiv ---------- */
@media (max-width: 1250px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile.track { grid-column: span 2; }
  .tile.weather { grid-column: span 2; }
}
@media (max-width: 760px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile.track, .tile.weather, #clockTile { grid-column: span 2; }
  .icon-btn#fsBtn { display: none; }
  .msg { grid-template-columns: 70px 1fr; }
  .msg-ico { display: none; }
  .now { display: none; }
  .brand-title { font-size: 18px; }
  .tile-value { font-size: 24px; }
}

/* ---------- Kiosk ---------- */
body.kiosk { cursor: none; }
body.kiosk .app { max-width: none; height: 100vh; }
body.kiosk .feed-wrap { overflow: hidden; }
body.kiosk .msg-text { font-size: 19px; }
body.kiosk .filters { display: none; }

#clockValue { white-space: nowrap; font-size: clamp(22px, 2.1vw, 30px); }
