:root {
  --bg: #0b0f17;
  --bg-2: #111827;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #9aa3b2;
  --accent: #38bdf8;
  --warning: #f59e0b;
  --closure: #ef4444;
  --roadworks: #f97316;
  --future: #8b5cf6;
  --news: #22c55e;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-border: #e3e7ee;
  --text: #0f172a;
  --muted: #5b6475;
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.12), transparent 60%),
              radial-gradient(900px 500px at 100% 0%, rgba(139, 92, 246, 0.12), transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 0 clamp(12px, 2vw, 28px) 24px;
}
a { color: inherit; }
.hidden { display: none !important; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 0 14px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.15), 0 0 24px var(--accent);
}
.brand h1 { margin: 0; font-size: clamp(18px, 2.2vw, 26px); font-weight: 800; letter-spacing: -0.02em; }
.brand .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.clock { text-align: center; }
#clock-time { font-size: clamp(22px, 3vw, 34px); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
#clock-date { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--text); font-size: 18px; cursor: pointer;
  transition: transform .15s, background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.1); transform: translateY(-1px); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* breaking */
.breaking {
  background: linear-gradient(90deg, #dc2626, #b91c1c); color: #fff; padding: 10px 16px;
  border-radius: 12px; margin-bottom: 14px; font-weight: 600; display: flex; gap: 12px; align-items: center;
  box-shadow: var(--shadow);
}
.breaking .badge { background: #fff; color: #b91c1c; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.breaking a { color: #fff; text-decoration: none; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.tile {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tile-color, var(--accent)); }
.tile-warning { --tile-color: var(--warning); }
.tile-closure { --tile-color: var(--closure); }
.tile-roadworks { --tile-color: var(--roadworks); }
.tile-future { --tile-color: var(--future); }
.tile-news { --tile-color: var(--news); }
.tile-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.tile-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; color: var(--tile-color); }
.tile-foot { color: var(--muted); font-size: 12px; }

/* layout */
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(360px, 1fr); gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.panel.sticky { position: sticky; top: 12px; max-height: calc(100vh - 24px); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* news */
.hero { display: grid; grid-template-columns: 1fr; margin-bottom: 12px; }
.hero a {
  position: relative; display: block; border-radius: 14px; overflow: hidden; min-height: 300px;
  text-decoration: none; color: #fff; background: var(--bg-2);
}
.hero img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.hero .hero-text {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 48px 20px 18px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.85));
}
.hero .topline { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: #93c5fd; font-weight: 700; }
.hero h3 { margin: 4px 0 6px; font-size: clamp(18px, 2vw, 26px); line-height: 1.2; font-weight: 800; }
.hero p { margin: 0; color: #d1d5db; font-size: 14px; line-height: 1.4; }
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; background: var(--bg-2);
  border: 1px solid var(--panel-border); text-decoration: none; color: inherit; transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #1f2937; }
.card .card-body { padding: 10px 12px 12px; }
.card .topline { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.card h4 { margin: 4px 0 4px; font-size: 14px; line-height: 1.3; font-weight: 700; }
.card .when { color: var(--muted); font-size: 12px; }
.regional-list { display: flex; flex-direction: column; }
.r-item {
  display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px 4px; text-decoration: none; color: inherit;
  border-top: 1px solid var(--panel-border);
}
.r-item:first-child { border-top: 0; }
.r-item img { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #1f2937; }
.r-item .r-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.r-item .r-sent { color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.35; }
.r-item .when { color: var(--muted); font-size: 11px; margin-top: 4px; }
.r-item:hover .r-title { color: var(--accent); }

/* traffic */
.map { height: 260px; border-radius: 12px; overflow: hidden; margin-bottom: 10px; border: 1px solid var(--panel-border); flex: none; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; flex: none; }
.chip {
  border: 1px solid var(--panel-border); background: transparent; color: var(--text); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.chip.active { background: var(--accent); color: #04121c; border-color: var(--accent); }
.traffic-list { overflow: auto; flex: 1; min-height: 120px; padding-right: 4px; }
.t-item {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; padding: 10px 8px; border-radius: 10px;
  border-left: 4px solid var(--c, var(--muted)); background: rgba(255, 255, 255, 0.03); margin-bottom: 8px; cursor: pointer;
}
.t-item:hover { background: rgba(255,255,255,.07); }
.t-item.warning { --c: var(--warning); }
.t-item.closure { --c: var(--closure); }
.t-item.roadworks { --c: var(--roadworks); }
.t-item.future { --c: var(--future); opacity: .85; }
.t-road { font-weight: 800; font-size: 15px; color: var(--c); align-self: start; padding-top: 2px; }
.t-road small { display: block; color: var(--muted); font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.t-title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.t-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.t-desc { color: var(--muted); font-size: 12px; margin-top: 6px; white-space: pre-line; line-height: 1.4; border-top: 1px dashed var(--panel-border); padding-top: 6px; }
.t-dist { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.1); text-transform: uppercase; letter-spacing: .05em; }
.badge.blocked { background: var(--closure); color: #fff; }
.badge.delay { background: var(--warning); color: #1c1200; }
.empty { color: var(--muted); font-size: 13px; padding: 16px 8px; text-align: center; }
.error { color: #fca5a5; font-size: 13px; padding: 8px; }

.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; backdrop-filter: blur(4px); }
.modal-card { background: var(--bg-2); border: 1px solid var(--panel-border); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.field { margin: 16px 0; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.row { display: flex; gap: 8px; }
input[type="text"], select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--panel-border); background: var(--panel); color: var(--text); font: inherit;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.btn { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--panel-border); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent); color: #04121c; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.results button { text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--panel); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.results button:hover { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toggles { display: flex; flex-direction: column; gap: 8px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* leaflet dark tweak */
:root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(.7) contrast(1.1) saturate(.8); }
.leaflet-container { background: var(--bg-2); font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg-2); color: var(--text); }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .panel.sticky { position: static; max-height: none; }
  .traffic-col { order: -1; }
  .traffic-list { max-height: 520px; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .clock { display: none; }
  .hero a { min-height: 220px; }
  .r-item { grid-template-columns: 80px 1fr; }
  .r-item img { width: 80px; }
}

/* favorites & notify */
.chip-wrap { display: inline-flex; align-items: stretch; }
.chip-wrap .chip { border-radius: 999px 0 0 999px; }
.chip-wrap .star { border: 1px solid var(--panel-border); border-left: 0; border-radius: 0 999px 999px 0; background: transparent; color: var(--muted); padding: 4px 8px; cursor: pointer; font-size: 12px; }
.chip-wrap .star.on { color: #fbbf24; }
.chip-wrap .star:hover { color: #fbbf24; }
.t-road .fav-star { color: #fbbf24; font-size: 11px; }
.fav-hint { margin: -4px 0 8px; flex: none; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 4px; border-top: 1px solid var(--panel-border); padding-top: 14px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field.two label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field.row { align-items: center; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
details.advanced label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.nlog { display: flex; flex-direction: column; gap: 6px; font-size: 12px; max-height: 200px; overflow: auto; }
.nlog .l { padding: 6px 8px; border-radius: 8px; background: var(--panel); border-left: 3px solid var(--news); }
.nlog .l.err { border-left-color: var(--closure); }
.nlog .l small { color: var(--muted); display: block; }
.ok { color: var(--news); }
@media (max-width: 640px) { .field.two { grid-template-columns: 1fr; } }

/* KI */
.ai-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, rgba(56,189,248,.18), rgba(139,92,246,.18)); border-color: rgba(139,92,246,.4); }
.ai-btn:hover { border-color: var(--accent); }
.sum-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2; border: 1px solid rgba(255,255,255,.25); background: rgba(10,14,22,.75);
  color: #fff; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; cursor: pointer; backdrop-filter: blur(4px);
  opacity: .85; transition: opacity .15s, transform .15s;
}
.sum-btn:hover { opacity: 1; transform: scale(1.05); border-color: var(--accent); }
.card { position: relative; }
.hero a { position: relative; }
.r-item { position: relative; }
.r-item .sum-btn { position: static; margin-top: 6px; padding: 3px 8px; font-size: 11px; background: var(--panel); color: var(--text); border-color: var(--panel-border); }
.ai-card { width: min(720px, 100%); display: flex; flex-direction: column; max-height: 90vh; }
.ai-head-text { min-width: 0; }
.ai-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.ai-card h2 { font-size: 16px; line-height: 1.3; }
.ai-messages { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; min-height: 160px; }
.msg { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--accent); color: #04121c; border-bottom-right-radius: 4px; }
.msg.model { align-self: flex-start; background: var(--panel); border: 1px solid var(--panel-border); border-bottom-left-radius: 4px; }
.msg.model h4 { margin: 10px 0 4px; font-size: 14px; }
.msg.model ul, .msg.model ol { margin: 4px 0 6px; padding-left: 20px; }
.msg.model li { margin: 2px 0; }
.msg.model p { margin: 0 0 8px; }
.msg.model p:last-child { margin-bottom: 0; }
.msg.error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.msg.thinking { color: var(--muted); font-style: italic; }
.msg.thinking::after { content: "…"; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.ai-form { display: flex; gap: 8px; margin-top: 10px; }
.ai-form input { flex: 1; }
.ai-foot { margin-top: 8px; }
.msg.model hr { border: 0; border-top: 1px solid var(--panel-border); margin: 8px 0; }
