:root {
  --bg: #f7f5ef;
  --card: #fff;
  --line: #dedbd1;
  --text: #242424;
  --muted: #77756d;
  --accent: #30302e;
  --bubble: #83c768;
  --bubble-light: #c9edb8;
  --good: #3d8c50;
  --near: #ad7a24;
  --off: #a74c43;
  --mobile-bg: #e8f2ff;
  --mobile-text: #35618e;
  --radius: 22px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Pretendard', 'Noto Sans KR', Arial,
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  touch-action: manipulation;
}
[hidden] {
  display: none !important;
}

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

.level-header {
  margin-bottom: 16px;
}
.level-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.level-heading {
  min-width: 0;
  flex: 1;
}
.level-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 15px;
  background: #e9e4d7;
  font-size: 25px;
}
.level-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.level-brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}
.level-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.mobile-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--mobile-bg);
  color: var(--mobile-text);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.level-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.device-guide {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #d7e5f5;
  border-radius: 14px;
  background: #f0f6fd;
  color: #4b6684;
  font-size: 12px;
  line-height: 1.5;
}
.device-guide strong {
  color: #315879;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
}
.mode-button {
  border: 0;
  border-radius: 12px;
  padding: 12px 10px;
  background: transparent;
  color: #77746d;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
}
.mode-button.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.mode-icon {
  margin-right: 5px;
}

.sensor-message {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
}
.sensor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bbb8ae;
}
.sensor-message.is-running .sensor-dot {
  background: #61ad6d;
  box-shadow: 0 0 0 4px rgba(97, 173, 109, 0.12);
}
.sensor-message.is-error .sensor-dot {
  background: #bb5b53;
}

.level-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(34, 31, 24, 0.055);
}
.panel-guide {
  margin-bottom: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.panel-guide strong {
  color: var(--text);
}

.flat-level {
  position: relative;
  width: min(76vw, 320px);
  aspect-ratio: 1;
  margin: 0 auto 20px;
  overflow: hidden;
  border: 2px solid #c9c5b9;
  border-radius: 50%;
  background: radial-gradient(
    circle at 42% 35%,
    #faf9f4 0,
    #eeeade 70%,
    #e3ded0 100%
  );
  box-shadow: inset 0 5px 18px rgba(0, 0, 0, 0.08);
}
.flat-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(70, 68, 62, 0.2);
  border-radius: 50%;
  pointer-events: none;
}
.ring-outer {
  width: 72%;
  height: 72%;
}
.ring-middle {
  width: 44%;
  height: 44%;
}
.ring-center {
  width: 18%;
  height: 18%;
  border: 2px solid rgba(70, 68, 62, 0.42);
}
.flat-axis {
  position: absolute;
  background: rgba(70, 68, 62, 0.15);
  pointer-events: none;
}
.axis-horizontal {
  top: 50%;
  left: 9%;
  width: 82%;
  height: 1px;
}
.axis-vertical {
  top: 9%;
  left: 50%;
  width: 1px;
  height: 82%;
}
.flat-bubble {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(61, 118, 55, 0.55);
  border-radius: 50%;
  background: radial-gradient(
    circle at 34% 28%,
    var(--bubble-light),
    var(--bubble)
  );
  box-shadow: 0 5px 12px rgba(76, 120, 62, 0.25);
  will-change: transform;
}
.bubble-shine {
  position: absolute;
  top: 10px;
  left: 13px;
  width: 13px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: rotate(-25deg);
}

.measure-status {
  width: fit-content;
  min-width: 130px;
  margin: 0 auto 16px;
  padding: 7px 14px;
  border-radius: 999px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  background: #efeee9;
  color: #77746d;
}
.measure-status.is-good {
  background: #e5f4e7;
  color: var(--good);
}
.measure-status.is-near {
  background: #fff1d8;
  color: var(--near);
}
.measure-status.is-off {
  background: #fae7e4;
  color: var(--off);
}

.value-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.value-card,
.main-angle,
.vertical-error {
  padding: 13px;
  border: 1px solid #ece9e0;
  border-radius: 14px;
  background: #faf9f5;
  text-align: center;
}
.value-label,
.main-angle-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}
.value-number {
  font-size: 23px;
  font-variant-numeric: tabular-nums;
}

.vertical-visual {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 280px;
  margin: 0 auto 8px;
}
.vertical-reference {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: calc(50% + 76px);
  width: 1px;
  border-left: 1px dashed #b8b4aa;
}
.vertical-reference span {
  position: absolute;
  top: 50%;
  left: 8px;
  width: max-content;
  transform: translateY(-50%);
  color: #aaa69c;
  font-size: 10px;
}
.phone-indicator {
  position: relative;
  width: 112px;
  height: 220px;
  padding: 8px;
  border: 4px solid #393936;
  border-radius: 22px;
  background: #222220;
  transform-origin: 50% 90%;
  will-change: transform;
}
.phone-screen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 15px;
  background: linear-gradient(160deg, #eeece3, #dcd8cb);
}
.phone-screen span {
  color: #77746c;
  font-size: 24px;
  font-weight: 800;
}
.phone-speaker {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 50%;
  width: 30px;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 5px;
  background: #555551;
}

.bar-level-wrap {
  padding: 0 5px 18px;
}
.bar-level {
  position: relative;
  height: 42px;
  overflow: hidden;
  border: 2px solid #c9c5b9;
  border-radius: 999px;
  background: #eeeade;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.08);
}
.bar-center {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 50%;
  width: 36px;
  transform: translateX(-50%);
  border-left: 2px solid #8d897d;
  border-right: 2px solid #8d897d;
}
.bar-bubble {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border: 1px solid #689a58;
  border-radius: 50%;
  background: var(--bubble);
  box-shadow: inset 5px 5px 8px rgba(255, 255, 255, 0.36);
  will-change: transform;
}

.vertical-values {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
}
.main-angle strong {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}
.vertical-error {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
}
.vertical-error strong {
  margin-top: 2px;
  color: var(--text);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.level-controls {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 7px;
}
.control-button {
  min-height: 48px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.control-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.control-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.level-info {
  padding: 15px 16px;
  border: 1px solid #e2ded4;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  color: #66635c;
  font-size: 12px;
  line-height: 1.65;
}
.level-info-title {
  margin-bottom: 6px;
  color: #343431;
  font-weight: 800;
}
.level-info p {
  margin: 0;
}
.level-info p + p {
  margin-top: 6px;
}
.level-note {
  color: #8a867b;
}
.unsupported-box {
  padding: 14px;
  border-radius: 14px;
  background: #f6e9e6;
  color: #935249;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
}
.level-footer {
  padding: 20px 0 4px;
  color: #aaa69c;
  text-align: center;
  font-size: 11px;
}

@media (max-width: 390px) {
  .level-page {
    padding-left: 12px;
    padding-right: 12px;
  }
  .level-panel {
    padding: 15px;
  }
  .level-controls {
    grid-template-columns: 1fr 1fr;
  }
  .control-button.primary {
    grid-column: 1 / -1;
  }
  .flat-bubble {
    width: 48px;
    height: 48px;
  }
  .level-title-row {
    gap: 6px;
  }
}

@media (min-width: 760px) and (pointer: fine) {
  .level-page {
    padding-top: 28px;
  }
}
