/* Виджет «Очередь на границе» для сайтов подписчиков — цвета и шрифт как на narvawatch.ee.
   color-scheme не задаём: если он отличается от схемы страницы-хозяина, браузер заливает iframe
   непрозрачным фоном — у тёмного виджета на светлом сайте появился бы тёмный прямоугольник вокруг карточки. */
:root {
  --surface: #fbfcfa; --surface-2: #eff1ee; --ink: #0f1e2b; --ink-2: #3e4b57; --muted: #5c6873;
  --grid: #e2e6e5; --axis: #c2c9cc; --border: rgba(15, 30, 43, 0.11);
  --series: #0072ce; --wash: rgba(0, 114, 206, 0.1); --typical: #96a1aa;
  --good: #127a42; --serious: #b0500d; --frame: #101a22;
}
:root[data-theme="dark"] {
  --surface: #121921; --surface-2: #1a232c; --ink: #e8edf1; --ink-2: #b8c2ca; --muted: #8a96a1;
  --grid: #212b34; --axis: #36434e; --border: rgba(232, 237, 241, 0.1);
  --series: #3d9bf0; --wash: rgba(61, 155, 240, 0.15); --typical: #6a7782;
  --good: #34c26f; --serious: #f0965c; --frame: #070b0f;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: transparent; }
/* Снизу — место под мягкую тень карточки (как на эскизе); по бокам она почти прозрачная и обрезки не видно */
body { padding: 1px 1px 6px; font: 400 14px/1.45 "Onest", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); -webkit-font-smoothing: antialiased; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
a { color: inherit; }
p { margin: 0; }

.w { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 1px 2px rgba(15, 30, 43, 0.06), 0 2px 6px rgba(15, 30, 43, 0.05); }
:root[data-theme="dark"] .w { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.w[data-state="loading"] { min-height: 120px; }

/* Шапка */
.w-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px 11px; border-bottom: 1px solid var(--border); }
.w-logo { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--surface); }
.w-title { flex: 1; min-width: 0; }
.w-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.w-title p:first-child { font-size: 14px; font-weight: 700; }
.w-title p + p { margin-top: 1px; color: var(--muted); font-size: 12px; }
.live {
  display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 3px 9px 3px 8px; border-radius: 999px;
  color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap;
}
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.live.off { color: var(--muted); background: var(--surface-2); letter-spacing: 0; font-weight: 600; }
.live.off::before { box-shadow: none; }

/* Сейчас */
.w-body { display: grid; gap: 14px; padding: 14px 16px 16px; }
.now-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.now { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.count { display: flex; align-items: baseline; gap: 8px; }
.count strong { font-size: 54px; font-weight: 700; line-height: 0.95; letter-spacing: -0.03em; } /* без табличных цифр: «12», а не «1 2» */
.count span { color: var(--ink-2); font-size: 16px; }
.verdict {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; white-space: nowrap;
  color: var(--ink-2); background: var(--surface-2); font-size: 12.5px; font-weight: 600;
}
.verdict.small { gap: 5px; padding: 4px 8px; font-size: 12px; }
.verdict[data-tone="good"] { color: var(--good); background: color-mix(in srgb, var(--good) 11%, transparent); }
.verdict[data-tone="serious"] { color: var(--serious); background: color-mix(in srgb, var(--serious) 11%, transparent); }
.status { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; color: var(--ink-2); font-size: 12.5px; }
.status.small { gap: 6px; margin-top: 8px; }
.status.small .pill { font-size: 11.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; color: var(--good); background: color-mix(in srgb, var(--good) 11%, transparent); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.closed { color: var(--ink-2); background: var(--surface-2); }
.pill.closed::before { background: var(--muted); }
.pill.soon { color: var(--serious); background: color-mix(in srgb, var(--serious) 11%, transparent); }
.nowrap { white-space: nowrap; }
.up { color: var(--serious); }
.down { color: var(--good); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 9px 10px; border-radius: 10px; background: var(--surface-2); }
.stat p:first-child { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.2; } /* длинные переводы переносятся */
.stat p:first-child svg { flex: none; }
.stat p + p { margin-top: 3px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* График за сегодня: одна линия очереди и пунктир «обычно» — легенда подписывает обе */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.chart-head p { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend i { display: inline-block; width: 12px; height: 0; margin-right: 4px; vertical-align: middle; border-top: 2px solid var(--series); }
.legend i.t { border-top: 2px dashed var(--typical); }
.chart { position: relative; height: 96px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--grid); }
.chart .base { stroke: var(--axis); }
.chart .band { fill: var(--surface-2); }
.chart .area { fill: var(--wash); }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .typical { fill: none; stroke: var(--typical); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .tick { fill: var(--muted); font-size: 10px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .now-dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }

/* Кадр с камеры */
.frame { position: relative; display: block; overflow: hidden; border-radius: 10px; background: var(--frame); aspect-ratio: 960 / 335; }
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame span { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; border-radius: 6px; background: rgba(8, 15, 22, 0.7); color: #fff; font-size: 11.5px; font-weight: 600; }

/* Прибытия */
.arr-title { margin-bottom: 2px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.arrivals { margin: 0; padding: 0; list-style: none; }
.arrivals li { display: grid; grid-template-columns: 26px 42px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 0; font-size: 13px; }
.arrivals li + li { border-top: 1px solid var(--border); }
.a-ico { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); }
.a-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.a-what p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.a-what p + p { color: var(--muted); font-size: 11.5px; }
.a-rise { padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 11.5px; font-weight: 700; }
.a-none { color: var(--muted); font-size: 13px; }

.w-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 12px; }
.w-foot a { flex: none; color: var(--series); font-weight: 600; text-decoration: none; }
.w-foot a:hover { text-decoration: underline; }

/* Компактный */
.w.compact .w-head { padding: 11px 16px 10px; }
.w.compact .w-body { gap: 8px; padding: 12px 16px 14px; }
.w.compact .count strong { font-size: 40px; }

/* Широкая полоса: число — график — следующий рейс; на узком месте — друг под другом */
.w.wide .w-cols { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr) minmax(200px, 270px); }
.w.wide .w-cols > div { padding: 14px 16px; }
.w.wide .w-cols > div + div { border-left: 1px solid var(--border); }
.w.wide .count strong { font-size: 44px; }
.w.wide .mini-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; font-weight: 700; line-height: 1.25; }
.w.wide .mini-title .w-logo { width: 24px; height: 24px; border-radius: 7px; }
.w.wide .mini-name { min-width: 0; }
.w.wide .side .facts { margin-top: 6px; }
.w.wide .mini-title .live { padding: 2px 7px 2px 6px; font-size: 10.5px; }
.w.wide .side { display: grid; gap: 6px; align-content: start; }
.w.wide .side .next { display: flex; gap: 8px; align-items: center; }
.w.wide .side .facts { color: var(--muted); font-size: 12px; }
.w.wide .side a { color: var(--series); font-size: 12px; font-weight: 600; text-decoration: none; }
@media (max-width: 640px) {
  .w.wide .w-cols { grid-template-columns: 1fr; }
  .w.wide .w-cols > div + div { border-left: 0; border-top: 1px solid var(--border); }
}

/* Большой — для страницы сайта во всю ширину колонки: «сейчас» и кадр рядом, крупный график, рейсы в ряд */
.w.large .w-head { gap: 12px; padding: 16px 20px 14px; }
.w.large .w-logo { width: 36px; height: 36px; border-radius: 10px; }
.w.large .w-title p:first-child { font-size: 16px; }
.w.large .w-title p + p { font-size: 12.5px; }
.w.large .w-body { gap: 22px; padding: 20px; }
.w.large .l-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; }
.w.large .l-top.single { grid-template-columns: minmax(0, 1fr); }
.w.large .l-now { display: grid; gap: 14px; align-content: start; }
.w.large .now-label { font-size: 14px; }
.w.large .count strong { font-size: 76px; }
.w.large .count span { font-size: 18px; }
.w.large .verdict { padding: 7px 11px; font-size: 13px; }
.w.large .status { font-size: 13px; }
.w.large .stat { padding: 11px 12px; border-radius: 12px; }
.w.large .stat p:first-child { font-size: 12px; }
.w.large .stat p + p { margin-top: 4px; font-size: 22px; }
.w.large .frame { height: 100%; min-height: 230px; border-radius: 12px; aspect-ratio: auto; }
.w.large .frame span { left: 10px; bottom: 10px; font-size: 12px; }
.w.large .chart-head { margin-bottom: 8px; }
.w.large .chart-head p, .w.large .arr-title { font-size: 14px; }
.w.large .legend { font-size: 12px; }
.w.large .chart .tick { font-size: 11px; }
.w.large .arr-title { margin-bottom: 10px; }
.w.large .arrivals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.w.large .arrivals li { grid-template-columns: 30px auto minmax(0, 1fr) auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 13.5px; }
.w.large .a-ico { width: 30px; height: 30px; }
.w.large .w-foot { padding: 12px 20px; font-size: 12.5px; }
/* Рейсы в ряд помещаются от ~900px; уже — списком, как в полном виджете */
@media (max-width: 900px) {
  .w.large .arrivals { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .w.large .arrivals li { padding: 8px 0; border: 0; border-radius: 0; }
  .w.large .arrivals li + li { border-top: 1px solid var(--border); }
}
@media (max-width: 720px) {
  .w.large .w-body { gap: 18px; padding: 16px; }
  .w.large .l-top { grid-template-columns: minmax(0, 1fr); }
  .w.large .frame { height: auto; min-height: 0; aspect-ratio: 16 / 9; }
  .w.large .count strong { font-size: 60px; }
}

/* Нет данных, неверный код, подписка закончилась */
.message { display: grid; justify-items: center; gap: 6px; padding: 22px 18px 20px; text-align: center; }
.message-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 4px; border-radius: 50%; background: var(--wash); color: var(--series); }
.message-title { font-size: 15px; font-weight: 600; }
.message-text { max-width: 300px; color: var(--ink-2); font-size: 13px; }
.message a { margin-top: 6px; padding: 8px 14px; border-radius: 10px; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 600; text-decoration: none; }
.notice { padding: 8px 10px; border-radius: 9px; color: var(--serious); background: color-mix(in srgb, var(--serious) 10%, transparent); font-size: 12.5px; }
