:root {
  --color-ink:       #1a2e2c;
  --color-ink-soft:  #4a6360;
  --color-ink-muted: #8a9e9a;
  --color-teal:      #3d7d75;
  --color-teal-light:#e6f2f0;
  --color-teal-mid:  #7ec8bd;
  --color-surface:   #ffffff;
  --color-bg:        #f2f4f3;
  --color-border:    rgba(26, 46, 44, 0.09);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  color: var(--color-ink);
  background: var(--color-bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

html,
body,
#root {
  min-height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
  background: var(--color-bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

h1,
h2,
p {
  margin: 0;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #20312f;
  color: #fffaf4;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #e6f1ef;
  color: #315f5a;
  font-size: 2rem;
  font-weight: 900;
}

.splash-screen h1 {
  color: #fffaf4;
  font-size: 2rem;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.phone-frame {
  width: min(100%, 430px);
  min-height: min(900px, calc(100dvh - 36px));
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(32, 49, 47, 0.12);
  border-radius: 22px;
  background: #fbfaf7;
  box-shadow: 0 24px 80px rgba(36, 53, 58, 0.16);
}

.app-header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-ink);
  letter-spacing: -0.2px;
}

.app-header--world {
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.world-back-btn {
  border: 0;
  background: transparent;
  color: var(--color-teal);
  font-size: 0.88rem;
  font-weight: 760;
  padding: 0;
  cursor: pointer;
  letter-spacing: -0.1px;
}

.brand-button,
.header-actions button,
.text-button,
.back-button {
  border: 0;
  background: transparent;
  color: var(--color-teal);
  font-weight: 760;
  font-size: 0.88rem;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  color: var(--color-ink);
  font-size: 1rem;
  font-weight: 860;
  letter-spacing: -0.2px;
}

.brand-button span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--color-ink);
  color: #fffaf4;
  font-size: 0.82rem;
  font-weight: 900;
}

.signout-btn {
  border: 0;
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 0.8rem;
  font-weight: 680;
}

.danger-button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-weight: 800;
  font-size: 0.92rem;
  background: #fff0f0;
  color: #c0392b;
  transition: opacity 0.15s;
}

.danger-button:active {
  opacity: 0.7;
}

/* ── Unread Badges ───────────────────────────────────── */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 5px;
  flex-shrink: 0;
}

.unread-chat {
  background: var(--color-teal, #3d7d75);
  color: #fff;
}

.unread-other {
  background: #e89b4a;
  color: #fff;
}

.world-row-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 4px;
}

/* Me screen danger zone */
.me-danger-zone {
  margin-top: 8px;
}
.me-danger-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-muted);
  margin-bottom: 10px;
}
.me-delete-btn {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-weight: 700;
  font-size: 0.92rem;
  background: transparent;
  color: #dc2626;
  transition: background 0.15s;
}
.me-delete-btn:active {
  background: #fff0f0;
}
.me-danger-hint {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
  margin-top: 8px;
}

/* Confirm dialog actions row */
.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}
.confirm-actions .danger-button {
  width: auto;
  min-width: 120px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-actions span {
  max-width: 100px;
  overflow: hidden;
  color: #5f706c;
  font-size: 0.86rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px 96px;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.centered {
  align-content: center;
  text-align: center;
}

/* ── Auth Screen ─────────────────────────────────────── */
.auth-screen {
  background: var(--color-surface);
  min-height: 100dvh;
  padding: 56px 24px 40px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}

.auth-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--color-ink);
  color: #fffaf4;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.auth-wordmark {
  font-size: 1.25rem;
  font-weight: 860;
  color: var(--color-ink);
  letter-spacing: -0.3px;
}

.auth-hero {
  margin-bottom: 32px;
}

.auth-hero h1 {
  font-size: 2rem;
  font-weight: 860;
  line-height: 1.1;
  color: var(--color-ink);
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.auth-hero p {
  color: var(--color-ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-legal {
  text-align: center;
  color: var(--color-ink-muted);
  font-size: 0.72rem;
  line-height: 1.6;
  margin-top: 8px;
}

.auth-legal-link {
  color: var(--color-teal);
  text-decoration: none;
  font-weight: 600;
}

/* ── Generic Blocks ──────────────────────────────────── */
.hero-block {
  display: grid;
  gap: 10px;
  padding: 10px 0 4px;
}

.hero-block h1,
.home-heading h1,
.world-hero h1,
.screen > h1 {
  color: var(--color-ink);
  font-size: 1.8rem;
  line-height: 1.05;
  letter-spacing: -0.3px;
}

.hero-block p,
.world-hero p,
.quiet-panel p,
.path-panel p,
.first-panel p {
  color: var(--color-ink-soft);
  line-height: 1.45;
}

.eyebrow {
  color: var(--color-teal);
  font-size: 0.72rem;
  font-weight: 860;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.notice,
.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1.4;
}

.notice {
  background: var(--color-teal-light);
  color: #2a5550;
}

.error {
  background: #fdecea;
  color: #8b2a24;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border-radius: 10px;
  background: #eff1f0;
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-ink-soft);
  font-weight: 760;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

.segmented .active {
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 820;
  box-shadow: 0 2px 8px rgba(26, 46, 44, 0.1);
}

.stack-form,
.inline-form {
  display: grid;
  gap: 12px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  color: #405653;
  font-size: 0.86rem;
  font-weight: 780;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 7px;
}

legend small {
  font-weight: 400;
  opacity: 0.6;
  margin-left: 4px;
}

input,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  padding: 11px 14px;
  outline: none;
  resize: vertical;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(61, 125, 117, 0.12);
}

.primary-button,
.secondary-button,
.icon-button,
.panel button:not(.text-button):not(.suggest-chip):not(.world-card):not(.world-delete-btn):not(.icon-pill),
.composer button,
.photo-form button,
.inline-form button {
  min-height: 46px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-weight: 800;
  font-size: 0.92rem;
  transition: opacity 0.15s;
}

.primary-button,
.panel button:not(.text-button):not(.suggest-chip):not(.world-card):not(.world-delete-btn):not(.icon-pill),
.composer button,
.inline-form button {
  background: var(--color-ink);
  color: #fffaf4;
}

.primary-button:active,
.composer button:active {
  opacity: 0.8;
}

.photo-form button {
  background: #eff1f0;
  color: var(--color-ink);
}

.secondary-button {
  background: #eff1f0;
  color: var(--color-ink);
}

.leave-btn {
  margin-top: 8px;
  width: 100%;
}

.icon-button {
  width: 46px;
  padding: 0;
  background: var(--color-ink);
  color: #fffaf4;
  font-size: 1.3rem;
  border-radius: var(--radius-sm);
}

.home-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 0;
  margin-bottom: -4px;
}

.search-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Search bar ─────────────────────────────────────────── */
.search-bar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  padding: 0 10px;
  gap: 6px;
  transition: border-color 0.15s;
}

.search-bar-wrap:focus-within {
  border-color: var(--color-teal);
}

.search-icon {
  color: var(--color-ink-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
  pointer-events: none;
  line-height: 1;
}

.search-bar {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 0.92rem;
  color: var(--color-ink);
  outline: none;
  -webkit-appearance: none;
}

.search-bar::placeholder {
  color: var(--color-ink-muted);
  opacity: 0.6;
}

.search-bar::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  border: none;
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.6;
}

.search-empty {
  color: var(--color-ink-muted);
  font-size: 0.88rem;
  padding: 12px 0 4px;
  margin: 0;
}
/* ─────────────────────────────────────────────────────── */

/* "+" quick menu in Chats */
.plus-btn {
  position: relative;
  z-index: 12;
}

.plus-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.plus-menu {
  position: fixed;
  top: 100px;
  right: calc(50% - min(215px, 50vw) + 12px);
  z-index: 11;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
  min-width: 180px;
}

.plus-menu button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-size: 0.92rem;
  font-weight: 640;
  color: var(--color-ink);
  text-align: left;
  transition: background 0.1s;
}

.plus-menu button:last-child {
  border-bottom: 0;
}

.plus-menu button:active {
  background: var(--color-teal-light);
}

.plus-menu button span {
  font-size: 1.1rem;
}

/* Bottom sheet */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 500;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, 100vw);
  background: var(--color-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 16px 20px calc(32px + env(safe-area-inset-bottom));
  z-index: 501;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 8px;
}

.bottom-sheet h2 {
  font-size: 1.1rem;
  margin: 0;
}

.bottom-sheet p {
  font-size: 0.88rem;
  color: var(--color-ink-muted);
  margin: 0;
  line-height: 1.5;
}

.onboarding-card {
  display: grid;
  gap: 20px;
  padding: 28px 20px;
  border: 1px solid rgba(61, 125, 117, 0.15);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, #eef7f5 0%, var(--color-surface) 100%);
  text-align: center;
}

.onboarding-brand {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--color-teal);
  text-transform: uppercase;
}

.onboarding-card h2 {
  font-size: 1.15rem;
  font-weight: 820;
  color: var(--color-ink);
  margin: 0;
  letter-spacing: -0.2px;
}

.onboarding-desc {
  color: var(--color-ink-soft);
  font-size: 0.86rem;
  line-height: 1.6;
  margin: 0;
}

.onboarding-steps {
  display: grid;
  gap: 10px;
  text-align: left;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.7);
  border-radius: 12px;
  border: 1px solid rgba(61,125,117,0.1);
}

.onboarding-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-teal);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.onboarding-step-body {
  display: grid;
  gap: 2px;
}

.onboarding-step-body strong {
  font-size: 0.9rem;
  font-weight: 760;
  color: var(--color-ink);
}

.onboarding-step-body span {
  font-size: 0.8rem;
  color: var(--color-ink-soft);
  line-height: 1.45;
}

.onboarding-cta {
  width: 100%;
}

.onboarding-join {
  font-size: 0.82rem;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  min-width: 0;          /* prevent panel from expanding parent grid beyond viewport */
  overflow: hidden;
}

.panel h2 {
  color: var(--color-ink);
  font-size: 1rem;
  font-weight: 760;
}

.profile-panel {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.profile-panel p {
  color: var(--color-ink-soft);
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

.avatar,
.world-icon,
.world-mark,
.key-mark {
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--color-teal-light);
  color: var(--color-teal);
  font-weight: 900;
}

.avatar,
.world-icon {
  width: 38px;
  height: 38px;
  font-size: 1.3rem;
}

.world-mark,
.key-mark {
  width: 64px;
  height: 64px;
  font-size: 2rem;
  border-radius: var(--radius-md);
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.invite-banner {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  background: var(--color-teal-light);
  border-color: rgba(61, 125, 117, 0.15);
}

.invite-banner p {
  color: var(--color-ink-soft);
}

/* Invite modal overlay — shown when user lands with ?invite= */
.invite-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 600;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}

.invite-modal {
  background: var(--color-surface);
  border-radius: 24px 24px 0 0;
  padding: 32px 28px 40px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  animation: slide-up 0.3s ease;
}

.invite-modal-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 16px;
}

.invite-modal-eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-teal);
  margin-bottom: 8px;
}

.invite-modal-title {
  font-size: 1.6rem;
  font-weight: 860;
  color: var(--color-ink);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.invite-modal-sub {
  font-size: 0.88rem;
  color: var(--color-ink-muted);
  margin-bottom: 28px;
}

.invite-modal-accept {
  width: 100%;
  min-height: 52px;
  background: var(--color-ink);
  color: var(--color-surface);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: -0.2px;
  margin-bottom: 14px;
  transition: opacity 0.15s;
}

.invite-modal-accept:active {
  opacity: 0.75;
}

.invite-modal-note {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
}

.invite-modal-decline {
  background: none;
  border: none;
  color: var(--color-ink-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Invite notice on auth screen */
.invite-auth-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-teal-light, #eef5f4);
  border: 1px solid rgba(61,125,117,0.18);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 4px;
  text-align: left;
}

.invite-auth-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.invite-auth-notice strong {
  display: block;
  font-size: 0.92rem;
  color: var(--color-ink);
  margin-bottom: 2px;
}

.invite-auth-notice p {
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  margin: 0;
}

.world-list {
  display: grid;
  gap: 4px;
}

/* ── Worlds home section (clean list, no panel border) ── */
.worlds-section {
  display: grid;
  gap: 10px;
}

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

.worlds-section-heading h2 {
  color: var(--color-ink);
  font-size: 1rem;
  font-weight: 760;
  margin: 0;
}

/* ── World card list (replaces world-row-wrap) ── */
.world-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.world-card-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  gap: 6px;
}

.world-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface) !important;   /* override .panel button */
  color: var(--color-ink) !important;             /* override .panel button */
  padding: 11px 12px;
  text-align: left;
  transition: background 0.12s;
  min-height: 62px;
}

.world-card:active {
  background: var(--color-teal-light) !important;
}

.world-card-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  line-height: 1;
}

.world-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.world-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.world-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.world-card-badge {
  flex-shrink: 0;
  background: var(--color-teal);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.world-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.world-card-tag {
  font-size: 0.75rem;
  color: var(--color-teal);
  background: var(--color-teal-light);
  border-radius: 99px;
  padding: 1px 6px;
  font-weight: 600;
}

.world-card-members {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
}

.world-card-activity {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.world-card-activity span {
  font-size: 0.73rem;
  color: var(--color-ink-muted);
}

/* Keep old .world-delete-btn for archive button */
.world-delete-btn {
  min-width: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 1.1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}

.world-delete-btn:active {
  background: #ffe0e0;
  color: #c0392b;
}

/* Keep old .world-row-wrap for backward compat (friends, etc.) */
.world-row-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
}

.world-row-wrap .world-row {
  width: 100%;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: grid;
  place-items: center;
  z-index: 600;
}

.confirm-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  margin: 20px;
  max-width: 320px;
  width: 100%;
}

.confirm-card p {
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.confirm-subtext {
  font-size: 0.83rem !important;
  color: var(--color-ink-muted);
  margin-bottom: 16px !important;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

.world-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 8px 10px;
  text-align: left;
  transition: background 0.12s;
}

.world-row:active {
  background: var(--color-teal-light);
}

.world-row strong,
.world-row small {
  display: block;
}

.world-row strong {
  color: var(--color-ink);
  font-size: 0.95rem;
}

.world-row small,
.world-row em {
  color: var(--color-ink-muted);
  font-style: normal;
  font-size: 0.78rem;
}

.quiet-panel {
  background: #f5f5f3;
  border-color: transparent;
}

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

.choice-grid button {
  min-height: 112px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(32, 49, 47, 0.08);
  border-radius: 8px;
  background: #fff;
  color: #20312f;
  text-align: left;
}

.choice-grid button.active {
  border-color: #4a8b83;
  background: #e6f1ef;
}

.choice-grid span {
  font-size: 1.1rem;
}

.choice-grid small {
  color: #5f706c;
  font-size: 0.72rem;
  line-height: 1.25;
}

.choice-grid.compact button {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 780;
}

/* ── Icon picker (CreateWorldScreen) ── */
.icon-picker-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.icon-picker-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}

.icon-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-pill {
  width: 38px;
  height: 38px;
  font-size: 1.3rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.icon-pill.active {
  border-color: var(--color-teal);
  background: var(--color-teal-light);
}

.world-screen {
  gap: 0;
  padding: 0 0 env(safe-area-inset-bottom, 20px);
}

/* World sub-tab header */
.world-subtab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.96);
  flex-shrink: 0;
}

.world-subtab-title {
  font-size: 0.82rem;
  font-weight: 760;
  color: var(--color-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.chat-header-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-ink);
  text-align: center;
}

.chat-header-sub {
  font-size: 0.72rem;
  color: var(--color-ink-muted);
  text-align: center;
}

/* World home immersive header */
.world-home-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 16px;
}

.world-home-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.world-home-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.world-home-title h1 {
  font-size: 1.4rem;
  font-weight: 860;
  margin: 0;
  letter-spacing: -0.5px;
  color: var(--color-ink);
  line-height: 1.1;
}

.world-home-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-teal);
  opacity: 0.75;
}

.world-share-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--color-teal);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.65;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.world-share-btn:hover {
  opacity: 1;
}

.world-hero {
  min-height: 140px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-teal-light) 0%, var(--color-surface) 100%);
  border: 1px solid rgba(61, 125, 117, 0.12);
}

.world-hero.compact {
  min-height: auto;
  padding: 14px 16px;
  border-radius: var(--radius-md);
}

.world-nav-panel {
  padding: 6px;
  gap: 2px;
}

/* Chat preview on world home */
.chat-preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.chat-preview-empty {
  color: var(--color-ink-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 8px 0;
}

.chat-preview-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.chat-preview-bubble {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  max-width: 88%;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.chat-preview-bubble.me {
  align-self: flex-end;
  background: var(--color-ink);
  color: #fffaf4;
}

.chat-preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  opacity: 0.6;
  margin-bottom: 2px;
}

.chat-preview-bubble p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  /* show up to 2 lines, then ellipsis — never let text expand the bubble width */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

.chat-preview-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 4px;
}

.chat-preview-compose input {
  min-height: 42px;
  min-width: 0;          /* grid children need this to respect minmax(0,1fr) */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 0.92rem;
  background: var(--color-bg);
  color: var(--color-ink);
  width: 100%;
  box-sizing: border-box;
}

.chat-preview-compose button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-ink);
  color: #fffaf4;
  font-weight: 800;
  font-size: 0.88rem;
}

.chat-preview-compose button:disabled {
  opacity: 0.4;
}

.world-nav-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  color: var(--color-ink);
  transition: background 0.12s;
}

.world-nav-row:active {
  background: var(--color-teal-light);
}

.world-nav-row strong {
  font-weight: 760;
  font-size: 0.93rem;
}

.world-nav-row em {
  color: var(--color-ink-muted);
  font-style: normal;
  font-size: 1rem;
}

.ai-insight-panel h2 {
  margin-top: 2px;
}

.insight-badge {
  font-size: 0.78rem;
  color: #8a9e9a;
}

.insight-quiet {
  color: #8a9e9a;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

.insight-need-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.insight-need-label strong {
  font-size: 0.95rem;
  color: #20312f;
}

.insight-need-label span {
  font-size: 0.73rem;
  color: #8a9e9a;
  white-space: nowrap;
}

.insight-dims {
  display: grid;
  gap: 8px;
}

.insight-dim-row {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 0.78rem;
  color: #5f706c;
}

.insight-dim-row > span:first-child {
  width: 90px;
  flex-shrink: 0;
}

.insight-dim-score {
  width: 34px;
  text-align: right;
  color: #4a8b83;
  font-weight: 700;
}

.insight-footer {
  color: #b0c0bc;
  font-size: 0.68rem;
}

.insight-ai-badge {
  display: inline-block;
  background: linear-gradient(90deg, #4a7c75, #3d7d75);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
}

/* ── World expression card ─────────────────────────────── */
.world-status-hint {
  margin: 0 16px 12px;
  font-size: 0.72rem;
  color: var(--color-teal);
  opacity: 0.7;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ─────────────────────────────────────────────────────── */

.insight-recommendation-label {
  display: block;
  color: #5f706c;
  font-size: 0.7rem;
  font-weight: 860;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.current-direction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f1eb;
}

.current-direction span {
  color: #5f706c;
  font-size: 0.78rem;
  font-weight: 780;
}

.current-direction strong {
  color: #20312f;
}

.next-possibility {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 10px;
  background: #20312f;
  color: #fffaf4;
}

.next-possibility .eyebrow {
  color: #9fd6cb;
}

.next-possibility p {
  color: #fffaf4;
  font-weight: 780;
  line-height: 1.35;
}

/* ── Trajectory Panel ─────────────────────────────────── */
.traj-panel {
  display: grid;
  gap: 12px;
}

.traj-state-panel,
.traj-events-panel {
  display: grid;
  gap: 12px;
}

.traj-dims {
  display: grid;
  gap: 10px;
}

.traj-dim {
  display: grid;
  gap: 4px;
}

.traj-dim-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.traj-dim-score {
  color: #4a8b83;
}

.traj-bar-track {
  height: 6px;
  background: rgba(32, 49, 47, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.traj-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a8b83, #7ec8bd);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.traj-up   { color: #4a8b83; font-size: 0.75rem; }
.traj-down { color: #a05040; font-size: 0.75rem; }

.traj-based-on {
  color: #8a9e9a;
  font-size: 0.73rem;
}

.traj-empty {
  color: #8a9e9a;
  font-size: 0.85rem;
  line-height: 1.5;
}

.traj-list {
  display: grid;
  gap: 0;
  position: relative;
}

.traj-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(32, 49, 47, 0.06);
}

.traj-row:last-child {
  border-bottom: none;
}

.traj-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  background: #c8dbd8;
}

.traj-dot.sig-created     { background: #4a8b83; }
.traj-dot.sig-joined      { background: #7ec8bd; }
.traj-dot.sig-message     { background: #a0c8c3; }
.traj-dot.sig-photo       { background: #e8a070; }
.traj-dot.sig-invite      { background: #b0c8e8; }
.traj-dot.sig-context     { background: #9870c8; }
.traj-dot.sig-reflection  { background: #c8b070; }
.traj-dot.sig-plan        { background: #70a8c8; }
.traj-dot.sig-plan-done   { background: #4a8b83; }
.traj-dot.sig-memory      { background: #e87090; }

.traj-row-body {
  display: grid;
  gap: 2px;
  flex: 1;
}

.traj-row-body strong {
  font-size: 0.85rem;
  color: #20312f;
}

.traj-row-body time {
  font-size: 0.73rem;
  color: #8a9e9a;
}

/* ── Memory Grid ─────────────────────────────────────── */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.memory-card {
  margin: 0;
  display: grid;
  gap: 6px;
  border-radius: 8px;
  overflow: hidden;
  background: #f4f1eb;
}

.memory-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.memory-card figcaption {
  padding: 0 8px 8px;
  color: #5f706c;
  font-size: 0.78rem;
}

/* ── Moments Panel ────────────────────────────────────── */
.moments-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.moments-tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.moments-tab-btn {
  min-height: 44px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 0.88rem;
  font-weight: 700;
  transition: color 0.12s, border-color 0.12s;
}

.moments-tab-btn.active {
  color: var(--color-ink);
  border-bottom-color: var(--color-ink);
}

/* AI Memories tab */
.ai-memories-tab {
  padding: 8px 0;
}

.ai-memories-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 32px 24px;
  background: linear-gradient(160deg, #f5f7f6 0%, #fbfaf7 100%);
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border);
}

.ai-memories-icon {
  font-size: 2rem;
  color: var(--color-teal);
  line-height: 1;
}

.ai-memories-placeholder h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--color-ink);
}

.ai-memories-placeholder p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--color-ink-muted);
  line-height: 1.6;
  max-width: 280px;
}

.ai-memories-coming {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-teal);
  background: var(--color-teal-light);
  padding: 4px 10px;
  border-radius: 20px;
}

/* Shared tab */
.shared-tab {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shared-compose-trigger {
  width: 100%;
  min-height: 46px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 0.9rem;
  font-weight: 640;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.12s, border-color 0.12s;
}

.shared-compose-trigger:active {
  background: var(--color-teal-light);
  border-color: var(--color-teal);
}

.shared-compose-trigger span {
  font-size: 1.2rem;
  line-height: 1;
}

.shared-compose-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.shared-compose-form textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: inherit;
}

.shared-img-preview {
  position: relative;
  display: inline-block;
}

.shared-img-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.shared-img-preview .chat-photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--color-ink);
  color: #fff;
  border-radius: 50%;
  border: 0;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
}

.shared-compose-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shared-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shared-empty {
  color: var(--color-ink-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 20px 0;
}

.shared-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.shared-card img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.shared-card p {
  margin: 0;
  padding: 10px 12px 4px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-ink);
}

.shared-card time {
  padding: 4px 12px 10px;
  font-size: 0.72rem;
  color: var(--color-ink-muted);
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.mood-grid button {
  min-height: 44px;
  border: 1px solid rgba(32, 49, 47, 0.13);
  border-radius: 8px;
  background: #fff;
  color: #5f706c;
  font-weight: 820;
}

.mood-grid button.active {
  border-color: #4a8b83;
  background: #e6f1ef;
  color: #315f5a;
}

.owner-segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-list {
  display: grid;
  gap: 8px;
}

.plan-empty-msg {
  color: var(--color-ink-muted);
  font-size: 0.88rem;
  margin: 4px 0 8px;
}

.plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #f4f1eb;
}

.plan-row.completed {
  opacity: 0.55;
}

.plan-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  cursor: pointer;
}

.plan-row input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: #315f5a;
}

.plan-row span {
  display: grid;
  gap: 2px;
}

.plan-row strong {
  color: #20312f;
  font-weight: 780;
}

.plan-row small {
  color: #5f706c;
  text-transform: capitalize;
}

.plan-feedback-tag {
  color: var(--color-teal);
  font-size: 0.7rem;
  font-weight: 700;
}

/* ── Plans Panel (tabbed) ───────────────────────────────── */
.plans-panel {
  display: grid;
  gap: 0;
}

.plans-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1.5px solid var(--color-border);
  margin-bottom: 0;
  padding: 0 16px;
}

.plans-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-ink-muted);
  padding: 12px 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.plans-tab-btn.active {
  color: var(--color-teal);
  border-bottom-color: var(--color-teal);
}

.plans-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--color-teal);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0 5px;
}

/* AI Plans tab */
.ai-plans-tab {
  display: grid;
  gap: 16px;
  padding: 16px;
}

/* AI Plan Suggestion Card */
.ai-plan-suggestion-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-teal);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-plan-suggestion-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-plan-suggestion-badge {
  font-size: 0.68rem;
  font-weight: 760;
  color: var(--color-teal);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.ai-plan-suggestion-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.3;
}

.ai-plan-suggestion-rationale {
  font-size: 0.8rem;
  color: #5f706c;
  line-height: 1.5;
  margin: 0;
}

.ai-plan-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.ai-plan-link-btn {
  display: inline-block;
  padding: 5px 12px;
  background: var(--color-teal-light);
  color: var(--color-teal);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.ai-plan-link-btn:active {
  opacity: 0.7;
}

.ai-plan-suggestion-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ai-plan-accept-btn {
  flex: 1;
  padding: 9px;
  background: var(--color-teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.ai-plan-accept-btn:disabled {
  opacity: 0.6;
}

.ai-plan-ignore-btn {
  padding: 9px 16px;
  background: transparent;
  color: #8a9e9a;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* AI Moment Cards */
.ai-moment-card {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.ai-moment-card:last-child {
  border-bottom: none;
}

.ai-moment-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  margin-top: 2px;
}

.ai-moment-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-moment-body strong {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.3;
}

.ai-moment-body p {
  font-size: 0.8rem;
  color: #5f706c;
  line-height: 1.5;
  margin: 0;
}

.ai-moment-body time {
  font-size: 0.7rem;
  color: #a0b0ad;
}

.ai-plans-coming {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: var(--color-teal-light);
  border-radius: 12px;
}

.ai-plans-coming-icon {
  font-size: 1.2rem;
  color: var(--color-teal);
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-plans-coming p {
  font-size: 0.82rem;
  color: #3a5a56;
  line-height: 1.5;
  margin: 0;
}

.ai-plans-grid {
  display: grid;
  gap: 10px;
}

.ai-plan-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  min-height: 72px;
}

.ai-plan-card-emoji {
  font-size: 1.8rem;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.ai-plan-card-body {
  display: grid;
  gap: 3px;
  flex: 1;
}

.ai-plan-card-tag {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.75);
}

.ai-plan-card-title {
  font-size: 0.95rem;
  font-weight: 760;
  color: #fff;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ai-plan-card-lock {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.18);
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

.ai-plans-note {
  font-size: 0.72rem;
  color: var(--color-ink-muted);
  line-height: 1.5;
  margin: 0;
  text-align: center;
  opacity: 0.7;
}

/* Our Plans tab */
.our-plans-tab {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.our-plans-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.our-plans-add-btn {
  border: 1.5px solid var(--color-teal);
  background: transparent;
  color: var(--color-teal);
  font-size: 0.82rem;
  font-weight: 760;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.12s;
}

.our-plans-add-btn:hover {
  background: var(--color-teal-light);
}

.our-plans-form {
  display: grid;
  gap: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px;
}

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

.our-plans-submit {
  padding: 0 16px;
  min-height: 42px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────── */

.plan-done-section {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.plan-done-label {
  font-size: 0.7rem;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  padding: 4px 0 2px;
}

/* ── My Side Panel ─────────────────────────────────────── */
.myside-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.myside-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.myside-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-teal);
}

.myside-title {
  display: block;
  font-size: 1rem;
  font-weight: 780;
  color: var(--color-ink);
  margin-bottom: 4px;
}

.myside-subtitle {
  font-size: 0.82rem;
  color: var(--color-ink-muted);
  line-height: 1.5;
  margin: 0;
}

.myside-form {
  display: grid;
  gap: 10px;
}

.myside-textarea {
  width: 100%;
  min-height: 130px;
  padding: 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--color-ink);
  background: var(--color-surface);
  resize: vertical;
  outline: none;
  line-height: 1.55;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.myside-textarea:focus {
  border-color: var(--color-teal);
}

.myside-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.myside-privacy {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-teal);
  opacity: 0.7;
}

.myside-save {
  padding: 8px 20px;
  min-height: auto;
  font-size: 0.88rem;
}

.myside-note {
  background: var(--color-teal-light);
  border-radius: 10px;
  padding: 12px 14px;
}

.myside-note p {
  font-size: 0.8rem;
  color: #3a5a56;
  line-height: 1.55;
  margin: 0;
}
/* ── Butler card (My Side daily digest) ──────────────── */
.butler-card {
  background: linear-gradient(135deg, #edf6f4 0%, #f4f2ee 100%);
  border: 1px solid rgba(61, 125, 117, 0.18);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.butler-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.butler-icon {
  font-size: 1rem;
  color: var(--color-teal);
}

.butler-label {
  font-size: 0.75rem;
  font-weight: 780;
  color: var(--color-teal);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.butler-loading {
  font-size: 0.84rem;
  color: var(--color-ink-muted);
  padding: 4px 0;
}

.butler-body {
  display: grid;
  gap: 10px;
}

.butler-section {
  display: grid;
  gap: 4px;
}

.butler-section-tag {
  font-size: 0.7rem;
  font-weight: 780;
  color: var(--color-teal);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.butler-section p {
  font-size: 0.88rem;
  color: var(--color-ink);
  line-height: 1.55;
  margin: 0;
}

.butler-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid rgba(61,125,117,0.12);
}

.butler-adjust-btn {
  font-size: 0.82rem;
  color: var(--color-teal);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-weight: 660;
}

.butler-privacy-note {
  font-size: 0.72rem;
  color: var(--color-ink-muted);
}

.butler-empty {
  font-size: 0.84rem;
  color: var(--color-ink-muted);
  margin: 0;
  line-height: 1.5;
}

.myside-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.myside-form-header strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 760;
  color: var(--color-ink);
  margin-bottom: 4px;
}

.myside-form-header p {
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  margin: 0;
  line-height: 1.5;
}

.myside-show-edit-btn {
  background: transparent;
  border: none;
  color: var(--color-teal);
  font-size: 0.84rem;
  font-weight: 660;
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
}

/* ── Read receipts ────────────────────────────────────── */
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.bubble-meta time {
  font-size: 0.68rem;
  opacity: 0.5;
}

.read-tick {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  line-height: 1;
  font-weight: 700;
}

.chat-bubble:not(.mine) .read-tick { display: none; }

.read-tick.seen {
  color: #7dd4cc;
}

/* ─────────────────────────────────────────────────────── */

/* ── Plan Reflection Card ──────────────────────────────── */
.plan-reflection-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 30, 0.55);
  z-index: 600;
  display: flex;
  align-items: flex-end;
  padding: 0 0 env(safe-area-inset-bottom, 20px);
}

.plan-reflection-card {
  width: 100%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 28px;
  display: grid;
  gap: 12px;
  animation: slide-up 0.22s ease;
}

@keyframes slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.plan-reflection-title {
  font-size: 1rem;
  font-weight: 760;
  color: var(--color-ink);
  margin: 0;
  text-align: center;
}

.plan-reflection-prompt {
  font-size: 0.82rem;
  color: var(--color-ink-muted);
  margin: 0;
  text-align: center;
}

.plan-reflection-options {
  display: grid;
  gap: 8px;
}

.plan-reflection-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.92rem;
  font-weight: 540;
  color: var(--color-ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.plan-reflection-opt:hover,
.plan-reflection-opt:active {
  background: var(--color-teal-light);
  border-color: var(--color-teal);
}

.plan-reflection-opt span {
  font-size: 1.1rem;
}

.plan-reflection-skip {
  border: none;
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  opacity: 0.6;
}
/* ─────────────────────────────────────────────────────── */

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

.identity-grid div {
  min-height: 68px;
  display: grid;
  align-content: center;
  gap: 5px;
  border-radius: 8px;
  background: #f4f1eb;
  padding: 10px;
}

.identity-grid span {
  color: #5f706c;
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.identity-grid strong {
  color: #20312f;
  font-size: 0.92rem;
  line-height: 1.1;
}

.path-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.path-rail span {
  min-height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f4f1eb;
  color: #5f706c;
  font-size: 0.63rem;
  font-weight: 820;
  text-align: center;
}

.path-rail .active {
  background: #e6f1ef;
  color: #315f5a;
  box-shadow: inset 0 0 0 1px rgba(74, 139, 131, 0.18);
}

.soft-list {
  display: grid;
  gap: 8px;
}

.soft-list span {
  padding: 10px 11px;
  border-radius: 8px;
  background: #eaf4f1;
  color: #315f5a;
  font-weight: 760;
  line-height: 1.35;
}

.reflection-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.reflection-panel summary::-webkit-details-marker {
  display: none;
}

.reflection-panel summary span {
  color: #20312f;
  font-weight: 850;
}

.reflection-panel summary strong {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(74, 139, 131, 0.12);
  color: #315f5a;
  font-size: 0.72rem;
}

.reflection-panel p,
.reflection-panel small {
  color: #5f706c;
}

.insight-need {
  margin-top: 10px;
  color: #20312f;
}

.insight-recommendation {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eaf4f1;
}

.insight-recommendation strong {
  display: block;
  color: #20312f;
  margin-bottom: 4px;
}

.insight-recommendation p {
  margin: 0;
  color: #3c4c49;
}

.insight-recommendation.quiet {
  background: transparent;
  padding: 0;
  color: #5f706c;
  font-style: italic;
}

.insight-evidence {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f1eb;
}

.insight-evidence p {
  margin: 0 0 4px;
}

.member-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.friend-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.friend-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  color: var(--color-ink);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.friend-pill-btn em {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-teal-light);
  color: var(--color-teal);
  font-style: normal;
  font-weight: 700;
  font-size: 0.8rem;
}

.friend-pill-btn.active {
  background: var(--color-teal-light);
  border-color: var(--color-teal);
  color: var(--color-teal);
}

.invite-hint {
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  margin-top: 6px;
}

.member-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: #f4f1eb;
  color: #20312f;
  font-weight: 760;
}

.member-pill em {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #315f5a;
  color: #fffaf4;
  font-style: normal;
  font-size: 0.74rem;
}

.invite-link {
  padding: 10px;
  border-radius: 8px;
  background: #f4f1eb;
  color: #315f5a;
  font-size: 0.84rem;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.live-indicator {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-ink-muted);
  letter-spacing: 0.02em;
  transition: color 0.3s ease;
}

.live-indicator-flash {
  color: var(--color-teal);
  animation: live-pulse 1.5s ease-out;
}

@keyframes live-pulse {
  0%   { color: var(--color-teal); }
  60%  { color: var(--color-teal-mid); }
  100% { color: var(--color-ink-muted); }
}

/* ── Chat screen (full redesign) ─────────────────────── */
.chat-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--color-bg);
  overflow-x: hidden;  /* prevent any child from causing horizontal page scroll */
  width: 100%;
  max-width: 100%;
}

.chat-insight-strip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #f0f7f6, #fbfaf7);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  line-height: 1.4;
  overflow: hidden;
}

/* flex child must have min-width:0 so long text wraps instead of overflowing */
.chat-insight-strip span:last-child {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.chat-insight-icon {
  color: var(--color-teal);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.chat-bubble-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

/* Full-height wrapper when the world chat tab is active */
.world-chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

/* On native iOS, dvh (dynamic viewport height) already updates when the keyboard
   appears, so .phone-frame (height:100dvh) naturally shrinks to the area above
   the keyboard.  No extra padding-bottom needed here — adding it would double-
   compensate and squeeze the chat header off-screen. */

.chat-empty {
  color: var(--color-ink-muted);
  font-size: 0.88rem;
  text-align: center;
  margin-top: auto;
  padding: 24px 0;
}

.chat-system-msg {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-ink-muted);
  padding: 4px 12px;
}

.chat-bubble-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 2px;
}

.chat-bubble-row.mine {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 78%;
  background: #f0efeb;
  border-radius: 16px 16px 16px 4px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-bubble.mine {
  background: var(--color-ink);
  color: #fffaf4;
  border-radius: 16px 16px 4px 16px;
}

.chat-bubble p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-bubble time {
  font-size: 0.68rem;
  opacity: 0.5;
  align-self: flex-end;
}

.chat-bubble-img {
  width: 100%;
  max-width: 240px;
  border-radius: 10px;
  display: block;
}

/* Photo preview strip */
.chat-photo-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.chat-photo-preview img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.chat-photo-preview-meta {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-photo-preview-meta input {
  flex: 1;
  min-height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 0.88rem;
  background: var(--color-bg);
}

.chat-photo-remove {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 1rem;
  padding: 4px;
}

/* Compose bar */
/* ── Compose area (WeChat-style) ─────────────────────── */
.compose-area {
  flex-shrink: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.compose-panel {
  display: flex;
  gap: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: #f5f4f1;
}

.compose-panel-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--color-ink-soft);
  cursor: pointer;
  transition: background 0.12s;
  margin: 0 6px;
}

.compose-panel-btn:first-child { margin-left: 0; }
.compose-panel-btn:last-child  { margin-right: 0; }

.compose-panel-btn:active { background: var(--color-teal-light); }
.compose-panel-btn.loading { opacity: 0.5; }

.compose-panel-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.chat-compose-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--color-surface);
}

.compose-plus-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  display: grid;
  place-items: center;
  color: var(--color-ink-muted);
  transition: background 0.12s, transform 0.15s;
}

.compose-plus-btn.open {
  transform: rotate(45deg);
  color: var(--color-teal);
  border-color: var(--color-teal);
}

.chat-compose-input {
  flex: 1;
  min-height: 38px;
  max-height: 100px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 16px;
  background: var(--color-bg);
  color: var(--color-ink);
  resize: none;
  outline: none;
}

.chat-compose-input:focus {
  border-color: var(--color-teal);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--color-teal);
  color: #fff;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: opacity 0.15s;
}

.chat-send-btn:disabled {
  opacity: 0.4;
}

.chat-live-row {
  display: flex;
  justify-content: center;
  padding: 2px 0 6px;
  background: var(--color-surface);
}

/* AI Suggest Bar */
.suggest-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(90deg, #f0f7f6, #fbfaf7);
  border-top: 1px solid rgba(74, 139, 131, 0.18);
  overflow-x: auto;
  /* prevent the bar itself from stretching the page wider than the viewport */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.suggest-chips {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.suggest-chip {
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(74, 139, 131, 0.25);
  color: #20312f;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
}

.suggest-chip:active {
  background: #e8f4f2;
}

.suggest-dismiss {
  color: #8a9e9a;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-left: auto;
  border: 0;
  background: transparent;
}

/* keep old composer/photo-form for any remaining uses */
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.photo-form {
  display: grid;
  gap: 8px;
}

.photo-form label {
  padding: 10px;
  border: 1px dashed rgba(74, 139, 131, 0.32);
  border-radius: 8px;
  background: #fbfaf7;
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
}

.ai-suggest-btn {
  color: #4a8b83;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 4px 0;
}

.ai-suggest-btn:disabled {
  opacity: 0.5;
}

.mobile-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  /* Web: pad for home indicator ourselves */
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Native iOS: phone-frame already reserves env(safe-area-inset-bottom)
   via its padding-bottom. Adding it again here causes a visible blank gap
   below the nav bar. In native mode, just use flat bottom padding.
   Also remove backdrop-filter: on iOS WKWebView, backdrop-filter creates
   a new stacking context that can render ABOVE elements with z-index,
   covering bottom sheets. Solid background is used instead. */
.native-ios .mobile-nav {
  padding-bottom: 10px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: #ffffff;
}

.mobile-nav button {
  min-height: 52px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink-muted);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.01em;
  transition: color 0.12s, background 0.12s;
}

.mobile-nav span {
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
}

.mobile-nav .active {
  background: var(--color-teal-light);
  color: var(--color-teal);
}

@media (max-width: 420px) {
  .app-shell {
    padding: 0;
  }

  .phone-frame {
    min-height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }
}

/* World picker (disambiguation when multiple worlds share a key) */
.world-picker-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.world-picker-btn:hover {
  background: var(--color-teal-light);
}

.world-picker-emoji {
  font-size: 1.4rem;
}

.world-picker-btn small {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--color-ink-muted);
  font-weight: 400;
}

/* ── Native iOS (Capacitor) overrides ────────────────────────── */

/* --keyboard-h is set by @capacitor/keyboard events in main.js.
   Default 0px keeps web layout unaffected. */
:root { --keyboard-h: 0px; }

/* ── Native iOS (Capacitor) overrides ────────────────────────── */
html.native-ios {
  font-size: 15px;
  overflow: hidden;
}

.native-ios body {
  overflow: hidden;
}

.native-ios .app-shell {
  padding: 0;
  display: block;
}

.native-ios .phone-frame {
  /* Use position:fixed so the frame is always anchored to the true viewport,
     independent of any body/html height chain.  This is the most reliable
     approach for WKWebView — it avoids the brittle height:100% propagation
     that collapses when Capacitor hasn't yet set body.style.height.

     Keyboard handling: when the keyboard opens, @capacitor/keyboard fires
     keyboardWillShow and we set --keyboard-h.  padding-bottom on this frame
     shrinks the content area by exactly that amount, keeping the compose bar
     above the keyboard.  max() ensures the bottom safe-area (home indicator)
     is always respected even when the keyboard is hidden. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  min-height: unset;
  max-height: unset;
  padding-bottom: max(var(--keyboard-h, 0px), env(safe-area-inset-bottom));
  box-sizing: border-box;
  transition: padding-bottom 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Native iOS bottom sheet keyboard avoidance.
   Strategy: keep the sheet anchored at bottom:0 (never move it).
   Instead, grow padding-bottom to equal --keyboard-h so the CONTENT
   scrolls up above the keyboard. The keyboard visual sits on top of
   the sheet background — the standard iOS pattern used by Messages, etc.
   max-height:90dvh prevents very tall sheets from overflowing into
   the status bar area. */
.native-ios .bottom-sheet {
  bottom: 0 !important;
  max-height: 90dvh;
  overflow-y: auto;
  padding-bottom: calc(var(--keyboard-h, 0px) + 16px);
  transition: padding-bottom 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Prevent iOS WebKit auto-zoom on input focus (triggered when font-size < 16px) */
.native-ios input,
.native-ios textarea,
.native-ios select {
  font-size: 16px !important;
}

.bottom-sheet {
  max-height: 90dvh;
  overflow-y: auto;
}

/* ── DM Chat (WeChat-style) ───────────────────────────────── */
.dm-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #f2f2f7;
  overflow: hidden;
}

/* Header */
.dm-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.dm-back-btn {
  font-size: 1.5rem;
  color: var(--color-teal, #2a8a7e);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 8px 0 0;
  line-height: 1;
  flex-shrink: 0;
}

.dm-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-teal, #2a8a7e);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.dm-header-name {
  font-weight: 600;
  font-size: 1rem;
  color: #111;
  flex: 1;
}

/* Bubble list */
.dm-bubble-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.dm-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.dm-bubble-row.mine {
  flex-direction: row-reverse;
}

.dm-bubble-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #aaa;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.dm-bubble {
  max-width: 72%;
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  padding: 8px 12px 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.dm-bubble.mine {
  background: #07c160;
  border-radius: 16px 16px 4px 16px;
  color: #fff;
}

.dm-bubble p {
  margin: 0 0 4px;
  font-size: 0.93rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.dm-bubble .bubble-meta {
  justify-content: flex-end;
  gap: 3px;
  margin-top: 0;
}

.dm-bubble .bubble-meta time {
  font-size: 0.65rem;
  opacity: 0.55;
}

.dm-bubble.mine .read-tick {
  color: rgba(255,255,255,0.55);
}

.dm-bubble.mine .read-tick.seen {
  color: rgba(255,255,255,0.9);
}

/* Compose bar */
.dm-compose {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.dm-compose-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 15px;
  background: #f9f9f9;
  outline: none;
}

.dm-compose-input:focus {
  border-color: var(--color-teal, #2a8a7e);
  background: #fff;
}

.dm-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #07c160;
  color: #fff;
  border: none;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-weight: 700;
}

.dm-send-btn:disabled {
  opacity: 0.5;
}

.chat-empty {
  text-align: center;
  color: #aaa;
  font-size: 0.88rem;
  padding: 24px 0;
}

/* ── World Invite Notifications ──────────────────────────── */
.world-invite-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px 0;
}

.world-invite-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1.5px solid var(--color-teal, #2a8a7e);
  border-radius: 12px;
  padding: 10px 12px;
}

.world-invite-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.world-invite-body {
  flex: 1;
  min-width: 0;
}

.world-invite-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.92rem;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-invite-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #888;
}

.world-invite-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Friend Request Rows ──────────────────────────────────── */
.friend-request-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: default;
}

.friend-req-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.req-accept-btn {
  background: var(--color-teal, #2a8a7e);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.req-reject-btn {
  background: none;
  color: #888;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.badge {
  display: inline-block;
  background: #ff3b30;
  color: #fff;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  vertical-align: middle;
  margin-left: 4px;
}

/* Native iOS DM keyboard spacing */
.native-ios .dm-compose {
  padding-bottom: max(10px, calc(env(safe-area-inset-bottom) + var(--keyboard-h, 0px)));
}
