:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #000000;
  color: #eef5ff;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100svh;
  background: #000000;
}

button,
pre,
summary {
  font: inherit;
}

.app {
  min-height: 100svh;
  background: #000000;
  padding: 0 max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.permission-app {
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.permission-screen {
  display: grid;
  min-height: calc(100svh - 36px);
  place-items: center;
}

.permission-button {
  display: grid;
  place-items: center;
  width: min(56vw, 290px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  color: #dc0b13;
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

.permission-button:active {
  transform: scale(0.97);
  filter: brightness(0.94);
  box-shadow: none;
}

.permission-button:disabled {
  cursor: wait;
  filter: grayscale(0.15) brightness(0.92);
}

.pin-icon {
  width: 77%;
  height: 77%;
  filter: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(80px + env(safe-area-inset-top));
  margin: 0 calc(-1 * max(18px, env(safe-area-inset-right))) 0 calc(-1 * max(18px, env(safe-area-inset-left)));
  padding: calc(18px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 16px max(18px, env(safe-area-inset-left));
  background: #000000;
}

.app-title {
  margin: 0;
  color: #ffffff;
  font-size: clamp(1.55rem, 7.4vw, 2rem);
  font-weight: 760;
  letter-spacing: 0;
  white-space: nowrap;
}

.menu-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-icon {
  width: 40px;
  height: 40px;
}

.data-view {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: calc(100svh - 80px);
  padding-bottom: 18px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 52vw;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #dbeafe;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.inline-status {
  justify-self: end;
  margin-top: -8px;
}

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 15;
  min-height: 100svh;
  padding:
    calc(98px + env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: #000000;
}

.settings-box {
  display: grid;
  gap: 24px;
  min-height: calc(100svh - 132px - env(safe-area-inset-top));
  align-content: start;
  padding: 22px;
  border: 2px solid #ffffff;
  background: #000000;
  color: #ffffff;
}

.settings-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.settings-title-row h2,
.settings-subtitle {
  margin: 0;
  color: #ffffff;
  font-size: 1.7rem;
  font-weight: 760;
  letter-spacing: 0;
}

.settings-title-row span {
  color: #ffffff;
  font-size: 1rem;
}

.permission-list {
  display: grid;
  gap: 4px;
  max-width: 430px;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  color: #ffffff;
  font-size: 1.28rem;
  line-height: 1.1;
}

.permission-row strong {
  min-width: 0;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 720;
  text-align: right;
  overflow-wrap: anywhere;
}

.status-dot {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.status-dot.good {
  background: #b9f6a4;
  color: #7bc466;
}

.status-dot.warn {
  background: #ffe68a;
  color: #e2bd3a;
}

.status-dot.bad {
  background: #ffb1ac;
  color: #ff7c75;
}

.refresh-label {
  margin: -8px 0 0;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 720;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.summary-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.summary-item.wide {
  grid-column: 1 / -1;
}

.summary-item span {
  color: #a8c7d8;
  font-size: 0.72rem;
}

.summary-item strong {
  min-width: 0;
  color: #f8fafc;
  font-size: 0.88rem;
  font-weight: 720;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.control-panel {
  display: grid;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.control-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.control-top label {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 720;
}

.control-top strong {
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 720;
  text-align: right;
}

.noise-slider {
  width: 100%;
  accent-color: #ffffff;
}

.control-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  color: #9fb7c9;
  font-size: 0.68rem;
}

.control-meta span:nth-child(2) {
  text-align: center;
}

.control-meta span:last-child {
  text-align: right;
}

.sensor-section {
  display: grid;
  gap: 8px;
}

.section-title {
  margin: 0;
  color: #e0f2fe;
  font-size: 0.86rem;
  font-weight: 720;
  letter-spacing: 0;
}

.sensor-table {
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  background: rgba(2, 6, 23, 0.58);
}

.table-row {
  display: grid;
  grid-template-columns: minmax(82px, 0.9fr) minmax(0, 1fr) minmax(0, 1fr);
  min-height: 42px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.table-row:first-child {
  border-top: 0;
}

.table-row > div {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 9px 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.table-row > div:first-child {
  border-left: 0;
}

.table-head {
  min-height: 34px;
  background: rgba(255, 255, 255, 0.08);
  color: #9fb7c9;
  font-size: 0.68rem;
  font-weight: 720;
  text-transform: uppercase;
}

.signal {
  color: #cbd5e1;
  font-size: 0.76rem;
}

.value {
  justify-content: flex-end;
  color: #f8fafc;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.2;
  text-align: right;
  overflow-wrap: anywhere;
}

.value.smooth {
  color: #b9f6d2;
}

.debug-details {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.debug-details summary {
  min-height: 42px;
  padding: 11px 12px;
  color: #dbeafe;
  cursor: pointer;
}

.json-output {
  width: 100%;
  max-height: 58svh;
  margin: 0;
  padding: 16px;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  background: rgba(2, 6, 23, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #d7ffea;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-list {
  display: grid;
  gap: 8px;
}

.error-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 8px;
  background: rgba(127, 29, 29, 0.28);
  color: #fecaca;
  font-size: 0.82rem;
  line-height: 1.35;
}

@media (min-width: 720px) {
  .app {
    display: grid;
    place-items: center;
  }

  .app-header,
  .settings-panel {
    width: min(720px, 100%);
    margin-inline: auto;
  }

  .permission-screen,
  .data-view {
    width: min(720px, 100%);
  }

  .json-output {
    font-size: 0.84rem;
  }

  .table-row {
    grid-template-columns: 1fr 1.35fr 1.35fr;
  }
}
