/* My Village — Soft Peach / Clay / Spring Sage / Cream / Olive / Russet */
:root {
  /* forest → olive */
  --forest: #687960;
  --forest-soft: #9CA986;
  --forest-deep: #6B7858;
  --forest-dark: #344E41;
  /* sage → spring sage */
  --sage: #CEDEC4;
  --sage-soft: #DEE8D4;
  /* beige → soft peach */
  --beige: #E8D4C0;
  --beige-soft: #F0DFCE;
  /* clay → terracotta clay */
  --clay: #d29379;
  --clay-soft: #E2AF9A;
  --clay-deep: #B5775D;
  /* paper → cream */
  --ivory: #FBF6EF;
  --cream: #F6F0E8;
  --paper: #fafbf7;
  /* ink → warm near-black */
  --ink: #2C2620;
  --ink-soft: #5A4F42;
  --ink-mute: #8F8374;
  /* russet — deep earthy accent */
  --amber: #9C6A2A;
  --russet: #9C6A2A;
  --russet-soft: #B98545;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #F0E6D8;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

@media (max-width: 599px) {
  body {
    background: var(--paper);
    overscroll-behavior: none;
  }
  .canvas-bg {
    padding: 0;
    min-height: 100dvh;
    background: var(--paper);
  }
  #root {
    display: block !important;
    width: 100%;
  }
  .app.fullscreen {
    width: 100%;
    overflow-x: hidden;
  }
}

@media (display-mode: standalone) {
  body {
    background: var(--paper);
    overscroll-behavior: none;
  }
  .canvas-bg {
    padding: 0;
    min-height: 100dvh;
    background: var(--paper);
  }
  #root {
    display: block !important;
    width: 100%;
  }
  .app.fullscreen {
    width: 100%;
    overflow-x: hidden;
  }
}

.serif {
  font-family: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  font-optical-sizing: auto;
  letter-spacing: -0.01em;
}

/* Canvas background - warm paper */
.canvas-bg {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(210, 147, 121, 0.14), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(134, 148, 112, 0.18), transparent 55%),
    #F0E6D8;
  min-height: 100vh;
  padding: 40px 20px 80px;
}

/* App wrapper inside device */
.app {
  background: var(--paper);
  min-height: 100%;
  position: relative;
  padding-top: 50px; /* below status bar */
  padding-bottom: 96px; /* above tab bar */
}

/* Header */
.app-header {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  padding: 8px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

/* Fullscreen mode (real device / PWA — no phone frame) */
.app.fullscreen {
  min-height: 100dvh;
  padding-top: 0;
  padding-bottom: 0;
}

.app.fullscreen .app-header {
  position: fixed;
  top: 0;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(246, 240, 232, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid rgba(52,78,65,0.08);
}

.app.fullscreen .tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.app.fullscreen .sheet,
.app.fullscreen .tweaks-panel {
  position: fixed;
}

.app.fullscreen .screen {
  position: static;
  overflow-y: visible;
  min-height: unset;
  /* Override inline padding on individual screens */
  padding-top: max(60px, calc(env(safe-area-inset-top) + 52px)) !important;
  padding-bottom: max(72px, calc(env(safe-area-inset-bottom) + 60px)) !important;
}

.app.fullscreen .sheet-backdrop {
  position: fixed;
}

.app-header-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--forest);
  letter-spacing: -0.015em;
}

.village-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  background: rgba(52, 78, 65, 0.08);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--forest);
}

.village-dot {
  width: 16px;
  height: 16px;
  border-radius: 6px;
  background: var(--forest);
  display: inline-block;
}

/* Tab bar */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 12px 28px;
  background: rgba(253, 251, 246, 0.86);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 0.5px solid rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-around;
  z-index: 30;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-mute);
  transition: color 0.2s;
  font-family: inherit;
}
.tab.active { color: var(--forest); }
.tab-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tab-icon-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tab-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--clay);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid var(--paper);
}

/* Cards */
.card {
  background: white;
  border-radius: 20px;
  border: 1px solid rgba(52, 78, 65, 0.06);
  box-shadow: 0 1px 2px rgba(52, 78, 65, 0.04), 0 2px 8px rgba(52, 78, 65, 0.03);
}

.card-warm {
  background: var(--beige-soft);
  border-radius: 20px;
  border: 1px solid rgba(208, 140, 96, 0.12);
}

.card-forest {
  background: var(--forest);
  color: white;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(52, 78, 65, 0.18);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--clay);
  color: white;
}
.btn-primary:hover { background: var(--clay-deep); }

.btn-forest {
  background: var(--forest);
  color: white;
}

.btn-ghost {
  background: rgba(210, 147, 121, 0.18);
  color: var(--clay-deep);
}
.btn-ghost:hover { background: rgba(210, 147, 121, 0.28); }

.btn-sm {
  padding: 8px 14px;
  font-size: 12.5px;
  border-radius: 10px;
  width: auto;
}

/* Avatar */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--sage);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  font-family: 'Fraunces', serif;
  flex-shrink: 0;
  overflow: hidden;
}

/* Scroll container for each screen */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 96px;
  padding-bottom: 110px;
}
.screen::-webkit-scrollbar { display: none; }

/* Subtle dotted pattern for arches */
.arch-deco {
  position: absolute;
  pointer-events: none;
  opacity: 0.08;
}

/* Ticket shape */
.ticket {
  position: relative;
  background: var(--clay);
  color: white;
  border-radius: 16px;
  padding: 14px 16px;
}
.ticket::before, .ticket::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  top: 50%;
  transform: translateY(-50%);
}
.ticket::before { left: -8px; }
.ticket::after { right: -8px; }

.ticket-dash {
  border-left: 2px dashed rgba(255,255,255,0.35);
  padding-left: 12px;
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chip-sage { background: rgba(206, 222, 196, 0.55); color: var(--forest-deep); }
.chip-clay { background: rgba(210, 147, 121, 0.18); color: var(--clay-deep); }
.chip-forest { background: rgba(134, 148, 112, 0.18); color: var(--forest-deep); }
.chip-amber { background: rgba(156, 106, 42, 0.14); color: var(--russet); }

/* Segmented control */
.segmented {
  display: flex;
  background: rgba(52, 78, 65, 0.06);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 9px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
}
.segmented button.active {
  background: white;
  color: var(--forest);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* Transitions */
.screen-enter {
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sheet-enter {
  animation: sheetUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Bottom sheet */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 39, 35, 0.35);
  z-index: 40;
  animation: fadeIn 0.25s ease-out;
}
.sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-radius: 28px 28px 0 0;
  padding: 10px 20px 36px;
  z-index: 41;
  max-height: 82%;
  overflow-y: auto;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(43, 39, 35, 0.18);
  border-radius: 2px;
  margin: 0 auto 14px;
}

/* Hero arches (decorative SVG wrapper) */
.hero-arch {
  position: absolute;
  right: -30px;
  top: -30px;
  width: 200px;
  height: 200px;
  opacity: 0.12;
  pointer-events: none;
}

/* Inputs */
.input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(52, 78, 65, 0.12);
  background: white;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}
.input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(206, 222, 196, 0.45);
}

/* Numeric stepper */
.stepper {
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid rgba(52, 78, 65, 0.12);
  border-radius: 12px;
  overflow: hidden;
}
.stepper button {
  width: 40px;
  height: 44px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--forest);
  cursor: pointer;
  font-family: inherit;
}
.stepper button:hover { background: var(--beige-soft); }
.stepper-val {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--forest);
  font-family: 'Fraunces', serif;
}

/* Calendar dots */
.cal-day {
  width: 36px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  background: none;
  border: none;
  font-family: inherit;
}
.cal-day.active {
  background: var(--forest);
  color: white;
}
.cal-day.today:not(.active) {
  color: var(--clay);
}
.cal-day .dot {
  position: absolute;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--clay);
}
.cal-day.active .dot { background: var(--sage-soft); }
.cal-day.muted { color: var(--ink-mute); opacity: 0.35; }

/* Row in list */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.row + .row {
  border-top: 0.5px solid rgba(52, 78, 65, 0.08);
}

/* Divider */
.div-soft {
  height: 0.5px;
  background: rgba(52, 78, 65, 0.08);
  margin: 0;
}

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 280px;
  background: rgba(253, 251, 246, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(52, 78, 65, 0.12);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  font-size: 12.5px;
  z-index: 1000;
  color: var(--ink);
}
.tweaks-panel h3 {
  margin: 0 0 12px;
  font-family: 'Fraunces', serif;
  font-size: 16px;
  color: var(--forest);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tweak-row { margin-bottom: 12px; }
.tweak-row label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tweak-opts {
  display: flex;
  gap: 6px;
}
.tweak-opt {
  flex: 1;
  padding: 7px 8px;
  border-radius: 9px;
  border: 1px solid rgba(52, 78, 65, 0.14);
  background: white;
  font-size: 11.5px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.tweak-opt.active {
  background: var(--forest);
  color: white;
  border-color: var(--forest);
}

/* Theme: soft */
.theme-soft {
  --paper: #fafbf7;
  --forest: #687960;
  --clay: #E2AF9A;
}

/* Theme: dusk */
.theme-dusk {
  --paper: #2C2620;
  --ink: #F6F0E8;
  --ink-soft: #DEC9B0;
  --ink-mute: #8F8374;
  --forest: #CEDEC4;
  --beige: #3A3128;
  --beige-soft: #332B23;
  --cream: #3A3128;
}
.theme-dusk .card {
  background: #3A3128;
  border-color: rgba(246, 240, 232, 0.08);
}
.theme-dusk .card-warm {
  background: #3A3128;
}
.theme-dusk .tab-bar {
  background: rgba(44, 38, 32, 0.92);
  border-top-color: rgba(255,255,255,0.08);
}
.theme-dusk .input {
  background: #3A3128;
  color: var(--ink);
  border-color: rgba(246, 240, 232, 0.12);
}
.theme-dusk .app-header-title {
  color: var(--ink);
}
.theme-dusk .village-chip {
  background: rgba(206, 222, 196, 0.14);
  color: var(--forest);
}

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