:root {
  --canvas: #FFF8F6;
  --paper: #FFFFFF;
  --surface-1: #FBF3F1;
  --surface-2: #F3E8E6;
  --divider: #EDE0DD;
  --ink: #1C1418;
  --text-secondary: #6E5C64;
  --text-tertiary: #A08E96;
  --rose: #F43F7A;
  --rose-pressed: #D62E66;
  --rose-soft: #FFE4EE;
  --rose-mist: #FFF0F5;
  --success: #1F9B6C;
  --error: #E23D4D;
  --radius-card: 16px;
  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-ui: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: linear-gradient(165deg, #FFE8F0 0%, #FFF0F5 42%, #FFF8F6 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  overflow: hidden;
}
body {
  display: flex;
  flex-direction: column;
}
button, input, textarea, select { font-family: inherit; }
button { border: none; background: none; padding: 0; cursor: pointer; color: inherit; }
img {
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.grain::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; animation: screenIn 180ms ease; }

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(12px + var(--safe-top)) 16px calc(24px + var(--tab-h) + var(--safe-bottom));
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll::-webkit-scrollbar,
.template-rail::-webkit-scrollbar,
.sample-rail::-webkit-scrollbar,
.filter-bar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
.scroll.edge {
  padding-left: 0;
  padding-right: 0;
}
.scroll.edge > .pad { padding-left: 16px; padding-right: 16px; }

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.h1 { font-size: 34px; }
.h2 { font-size: 28px; }
.h3 { font-size: 22px; }
.meta { color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.caption { color: var(--text-tertiary); font-size: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: none;
  box-shadow: 0 6px 16px rgba(244,63,122,0.12);
  transition: transform 120ms ease, background 150ms ease, opacity 150ms ease, box-shadow 180ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, #FF6B9A 0%, var(--rose) 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 8px 22px rgba(244,63,122,0.28);
}
.btn-primary:active { background: var(--rose-pressed); }
.btn-ink { background: var(--ink); color: #fff; box-shadow: 0 6px 16px rgba(28,20,24,0.18); }
.btn-soft {
  background: linear-gradient(180deg, #FFF0F5 0%, var(--rose-soft) 100%);
  color: #B01D4F;
  border: 1px solid rgba(244,63,122,0.16);
  box-shadow: 0 4px 14px rgba(244,63,122,0.1);
}
.btn-outline {
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  border: 1.5px solid rgba(244,63,122,0.22);
  min-height: 44px;
  box-shadow: 0 2px 10px rgba(28,20,24,0.04);
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(28,20,24,0.04);
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
}
.chip.active {
  background: var(--rose-soft);
  color: #B01D4F;
  border-color: rgba(244,63,122,0.35);
  box-shadow: 0 0 0 1.5px rgba(244,63,122,0.35), 0 4px 12px rgba(244,63,122,0.12);
}
.chip.daily { background: #F3EDE6; color: #7A5C3E; }
.chip.date { background: #FFE4EE; color: #C2185B; }
.chip.party { background: #F3E8FF; color: #6B3FA0; }
.chip.work { background: #E8F0F5; color: #2F5F7A; }
.chip.travel { background: #E6F5EF; color: #1F7A5A; }

.field {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 20px;
  background: var(--surface-2);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
.field:focus { box-shadow: inset 0 0 0 1.5px var(--rose-soft); }
textarea.field { min-height: 96px; resize: none; line-height: 1.45; }

.card {
  background: var(--paper);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 2px rgba(28,20,24,0.04), 0 8px 24px rgba(244,63,122,0.06);
  overflow: hidden;
}
.card:active { transform: scale(0.98); }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(255,248,246,0.92);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-top: 0.5px solid var(--divider);
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  min-height: 44px;
}
.tab span { display: none !important; }
.tab img {
  width: 34px;
  height: 34px;
  opacity: 0.72;
}
.tab.active { color: var(--rose); }
.tab.active img {
  opacity: 1;
  width: 36px;
  height: 36px;
  filter: invert(42%) sepia(82%) saturate(2800%) hue-rotate(314deg) brightness(97%) contrast(96%);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(28,20,24,0.28);
  z-index: 80;
  display: none;
  align-items: flex-end;
}
.sheet.open { display: flex; animation: sheetScrimIn 180ms ease; }
.sheet-panel {
  width: 100%;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: sheetUp 280ms ease;
}
