@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
  --bg: #faf5f0;
  --surface: #ffffff;
  --primary: #d4869e;
  --primary-light: #f0d6e0;
  --primary-dark: #b86a82;
  --secondary: #9cb4a0;
  --secondary-light: #dce8de;
  --text: #3d2c2c;
  --text-2: #8a7a7a;
  --text-3: #b8a8a8;
  --border: #ede4e4;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

input, button, textarea { font-family: inherit; }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s ease;
  white-space: nowrap;
  background: var(--text);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.toast.error { background: #e86868; }
.toast.success { background: var(--secondary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Login Page ── */
#page-login {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 48px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}

.login-logo {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
}

.login-title {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 32px;
}

.input-group {
  position: relative;
  margin-bottom: 12px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--primary);
}

.input-group input::placeholder {
  color: var(--text-3);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-2);
  width: auto;
  padding: 8px;
  cursor: pointer;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
}

.auth-tab.active {
  color: var(--primary-dark);
  background: var(--primary-light);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-3);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-footer {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  margin-top: 24px;
}

/* ── App Container (Home + sub pages) ── */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.app-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* ── Home Page ── */
.page {
  display: none;
  padding: 0 20px 80px;
}

.page.active { display: block; }

.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 12px;
}

.section-label::before {
  content: '';
  width: 3px; height: 14px;
  background: var(--primary);
  border-radius: 2px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.chart-container {
  height: 120px;
  position: relative;
  margin-top: 8px;
}
.chart-container canvas {
  width: 100%;
  height: 100%;
}

.region-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.region-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.region-chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.capture-btn {
  width: 100%;
  padding: 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.capture-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary-light);
  margin-top: 6px;
  flex-shrink: 0;
}

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

.timeline-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 13px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.nav-inner {
  display: flex;
  gap: 4px;
  max-width: 480px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  border: none;
  background: none;
  font-weight: 500;
}

.nav-item.active {
  color: var(--primary-dark);
  background: var(--primary-light);
}

/* ── Camera ── */
#page-camera {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
}

.camera-preview {
  width: 100%;
  height: 100%;
  position: relative;
}

.camera-preview video, .camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-close {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-bottom {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  z-index: 10;
}

.camera-gallery {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-shutter {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255,255,255,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-shutter-inner {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ddd;
}

.camera-retake {
  display: none;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.camera-confirm {
  display: none;
  position: absolute;
  bottom: 120px;
  left: 16px;
  right: 16px;
  z-index: 10;
}

/* ── History ── */
.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.sub-header h2 {
  font-size: 18px;
  font-weight: 700;
}

/* ── Profile ── */
.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.profile-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.profile-name {
  font-weight: 600;
  font-size: 15px;
}

.profile-plan {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 2px;
}

.menu-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.menu-row + .menu-row {
  border-top: 1px solid var(--border);
}

.menu-row:hover {
  background: var(--bg);
}

.menu-row span:first-child { font-size: 16px; }
.menu-row span:nth-child(2) { flex: 1; color: var(--text); }
.menu-row .arrow { color: var(--text-3); }

.btn-danger {
  border: 1.5px solid #f0b0b0;
  color: #c86868;
  background: var(--surface);
}

.btn-danger:hover {
  background: #fdf0f0;
}

.version {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  margin-top: 32px;
}

/* ── Pro ── */
.pro-banner {
  background: linear-gradient(135deg, #faf0e6, #f5e6d0);
  border: 1px solid #e8d5c0;
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}

.pro-banner h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pro-price {
  font-size: 32px;
  font-weight: 700;
  margin: 12px 0;
}

.pro-price span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-2);
}

.pro-features {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.pro-features li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-2);
}

.pro-features li::before {
  content: '✓ ';
  color: var(--secondary);
  font-weight: 700;
}

/* ── Scan overlay ── */
.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(250, 245, 240, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.scan-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.scan-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

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

/* ── Detail Modal ── */
.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
}

.detail-close {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.detail-content {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.detail-image {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--surface);
}

.detail-image img {
  width: 100%;
  display: block;
}

.detail-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

@media (max-width: 480px) {
  .detail-modal { padding: 0; }
  .detail-content { padding: 0; }
  .detail-close { padding: 16px 16px 0; }
  .detail-image { border-radius: 0; }
  .detail-info { border-radius: 0; border-left: none; border-right: none; }
}
