:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070a0c;
  --bg: #151a1f;
  --panel: rgba(255, 255, 255, .055);
  --panel-strong: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .24);
  --muted: rgba(255, 255, 255, .62);
  --soft: rgba(255, 255, 255, .42);
  --white: #f6f7f8;
  --black: #101214;
  --danger: #ff8d8d;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: #070a0c; }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, select { color: inherit; font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.app {
  position: relative;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 110% 95%, rgba(255,255,255,.25), transparent 32%),
    radial-gradient(circle at -15% 45%, rgba(255,255,255,.08), transparent 38%),
    linear-gradient(145deg, #11161a 0%, #1f252a 58%, #30363b 100%);
  color: var(--white);
  box-shadow: 0 0 80px rgba(0,0,0,.65);
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.11'/%3E%3C/svg%3E");
}

.screen { position: relative; z-index: 1; min-height: 100dvh; padding: var(--safe-top) 22px calc(118px + var(--safe-bottom)); }
.screen--auth { padding-bottom: calc(28px + var(--safe-bottom)); }
.screen--camera { padding-bottom: calc(110px + var(--safe-bottom)); }
.screen-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.brand { margin: 0; font-size: 42px; font-weight: 500; letter-spacing: -.08em; }
.brand--word { font-size: 31px; letter-spacing: -.05em; }
.avatar-mini { width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; object-fit: cover; background: #101316; }
.eyebrow { margin: 30px 0 10px; color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.title { margin: 0; font-size: clamp(34px, 10vw, 48px); line-height: .98; letter-spacing: -.045em; }
.subtitle { margin: 14px 0 0; color: var(--muted); font-size: 16px; line-height: 1.45; }
.section-title { margin: 28px 0 14px; font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.back, .round-button, .icon-button {
  display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.055);
}
.back, .round-button { width: 48px; height: 48px; }
.back { font-size: 30px; line-height: 1; }
.icon-button { width: 42px; height: 42px; }

.auth-hero {
  position: absolute; inset: 0 0 auto 42%; height: 410px; z-index: -1;
  background: linear-gradient(90deg, var(--bg), transparent 45%), linear-gradient(0deg, var(--bg), transparent 42%), url("./assets/registration-hero.webp") center/cover;
  opacity: .92;
}
.auth-logo { margin: 68px 0 74px; }
.auth-card { position: relative; }
.step { margin: 0 0 42px; color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.form { display: grid; margin-top: 24px; gap: 10px; }
.field { position: relative; display: flex; min-height: 58px; align-items: center; border: 1px solid var(--line); border-radius: 15px; background: rgba(14,17,20,.35); }
.field:focus-within { border-color: rgba(255,255,255,.75); background: rgba(255,255,255,.08); }
.field span { width: 52px; text-align: center; color: var(--muted); }
.field input, .field select { min-width: 0; flex: 1; height: 56px; border: 0; outline: 0; background: transparent; }
.field input::placeholder { color: var(--soft); }
.field .field-action { width: 46px; height: 46px; border: 0; background: transparent; color: var(--muted); }
.check-row { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; color: var(--muted); font-size: 12px; line-height: 1.35; }
.check-row input { width: 18px; height: 18px; margin: 0; accent-color: #fff; }
.check-row a { color: #fff; text-underline-offset: 2px; }

.button { min-height: 56px; padding: 0 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); font-weight: 650; }
.button--primary { border-color: #fff; background: #fff; color: #111; }
.button--ghost { background: rgba(255,255,255,.035); }
.button--danger { color: var(--danger); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.auth-alt { display: grid; margin-top: 10px; gap: 10px; }
.auth-switch { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-switch button { border: 0; background: none; color: #fff; font-weight: 650; }
.privacy-note { margin: 16px 0 0; color: var(--soft); font-size: 11px; line-height: 1.4; text-align: center; }

.search-box { display: flex; min-height: 62px; margin-top: 22px; align-items: center; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.search-box span { width: 54px; text-align: center; font-size: 28px; }
.search-box input { min-width: 0; flex: 1; height: 60px; padding-right: 12px; border: 0; outline: 0; background: transparent; font-size: 17px; }

.stat-card, .continue-card, .profile-card, .settings-card, .result-card, .scan-result {
  border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(135deg, rgba(255,255,255,.055), rgba(255,255,255,.015));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.stat-card { margin-top: 16px; padding: 22px; }
.stat-main { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: end; gap: 18px; }
.stat-main strong { display: block; font-size: 46px; line-height: .9; }
.stat-main i { align-self: stretch; background: var(--line); }
.stat-value { text-align: right; font-size: 22px; }
.progress { height: 5px; margin-top: 22px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.2); }
.progress span { display: block; height: 100%; border-radius: inherit; background: #fff; transition: width 500ms ease; }
.continue-card { display: flex; margin-top: 12px; padding: 16px; align-items: center; gap: 14px; }
.continue-card .timer { display: grid; width: 58px; height: 58px; flex: 0 0 auto; place-items: center; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; font-size: 12px; }
.continue-card .grow { flex: 1; }

.space-strip { display: grid; grid-template-columns: repeat(2, 78%); margin: 12px -22px 0; padding: 0 22px 10px; overflow-x: auto; gap: 12px; scrollbar-width: none; }
.space-strip::-webkit-scrollbar { display: none; }
.space-card { position: relative; min-height: 210px; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #111 center/cover; text-align: left; }
.space-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.82), transparent 65%); }
.space-card__content { position: absolute; z-index: 1; right: 18px; bottom: 18px; left: 18px; }
.space-card h3 { margin: 0; font-size: 24px; }
.space-card p { margin: 5px 0 0; color: rgba(255,255,255,.82); }
.spaces-grid { display: grid; margin-top: 16px; grid-template-columns: 1fr 1fr; gap: 12px; }
.spaces-grid .space-card:first-child { grid-column: 1 / -1; min-height: 235px; }
.spaces-grid .space-card:not(:first-child) { min-height: 230px; }
.add-space { width: 100%; margin-top: 14px; }

.results { display: grid; margin-top: 18px; gap: 10px; }
.result-card { display: grid; min-height: 112px; grid-template-columns: 112px 1fr 38px; overflow: hidden; align-items: stretch; text-align: left; }
.result-card img { width: 112px; height: 100%; object-fit: cover; }
.result-card__body { padding: 14px 10px 12px 16px; }
.result-card h3 { margin: 0; font-size: 17px; }
.result-card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.result-card .chev { display: grid; place-items: center; font-size: 28px; color: var(--muted); }
.empty { padding: 42px 20px; border: 1px dashed var(--line); border-radius: 22px; color: var(--muted); text-align: center; }

.profile-card { display: grid; margin-top: 22px; padding: 20px; grid-template-columns: 112px 1fr; gap: 18px; align-items: center; }
.profile-card img { width: 112px; height: 112px; border: 1px solid var(--line); border-radius: 50%; object-fit: cover; }
.profile-card h2 { margin: 0; font-size: 24px; }
.profile-card p { margin: 7px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.pill { display: inline-block; margin-top: 12px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; }
.settings-card { overflow: hidden; }
.setting-row { display: flex; width: 100%; min-height: 58px; padding: 0 16px; border: 0; border-bottom: 1px solid rgba(255,255,255,.1); align-items: center; gap: 12px; background: transparent; text-align: left; }
.setting-row:last-child { border-bottom: 0; }
.setting-row span:first-child { width: 26px; color: var(--muted); text-align: center; }
.setting-row b { flex: 1; font-weight: 450; }
.setting-row i { color: var(--muted); font-style: normal; font-size: 22px; }

.bottom-nav {
  position: fixed; z-index: 20; right: max(12px, calc((100vw - 430px) / 2 + 12px)); bottom: var(--safe-bottom); left: max(12px, calc((100vw - 430px) / 2 + 12px));
  display: grid; height: 82px; padding: 8px 8px; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 26px;
  background: rgba(62,68,73,.78); box-shadow: 0 10px 42px rgba(0,0,0,.3); backdrop-filter: blur(24px);
}
.nav-item { display: grid; min-width: 0; padding: 6px 2px; border: 0; border-radius: 18px; place-content: center; gap: 4px; background: transparent; color: rgba(255,255,255,.62); font-size: 10px; }
.nav-item b { font-size: 24px; font-weight: 400; line-height: 1; }
.nav-item.is-active { color: #fff; background: rgba(255,255,255,.07); }
.nav-item--scan { width: 72px; height: 72px; margin: -3px auto 0; border: 1px solid rgba(255,255,255,.65); border-radius: 50%; color: #fff; background: rgba(255,255,255,.08); }

.sheet-backdrop { position: fixed; z-index: 40; inset: 0; background: rgba(3,5,6,.65); backdrop-filter: blur(5px); }
.sheet { position: fixed; z-index: 41; right: max(0px, calc((100vw - 430px) / 2)); bottom: 0; left: max(0px, calc((100vw - 430px) / 2)); max-height: 86dvh; padding: 22px 22px calc(22px + var(--safe-bottom)); overflow-y: auto; border: 1px solid var(--line); border-radius: 28px 28px 0 0; background: linear-gradient(145deg, #2f353a, #1d2226); box-shadow: 0 -18px 80px rgba(0,0,0,.45); }
.sheet-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 24px; }
.sheet-head p { margin: 5px 0 0; color: var(--muted); }
.sheet-actions { display: grid; margin-top: 20px; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-action { min-height: 148px; padding: 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); text-align: center; }
.sheet-action b { display: block; font-size: 36px; font-weight: 400; }
.sheet-action strong { display: block; margin-top: 12px; }
.sheet-action span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.sheet .form { margin-top: 20px; }

.camera-frame { position: relative; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; aspect-ratio: .96; background: #0b0d0f; }
.camera-frame img { width: 100%; height: 100%; object-fit: cover; }
.scan-corners { position: absolute; top: 50%; left: 50%; width: 122px; height: 122px; transform: translate(-50%,-50%); border: 3px solid transparent; border-top-color: #fff; border-bottom-color: #fff; border-radius: 22px; }
.scan-result { display: flex; margin-top: 14px; padding: 16px; align-items: center; gap: 12px; }
.scan-result .grow { flex: 1; }
.scan-result p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.analysis-image { margin: 18px -22px 0; }
.analysis-image img { display: block; width: 100%; max-height: 440px; object-fit: cover; }
.analysis-card { margin-top: 0; padding: 20px; border-radius: 0 0 24px 24px; }
.analysis-list { display: grid; margin-top: 16px; gap: 12px; }
.analysis-row { display: flex; align-items: center; gap: 10px; }
.analysis-row span:first-child { flex: 1; }

.toast { position: fixed; z-index: 100; bottom: calc(112px + var(--safe-bottom)); left: 50%; max-width: min(360px, calc(100vw - 32px)); padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; opacity: 0; transform: translate(-50%, 8px); background: rgba(10,12,14,.9); color: #fff; font-size: 12px; text-align: center; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }

.beta-ribbon { position: fixed; z-index: 30; top: 8px; left: 50%; padding: 4px 8px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; transform: translateX(-50%); background: rgba(9,11,13,.72); color: rgba(255,255,255,.56); font-size: 9px; pointer-events: none; backdrop-filter: blur(10px); }

@media (min-width: 700px) {
  body { padding: 14px 0; }
  .app { min-height: calc(100dvh - 28px); border: 1px solid rgba(255,255,255,.12); border-radius: 30px; }
  .screen { min-height: calc(100dvh - 28px); }
}

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