:root {
  color-scheme: light;
  --paper: #f5efe8;
  --paper-deep: #e9e0d4;
  --ink: #20302d;
  --ink-soft: #65736f;
  --coral: #d95d56;
  --coral-deep: #b94340;
  --mint: #dcebe5;
  --mint-strong: #3f7b6d;
  --gold: #d4a653;
  --electric: #7ae7ff;
  --electric-deep: #167d9b;
  --white: #fffdf9;
  --line: rgba(32, 48, 45, 0.13);
  --shadow: 0 20px 60px rgba(76, 55, 39, 0.12);
  --font: "Avenir Next", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(217, 93, 86, 0.28);
  outline-offset: 3px;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(32, 48, 45, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 48, 45, 0.028) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 74%);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--coral-deep);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-shell {
  width: min(100%, 430px);
  animation: rise-in 500ms ease both;
}

.brand-lockup,
.brand-button {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup {
  margin-bottom: 30px;
}

.brand-lockup h1,
.pair-copy h1,
.presence-row h1,
.settings-header h2 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--coral);
  box-shadow: 0 13px 27px rgba(185, 67, 64, 0.22);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.8;
}

.brand-mark-small {
  width: 34px;
  height: 34px;
  box-shadow: none;
}

.brand-mark-small svg {
  width: 16px;
  height: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 26px;
  background: var(--paper-deep);
  border-radius: 8px;
}

.segment {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  cursor: pointer;
}

.segment.is-active {
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 5px 16px rgba(76, 55, 39, 0.1);
}

.auth-form,
.settings-form,
.pair-form {
  display: grid;
  gap: 17px;
}

.auth-form label,
.settings-form label,
.pair-form label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.78);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
  border-color: rgba(217, 93, 86, 0.58);
  box-shadow: 0 0 0 4px rgba(217, 93, 86, 0.09);
  outline: 0;
}

.primary-button,
.quiet-button,
.danger-button {
  min-height: 46px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  border: 1px solid var(--coral);
  color: var(--white);
  background: var(--coral);
  box-shadow: 0 10px 24px rgba(185, 67, 64, 0.18);
}

.primary-button:hover {
  background: var(--coral-deep);
  border-color: var(--coral-deep);
}

.primary-button:disabled,
.quiet-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.primary-button svg,
.quiet-button svg,
.danger-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button.compact {
  min-height: 50px;
  white-space: nowrap;
}

.quiet-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--white);
}

.quiet-button:hover {
  border-color: rgba(63, 123, 109, 0.4);
  background: var(--mint);
}

.danger-button {
  width: 100%;
  margin-top: 24px;
  border: 1px solid rgba(185, 67, 64, 0.2);
  color: var(--coral-deep);
  background: rgba(217, 93, 86, 0.07);
}

.form-message {
  min-height: 18px;
  margin: -5px 0 0;
  color: var(--coral-deep);
  font-size: 0.82rem;
  line-height: 1.45;
}

.form-message.is-success {
  color: var(--mint-strong);
}

.app-view {
  width: min(100%, 980px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}

.brand-button {
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.76);
  cursor: pointer;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pair-layout {
  width: min(100%, 700px);
  margin: auto;
  display: grid;
  gap: 26px;
  padding: 40px 0;
  animation: rise-in 500ms ease both;
}

.pair-copy {
  max-width: 560px;
}

.pair-copy h1 {
  font-size: clamp(2.2rem, 8vw, 4.2rem);
}

.pair-copy > p:last-child {
  max-width: 440px;
  margin: 17px 0 0;
  color: var(--ink-soft);
  line-height: 1.75;
}

.invite-ticket {
  padding: 24px;
  border-block: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 20px;
  align-items: center;
}

.invite-ticket > span {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.invite-ticket strong {
  grid-row: 2;
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}

.invite-ticket .quiet-button {
  grid-row: 1 / 3;
  grid-column: 2;
}

.pair-form {
  width: min(100%, 580px);
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.inline-field input {
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.dashboard {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: clamp(30px, 7vh, 70px) 0 34px;
  animation: rise-in 520ms ease both;
}

.presence-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.presence-row h1 {
  font-size: clamp(2.4rem, 8vw, 4.7rem);
}

.presence-pill {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 253, 249, 0.6);
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
}

.presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a4aaa5;
}

.presence-pill.is-online .presence-dot {
  background: #4f9a7e;
  box-shadow: 0 0 0 5px rgba(79, 154, 126, 0.12);
}

.button-stage {
  position: relative;
  height: clamp(300px, 48vh, 430px);
  display: grid;
  place-items: center;
}

.orbit {
  position: absolute;
  border: 1px solid rgba(217, 93, 86, 0.15);
  border-radius: 50%;
  pointer-events: none;
}

.orbit-one {
  width: min(70vw, 330px);
  height: min(70vw, 330px);
}

.orbit-two {
  width: min(84vw, 398px);
  height: min(84vw, 398px);
  border-color: rgba(63, 123, 109, 0.1);
}

.miss-button {
  position: relative;
  z-index: 1;
  width: clamp(210px, 31vw, 280px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--white);
  background: var(--coral);
  box-shadow:
    0 24px 55px rgba(185, 67, 64, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.miss-button:hover {
  transform: translateY(-3px);
  background: var(--coral-deep);
  box-shadow:
    0 30px 64px rgba(185, 67, 64, 0.29),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.miss-button:active {
  transform: scale(0.975);
}

.miss-button:disabled {
  cursor: wait;
  background: #c58f8a;
}

.miss-button-inner {
  display: grid;
  justify-items: center;
  gap: 9px;
}

.heart-icon {
  width: clamp(46px, 8vw, 68px);
  height: clamp(46px, 8vw, 68px);
  fill: rgba(255, 255, 255, 0.16);
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.miss-button strong {
  font-size: clamp(1.5rem, 5vw, 2rem);
  letter-spacing: 0;
}

.miss-button small {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.77rem;
}

.miss-button.is-pulsing {
  animation: heartbeat 720ms ease;
}

.miss-button.is-pulsing .heart-icon {
  animation: heart-glow 720ms ease;
}

.last-thought {
  min-height: 24px;
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.history-section {
  margin-top: 52px;
  padding-top: 25px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h2,
.setting-copy h3,
.settings-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 1rem;
}

.quiet-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--mint-strong);
  font-size: 0.74rem;
  font-weight: 700;
}

.quiet-badge svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.history-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.history-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--coral-deep);
  background: rgba(217, 93, 86, 0.1);
}

.history-item.received .history-mark {
  color: var(--mint-strong);
  background: var(--mint);
}

.history-mark svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
}

.history-copy strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

.history-copy span,
.history-time,
.empty-history {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.history-time {
  white-space: nowrap;
}

.empty-history {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.app-footer {
  width: min(100%, 720px);
  margin: auto auto 0;
  padding-top: 34px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 20px;
  display: grid;
  place-items: end center;
  background: rgba(25, 35, 33, 0.34);
  backdrop-filter: blur(7px);
}

.settings-panel {
  width: min(100%, 520px);
  max-height: min(88dvh, 760px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 8px 8px 0 0;
  background: var(--white);
  box-shadow: var(--shadow);
  animation: panel-in 260ms ease both;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 27px;
}

.settings-header h2 {
  font-size: 1.9rem;
}

.settings-section {
  padding: 18px 0;
  border-block: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 18px;
  align-items: center;
}

.setting-copy h3 {
  font-size: 0.95rem;
}

.setting-copy p,
.setting-note {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.55;
}

.ios-install-hint,
.setting-note {
  grid-column: 1 / -1;
}

.settings-form {
  padding-top: 22px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch > span:not(.sr-only) {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c7cec9;
  transition: background 180ms ease;
}

.switch > span:not(.sr-only)::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 3px 8px rgba(32, 48, 45, 0.2);
  transition: transform 180ms ease;
}

.switch input:checked + span {
  background: var(--mint-strong);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 24px 1fr;
  gap: 10px;
  align-items: end;
}

.time-separator {
  min-height: 50px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
}

.time-separator::before {
  content: "";
  width: 12px;
  height: 1px;
  background: var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 40px);
  padding: 12px 16px;
  border-radius: 7px;
  color: var(--white);
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.zap-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
}

.zap-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(210, 250, 255, 0.86);
  animation: zap-flash 760ms steps(2, end) both;
}

.zap-bolt {
  position: relative;
  z-index: 2;
  width: min(34vw, 180px);
  height: min(34vw, 180px);
  fill: var(--white);
  stroke: var(--electric);
  stroke-width: 1.2;
  filter:
    drop-shadow(0 0 12px var(--white))
    drop-shadow(0 0 32px var(--electric))
    drop-shadow(0 0 70px var(--electric-deep));
  animation: zap-bolt 760ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.zap-arc {
  position: absolute;
  width: min(82vw, 760px);
  height: 16px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--white) 14%,
    var(--electric) 34%,
    var(--white) 50%,
    var(--electric) 66%,
    var(--white) 84%,
    transparent 100%
  );
  clip-path: polygon(
    0 52%,
    16% 26%,
    30% 68%,
    43% 20%,
    57% 72%,
    70% 30%,
    84% 65%,
    100% 48%,
    100% 62%,
    84% 80%,
    70% 48%,
    57% 88%,
    43% 38%,
    30% 86%,
    16% 44%,
    0 70%
  );
  filter: drop-shadow(0 0 9px var(--electric));
  animation: zap-arc 640ms ease-out both;
}

.zap-arc-one { transform: rotate(12deg); }
.zap-arc-two { transform: rotate(102deg); animation-delay: 40ms; }
.zap-arc-three { transform: rotate(193deg); animation-delay: 20ms; }
.zap-arc-four { transform: rotate(284deg); animation-delay: 60ms; }

body.is-zapped .app-view {
  animation: screen-jolt 600ms steps(2, end);
}

body.is-zapped .miss-button {
  background: var(--electric-deep);
  box-shadow:
    0 0 0 12px rgba(122, 231, 255, 0.18),
    0 0 70px rgba(122, 231, 255, 0.85);
  animation: electrified 680ms steps(2, end);
}

.floating-heart {
  position: fixed;
  z-index: 15;
  color: var(--coral);
  pointer-events: none;
  animation: float-away 1000ms ease-out forwards;
}

.floating-heart svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

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

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

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  18% { transform: scale(0.96); }
  34% { transform: scale(1.045); }
  50% { transform: scale(0.985); }
  68% { transform: scale(1.02); }
}

@keyframes heart-glow {
  0%, 100% { transform: scale(1); fill: rgba(255, 255, 255, 0.16); }
  48% { transform: scale(1.13); fill: rgba(255, 255, 255, 0.72); }
}

@keyframes float-away {
  from {
    opacity: 0.9;
    transform: translate(-50%, 0) scale(0.7);
  }
  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--drift)), -110px) scale(1.2) rotate(var(--rotate));
  }
}

@keyframes zap-flash {
  0%, 100% { opacity: 0; }
  8%, 18%, 34% { opacity: 1; }
  12%, 25%, 48% { opacity: 0.08; }
  62% { opacity: 0.24; }
}

@keyframes zap-bolt {
  0% { opacity: 0; transform: scale(0.45) rotate(-8deg); }
  15% { opacity: 1; transform: scale(1.08) rotate(3deg); }
  28% { opacity: 0.25; transform: scale(0.94) rotate(-2deg); }
  44% { opacity: 1; transform: scale(1.03) rotate(1deg); }
  72% { opacity: 0.75; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.25); }
}

@keyframes zap-arc {
  0% { opacity: 0; scale: 0.55; }
  20%, 55% { opacity: 0.95; scale: 1; }
  100% { opacity: 0; scale: 1.08; }
}

@keyframes screen-jolt {
  0%, 100% { transform: translate(0, 0); }
  12% { transform: translate(-9px, 3px); }
  20% { transform: translate(8px, -5px); }
  30% { transform: translate(-6px, -2px); }
  41% { transform: translate(5px, 4px); }
  55% { transform: translate(-3px, 1px); }
  72% { transform: translate(2px, -1px); }
}

@keyframes electrified {
  0%, 100% { transform: scale(1); }
  18% { transform: scale(0.93) rotate(-2deg); }
  32% { transform: scale(1.05) rotate(2deg); }
  48% { transform: scale(0.98) rotate(-1deg); }
  64% { transform: scale(1.02); }
}

@media (max-width: 620px) {
  .app-view {
    padding-inline: 18px;
  }

  .presence-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .presence-row h1 {
    font-size: clamp(2.6rem, 14vw, 4rem);
  }

  .button-stage {
    height: clamp(330px, 52vh, 430px);
  }

  .miss-button {
    width: min(66vw, 260px);
  }

  .orbit-one {
    width: min(78vw, 310px);
    height: min(78vw, 310px);
  }

  .orbit-two {
    width: min(92vw, 370px);
    height: min(92vw, 370px);
  }

  .history-section {
    margin-top: 35px;
  }

  .history-item {
    grid-template-columns: 32px 1fr auto;
  }

  .app-footer {
    padding-top: 24px;
  }

  .modal-backdrop {
    padding: 0;
  }

  .settings-panel {
    max-height: 92dvh;
    border-radius: 8px 8px 0 0;
    padding: 22px 18px max(22px, env(safe-area-inset-bottom));
  }

  .invite-ticket {
    padding-inline: 0;
  }
}

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

