:root {
  --paper: #e8f0ea;
  --paper-strong: #f8f5e9;
  --ink: #151515;
  --muted: #59625c;
  --line: #c9d1c8;
  --red: #e54835;
  --amber: #e1a32d;
  --green: #25895c;
  --cyan: #267b87;
  --field: #fff;
  --panel-bg: rgba(248, 245, 233, 0.88);
  --primary-text: #fff8e8;
  --shadow: 0 18px 46px rgba(21, 21, 21, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(21, 21, 21, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(21, 21, 21, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Aptos", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 0 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--paper-strong);
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
  box-shadow: 5px 5px 0 var(--ink);
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1,
.signal-band h2,
.android-panel h2,
.install-panel h2,
.timeline-section h2 {
  margin: 0;
}

.brand-copy h1 {
  font-size: 28px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill {
  padding: 8px 10px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.about-link {
  margin-left: auto;
  padding: 8px 10px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.about-link:focus-visible,
.about-section a:focus-visible {
  outline: 3px solid rgba(229, 72, 53, 0.28);
  outline-offset: 3px;
}

.status-ok {
  background: rgba(37, 137, 92, 0.15);
  color: var(--green);
}

.status-warn {
  background: rgba(229, 72, 53, 0.13);
  color: var(--red);
}

.status-muted {
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  max-width: 1120px;
  margin: 0 auto;
}

.signal-band,
.android-panel,
.install-panel,
.controls-band,
.settings-grid,
.timeline-section,
.about-section {
  border: 2px solid var(--ink);
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.signal-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  min-height: 164px;
}

.signal-band h2 {
  font-size: clamp(26px, 6vw, 60px);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.latest-text {
  max-width: 820px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.signal-metrics {
  display: grid;
  place-items: center;
  min-width: 104px;
  padding: 10px;
  border-left: 2px solid var(--ink);
}

.signal-metrics span {
  font-size: 54px;
  font-weight: 900;
  line-height: 1;
}

.signal-metrics small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.android-panel {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.android-panel h2 {
  font-size: 24px;
  line-height: 1.08;
}

.native-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.native-status-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--field);
}

.native-status-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.native-status-item strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-ok {
  color: var(--green);
}

.state-warn {
  color: var(--red);
}

.install-panel {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
}

.install-panel ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.5;
}

.controls-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.primary-action,
.secondary-action,
.refresh-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-strong);
  font-weight: 900;
}

.primary-action {
  background: var(--red);
  color: var(--primary-text);
}

.secondary-action {
  background: var(--field);
}

.secondary-action.is-active {
  background: var(--red);
  color: var(--primary-text);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.android-shell .controls-band {
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
}

.android-shell #notifyButton {
  min-height: 58px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.setting-block,
.switch-line {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.setting-block label,
.switch-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.setting-block input,
.setting-block select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

.setting-block input:focus,
.setting-block select:focus {
  box-shadow: 0 0 0 3px rgba(229, 72, 53, 0.2);
}

.search-block {
  position: relative;
}

.city-results {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  display: grid;
  max-height: 220px;
  overflow: auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--field);
  box-shadow: var(--shadow);
}

.city-result {
  display: block;
  width: 100%;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--field);
  text-align: left;
}

.city-result strong,
.city-result span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-result span {
  color: var(--muted);
  font-size: 12px;
}

.switch-line {
  align-items: end;
  grid-template-columns: auto 1fr;
  min-height: 62px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--field);
}

.switch-line input {
  width: 24px;
  height: 24px;
  accent-color: var(--red);
}

.timeline-section {
  padding: 12px;
}

.about-section {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.about-section h2,
.about-section p {
  margin: 0;
}

.about-section h2 {
  font-size: 22px;
  line-height: 1.12;
}

.about-section p {
  color: var(--muted);
  line-height: 1.45;
}

.about-section a {
  color: var(--ink);
  font-weight: 900;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
}

.refresh-action {
  background: var(--amber);
  white-space: nowrap;
}

.refresh-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.refresh-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline {
  display: grid;
  gap: 10px;
}

.alert-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--field);
}

.alert-stripe {
  width: 8px;
  height: 100%;
  min-height: 62px;
  border-radius: 4px;
  background: var(--amber);
}

.alert-row.drone .alert-stripe,
.alert-row.air_raid .alert-stripe,
.alert-row.artillery .alert-stripe {
  background: var(--red);
}

.alert-row.cancel .alert-stripe {
  background: var(--green);
}

.alert-row h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.25;
}

.alert-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.alert-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--paper-strong);
  background: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111614;
    --paper-strong: #20261f;
    --ink: #f3f0e8;
    --muted: #b4beb6;
    --line: #3a453e;
    --red: #ff5948;
    --amber: #efb23e;
    --green: #55c78f;
    --cyan: #67c3d0;
    --field: #171d19;
    --panel-bg: rgba(27, 32, 28, 0.92);
    --primary-text: #fff8e8;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  }

  body {
    background:
      linear-gradient(90deg, rgba(243, 240, 232, 0.035) 1px, transparent 1px),
      linear-gradient(0deg, rgba(243, 240, 232, 0.035) 1px, transparent 1px),
      var(--paper);
  }

  .about-link,
  .status-muted {
    background: rgba(255, 255, 255, 0.08);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .signal-band,
  .android-panel,
  .install-panel,
  .controls-band,
  .settings-grid,
  .about-section {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .about-link {
    order: 3;
    margin-left: 0;
  }

  .status-pill {
    order: 2;
    margin-left: auto;
  }

  .signal-metrics {
    display: flex;
    justify-content: space-between;
    border-left: 0;
    border-top: 2px solid var(--ink);
  }

  .controls-band {
    gap: 8px;
  }

  .android-shell .controls-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .android-shell #notifyButton {
    grid-column: 1 / -1;
  }

  .native-status-grid {
    grid-template-columns: 1fr;
  }

  .alert-row {
    grid-template-columns: 8px minmax(0, 1fr);
  }

  .alert-time {
    grid-column: 2;
  }
}
