/* caution.men — Apple-inspired look, dark mode */

:root {
  --bg: #000;
  --surface: rgba(28, 28, 30, 0.72);
  --surface-solid: #1c1c1e;
  --hair: rgba(255, 255, 255, 0.09);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --red: #ff453a;
  --red-deep: #d70015;
  --green: #30d158;
  --blue: #0a84ff;
  --amber: #ffd60a;
  --radius: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; background: var(--bg); }

body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; }

/* ───── ambient background ───── */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient i {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55;
  transition: background 1.2s var(--ease), opacity 1.2s var(--ease);
}
.ambient i:nth-child(1) {
  width: 70vmax; height: 70vmax; left: 50%; top: 42%; translate: -50% -50%;
  background: radial-gradient(circle, rgba(255, 69, 58, 0.22), transparent 62%);
  animation: drift 18s ease-in-out infinite alternate;
}
.ambient i:nth-child(2) {
  width: 50vmax; height: 50vmax; right: -20vmax; top: -20vmax;
  background: radial-gradient(circle, rgba(94, 92, 230, 0.16), transparent 65%);
  animation: drift 22s ease-in-out infinite alternate-reverse;
}
body[data-mode="sent"] .ambient i:nth-child(1) { background: radial-gradient(circle, rgba(255, 69, 58, 0.34), transparent 62%); }
body[data-mode="safe"] .ambient i:nth-child(1) { background: radial-gradient(circle, rgba(48, 209, 88, 0.22), transparent 62%); }
@keyframes drift { to { transform: translate(4vmax, -3vmax) scale(1.08); } }

/* ───── nav ───── */
.nav {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 22px 14px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hair);
}
.brand { font-weight: 600; font-size: 19px; letter-spacing: -0.03em; }
.brand-dot { color: var(--red); }
.nav-btn {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.08); fill: var(--text-2);
  transition: background 0.2s;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* ───── screens ───── */
main {
  position: relative; z-index: 1; flex: 1;
  display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  padding: 24px 22px calc(env(safe-area-inset-bottom) + 28px);
}
.screen {
  grid-area: 1 / 1;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  opacity: 0; visibility: hidden;
  transform: translateY(16px) scale(0.985);
  filter: blur(6px);
  transition: opacity 0.6s var(--ease), transform 0.7s var(--ease), filter 0.6s var(--ease), visibility 0s 0.6s;
}
.screen.is-active {
  opacity: 1; visibility: visible; transform: none; filter: none;
  transition: opacity 0.7s var(--ease) 0.08s, transform 0.8s var(--ease) 0.08s, filter 0.7s var(--ease) 0.08s, visibility 0s;
}

/* ───── typography ───── */
.eyebrow {
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--red); margin-bottom: 10px; text-transform: none;
}
.eyebrow.ok { color: var(--green); }
h1 {
  font-size: clamp(44px, 12vw, 64px); line-height: 1.04; font-weight: 700;
  letter-spacing: -0.045em; margin-bottom: 16px;
}
.h-md { font-size: clamp(34px, 9vw, 44px); line-height: 1.08; letter-spacing: -0.04em; }
.grad {
  background: linear-gradient(100deg, #ff6b5e 0%, #ff375f 45%, #bf5af2 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { color: var(--text-2); font-size: 19px; line-height: 1.42; max-width: 34ch; }
.fine { color: var(--text-3); font-size: 13px; margin-top: 22px; }
.fine.left { text-align: left; margin: 2px 0 6px; }

/* ───── card / form ───── */
.card {
  width: 100%; margin-top: 32px; padding: 22px;
  background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--radius);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  display: flex; flex-direction: column; gap: 14px; text-align: left;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 500; padding-left: 4px; }
.field em { font-style: normal; color: var(--text-3); }
.field input {
  height: 52px; padding: 0 16px; border-radius: 14px;
  background: rgba(118, 118, 128, 0.16); border: 1px solid transparent;
  outline: none; font-size: 17px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: var(--text-3); }
.field input:focus { border-color: rgba(10, 132, 255, 0.9); box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.22); background: rgba(118, 118, 128, 0.22); }
.code-input {
  text-align: center; font-size: 26px !important; font-weight: 600;
  letter-spacing: 0.35em; text-indent: 0.35em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.shake { animation: shake 0.45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.err { color: var(--red); font-size: 14px; min-height: 1.3em; text-align: center; }

/* ───── buttons ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 26px; border-radius: 980px;
  font-size: 17px; font-weight: 600; text-decoration: none; color: var(--text);
  transition: transform 0.2s var(--ease), background 0.2s, opacity 0.2s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--text); color: #000; }
.btn-primary:hover { background: #fff; }
.btn-green { background: var(--green); color: #00210a; }
.btn-ghost { background: rgba(255, 255, 255, 0.08); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.13); }
.btn-link { background: none; color: var(--blue); font-weight: 500; height: 44px; }
.btn-link.danger { color: var(--red); }
.btn.loading > span { opacity: 0; }
.btn.loading { position: relative; }
.btn.loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(0, 0, 0, 0.2); border-top-color: #000; animation: spin 0.8s linear infinite;
}
.stack { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 34px; }

/* ───── SOS button ───── */
.sos-stage {
  --size: min(66vw, 270px);
  position: relative; width: var(--size); height: var(--size);
  margin: 34px 0 18px; display: grid; place-items: center;
}
.wave {
  position: absolute; inset: 8%; border-radius: 50%;
  border: 1.5px solid rgba(255, 69, 58, 0.45);
  animation: wave 3.6s var(--ease) infinite; opacity: 0;
}
.wave:nth-child(2) { animation-delay: 1.2s; }
.wave:nth-child(3) { animation-delay: 2.4s; }
@keyframes wave { 0% { transform: scale(0.9); opacity: 0.7; } 100% { transform: scale(1.55); opacity: 0; } }

.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-track { stroke: rgba(255, 255, 255, 0.06); }
.ring-fill {
  stroke: #fff; stroke-linecap: round;
  stroke-dasharray: 590.6; stroke-dashoffset: 590.6;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

.sos {
  position: relative; width: 84%; height: 84%; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.35), transparent 46%),
    radial-gradient(circle at 50% 50%, #ff5a4f 0%, #ff3b30 45%, #c5000f 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 -14px 30px rgba(0, 0, 0, 0.25) inset,
    0 30px 70px -10px rgba(255, 59, 48, 0.55),
    0 0 120px rgba(255, 59, 48, 0.35);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.sos-label {
  font-size: clamp(46px, 15vw, 64px); font-weight: 800; letter-spacing: -0.02em;
  color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.sos.holding { transform: scale(0.94); box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset, 0 -14px 30px rgba(0,0,0,.25) inset, 0 20px 50px -10px rgba(255,59,48,.7), 0 0 180px rgba(255,59,48,.6); }
.sos:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.8); outline-offset: 8px; }

.hint { color: var(--text-2); font-size: 15px; min-height: 1.4em; transition: color 0.2s; }
.hint.go { color: var(--text); }

.chips { display: flex; gap: 8px; margin-top: 26px; flex-wrap: wrap; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 980px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--hair);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  max-width: 100%; transition: background 0.2s;
}
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.chip:hover { background: rgba(255, 255, 255, 0.12); }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.led.ok { background: var(--green); box-shadow: 0 0 10px var(--green); }
.led.wait { background: var(--amber); animation: blink 1.2s infinite; }
.led.bad { background: var(--red); }
@keyframes blink { 50% { opacity: 0.3; } }

/* ───── sent ───── */
.orb {
  width: 108px; height: 108px; border-radius: 50%; margin-bottom: 26px;
  display: grid; place-items: center; color: #fff; position: relative;
  background: radial-gradient(circle at 50% 30%, #ff6b60, #d70015);
  box-shadow: 0 0 80px rgba(255, 59, 48, 0.55);
}
.orb::before, .orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(255, 69, 58, 0.5); animation: wave 2.4s var(--ease) infinite;
}
.orb::after { animation-delay: 1.2s; }
.orb svg { width: 46px; height: 46px; opacity: 0; transform: scale(0.6); transition: 0.5s var(--ease); }
.orb.done svg { opacity: 1; transform: none; }
.orb.safe { background: radial-gradient(circle at 50% 30%, #5be584, #1f9e44); box-shadow: 0 0 80px rgba(48, 209, 88, 0.45); }
.orb.safe::before, .orb.safe::after { border-color: rgba(48, 209, 88, 0.45); }

.live {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 22px;
  padding: 10px 16px; border-radius: 980px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--hair);
  font-size: 14px; color: var(--text-2);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1.4s infinite; }
.live-time { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ───── sheet ───── */
.sheet {
  margin: auto auto 0; width: 100%; max-width: 480px; border: 0; padding: 0;
  background: transparent; color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet[open] .sheet-body { animation: sheet-in 0.5s var(--ease); }
.sheet-body {
  display: flex; flex-direction: column; gap: 14px;
  padding: 10px 22px calc(env(safe-area-inset-bottom) + 22px);
  background: var(--surface-solid); border: 1px solid var(--hair); border-bottom: 0;
  border-radius: 28px 28px 0 0;
}
.sheet h2 { font-size: 24px; letter-spacing: -0.03em; margin: 6px 0 4px; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); margin: 0 auto; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@media (min-width: 600px) {
  .sheet { margin: auto; }
  .sheet-body { border-radius: 28px; border-bottom: 1px solid var(--hair); }
  .grabber { display: none; }
}

/* ───── toast / spinner ───── */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); z-index: 20;
  translate: -50% 20px; opacity: 0; pointer-events: none;
  padding: 12px 20px; border-radius: 980px; font-size: 15px; font-weight: 500;
  background: rgba(44, 44, 46, 0.9); border: 1px solid var(--hair);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  transition: 0.45s var(--ease); white-space: nowrap;
}
.toast.show { translate: -50% 0; opacity: 1; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--text); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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