:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #94a8bb;
  --panel: rgba(18, 35, 51, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.12);
  --blue: #17a7ff;
  --cyan: #22e1c3;
  --yellow: #ffc93d;
  --green: #35e38d;
  --danger: #ff6b75;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #06101a;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 5%, rgba(23, 167, 255, 0.17), transparent 30rem),
    radial-gradient(circle at 5% 95%, rgba(34, 225, 195, 0.09), transparent 27rem),
    linear-gradient(145deg, #07111b 0%, #0a1927 52%, #07131f 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button,
label {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 78px 1fr 78px;
  align-items: center;
  min-height: 58px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 25px;
  height: 25px;
  border: 2px solid var(--blue);
  border-radius: 7px;
  position: relative;
  transform: rotate(-7deg);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--yellow);
}

.brand-mark::before {
  width: 2px;
  height: 13px;
  left: 7px;
  top: 4px;
  box-shadow: 5px 3px 0 -0.4px var(--yellow);
}

.brand-mark::after {
  width: 7px;
  height: 2px;
  right: -5px;
  bottom: -4px;
  transform: rotate(45deg);
}

.icon-button,
.install-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 2rem;
  line-height: 1;
}

.install-button {
  padding: 0 11px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 750;
}

.screen {
  display: none;
  min-height: calc(100vh - 116px);
  animation: screen-in 260ms ease-out;
}

.screen.is-active {
  display: block;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-screen {
  padding-top: clamp(26px, 7vh, 72px);
}

.hero {
  text-align: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.17em;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 9vw, 3.55rem);
  line-height: 1.03;
  letter-spacing: -0.055em;
}

.hero > p:last-child,
.section-heading > p:last-child {
  margin: 14px auto 0;
  max-width: 420px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.tool-grid {
  display: grid;
  gap: 14px;
  margin-top: clamp(32px, 7vh, 64px);
}

.tool-card {
  display: grid;
  grid-template-columns: 74px 1fr 28px;
  align-items: center;
  gap: 15px;
  min-height: 118px;
  padding: 18px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035));
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tool-card:active {
  transform: scale(0.985);
}

.tool-card:hover,
.tool-card:focus-visible {
  border-color: rgba(23, 167, 255, 0.55);
  background: linear-gradient(120deg, rgba(23, 167, 255, 0.13), rgba(255, 255, 255, 0.04));
  outline: none;
}

.tool-card strong {
  display: block;
  font-size: 1.43rem;
  letter-spacing: -0.025em;
}

.tool-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tool-card b {
  color: var(--blue);
  font-size: 1.45rem;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border-radius: 22px;
  background: #0a2031;
}

.ruler-icon {
  position: relative;
  display: flex;
  justify-content: space-evenly;
  align-items: flex-start;
  padding: 19px 12px 0;
  border: 1px solid rgba(255, 201, 61, 0.22);
  transform: rotate(-6deg);
}

.ruler-icon::after {
  content: "";
  position: absolute;
  inset: 15px 9px;
  border: 3px solid var(--yellow);
  border-radius: 7px;
}

.ruler-icon i {
  z-index: 1;
  width: 2px;
  height: 12px;
  background: var(--yellow);
}

.ruler-icon i:nth-child(even) {
  height: 7px;
}

.level-icon {
  position: relative;
  border: 1px solid rgba(34, 225, 195, 0.22);
}

.level-icon::before {
  content: "";
  width: 46px;
  height: 20px;
  border: 3px solid var(--cyan);
  border-radius: 999px;
}

.level-icon i {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(34, 225, 195, 0.8);
}

.compatibility-note {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px auto 0;
  padding: 13px 16px;
  border-radius: 16px;
  background: rgba(53, 227, 141, 0.07);
  color: #b5c8d8;
}

.compatibility-note > span {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  color: #05140d;
  background: var(--green);
  font-weight: 900;
}

.compatibility-note p {
  margin: 0;
  font-size: 0.73rem;
  line-height: 1.45;
}

.tool-screen {
  padding-top: 18px;
}

.section-heading {
  text-align: center;
}

.section-heading h1 {
  font-size: clamp(2rem, 8vw, 3rem);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 24px 0 16px;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #73889b;
  background: var(--panel-soft);
  font-size: 0.7rem;
  font-weight: 750;
}

.steps span {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.steps li.is-current {
  color: var(--ink);
  border-color: rgba(23, 167, 255, 0.6);
  background: rgba(23, 167, 255, 0.13);
}

.steps li.is-done {
  color: var(--cyan);
  border-color: rgba(34, 225, 195, 0.25);
}

.measure-stage {
  animation: screen-in 220ms ease-out;
}

.camera-frame,
.canvas-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: #02070c;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

#cameraVideo,
#measureCanvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.camera-placeholder strong {
  color: var(--ink);
}

.camera-placeholder small {
  max-width: 230px;
  text-align: center;
}

.camera-symbol {
  position: relative;
  width: 58px;
  height: 42px;
  margin-bottom: 8px;
  border: 3px solid var(--blue);
  border-radius: 13px;
}

.camera-symbol::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 9px;
  left: 17px;
  border: 3px solid var(--blue);
  border-radius: 50%;
}

.camera-symbol::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 7px;
  top: -8px;
  left: 16px;
  border-radius: 5px 5px 0 0;
  background: var(--blue);
}

.camera-guide {
  pointer-events: none;
  position: absolute;
  inset: auto 14px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 0.66rem;
}

.camera-guide span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
}

.action-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

.primary-button {
  border: 0;
  color: #04111d;
  background: linear-gradient(135deg, #25b8ff, #21e0c4);
  box-shadow: 0 10px 28px rgba(23, 167, 255, 0.18);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.985);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.message {
  min-height: 19px;
  margin: 10px 3px 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.45;
}

.message.is-error {
  color: #ff9299;
}

.canvas-wrap {
  touch-action: none;
}

#measureCanvas {
  cursor: crosshair;
}

.canvas-hint {
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: 13px;
  width: calc(100% - 28px);
  transform: translateX(-50%);
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.72);
  text-align: center;
  font-size: 0.68rem;
}

.result-panel {
  margin-top: 13px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--panel);
  text-align: center;
}

.result-panel p {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-panel > strong {
  display: block;
  font-size: 1.1rem;
}

.result-panel > small {
  display: block;
  margin: 8px 0 15px;
  color: var(--muted);
  line-height: 1.45;
}

#measurementResult {
  display: block;
  color: var(--yellow);
  font-size: clamp(2.4rem, 12vw, 4rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.06em;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.text-button {
  display: block;
  margin: 12px auto 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.level-display {
  margin: 30px 0 18px;
  text-align: center;
}

.level-circle {
  position: relative;
  width: min(70vw, 310px);
  aspect-ratio: 1;
  margin: 0 auto 22px;
  overflow: hidden;
  border: 3px solid rgba(34, 225, 195, 0.58);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(34, 225, 195, 0.06) 0 20%, transparent 20% 100%),
    rgba(3, 13, 21, 0.82);
  box-shadow: inset 0 0 70px rgba(34, 225, 195, 0.07), 0 20px 60px rgba(0, 0, 0, 0.22);
}

.level-circle.is-level {
  border-color: var(--green);
  box-shadow: inset 0 0 80px rgba(53, 227, 141, 0.13), 0 0 45px rgba(53, 227, 141, 0.12);
}

.axis {
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(255, 255, 255, 0.16);
  transform: translate(-50%, -50%);
}

.axis-x {
  width: 100%;
  height: 1px;
}

.axis-y {
  width: 1px;
  height: 100%;
}

.level-bubble {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b5fff3, var(--cyan) 45%, #0b9e8a 100%);
  box-shadow: 0 7px 23px rgba(34, 225, 195, 0.4);
  transition: left 90ms linear, top 90ms linear, background 180ms ease;
}

.level-circle.is-level .level-bubble {
  background: radial-gradient(circle at 35% 30%, #d7ffe9, var(--green) 50%, #0b9e58 100%);
}

#levelValue {
  display: block;
  font-size: 3.5rem;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.06em;
}

#levelState {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

#levelState.is-level {
  color: var(--green);
}

.axis-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.axis-values span {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 0.68rem;
}

.axis-values b {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 0.94rem;
}

footer {
  padding: 24px 0 4px;
  color: #526779;
  text-align: center;
  font-size: 0.68rem;
}

.is-hidden {
  display: none !important;
}

@media (min-width: 700px) {
  .app-shell {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
