:root {
  --bg: #0E0D0C;
  --bg-radial: radial-gradient(circle at 50% 12%, rgba(232, 184, 125, 0.14), transparent 55%);
  --surface: #181614;
  --surface-2: #221E1B;
  --surface-glass: rgba(24, 22, 20, 0.86);
  --border: rgba(232, 184, 125, 0.16);
  --border-strong: rgba(232, 184, 125, 0.36);
  --text: #F6F1EA;
  --text-muted: #B6ABA0;
  --accent: #E8B87D;
  --accent-2: #D48A78;
  --accent-ink: #19130D;
  --good: #9EC7A8;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --radius: 22px;
}

body.theme-ivory {
  --bg: #FBF7F1;
  --bg-radial: radial-gradient(circle at 50% 10%, rgba(212, 138, 120, 0.16), transparent 55%);
  --surface: #FFFFFF;
  --surface-2: #F4EDE3;
  --surface-glass: rgba(255, 255, 255, 0.90);
  --border: rgba(154, 102, 62, 0.16);
  --border-strong: rgba(154, 102, 62, 0.38);
  --text: #1E1915;
  --text-muted: #6E6257;
  --accent: #B76E3C;
  --accent-2: #C96F5B;
  --accent-ink: #FFFDF9;
  --good: #3F7D55;
  --shadow: 0 14px 36px rgba(84, 56, 32, 0.10);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image: var(--bg-radial);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guest-shell {
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  font-size: 16px;
  box-shadow: 0 0 24px rgba(232, 184, 125, 0.35);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.plan-badge {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-soft {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 24px; line-height: 1.22; }
h2 { font-size: 19px; line-height: 1.28; }
h3 { font-size: 16px; line-height: 1.32; }

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* Orbit Map */
.orbit-stage {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  margin: 6px auto 4px;
  display: grid;
  place-items: center;
}

.orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed var(--border);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
  cursor: pointer;
}

.orbit-ring-3 { width: 96%; height: 96%; }
.orbit-ring-2 { width: 68%; height: 68%; }
.orbit-ring-1 { width: 42%; height: 42%; }

.orbit-ring.active {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(232, 184, 125, 0.06);
  box-shadow: 0 0 28px rgba(232, 184, 125, 0.12) inset;
}

.orbit-center {
  position: relative;
  z-index: 4;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 0 32px rgba(232, 184, 125, 0.42);
  pointer-events: none;
}

.orbit-center span:first-child {
  font-size: 20px;
  line-height: 1;
}

.friend-node {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 2px;
}

.friend-node-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.friend-node.in-target .friend-node-avatar {
  border-color: var(--accent);
  transform: scale(1.08);
  box-shadow: 0 0 18px rgba(232, 184, 125, 0.45);
}

.friend-node-name {
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-glass);
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.orbit-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.pill-btn {
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.pill-btn.active {
  border-color: var(--accent);
  background: rgba(232, 184, 125, 0.14);
  color: var(--text);
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mood-btn {
  min-height: 62px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mood-btn.active {
  border-color: var(--accent);
  background: linear-gradient(160deg, rgba(232, 184, 125, 0.22), rgba(212, 138, 120, 0.16));
}

.input, .textarea, .select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
}

.textarea {
  resize: vertical;
  min-height: 76px;
}

.sos-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.sos-btn {
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 12px 34px rgba(232, 184, 125, 0.30);
  animation: gentlePulse 3.2s infinite ease-in-out;
}

.sos-btn:active {
  transform: scale(0.985);
}

@keyframes gentlePulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(232, 184, 125, 0.28); }
  50% { box-shadow: 0 14px 42px rgba(232, 184, 125, 0.48); }
}

.btn {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
}

.btn-ghost {
  border-color: var(--border);
  background: transparent;
}

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 11px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.grow {
  flex: 1;
}

/* Replies & Capsule */
.reply-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reply-author {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.avatar-chip {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.kind-tag {
  font-size: 12px;
  color: var(--accent);
  background: rgba(232, 184, 125, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.video-circle-wrap {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent);
  margin: 4px auto;
  background: #000;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.video-circle-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--border);
}

audio {
  width: 100%;
  height: 44px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  z-index: 30;
}

.nav-btn {
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}

.nav-btn.active {
  background: rgba(232, 184, 125, 0.14);
  color: var(--accent);
}

/* Modal / Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-sheet {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.toast {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow);
}

.rec-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e25555;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
