:root {
  --background: #fbfefd;
  --foreground: #0f1724;
  --border: #00000014;
  --input: #ffffff;
  --primary: #2BB7A9;
  --primary-foreground: #ffffff;
  --secondary: #eef9f7;
  --secondary-foreground: #0a6b5c;
  --muted: #f6f7f8;
  --muted-foreground: #9aa3ad;
  --success: #dff7ef;
  --success-foreground: #07694f;
  --accent: #ffd166;
  --accent-foreground: #352100;
  --destructive: #ffefef;
  --destructive-foreground: #8b1e1e;
  --warning: #fff4e5;
  --warning-foreground: #664400;
  --card: #ffffff;
  --card-foreground: #0f1724;
  --sidebar: #f6fbfa;
  --sidebar-foreground: #0b2630;
  --sidebar-primary: #e2f9f5;
  --sidebar-primary-foreground: #0a6b5c;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --font-family-body: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family-body);
  background-color: var(--background);
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.menu-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xl);
  background: var(--muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--card);
  z-index: 9999;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
}

.drawer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.drawer-user-info {
  flex: 1;
  min-width: 0;
}

.drawer-user-email {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-user-credits {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.drawer-nav {
  flex: 1;
  padding: 8px 0;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family-body);
  transition: background 0.15s ease;
}

.drawer-nav-item:hover {
  background: var(--muted);
}

.drawer-nav-item.active {
  background: var(--sidebar-primary);
  color: var(--sidebar-primary-foreground);
  font-weight: 600;
}

.drawer-nav-item iconify-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.drawer-nav-item.logout {
  color: var(--destructive-foreground);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
  width: 100%;
}

.page-header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--foreground);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xl);
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.back-text-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-family-body);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.list-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.list-card:hover {
  background: var(--muted);
}

.list-card + .list-card {
  border-top: 1px solid var(--border);
}

.list-card-photo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--muted);
  flex-shrink: 0;
}

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

.list-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-sub {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.list-card-right {
  text-align: right;
  flex-shrink: 0;
}

.list-card-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--success-foreground);
}

.list-card-date {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  font-size: 40px;
  color: var(--muted-foreground);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
}

.empty-state-sub {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.settings-group {
  padding: 0 20px;
}

.settings-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  padding: 20px 0 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

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

.settings-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}

.settings-sub {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--muted);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.info-section {
  padding: 20px;
}

.info-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.info-block:last-child {
  border-bottom: none;
}

.info-block-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 8px;
}

.info-block-text {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--muted);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}

.narrative-overlay-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 36, 0.35);
  z-index: 9998;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.narrative-overlay-backdrop.active {
  display: block;
}

.narrative-overlay {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: var(--card, #fff);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(15, 23, 36, 0.12);
  z-index: 9999;
  overflow: hidden;
  flex-direction: column;
}
.narrative-overlay.active {
  display: flex;
}

.narrative-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border, #eee);
}

.narrative-overlay-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground, #0f1724);
}

.narrative-overlay-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--muted-foreground, #9aa3ad);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.narrative-overlay-close:active {
  background: var(--muted, #f6f7f8);
}

.narrative-overlay-body {
  padding: 12px 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.narrative-section {
  margin-bottom: 14px;
}
.narrative-section:last-child {
  margin-bottom: 0;
}

.narrative-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground, #9aa3ad);
  margin-bottom: 3px;
}

.narrative-section-value {
  font-size: 13px;
  color: var(--foreground, #0f1724);
  line-height: 1.45;
}
.narrative-section-value .mono {
  font-family: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 12px;
}

.narrative-outlier-list {
  margin-top: 4px;
  padding-left: 14px;
  font-size: 12px;
  color: var(--muted-foreground, #9aa3ad);
  line-height: 1.5;
}
.narrative-outlier-list li {
  margin-bottom: 2px;
  word-break: break-word;
}
.narrative-outlier-reason {
  font-style: italic;
  color: var(--destructive-foreground, #8b1e1e);
  font-size: 11px;
}

.confidence-tappable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.confidence-tappable:active {
  opacity: 0.65;
}

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.welcome-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.welcome-overlay-content {
  text-align: center;
  color: #1a2b3c;
  max-width: 360px;
  padding: 40px 28px;
}
.welcome-overlay-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.welcome-overlay-logo svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
  animation: welcomePulse 3s ease-in-out infinite;
}
@keyframes welcomePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
.welcome-overlay-logo span {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #1a2b3c;
}
.welcome-subtitle {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.welcome-overlay-content h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  color: #1a2b3c;
  line-height: 1.3;
}
.welcome-overlay-content p {
  font-size: 15px;
  font-weight: 400;
  color: #546e7a;
  line-height: 1.6;
  margin-bottom: 36px;
}
.welcome-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 16px;
  font-weight: 700;
  padding: 14px 36px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 8px 24px -6px rgba(43, 183, 169, 0.4);
}
.welcome-start-btn:active {
  transform: scale(0.97);
}
.welcome-skip-btn {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: #90a4ae;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 10001;
  pointer-events: none;
}

.return-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  max-width: 480px;
  width: 100%;
  z-index: 9000;
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  transition: transform 0.35s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.return-banner.visible {
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .confetti-canvas { display: none; }
  .welcome-overlay { transition: none; }
  .welcome-overlay-logo svg { animation: none; }
  .return-banner { transition: none; }
}