:root {
  color-scheme: dark;
  --bg: #080d18;
  --panel: #101828;
  --panel-2: #172238;
  --line: #243149;
  --text: #eef2f8;
  --muted: #95a1b7;
  --red: #ff4545;
  --red-bg: #3b0c11;
  --orange: #ffab2e;
  --orange-bg: #3a2606;
  --green: #35d07f;
  --green-bg: #0b2b1c;
  --blue: #5aa9ff;
  --blue-bg: #0d2240;
  --gray-bg: #1d2433;
  --radius: 14px;
  /* Scales with the screen so a TV across the room stays readable. */
  font-size: clamp(14px, 0.55rem + 0.6vw, 26px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  line-height: 1.35;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.7rem 1rem 0.5rem;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
h2 { margin: 0 0 0.6rem; font-size: 0.95rem; font-weight: 600; color: var(--muted); }
h2 small { font-weight: 400; }

.btn {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #04101f; font-weight: 700; }
.btn.attention { background: var(--orange); border-color: var(--orange); color: #1d1200; font-weight: 700; animation: blink 1.2s ease-in-out infinite; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; }
.brand { font-size: 1.35rem; font-weight: 800; }
.clockbox { display: flex; align-items: baseline; gap: 0.8rem; }
.clock { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.date { color: var(--muted); font-size: 0.95rem; }
.top-actions { display: flex; align-items: center; gap: 0.5rem; }
.conn { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); margin-inline-end: 0.3rem; }
.conn .dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--muted); }
.conn.ok .dot { background: var(--green); box-shadow: 0 0 0.5rem var(--green); }
.conn.warn .dot { background: var(--orange); }
.conn.bad .dot { background: var(--red); animation: blink 1s infinite; }

/* Warnings and area status */
.warnings { display: flex; flex-direction: column; gap: 0.4rem; }
.warnings:empty { display: none; }
.warning { padding: 0.55rem 1rem; border-radius: var(--radius); font-weight: 700; }
.warning-red { background: var(--red-bg); border: 2px solid var(--red); }
.warning-orange { background: var(--orange-bg); border: 2px solid var(--orange); }

.status { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1.3rem; border-radius: var(--radius); border: 2px solid var(--line); background: var(--gray-bg); }
.status-icon { font-size: 2.2rem; line-height: 1; }
.status-title { font-size: 1.75rem; font-weight: 800; }
.status-sub { color: var(--muted); margin-top: 0.15rem; }
.status-green { background: var(--green-bg); border-color: var(--green); }
.status-orange { background: var(--orange-bg); border-color: var(--orange); }
.status-red { background: var(--red-bg); border-color: var(--red); }
.status-info { background: var(--blue-bg); border-color: var(--blue); }
.status-red .status-sub, .status-orange .status-sub { color: var(--text); }

/* Main layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, 30%); gap: 0.7rem; min-height: 0; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 0.8rem 1rem; min-width: 0; }
.empty { color: var(--muted); margin: 0.4rem 0; }

/* Event cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 0.7rem; perspective: 1200px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: var(--panel-2);
  border-inline-start: 0.4rem solid var(--orange);
  transform-origin: top center;
}
.card.level-3 { border-inline-start-color: var(--red); background: linear-gradient(to left, rgba(255, 69, 69, 0.14), var(--panel-2) 65%); }
.card:hover { outline: 1px solid var(--muted); }
.card-tag { align-self: flex-start; font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--orange-bg); color: var(--orange); }
.level-3 .card-tag { background: var(--red-bg); color: var(--red); }
.card-title { margin: 0; font-size: 1.2rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-summary { margin: 0; color: var(--muted); font-size: 0.95rem; }
.card-meta { margin-top: auto; display: flex; justify-content: space-between; gap: 0.5rem; color: var(--muted); font-size: 0.8rem; }

/* Alerts list */
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.alert { padding: 0.5rem 0.75rem; border-radius: 10px; background: var(--panel-2); border-inline-start: 0.35rem solid var(--muted); }
.alert.sev-red { border-inline-start-color: var(--red); }
.alert.sev-orange { border-inline-start-color: var(--orange); }
.alert.sev-green { border-inline-start-color: var(--green); }
.alert.sev-info { border-inline-start-color: var(--blue); }
.alert.mine { outline: 2px solid var(--text); }
.alert-head { display: flex; justify-content: space-between; gap: 0.5rem; font-weight: 700; }
.alert-time { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.alert-cities { color: var(--muted); font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Regular flashes */
.flashes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.1rem 1.5rem; perspective: 1200px; }
.flash a { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.flash-time { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.flash-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flash-src { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

.footer { color: var(--muted); font-size: 0.78rem; text-align: center; }

.flip-in { animation: flip-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes flip-in { from { opacity: 0; transform: rotateX(-80deg); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0.45; } }

/* Full-screen alert for the viewer's own area */
.takeover { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; background: #6d0009; overflow: auto; }
.takeover::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at center, #e0001b, transparent 70%); animation: pulse 1.6s ease-in-out infinite; }
.takeover-inner { position: relative; max-width: 90rem; }
.takeover-icon { font-size: clamp(3rem, 8vw, 9rem); line-height: 1; }
.takeover h1 { margin: 0.2em 0; font-size: clamp(2.2rem, 6.5vw, 8rem); line-height: 1.1; }
.takeover-desc { margin: 0 0 0.6em; font-size: clamp(1.5rem, 3.6vw, 4.2rem); font-weight: 800; }
.takeover-cities { margin: 0 0 0.4em; font-size: clamp(1.1rem, 2vw, 2.4rem); }
.takeover-time { margin: 0; font-size: clamp(1rem, 1.6vw, 2rem); opacity: 0.9; }
.takeover-src { margin: 1em 0 0; opacity: 0.8; }
.takeover .btn { margin-top: 1.2rem; background: rgba(0, 0, 0, 0.25); border-color: rgba(255, 255, 255, 0.4); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Settings dialog */
.settings { width: min(34rem, 92vw); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; }
.settings::backdrop { background: rgba(0, 0, 0, 0.6); }
.settings h2 { font-size: 1.3rem; color: var(--text); }
.settings label { display: block; font-weight: 600; margin: 0.9rem 0 0.35rem; }
.settings .check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.row { display: flex; gap: 0.5rem; }
.field { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.45rem 0.7rem; }
.chips { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding-block: 0.2rem; padding-inline: 0.7rem 0.3rem; }
.chip-x { font: inherit; font-size: 1.1rem; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 1rem 0 0.35rem; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 1.2rem; }

@media (max-width: 900px) {
  body { padding: 0.5rem; }
  .layout { grid-template-columns: 1fr; }
  .flashes { grid-template-columns: 1fr; }
  .flash-title { white-space: normal; }
  .clock { font-size: 1.6rem; }
  .status-title { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .flip-in, .takeover::before, .btn.attention, .conn.bad .dot { animation: none; }
}
