/* =========================================
   Sonae (備え) ─ Design System & Styles
   ========================================= */

/* --- Design Tokens --- */
:root {
  /* Primary palette – calming teal */
  --c-primary: #1A7A6D;
  --c-primary-dark: #145F54;
  --c-primary-light: #2A9D8F;
  --c-primary-bg: #E0F2F0;

  /* Accent – warm amber */
  --c-accent: #E89B3E;
  --c-accent-dark: #C57F2A;
  --c-accent-light: #F5C882;

  /* Semantic */
  --c-danger: #E05252;
  --c-danger-bg: #FDE8E8;
  --c-warning: #E8A838;
  --c-warning-bg: #FEF3D6;
  --c-success: #3DAA6D;
  --c-success-bg: #DFF5E6;

  /* Neutral */
  --c-bg: #F4F7F6;
  --c-surface: #FFFFFF;
  --c-surface-alt: #EDF1F0;
  --c-border: #D8DFDE;
  --c-text: #1A2B2A;
  --c-text-2: #5A706E;
  --c-text-3: #8FA3A0;

  /* Spacing */
  --sp-xs: 4px;
  --sp-s: 8px;
  --sp-m: 16px;
  --sp-l: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Radius */
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 20px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-s: 0 1px 3px rgba(26, 43, 42, 0.06);
  --shadow-m: 0 4px 12px rgba(26, 43, 42, 0.08);
  --shadow-l: 0 8px 30px rgba(26, 43, 42, 0.12);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  --fs-xs: 12px;
  --fs-s: 14px;
  --fs-m: 16px;
  --fs-l: 20px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
  --fs-3xl: 40px;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-bold: 700;

  /* Layout */
  --header-h: calc(56px + env(safe-area-inset-top, 0px));
  --nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.3s;
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0D1B1A;
    --c-surface: #1A2B2A;
    --c-surface-alt: #243836;
    --c-border: #344846;
    --c-text: #E4EDEC;
    --c-text-2: #A0B5B3;
    --c-text-3: #6B8582;
    --c-primary-bg: #15302D;
    --c-danger-bg: #2D1515;
    --c-warning-bg: #2D2415;
    --c-success-bg: #152D1E;
    --shadow-s: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-m: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-l: 0 8px 30px rgba(0, 0, 0, 0.4);
  }
}

/* [data-theme="dark"] for manual toggle */
[data-theme="dark"] {
  --c-bg: #0D1B1A;
  --c-surface: #1A2B2A;
  --c-surface-alt: #243836;
  --c-border: #344846;
  --c-text: #E4EDEC;
  --c-text-2: #A0B5B3;
  --c-text-3: #6B8582;
  --c-primary-bg: #15302D;
  --c-danger-bg: #2D1515;
  --c-warning-bg: #2D2415;
  --c-success-bg: #152D1E;
  --shadow-s: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-m: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-l: 0 8px 30px rgba(0, 0, 0, 0.4);
}


/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  font-size: var(--fs-m);
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.6;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 var(--sp-m);
  padding-top: var(--safe-top);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.header.hidden {
  display: none;
}

.header-title {
  flex: 1;
  font-size: var(--fs-l);
  font-weight: var(--fw-bold);
  text-align: center;
}

.header-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--c-primary);
  cursor: pointer;
  border-radius: var(--r-s);
  transition: background var(--dur) var(--ease);
}

.header-btn:active {
  background: var(--c-primary-bg);
}

.header-btn svg {
  width: 24px;
  height: 24px;
}

/* --- Main Content Area --- */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* --- Bottom Nav --- */
.nav {
  display: flex;
  align-items: stretch;
  height: var(--nav-h);
  padding-bottom: var(--safe-bottom);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -2px 10px rgba(26, 43, 42, 0.04);
}

.nav.hidden {
  display: none;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--c-text-3);
  font-size: var(--fs-xs);
  font-family: var(--font);
  cursor: pointer;
  transition: color var(--dur) var(--ease);
  min-height: 44px;
}

.nav-item.active {
  color: var(--c-primary);
}

.nav-item svg {
  width: 24px;
  height: 24px;
  transition: transform var(--dur) var(--ease);
}

.nav-item.active svg {
  transform: scale(1.1);
}

.nav-label {
  font-weight: var(--fw-medium);
}


/* --- Screen Transitions --- */
.screen {
  animation: screenIn 0.35s var(--ease) both;
  padding: var(--sp-l) var(--sp-m);
  padding-bottom: calc(var(--sp-2xl) + var(--safe-bottom));
  min-height: 100%;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes screenOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-12px);
  }
}


/* --- Card --- */
.card {
  background: var(--c-surface);
  border-radius: var(--r-m);
  padding: var(--sp-l);
  box-shadow: var(--shadow-s);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.card:active {
  transform: scale(0.98);
}

.card+.card {
  margin-top: var(--sp-m);
}

.card-selectable {
  cursor: pointer;
  border: 2px solid transparent;
}

.card-selectable.selected {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-m);
}


/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-s);
  height: 52px;
  padding: 0 var(--sp-xl);
  border: none;
  border-radius: var(--r-full);
  font-family: var(--font);
  font-size: var(--fs-m);
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform 0.15s var(--ease), opacity var(--dur) var(--ease);
  min-width: 44px;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:active {
  background: var(--c-primary-dark);
}

.btn-secondary {
  background: var(--c-primary-bg);
  color: var(--c-primary);
}

.btn-secondary:active {
  background: var(--c-border);
}

.btn-accent {
  background: var(--c-accent);
  color: #fff;
}

.btn-accent:active {
  background: var(--c-accent-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--c-text-2);
}

.btn-ghost:active {
  background: var(--c-surface-alt);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  height: 40px;
  padding: 0 var(--sp-m);
  font-size: var(--fs-s);
}

.btn svg {
  width: 20px;
  height: 20px;
}


/* --- Counter (＋−) --- */
.counter {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
}

.counter-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary-bg);
  color: var(--c-primary);
  border: none;
  border-radius: var(--r-full);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform 0.15s var(--ease);
  -webkit-user-select: none;
  user-select: none;
}

.counter-btn:active {
  background: var(--c-primary);
  color: #fff;
  transform: scale(0.9);
}

.counter-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.counter-btn svg {
  width: 24px;
  height: 24px;
}

.counter-value {
  min-width: 48px;
  text-align: center;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}


/* --- Toggle (持ってる / まだ) --- */
.toggle-wrap {
  display: flex;
  border-radius: var(--r-full);
  background: var(--c-surface-alt);
  padding: 3px;
  gap: 2px;
  min-width: 140px;
  flex-shrink: 0;
}

.toggle-opt {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-full);
  background: transparent;
  font-family: var(--font);
  font-size: var(--fs-s);
  font-weight: var(--fw-medium);
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  min-height: 44px;
  white-space: nowrap;
  padding: 0 var(--sp-m);
}

.toggle-opt.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-s);
}

.toggle-opt[data-val="owned"].active {
  background: var(--c-success);
  color: #fff;
}

.toggle-opt[data-val="needed"].active {
  background: var(--c-warning);
  color: #fff;
}


/* --- Segment Control (age / build) --- */
.segment {
  display: flex;
  gap: var(--sp-xs);
  background: var(--c-surface-alt);
  border-radius: var(--r-m);
  padding: 3px;
}

.segment-item {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-s);
  background: transparent;
  font-family: var(--font);
  font-size: var(--fs-s);
  font-weight: var(--fw-medium);
  color: var(--c-text-3);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  min-height: 44px;
}

.segment-item.active {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: var(--shadow-s);
  font-weight: var(--fw-bold);
}


/* --- Progress Bar --- */
.progress {
  height: 8px;
  background: var(--c-surface-alt);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary-light), var(--c-primary));
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease);
}


/* --- Category Tabs --- */
.cat-tabs {
  display: flex;
  overflow-x: auto;
  gap: var(--sp-s);
  padding: var(--sp-s) 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.cat-tabs::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  height: 40px;
  padding: 0 var(--sp-m);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-full);
  background: var(--c-surface);
  font-family: var(--font);
  font-size: var(--fs-s);
  font-weight: var(--fw-medium);
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  min-height: 44px;
}

.cat-tab.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.cat-tab svg {
  width: 18px;
  height: 18px;
}

.cat-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.25);
  font-size: 11px;
  font-weight: var(--fw-bold);
}

.cat-tab:not(.active) .cat-tab-badge {
  background: var(--c-surface-alt);
}


/* --- Checklist Swipe Container --- */
.checklist-swipe {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: var(--sp-m) calc(-1 * var(--sp-m)) 0;
}

.checklist-swipe::-webkit-scrollbar {
  display: none;
}

.checklist-page {
  flex: 0 0 100%;
  scroll-snap-align: start;
  padding: 0 var(--sp-m);
  display: flex;
  flex-direction: column;
  gap: var(--sp-s);
  min-height: 200px;
}

/* --- Checklist Item --- */
.checklist-item {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m);
  background: var(--c-surface);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-s);
}

.checklist-item+.checklist-item {
  margin-top: var(--sp-s);
}

.checklist-item.owned {
  opacity: 0.55;
  background: var(--c-surface-alt);
}

.checklist-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary-bg);
  border-radius: var(--r-s);
  flex-shrink: 0;
}

.checklist-icon svg {
  width: 24px;
  height: 24px;
  color: var(--c-primary);
}

.checklist-info {
  flex: 1;
  min-width: 0;
}

.checklist-name {
  font-weight: var(--fw-medium);
  font-size: var(--fs-m);
}

.checklist-qty {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}


/* --- Expiry Item --- */
.expiry-item {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m);
  background: var(--c-surface);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-s);
}

.expiry-item+.expiry-item {
  margin-top: var(--sp-s);
}

.expiry-item.expiring-soon {
  border-left: 4px solid var(--c-warning);
}

.expiry-item.expired {
  border-left: 4px solid var(--c-danger);
  background: var(--c-danger-bg);
}

.expiry-date {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}

.expiry-date.warn {
  color: var(--c-warning);
  font-weight: var(--fw-bold);
}

.expiry-date.danger {
  color: var(--c-danger);
  font-weight: var(--fw-bold);
}


/* --- Onboarding --- */
.onboarding {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.onboarding-slides {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.onboarding-slides::-webkit-scrollbar {
  display: none;
}

.onboarding-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2xl) var(--sp-l);
  text-align: center;
  gap: var(--sp-xl);
}

.onboarding-illustration {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-illustration svg {
  width: 100%;
  height: 100%;
  color: var(--c-primary);
}

.onboarding-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: 1.4;
}

.onboarding-desc {
  font-size: var(--fs-m);
  color: var(--c-text-2);
  max-width: 280px;
  line-height: 1.7;
}

.onboarding-footer {
  padding: var(--sp-l) var(--sp-l) var(--sp-2xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-m);
}

.onboarding-dots {
  display: flex;
  gap: var(--sp-s);
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--c-border);
  transition: all var(--dur) var(--ease);
}

.onboarding-dot.active {
  width: 24px;
  background: var(--c-primary);
}


/* --- Entry Selection --- */
.entry-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  gap: var(--sp-l);
  padding-top: var(--sp-2xl);
}

.entry-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  text-align: center;
  margin-bottom: var(--sp-m);
}

.entry-cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-m);
  width: 100%;
  max-width: 360px;
}

.entry-card {
  display: flex;
  align-items: center;
  gap: var(--sp-l);
  padding: var(--sp-l) var(--sp-l);
  background: var(--c-surface);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-m);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--dur) var(--ease);
  min-height: 88px;
}

.entry-card:active {
  transform: scale(0.97);
  border-color: var(--c-primary);
}

.entry-card-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary-bg);
  border-radius: var(--r-m);
  flex-shrink: 0;
}

.entry-card-icon svg {
  width: 28px;
  height: 28px;
  color: var(--c-primary);
}

.entry-card-text h3 {
  font-size: var(--fs-l);
  font-weight: var(--fw-bold);
  margin-bottom: 2px;
}

.entry-card-text p {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}


/* --- Family Setup --- */
.family-section {
  margin-bottom: var(--sp-xl);
}

.family-section-title {
  font-size: var(--fs-s);
  font-weight: var(--fw-bold);
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--sp-m);
}

.family-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-m) 0;
  border-bottom: 1px solid var(--c-border);
}

.family-member:last-child {
  border-bottom: none;
}

.family-member-info {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
}

.family-member-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary-bg);
  border-radius: var(--r-full);
}

.family-member-icon svg {
  width: 24px;
  height: 24px;
  color: var(--c-primary);
}

.family-member-name {
  font-weight: var(--fw-medium);
}

/* --- Child Detail Card --- */
.child-detail {
  background: var(--c-surface);
  border-radius: var(--r-m);
  padding: var(--sp-m);
  margin-top: var(--sp-s);
  box-shadow: var(--shadow-s);
}

.child-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-m);
}

.child-detail-row:last-child {
  margin-bottom: 0;
}

.child-detail-label {
  font-size: var(--fs-s);
  color: var(--c-text-2);
  font-weight: var(--fw-medium);
}


/* --- Result Screen --- */
.result-header {
  text-align: center;
  padding: var(--sp-xl) 0;
}

.result-headline {
  font-size: var(--fs-l);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-s);
}

.result-sub {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-m);
  margin: var(--sp-l) 0;
}

.result-card {
  background: var(--c-surface);
  border-radius: var(--r-m);
  padding: var(--sp-m);
  box-shadow: var(--shadow-s);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-s);
  text-align: center;
}

.result-card-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary-bg);
  border-radius: var(--r-m);
}

.result-card-icon svg {
  width: 24px;
  height: 24px;
  color: var(--c-primary);
}

.result-card-value {
  font-size: var(--fs-l);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
  white-space: nowrap;
}

.result-card-label {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}


/* --- Settings --- */
.settings-group {
  margin-bottom: var(--sp-xl);
}

.settings-group-title {
  font-size: var(--fs-s);
  font-weight: var(--fw-bold);
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--sp-m);
  padding-left: var(--sp-xs);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-m);
  background: var(--c-surface);
  border-radius: var(--r-m);
  margin-bottom: 1px;
  cursor: pointer;
  min-height: 52px;
}

.settings-item:first-of-type {
  border-radius: var(--r-m) var(--r-m) 0 0;
}

.settings-item:last-of-type {
  border-radius: 0 0 var(--r-m) var(--r-m);
  margin-bottom: 0;
}

.settings-item:only-of-type {
  border-radius: var(--r-m);
}

.settings-item-label {
  font-weight: var(--fw-medium);
}

.settings-item-value {
  color: var(--c-text-2);
  font-size: var(--fs-s);
}

.settings-item-arrow {
  color: var(--c-text-3);
}

.settings-item-arrow svg {
  width: 20px;
  height: 20px;
}


/* --- Expiry Date Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 500px;
  background: var(--c-surface);
  border-radius: var(--r-l) var(--r-l) 0 0;
  padding: var(--sp-l);
  padding-bottom: calc(var(--sp-l) + var(--safe-bottom));
  animation: slideUp 0.3s var(--ease);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--c-border);
  border-radius: var(--r-full);
  margin: 0 auto var(--sp-l);
}

.modal-title {
  font-size: var(--fs-l);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-l);
  text-align: center;
}

.modal-input-group {
  margin-bottom: var(--sp-l);
}

.modal-label {
  font-size: var(--fs-s);
  font-weight: var(--fw-medium);
  color: var(--c-text-2);
  margin-bottom: var(--sp-s);
  display: block;
}

.modal-input {
  width: 100%;
  height: 48px;
  padding: 0 var(--sp-m);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-m);
  background: var(--c-bg);
  font-family: var(--font);
  font-size: var(--fs-m);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

.modal-input:focus {
  border-color: var(--c-primary);
}

.modal-actions {
  display: flex;
  gap: var(--sp-m);
}

.modal-actions .btn {
  flex: 1;
}


/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2xl) var(--sp-l);
  text-align: center;
  gap: var(--sp-m);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  color: var(--c-text-3);
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--fs-m);
  color: var(--c-text-2);
  line-height: 1.6;
}


/* =========================================
   Phase 2: Product Recommendations
   ========================================= */

/* --- Product Tiers Card Grid --- */
.product-tiers {
  display: flex;
  flex-direction: column;
  gap: var(--sp-m);
  margin-bottom: var(--sp-l);
}

.product-card {
  display: block;
  position: relative;
  padding: var(--sp-m) var(--sp-l);
  border-radius: var(--r-m);
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all var(--dur) var(--ease);
  overflow: hidden;
}

.product-card:active {
  transform: scale(0.98);
}

.product-card.budget {
  border-color: var(--c-success);
  background: var(--c-success-bg);
}

.product-card.standard {
  border-color: var(--c-primary);
  background: var(--c-primary-bg);
  box-shadow: var(--shadow-m);
}

.product-card.premium {
  border-color: var(--c-accent);
  background: var(--c-warning-bg);
}

.product-tier-label {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  padding: 2px 10px;
  border-radius: var(--r-full);
  margin-bottom: var(--sp-s);
}

.product-card.budget .product-tier-label {
  background: var(--c-success);
  color: #fff;
}

.product-card.standard .product-tier-label {
  background: var(--c-primary);
  color: #fff;
}

.product-card.premium .product-tier-label {
  background: var(--c-accent);
  color: #fff;
}

.product-tier-name {
  font-weight: var(--fw-bold);
  font-size: var(--fs-m);
  margin-bottom: var(--sp-xs);
}

.product-tier-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  margin-bottom: var(--sp-s);
}

.product-price {
  font-size: var(--fs-l);
  font-weight: var(--fw-bold);
  color: var(--c-primary-dark);
}

.product-shelf {
  font-size: var(--fs-xs);
  color: var(--c-text-2);
  background: var(--c-surface-alt);
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.product-tier-cta {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--fs-s);
  color: var(--c-primary);
  font-weight: var(--fw-medium);
}

.product-tier-cta svg {
  width: 16px;
  height: 16px;
}


/* =========================================
   Phase 2: Rolling Stock
   ========================================= */

.rolling-stock-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m) var(--sp-l);
  background: linear-gradient(135deg, var(--c-primary-bg) 0%, var(--c-surface) 100%);
  border: 1.5px solid var(--c-primary);
  border-radius: var(--r-m);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.rolling-stock-banner:active {
  transform: scale(0.98);
  background: var(--c-primary-bg);
}

.rolling-stock-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary);
  border-radius: var(--r-m);
  flex-shrink: 0;
}

.rolling-stock-icon svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.rolling-stock-info {
  flex: 1;
}

.rolling-stock-title {
  font-weight: var(--fw-bold);
  font-size: var(--fs-m);
}

.rolling-stock-desc {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}

.rolling-stock-arrow {
  color: var(--c-primary);
}

.rolling-stock-arrow svg {
  width: 20px;
  height: 20px;
}

/* Flow visualization (consume → buy → update) */
.rolling-stock-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-m);
  padding: var(--sp-l) 0;
}

.flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-s);
}

.flow-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-alt);
  border-radius: var(--r-full);
  transition: all var(--dur) var(--ease);
}

.flow-icon.active {
  background: var(--c-primary);
  color: #fff;
}

.flow-icon svg {
  width: 22px;
  height: 22px;
}

.flow-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--c-text-2);
}

.flow-arrow {
  color: var(--c-text-3);
  font-size: var(--fs-l);
  margin-top: -20px;
}


/* =========================================
   Phase 2: Expiry Summary
   ========================================= */

.expiry-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m) var(--sp-l);
  background: var(--c-surface);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-s);
  flex-wrap: wrap;
}

.expiry-summary-count {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
}

.expiry-summary-label {
  font-size: var(--fs-s);
  color: var(--c-text-2);
}

.expiry-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  gap: var(--sp-xs);
}

.expiry-badge.danger {
  background: var(--c-danger-bg);
  color: var(--c-danger);
}

.expiry-badge.warning {
  background: var(--c-warning-bg);
  color: var(--c-warning);
}

/* Near expiry (90 days) - different from soon (30 days) */
.expiry-item.expiring-near {
  border-left: 4px solid var(--c-text-3);
}


/* =========================================
   Phase 2: Shopping List
   ========================================= */

.shopping-item {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m);
  border-bottom: 1px solid var(--c-border);
}

.shopping-item:last-child {
  border-bottom: none;
}


/* =========================================
   Phase 2: Small Icon Buttons
   ========================================= */

.btn-icon-s {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--r-full);
  color: var(--c-primary);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
}

.btn-icon-s:active {
  background: var(--c-primary-bg);
  transform: scale(0.9);
}

.btn-icon-s svg {
  width: 20px;
  height: 20px;
}

/* Expiry actions row */
.expiry-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}


/* =========================================
   Phase 2: Modal Improvements
   ========================================= */

/* Animated modal overlay */
.modal-overlay {
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.modal-overlay.visible {
  opacity: 1;
}

.modal-overlay .modal-sheet {
  transform: translateY(100%);
  transition: transform 0.35s var(--ease);
}

.modal-overlay.visible .modal-sheet {
  transform: translateY(0);
}

/* Override old animation */
.modal-overlay .modal-sheet {
  animation: none;
}

/* Improved modal actions - stack on small screens */
.modal-actions {
  flex-direction: column;
  gap: var(--sp-s);
}


/* =========================================
   Phase 2: Photo Preview
   ========================================= */

.photo-preview {
  border-radius: var(--r-m);
  overflow: hidden;
  background: var(--c-surface-alt);
}


/* --- Utility --- */
.text-center {
  text-align: center;
}

.mt-s {
  margin-top: var(--sp-s);
}

.mt-m {
  margin-top: var(--sp-m);
}

.mt-l {
  margin-top: var(--sp-l);
}

.mt-xl {
  margin-top: var(--sp-xl);
}

.mb-m {
  margin-bottom: var(--sp-m);
}

.mb-l {
  margin-bottom: var(--sp-l);
}

.gap-s {
  gap: var(--sp-s);
}

.gap-m {
  gap: var(--sp-m);
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* --- Legal Content --- */
.legal-content {
  padding: var(--sp-m);
  font-size: var(--fs-s);
  line-height: 1.8;
  color: var(--c-text);
}

.legal-content h3 {
  font-size: var(--fs-m);
  font-weight: var(--fw-bold);
  margin-top: var(--sp-l);
  margin-bottom: var(--sp-s);
  color: var(--c-text);
}

.legal-content p {
  margin-bottom: var(--sp-m);
}

.legal-content ul {
  margin-bottom: var(--sp-m);
  padding-left: var(--sp-l);
}

.legal-content li {
  margin-bottom: var(--sp-xs);
}