:root {
  --bg: #e8eef4;
  --bg2: #f7fafc;
  --ink: #243447;
  --muted: #5d7388;
  --line: #c5d2de;
  --accent: #4a6d8c;
  --accent-soft: #d7e4ef;
  --danger: #8a4b4b;
  --ok: #3d6b55;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(36, 52, 71, 0.08);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #f4f8fb 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #dfe9f2 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
}

body {
  min-height: 100dvh;
}

button, input, select {
  font: inherit;
}

.hidden { display: none !important; }

.app-shell {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.toast-stack {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e3144;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* В потоке страницы (сверху) — кликабельна на iPhone 12/16, не под Safari UI */
.notify-perm-banner {
  position: relative;
  z-index: 5;
  width: 100%;
  background: #fff3cd;
  border: 1px solid #e6d59a;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  pointer-events: auto;
  -webkit-tap-highlight-color: rgba(0,0,0,0.08);
}

.notify-perm-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
  color: #5a4a00;
}

.notify-perm-text strong {
  font-size: 0.9rem;
}

.notify-perm-banner .primary {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 96px;
  padding: 10px 14px;
  font-size: 0.9rem;
  touch-action: manipulation;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 40, 0.35);
  z-index: 80;
  -webkit-tap-highlight-color: transparent;
}

/* Меню сверху вниз — одинаково на 12 Pro Max и 16 */
.menu-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  bottom: auto;
  width: min(440px, 100%);
  max-height: min(92dvh, 100%);
  height: auto;
  background: var(--bg2);
  z-index: 81;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0 0 16px 16px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.menu-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
}

.menu-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

/* Love is… — черновик рамки карточки (пока без иллюстраций) */
.offer.love-card {
  background: linear-gradient(180deg, #fffdf9 0%, #fff 40%);
  border: 2px solid #e8d4c4;
  border-radius: 16px;
  position: relative;
  padding-top: 14px;
}

.offer.love-card::before {
  content: "";
  display: block;
  height: 72px;
  margin: 0 0 10px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 40%, #f5e6dc 0%, transparent 55%),
    radial-gradient(circle at 70% 60%, #e8d4c4 0%, transparent 50%),
    linear-gradient(135deg, #faf3ee, #f0e0d4);
  opacity: 0.85;
}

.offer.love-card h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  color: #4a3a32;
}

.offer.love-card .humor {
  font-family: Georgia, "Times New Roman", serif;
  color: #7a5a48;
  border-top: 1px dashed #e8d4c4;
  padding-top: 8px;
  margin-top: 8px;
}

.chat-media img,
.chat-media video {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 4px;
}

.chat-media audio {
  width: 100%;
  margin-top: 4px;
}

.chat-compose {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.chat-compose input[type="text"] {
  min-width: 0;
  flex: 1 1 auto;
}

.chat-compose .icon-btn {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
}

.chat-compose .icon-btn.recording {
  background: #b44;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand img {
  width: 40px;
  height: 40px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.card .hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

input, select {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.roles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 4px;
}

.role-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 8px;
  cursor: pointer;
  color: var(--ink);
}

.role-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

button.primary, button.ghost, button.danger {
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #fff;
  flex: 1;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

button.danger {
  background: #f3e6e6;
  color: var(--danger);
}

.error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 4px 0 8px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

.topbar .brand {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar .brand h1 {
  font-size: 1.2rem;
  line-height: 1.2;
}

.topbar .brand p {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding-top: 2px;
}

.topbar .icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.15rem;
  touch-action: manipulation;
}

.home-grid {
  display: grid;
  gap: 12px;
  padding-bottom: 8px;
}

.meter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meter input[type="range"] {
  flex: 1;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.weather {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.weather .box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.weather .big {
  font-size: 1.8rem;
  font-weight: 650;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--ink);
}

.mood-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.mood-inline .mood-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.mood-inline .mood-row {
  grid-template-columns: repeat(3, 40px);
  margin: 0;
  flex: 0;
}

.mood-inline .mood-btn {
  padding: 8px;
}

.mood-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.partner-wait {
  text-align: center;
  padding: 18px 8px 8px;
}

.partner-wait .big {
  font-size: 1.2rem;
  font-weight: 650;
  margin: 0 0 8px;
}

.waiting-play {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  text-align: left;
}

.waiting-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.waiting-block.dimmed {
  opacity: 0.55;
}

.waiting-block h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.waiting-block textarea,
.waiting-block input[type="text"] {
  width: 100%;
  margin: 8px 0;
  resize: vertical;
}

.btn-row.wrap {
  flex-wrap: wrap;
}

.btn-row .ghost.active,
.mood-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}


.test-banner {
  background: #fff3cd;
  color: #6a5500;
  border: 1px solid #e6d59a;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  text-align: center;
}

.chat-log {
  max-height: min(55dvh, 420px);
  min-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-media img {
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  margin-top: 4px;
  background: #eee;
}


.chat-bubble {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.35;
  background: #fff;
  border: 1px solid var(--line);
}

.chat-bubble.mine {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: transparent;
}

.chat-bubble .who {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.chat-compose .ghost:not(.hidden) {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  min-width: 40px;
}

.chat-translate-preview {
  background: #fff8f0;
  border: 1px solid #e8d4c4;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.chat-translate-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.chat-translate-src {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.chat-translate-preview textarea {
  width: 100%;
  margin: 6px 0 10px;
  resize: vertical;
}


.chat-compose input {
  flex: 1;
}

.chat-compose .primary {
  flex: 0;
  min-width: 48px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.check-row input {
  width: auto;
}

.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(232, 238, 244, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 70;
}

.fine-print {
  margin-top: 14px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.mood-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.mood-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 6px;
  cursor: pointer;
}

.offers-box {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.offer {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.offer.glow {
  border-color: #c9a86a;
  box-shadow: 0 0 0 3px rgba(201, 168, 106, 0.22);
  background: #fffdf7;
}

.offer h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.offer .meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.offer .body {
  font-size: 0.92rem;
  line-height: 1.4;
  margin: 0 0 10px;
}

.offer .humor {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin: -4px 0 10px;
}

.anchor-banner {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 6px;
}

.badge.gold {
  background: #f3e6c8;
  color: #7a5b20;
}

hr.soft {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.door-grid {
  display: grid;
  gap: 12px;
}

.door {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  display: grid;
  gap: 4px;
  box-shadow: var(--shadow);
}

.door strong {
  font-size: 1.15rem;
}

.door-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.door-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.door-he {
  background: linear-gradient(145deg, #e8f0f7, #f7fafc);
  border-color: #9bb4c9;
}

.door-she {
  background: linear-gradient(145deg, #f7ebe8, #fcf8f7);
  border-color: #c9a99b;
}

.door-admin {
  padding: 12px;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* His space — cool slate */
body.theme-he {
  --bg: #dbe6f0;
  --bg2: #f4f8fb;
  --ink: #1e3144;
  --muted: #5a7085;
  --line: #b7c9d8;
  --accent: #3d5f7a;
  --accent-soft: #d2e0ec;
  --danger: #8a4b4b;
}

body.theme-he .brand h1::after {
  content: " · North";
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85em;
}

/* Her space — warm clay (not pink-glitter) */
body.theme-she {
  --bg: #f0e4dc;
  --bg2: #fcf8f5;
  --ink: #3a2a24;
  --muted: #7a655c;
  --line: #d5c0b4;
  --accent: #8a5a48;
  --accent-soft: #eedfd6;
  --danger: #8a4b4b;
  background:
    radial-gradient(1200px 600px at 10% -10%, #faf3ee 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e8d5ca 0%, transparent 50%),
    var(--bg);
}

body.theme-she .brand h1::after {
  content: " · South";
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85em;
}

body.theme-admin {
  --accent: #4a6d8c;
}

details {
  margin-top: 12px;
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
