:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-header-top: calc(12px + var(--safe-top));
}

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

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  color: #1c1c1e;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

/* ========== 纯白遮罩 + 蓝光晕登录门禁 ========== */
.auth-gate-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}
.auth-gate-mask.show {
  display: flex;
  animation: authFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.auth-gate-card {
  width: 100%;
  max-width: 375px;
  min-height: 480px;
  background: transparent;
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-glow-top {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(176,204,232,0.45) 0%, rgba(245,248,252,0) 70%);
  pointer-events: none;
}

.auth-glow-bottom {
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(136,171,218,0.3) 0%, rgba(221,232,244,0) 70%);
  pointer-events: none;
}

.auth-content-box {
  width: 280px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.auth-subtitle {
  font-size: 8px;
  color: rgba(136,171,218,0.7);
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.auth-title {
  font-size: 24px;
  font-weight: 300;
  color: #6a8aa8;
  letter-spacing: 6px;
  text-indent: 6px;
}

.auth-divider {
  width: 40px;
  height: 1px;
  background: rgba(136,171,218,0.3);
  margin: 12px auto 24px;
}

.auth-inputs-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.auth-inputs-wrap input {
  width: 100%;
  height: 44px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,1);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 13px;
  color: #6a8aa8;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  transition: all 0.2s ease;
  -webkit-user-select: text;
  user-select: text;
}
.auth-inputs-wrap input::placeholder {
  color: rgba(106, 138, 168, 0.5);
}
.auth-inputs-wrap input:focus {
  background: rgba(255,255,255,0.9);
  border-color: rgba(176,204,232,0.8);
  box-shadow: 0 0 10px rgba(136,171,218,0.15);
}

.auth-submit-btn {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, #b0cce8, #88abda);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 4px;
  text-indent: 4px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(136,171,218,0.25);
  transition: all 0.2s ease;
}
.auth-submit-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}
.auth-submit-btn:disabled {
  opacity: 0.6;
  transform: none;
}

.auth-switch-text {
  margin-top: 18px;
  font-size: 13px;
  color: rgba(106, 138, 168, 0.75);
  letter-spacing: 0.5px;
  line-height: 1.5;
}
.auth-switch-text span {
  color: #6a8aa8;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-switch-text span:active {
  opacity: 0.5;
}

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

/* ========== 全屏壁纸层 ========== */
.home-bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
  pointer-events: none;
}

/* ========== 主容器 ========== */
.app-shell { 
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100vh; 
  width: 100vw;
  max-width: 430px; 
  display: flex; 
  flex-direction: column; 
  overflow: hidden;
  background: transparent;
  z-index: 1;
}

.page-container { 
  flex: 1; 
  overflow: hidden; 
  padding: 0; 
  display: flex; 
  flex-direction: column; 
  position: relative;
  z-index: 1;
}

.page { 
  display: none; 
  flex-direction: column; 
  gap: 20px; 
  height: 100%; 
  overflow-y: auto; 
  /* 垫高安全距离，绝不允许内容或输入法挡住底部 */
  padding: calc(16px + var(--safe-top)) 16px calc(var(--safe-bottom) + 115px); 
  position: relative; 
  box-sizing: border-box;
}
.page.active { display: flex; }

/* 头像展示区布局 */
.couple-section {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 4px 0;
  flex-shrink: 0;
}

.couple-left {
  flex: 5;
  min-width: 0;
  padding-top: 21px; 
}

.couple-right {
  flex: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* ========== 底部栏定位（安卓/苹果双重保险防遮挡） ========== */
.tab-bar {
  position: fixed;
  /* 基础留足 18px，配合 safe-bottom，即使在安卓 Edge 的浮动工具栏上也不会被截断 */
  bottom: calc(var(--safe-bottom) + 18px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 380px;
  width: calc(100% - 32px);
}

.page-title { font-size:28px; font-weight:700; letter-spacing:-.5px; padding:8px 0; }

/* ========== Toast ========== */
.toast-message {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 12px 24px; background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff; border-radius: 14px; font-size: 14px; font-weight: 500;
  z-index: 20000; opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.toast-message.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ========== 照片操作卡片（全局） ========== */
.photo-action-card {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 14px; overflow: hidden; z-index: 1200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; min-width: 200px;
}
.photo-action-card.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.photo-action-card button {
  display: block; width: 100%; padding: 16px 24px; border: none;
  background: transparent; font-size: 16px; font-weight: 500;
  color: #1c1c1e; cursor: pointer; font-family: inherit;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.photo-action-card button:last-child { border-bottom: none; }
.photo-action-card button:active { background: rgba(0,0,0,0.05); }
.photo-action-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.2);
  z-index: 1100; display: none;
}
.photo-action-mask.show { display: block; }

/* ========== 图片裁剪 ========== */
.crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.9);
  display: none;
  flex-direction: column;
}
.crop-overlay.show {
  display: flex;
}

.crop-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.crop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 16px 12px;
  flex-shrink: 0;
}
.crop-header span { font-size: 16px; font-weight: 600; color: #fff; }

.crop-cancel, .crop-confirm {
  padding: 8px 18px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.crop-cancel { background: rgba(255,255,255,0.15); color: #fff; }
.crop-confirm { background: #fff; color: #111; }
.crop-cancel:active, .crop-confirm:active { opacity: 0.7; }

.crop-toolbar {
  display: flex; justify-content: center; gap: 8px;
  padding: 0 16px 8px; flex-shrink: 0;
}
.crop-ratio-btn {
  padding: 5px 14px; border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 6px; background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.crop-ratio-btn.active {
  background: rgba(255,255,255,0.9); color: #111; border-color: rgba(255,255,255,0.9);
}
.crop-ratio-btn:active { opacity: 0.7; }

.crop-workspace {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow: hidden;
}
.crop-workspace canvas {
  max-width: 100%; max-height: 100%; touch-action: none;
}

/* ========== 独立 App 页面通用骨架 ========== */
.app-page {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  height: 100vh;
  background: #ffffff;
  z-index: 50;
  display: none;
  flex-direction: column;
  padding: 0;
}
.app-page.active {
  display: flex;
  animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.app-header {
  padding: var(--app-header-top) 16px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #3c3c43;
  display: flex;
  align-items: center;
  padding: 4px;
  margin-left: -4px;
  flex-shrink: 0;
}
.icon-back-btn:active { opacity: 0.5; }
.icon-back-btn svg {
  width: 28px; height: 28px;
  stroke: currentColor; stroke-width: 2.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}

.app-title {
  font-size: 32px;
  font-weight: 700;
  color: #1c1c1e;
  line-height: 1;
}

.app-content { 
  flex: 1; 
  overflow-y: auto; 
  padding: 0 16px 20px; 
  -webkit-overflow-scrolling: touch; 
}

/* ========== 全局抹杀 iframe 与 Netlify 浮动元素 ========== */
iframe,
iframe[src*="netlify"],
iframe[id*="netlify"],
#netlify-drawer,
.netlify-drawer,
[data-netlify-deploy-id],
div[id*="netlify"],
div[class*="netlify-feedback"],
netlify-drawer {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  top: -9999px !important;
  left: -9999px !important;
  z-index: -9999 !important;
}