:root {
  --bg: #f7f8f8;
  --panel: #ffffff;
  --text: #172022;
  --muted: #657174;
  --border: #d9dfdf;
  --accent: #4f8f9b;
  --accent-weak: #dceced;
  --danger: #a94b45;
  --ok: #3f8565;
  --button-text: #ffffff;
  --log-bg: #eef2f2;
  --disabled: #aeb7b8;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 14px;
  --space-lg: 22px;
  --space-xl: 32px;
}


@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111617;
    --panel: #171e20;
    --text: #edf2f2;
    --muted: #a5b0b2;
    --border: #303a3d;
    --accent: #6eabb2;
    --accent-weak: #213538;
    --danger: #d37a72;
    --ok: #79ba9d;
    --button-text: #081113;
    --log-bg: #0d1213;
    --disabled: #566164;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 32px);
  display: grid;
  gap: var(--space-lg);
  align-content: start;
}

.orb-section {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding-top: 10px;
}

.orb-wrap {
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
}

.orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(1);
  transform-origin: center;
  will-change: transform;
}

.orb.calibrating {
  animation: calibrating-pulse 2.4s ease-in-out infinite;
}

@keyframes calibrating-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

.phase-label {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.prep-note {
  padding: 12px 14px;
  background: var(--accent-weak);
  border: 0.5px solid var(--border);
  border-radius: 8px;
}

.prep-note p {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  min-width: 0;
  padding: 14px;
  background: var(--panel);
  border: 0.5px solid var(--border);
  border-radius: 8px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.45rem, 7vw, 2rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.controls {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 0.5px solid var(--border);
  border-radius: 8px;
}

.control {
  display: grid;
  gap: 8px;
}

.control span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-row {
  display: grid;
  gap: 8px;
}

.version-label {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
}

.sensor-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.sensor-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--disabled);
}

.sensor-dot.active {
  background: var(--ok);
}

.sensor-dot.denied {
  background: var(--danger);
}

.status-message {
  min-height: 1.5em;
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.buttons {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 44px;
  padding: 10px 12px;
  border: 0.5px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--button-text);
  cursor: pointer;
}

.primary-action {
  min-height: 50px;
  font-weight: 700;
}

.secondary-action {
  background: transparent;
  color: var(--accent);
}

button:disabled {
  border-color: var(--border);
  background: var(--disabled);
  color: var(--panel);
  cursor: not-allowed;
}

.secondary-action:disabled {
  background: transparent;
  color: var(--disabled);
}

button:not(:disabled):active {
  transform: translateY(1px);
}


.diagnostics-panel {
  border-top: 0.5px solid var(--border);
  padding-top: 12px;
}

.diagnostics-panel summary {
  width: fit-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
}

.diagnostics-panel summary:focus-visible,
button:focus-visible,
a:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.diagnostics-content {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.debug-section {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--log-bg);
  border: 0.5px solid var(--border);
  border-radius: 8px;
}

.debug-line {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

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

.report-section[hidden] {
  display: none;
}

.report-section label {
  color: var(--muted);
  font-size: 0.9rem;
}

.report-text {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  resize: vertical;
  background: var(--log-bg);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.log-section {
  min-height: 140px;
}

.session-log {
  min-height: 140px;
  max-height: 190px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: var(--log-bg);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 4px 0 12px;
}

.app-footer a,
.about-nav a,
.about-content a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

.app-footer a {
  color: var(--muted);
  font-size: 0.86rem;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  min-width: 28px;
  min-height: 28px;
  justify-content: center;
}

.about-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 32px) 48px;
}

.about-nav {
  display: flex;
  gap: 18px;
  margin-bottom: 28px;
}

.about-nav a {
  font-weight: 700;
  text-decoration: none;
}

.about-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.about-content h1,
.about-content h2,
.about-content h3,
.about-content p,
.about-content ol,
.about-content ul {
  margin: 0;
}

.about-content h1 {
  font-size: clamp(2rem, 10vw, 3.3rem);
  line-height: 1;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.about-content h2 {
  margin-top: 18px;
  font-size: 1.35rem;
  line-height: 1.2;
}

.about-content h3 {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.3;
}

.about-content p,
.about-content li {
  color: var(--text);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.about-content h1 a,
.about-content p a {
  overflow-wrap: anywhere;
}

.about-content ol,
.about-content ul {
  display: grid;
  gap: 10px;
  padding-left: 1.35rem;
}

.about-content li::marker {
  color: var(--muted);
}

@media (max-width: 560px) {
  .app-shell {
    gap: 18px;
  }

  .orb-wrap {
    width: 220px;
    height: 220px;
  }

  .stats,
  .buttons {
    grid-template-columns: 1fr;
  }

  .about-shell {
    padding-top: 20px;
  }

  .about-content h1 {
    font-size: 1.9rem;
    line-height: 1.08;
  }
}
