/* Public dashboard. Tokens, components, then responsive rules; no override stack. */
:root {
  font:
    100% system-ui,
    -apple-system,
    sans-serif;
  color-scheme: light;
  --page: #f2f4f8;
  --surface: #ffffff;
  --ink: #192840;
  --muted: #627089;
  --line: #dce2ec;
  --accent: #315bd6;
  --button: #e8edf8;
  --card-ink: #192840;
  color: var(--ink);
  background: var(--page);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101722;
  --surface: #192332;
  --ink: #edf2ff;
  --muted: #aab8d0;
  --line: #304057;
  --accent: #a9beff;
  --button: #25334c;
  --card-ink: #edf2ff;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  max-width: 920px;
  margin: auto;
  padding: 22px 18px 26px;
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--button);
  padding: 12px 16px;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
button:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
header > div {
  min-width: 0;
}
.eyebrow {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--accent);
}
h1 {
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -0.045em;
  margin: 6px 0 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.refresh {
  width: 48px;
  padding: 0;
  flex-shrink: 0;
  font-size: 1.65rem;
  background: var(--surface);
}
#connection {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 10px 0 8px;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}
.section-heading span {
  font-size: 0.7rem;
  color: var(--muted);
}
#readings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.reading {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--card-ink);
  overflow: hidden;
}
.reading.hero {
  grid-column: 1 / -1;
  border-radius: 28px;
  border-color: var(--q-border, #233c74);
  background: var(--q-dark, #162c55);
  background: linear-gradient(125deg, var(--q-dark, #162c55) 0%,
    color-mix(in srgb, var(--q-border, #4268ab) 70%, black 30%) 100%);
  color: #f4f7ff;
  --card-ink: #f4f7ff;
}
.metric-open {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 154px;
  border: 0;
  background: transparent;
  border-radius: inherit;
  padding: 18px;
  text-align: left;
  color: inherit;
}
.hero .metric-open {
  min-height: 210px;
  padding: 24px;
}
.reading-title {
  width: 100%;
  padding-right: 28px;
  font-size: 0.85rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.reading-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  max-width: 100%;
  margin-top: 13px;
}
.reading-value strong {
  font-size: 2.2rem;
  font-weight: 550;
  letter-spacing: -0.05em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.hero .reading-value strong {
  font-size: 5rem;
}
.reading-value small {
  font-size: 0.75rem;
}
.quality {
  margin-top: 10px;
  font-size: 0.75rem;
  line-height: 1.5;
  font-weight: 500;
}
.quality::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--q-border);
}
.hero .quality::before {
  background: var(--q-accent);
}
.scale-slot {
  display: block;
  width: 100%;
  margin-top: auto;
  padding-top: 8px;
}
.quality-scale {
  display: flex;
  width: 100%;
  gap: 4px;
  height: 5px;
  margin: 8px 0 4px;
}
.quality-step {
  flex: 1;
  min-width: 0;
  background: var(--q-border);
  border-radius: 5px;
  opacity: 0.55;
}
.quality-step.current {
  opacity: 1;
  outline: 1.5px solid var(--card-ink);
  outline-offset: 2px;
}
.chevron {
  display: none;
}
.metric-help {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
}
.metric-help span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.75rem;
}
.metric-open:focus-visible,
.metric-help:focus-visible {
  outline-offset: -4px;
}
.reading-risk,
.reading-description {
  margin: 0;
  padding: 0 18px 18px;
  font-size: 0.75rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.hero .reading-risk,
.hero .reading-description {
  padding: 0 24px 18px;
  font-size: 0.8rem;
}
.pm-context {
  margin: 0;
  padding: 0 24px 20px;
  font-size: 0.65rem;
  line-height: 1.6;
  opacity: 0.75;
}
/* «Поделиться ссылкой»: меню телефона или копирование ссылки (share.js, только веб). */
.share-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 16px 0 0;
  font-weight: 600;
}
.share-button svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.share-status {
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.share-status:empty {
  display: none;
}
.donate-button {
  display: block;
  width: 100%;
  margin: 12px 0 0;
  color: var(--accent);
  background: transparent;
}
.error {
  font-size: 0.8rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.error {
  color: #b73538;
}
.error:empty {
  display: none;
}
footer {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.7;
  text-align: center;
  overflow-wrap: anywhere;
}
.creator {
  display: inline-block;
  margin-top: 5px;
}
.usage {
  margin-top: 15px;
}
.usage p {
  margin: 0;
}
.usage strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.usage small {
  display: block;
  margin-top: 4px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  background: var(--surface);
  color: var(--ink);
  width: calc(100% - 24px);
  max-width: 680px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
dialog::backdrop {
  background: #091325b3;
}
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: -22px;
  margin: -22px -22px 18px;
  padding: 14px 14px 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.dialog-heading h2 {
  margin: 6px 0 0;
  font-size: 1.1rem;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.dialog-heading button {
  width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  padding: 0;
}
#helpBody,
#donationPurpose {
  font-size: 0.95rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
#helpBody h3 {
  font-size: 1rem;
  margin: 24px 0 8px;
}
#helpBody p {
  margin: 0 0 14px;
}
.help-source,
#historySource {
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--muted);
}
#helpDone {
  width: 100%;
}
#donationQr {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
  margin: auto;
  border-radius: 12px;
}
.quality-legend {
  margin: 18px 0;
  font-size: 0.85rem;
  line-height: 1.6;
}
.quality-legend summary {
  cursor: pointer;
  min-height: 48px;
  padding: 12px 4px;
  font-weight: 600;
}
.quality-legend ul {
  list-style: none;
  padding: 0;
}
.quality-legend li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
}
.quality-swatch {
  flex: 0 0 16px;
  height: 16px;
  margin-top: 4px;
  border-radius: 5px;
  background: var(--q-border);
}
.history-period {
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 16px;
  font-weight: 600;
}
.history-period span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
}
.history-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 0;
  border-block: 1px solid var(--line);
}
.history-stats span {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
}
.history-stats strong {
  display: block;
  font-size: 1.3rem;
  margin-top: 5px;
  overflow-wrap: anywhere;
}
.history-stats small {
  display: block;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 400;
}
.history-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: pan-y;
  margin-top: 14px;
}
.history-svg text {
  font-size: 11px;
  fill: var(--muted);
}
.chart-grid {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.chart-grid-time,
.chart-cross {
  stroke-dasharray: 3 5;
}
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-dot {
  fill: var(--accent);
}
/* Цвет по уровню значения (владелец 12.11.2026: «линия меняла цвет от уровня»); переходы — на порогах шкалы. */
.chart-line.chart-line-levels {
  stroke: url(#chart-levels);
}
.level-stop {
  stop-color: var(--q-border);
}
.chart-dot[data-tone]:not([data-tone=""]) {
  fill: var(--q-border);
}
.chart-cross {
  fill: none;
  stroke: var(--muted);
}
.chart-cursor circle {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 3;
}
.chart-cursor circle[data-tone]:not([data-tone=""]) {
  stroke: var(--q-border);
}
.history-selected {
  min-height: 24px;
  font-size: 0.8rem;
  line-height: 1.6;
  text-align: center;
}
.history-scrub {
  width: 100%;
  min-height: 44px;
  margin: 8px 0;
  accent-color: var(--accent);
}
.history-note {
  color: var(--muted);
  font-size: 0.65rem;
  text-align: center;
  line-height: 1.6;
}
@media (min-width: 600px) {
  body {
    padding: 36px;
  }
  #readings {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .hero .metric-open {
    min-height: 220px;
  }
}
@media (max-width: 339px) {
  #readings {
    grid-template-columns: minmax(0, 1fr);
  }
  .history-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  body {
    padding-top: 16px;
  }
  dialog {
    max-height: calc(100dvh - 16px);
  }
}

/* Measurement palette shared with the quality model. */
[data-tone="indigo"] {
  --q-dark: #35265f;
  --q-light: #e9e4ff;
  --q-border: #6b4a9b;
  --q-accent: #c5a8ff;
}
[data-tone="violet"] {
  --q-dark: #462451;
  --q-light: #f5e4ff;
  --q-border: #8b4994;
  --q-accent: #e3a6ff;
}
[data-tone="blue"] {
  --q-dark: #20385f;
  --q-light: #e5eeff;
  --q-border: #406ba8;
  --q-accent: #9ec5ff;
}
[data-tone="azure"] {
  --q-dark: #174961;
  --q-light: #e1f3ff;
  --q-border: #327f9e;
  --q-accent: #81d4ff;
}
[data-tone="cyan"] {
  --q-dark: #154d50;
  --q-light: #dff8fa;
  --q-border: #2f8788;
  --q-accent: #70e4e4;
}
[data-tone="teal"] {
  --q-dark: #164b42;
  --q-light: #e1f5ef;
  --q-border: #34856f;
  --q-accent: #79e4c6;
}
[data-tone="green"] {
  --q-dark: #254b27;
  --q-light: #e9f5df;
  --q-border: #51873b;
  --q-accent: #a9eb80;
}
[data-tone="lime"] {
  --q-dark: #414c1d;
  --q-light: #f0f4ce;
  --q-border: #7b8b29;
  --q-accent: #daed70;
}
/* Жёлтый — яркий тёплый с тёмным текстом (владелец 12.11.2026 выбрал вариант «Тёплый»: тёмные жёлтые
   получались коричневыми). Был оливковый #55471a/#a78b2c. */
[data-tone="yellow"] {
  --q-dark: #ffd84d;
  --q-light: #fff4c7;
  --q-border: #f2b000;
  --q-accent: #6b4400;
}
.reading.hero[data-tone="yellow"] {
  border-color: #f2a900;
  background: linear-gradient(125deg, #ffd84d 0%, #ffb020 100%);
  color: #2e2000;
  --card-ink: #2e2000;
}
[data-tone="amber"] {
  --q-dark: #5a3e18;
  --q-light: #fff0df;
  --q-border: #b87b28;
  --q-accent: #ffc16c;
}
[data-tone="orange"] {
  --q-dark: #5f301b;
  --q-light: #ffeadf;
  --q-border: #c46c39;
  --q-accent: #ffa06e;
}
[data-tone="red"] {
  --q-dark: #60232a;
  --q-light: #ffe7e9;
  --q-border: #bb535e;
  --q-accent: #ff9ba7;
}
[data-tone="purple"] {
  --q-dark: #50244f;
  --q-light: #f6e4f5;
  --q-border: #a1589c;
  --q-accent: #eda3e5;
}
[data-tone="maroon"] {
  --q-dark: #571c38;
  --q-light: #ffe3ed;
  --q-border: #ac3f6a;
  --q-accent: #ff91bd;
}
[data-tone="neutral"] {
  --q-dark: #28343e;
  --q-light: #edf0f2;
  --q-border: #697d89;
  --q-accent: #c1ced7;
}

/* Keep large Android text inside a narrow card: flex items must be shrinkable. */
.reading-value {
  min-width: 0;
  width: 100%;
}
.reading-value strong,
.reading-value small {
  min-width: 0;
  max-width: 100%;
}
.reading-value small {
  overflow-wrap: anywhere;
}
.quality,
.pm-context {
  max-width: 100%;
  overflow-wrap: anywhere;
}
#aboutDialog p {
  font-size: 0.9rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
#aboutDone {
  margin-top: 18px;
  width: 100%;
}
.app-version {
  color: var(--muted);
}

.current-context {
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  background: var(--button);
  border-radius: 0 12px 12px 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.theme-toggle {
  width: 48px;
  padding: 0;
  font-size: 1.5rem;
  background: var(--surface);
}
@media (max-width: 359px) {
  header {
    flex-wrap: wrap;
  }
  .header-actions {
    margin-left: auto;
  }
}

.privacy-code,.privacy-url { display:block; overflow-wrap:anywhere; word-break:break-word; user-select:text; max-width:100%; }
#aboutDialog { overflow-wrap:anywhere; }

.history-calendar{margin:12px 0 20px}.history-calendar label{display:block;font-size:14px;margin-bottom:8px}.calendar-navigation{display:flex;align-items:center;gap:8px}.calendar-navigation input{min-width:0;flex:1;font:inherit;padding:12px;border:1px solid currentColor;border-radius:12px;background:transparent;color:inherit;color-scheme:light dark}.calendar-navigation button{min-width:44px;min-height:44px;font-size:24px}.calendar-actions{display:flex;flex-wrap:wrap;gap:12px;margin-top:10px}.calendar-actions button{min-height:44px;padding:8px 16px;font:inherit}.history-calendar button:disabled{opacity:.4}.history-calendar button:focus-visible,.history-calendar input:focus-visible{outline:3px solid #4b95ed;outline-offset:3px}


/* RU/KG language switch adjacent to theme; both themes, narrow screens. */
.language-toggle {
  width: 54px;
  min-width: 54px;
  min-height: 44px;
  padding: 0 2px;
  flex-shrink: 0;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: -.035em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--border, #8886);
  border-radius: 12px;
  background: var(--surface, transparent);
  color: inherit;
}
.language-toggle [data-lang-option] { opacity: .56; }
:root:not([data-lang="kg"]) .language-toggle [data-lang-option="ru"],
:root[data-lang="kg"] .language-toggle [data-lang-option="kg"] {
  opacity: 1;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.language-toggle .language-slash { opacity: .45; }
.language-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
@media (max-width: 350px) {
  .header-actions { gap: 4px; }
  .language-toggle { width: 50px; min-width: 50px; font-size: .7rem; }
}


/* The existing large PM2.5 card follows the CURRENT concentration category. */
.hero .pm-alert {
  display: block;
  margin: 0 24px 12px;
  padding: 9px 13px;
  width: fit-content;
  max-width: calc(100% - 48px);
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 800;
  line-height: 1.5;
  color: white;
}
.hero .pm-alert[hidden] { display: none; }
.hero[data-tone="orange"] .reading-risk,
.hero[data-tone="red"] .reading-risk,
.hero[data-tone="purple"] .reading-risk,
.hero[data-tone="maroon"] .reading-risk {
  margin: 0 24px 14px;
  padding: 10px 12px;
  border-left: 3px solid rgba(255,255,255,.85);
  background: rgba(0,0,0,.16);
  border-radius: 0 9px 9px 0;
  font-weight: 550;
}
