/* Haru — cozy JP/KR paper theme (palette from ios/Haru/Theme.swift). */
@font-face { font-family: "Zen Maru Gothic"; src: url(fonts/ZenMaruGothic-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Zen Maru Gothic"; src: url(fonts/ZenMaruGothic-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Gowun Dodum"; src: url(fonts/GowunDodum-Regular.ttf) format("truetype"); font-display: swap; }
@font-face { font-family: "Nanum Pen Script"; src: url(fonts/NanumPenScript-Regular.ttf) format("truetype"); font-display: swap; }

:root {
  --paper: #F6EFE2;
  --paper-deep: #EFE4D0;
  --card: #FFFAF1;
  --ink: #3A3240;
  --muted: #9A8F93;
  --sakura: #F4B9C6;
  --matcha: #9DBF8E;
  --hojicha: #B07A5A;
  --persimmon: #E8875A;
  --yuzu: #F2C14E;
  --indigo: #4F5D7E;
  --hanko: #D2493F;
  --radius: 28px;
  --shadow: 0 14px 30px -14px rgba(176, 122, 90, 0.45);
  --font: "Zen Maru Gothic", "Gowun Dodum", "Hiragino Maru Gothic ProN", "Apple SD Gothic Neo", system-ui, sans-serif;
  --tabs-h: 64px;
  --safe-b: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-t: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  background-image: radial-gradient(rgba(176, 122, 90, 0.07) 1px, transparent 1.2px);
  background-size: 7px 7px;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }
h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }

.app { max-width: 520px; margin: 0 auto; min-height: 100%; position: relative; }
#main { padding: calc(14px + var(--safe-t)) 16px calc(var(--tabs-h) + 96px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.boot { display: grid; place-items: center; gap: 12px; padding-top: 22vh; font-size: 28px; font-weight: 700; color: var(--hojicha); }
.boot img { width: 160px; border-radius: 28px; box-shadow: var(--shadow); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-top: 8px; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: .02em; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--persimmon); font-size: 22px; }
.icon-btn svg, .tab svg, .fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sample-banner { align-self: center; font-size: 11px; color: var(--hojicha); background: rgba(242, 193, 78, .25); border-radius: 99px; padding: 4px 12px; }

.card { background: var(--card); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); }
.eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .04em; margin: 4px 0 6px; }
.section { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 10px 4px -4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.center { text-align: center; justify-content: center; }
.big-muted { font-size: 22px; color: var(--hojicha); font-weight: 700; }
.empty { text-align: center; padding: 60px 0; display: grid; gap: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.chev { color: var(--muted); font-size: 22px; margin-left: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--persimmon); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; font-weight: 700; box-shadow: 0 8px 18px -10px rgba(232, 135, 90, .9); cursor: pointer; }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(176, 122, 90, .25); font-weight: 400; }
.btn.danger { background: var(--card); color: var(--hanko); box-shadow: inset 0 0 0 1.5px rgba(210, 73, 63, .35); margin-top: 18px; width: 100%; }
.btn.wide { width: 100%; padding: 14px; font-size: 16px; }

/* Day card */
.day-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 22px 40px -18px rgba(176, 122, 90, .55); cursor: pointer; display: grid; gap: 12px; position: relative;
  background-image: radial-gradient(rgba(176, 122, 90, .05) 1px, transparent 1.3px); background-size: 5px 5px; }
.dc-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dc-date { font-size: 28px; font-weight: 700; letter-spacing: .04em; }
.dc-wd { font-size: 12px; color: var(--muted); }
.hanko { width: 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--hanko); color: var(--hanko); display: grid; place-items: center; font-weight: 700; font-size: 18px; transform: rotate(-8deg); opacity: .9; }
.dc-scene { position: relative; border-radius: 20px; overflow: visible; }
.dc-scene > img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 20px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.04); background: var(--paper-deep); }
.day-card:not(.big) .dc-scene > img { aspect-ratio: 4 / 3; }
.chip { position: absolute; top: 10px; left: 10px; background: rgba(58, 50, 64, .45); color: #fff; font-size: 11px; padding: 3px 10px; border-radius: 99px; backdrop-filter: blur(6px); }
.polaroid { position: absolute; right: -8px; bottom: -14px; width: 34%; margin: 0; background: #fff; padding: 6px 6px 18px; border-radius: 4px; box-shadow: 0 10px 18px -8px rgba(58, 50, 64, .45); transform: rotate(4deg); }
.polaroid::before { content: ""; position: absolute; top: -8px; left: 30%; width: 40%; height: 14px; background: rgba(244, 185, 198, .75); transform: rotate(-4deg); }
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.note { font-size: 16px; line-height: 1.6; }
.note.ko { font-family: "Nanum Pen Script", "Gowun Dodum", var(--font); font-size: 21px; line-height: 1.35; }
.note.muted { color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 11.5px; padding: 4px 10px; border-radius: 99px; background: rgba(157, 191, 142, .3); }
.pill.matcha { background: rgba(157, 191, 142, .32); }
.pill.sakura { background: rgba(244, 185, 198, .38); }
.pill.yuzu { background: rgba(242, 193, 78, .32); }
.pill.indigo { background: rgba(79, 93, 126, .18); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wk { display: grid; gap: 3px; justify-items: center; font-size: 11px; color: var(--muted); }
.wk img, .wk-empty { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--paper-deep); }
.wk.on img, .wk.on .wk-empty { box-shadow: 0 0 0 2.5px var(--persimmon); }

.prompt-text { font-size: 17px; line-height: 1.5; }
.walk, .tidy-invite, .memory { display: flex; align-items: center; gap: 14px; }
.walk .btn { margin-left: auto; }
.walk-title { font-weight: 700; font-size: 15px; }
.walk-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--matcha); flex: none; }
.walk-dot.live { background: var(--persimmon); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(232, 135, 90, 0); transform: scale(1.15); } 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 135, 90, .5); } }
.tidy-invite { cursor: pointer; }
.tidy-stack { position: relative; width: 38px; height: 44px; flex: none; }
.tidy-stack span { position: absolute; inset: 0; border-radius: 8px; background: #fff; box-shadow: 0 3px 8px -3px rgba(58,50,64,.4); }
.tidy-stack span:nth-child(1) { transform: rotate(-10deg); background: var(--sakura); }
.tidy-stack span:nth-child(2) { transform: rotate(6deg); background: var(--yuzu); }
.moment { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 18px; padding: 12px; }
.thumb { width: 58px; height: 58px; border-radius: 12px; object-fit: cover; flex: none; }

/* Tabs */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(520px, 100%); height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255, 250, 241, .92); backdrop-filter: blur(14px); border-top: 1px solid rgba(176, 122, 90, .15); z-index: 20; }
.tab { display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 10.5px; color: var(--muted); }
.tab.on { color: var(--persimmon); }
.fab { position: absolute; right: 18px; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); width: 58px; height: 58px; border-radius: 50%; background: var(--persimmon); color: #fff; display: grid; place-items: center; box-shadow: 0 14px 24px -10px rgba(232, 135, 90, .95); }
.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }

/* Days */
.segmented { display: flex; background: var(--paper-deep); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented a, .segmented button { flex: 1; text-align: center; padding: 7px 0; border-radius: 10px; font-size: 13px; color: var(--muted); }
.segmented .on { background: var(--card); color: var(--ink); box-shadow: 0 2px 6px -2px rgba(58,50,64,.25); }
.search { width: 100%; border: 0; background: var(--paper-deep); border-radius: 12px; padding: 10px 14px; outline: none; }
.deck { position: relative; height: 560px; perspective: 1200px; margin-top: 6px; }
.deck-card { position: absolute; inset: 0 8px auto; transform: translateY(calc(var(--depth) * 14px)) scale(calc(1 - var(--depth) * .05)) rotate(calc(var(--depth) * -2deg)); transition: transform .5s cubic-bezier(.2, .9, .3, 1.1), opacity .3s; touch-action: pan-y; user-select: none; }
.deck-card:nth-last-child(2) { transform: translateY(14px) scale(.95) rotate(2.4deg); }
.deck-foot { display: flex; justify-content: center; align-items: center; gap: 10px; }
.timeline { display: grid; gap: 10px; }
.tl-row { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--card); border-radius: 18px; padding: 10px; box-shadow: var(--shadow); }
.tl-row img { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; flex: none; }
.tl-row .note { font-size: 14px; line-height: 1.45; }
.tl-row .note.ko { font-size: 18px; }
.tl-date { font-size: 12px; color: var(--muted); }
.calendar { background: var(--card); border-radius: 22px; padding: 12px; box-shadow: var(--shadow); }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); }
.cal-cell { aspect-ratio: 1; border-radius: 10px; position: relative; display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.cal-cell.has img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.cal-cell.has span { position: relative; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); font-weight: 700; }

/* Map */
#map { height: calc(100vh - 260px); min-height: 360px; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); background: var(--paper-deep); }
#map.paper .tiles { opacity: .22 !important; filter: sepia(.8) saturate(.3) contrast(.85); }
#map .leaflet-control-attribution { font-size: 9px; background: rgba(255,250,241,.75); border-radius: 0 0 0 8px; }
#map.paper { background: #f3e9d7; background-image: radial-gradient(rgba(176,122,90,.08) 1px, transparent 1.3px); background-size: 6px 6px; }
.leaflet-container { font-family: var(--font); }
.map-stats { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: -78px; margin-inline: 12px; position: relative; z-index: 500; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch i { width: 44px; height: 26px; border-radius: 99px; background: var(--paper-deep); position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + i { background: var(--matcha); }
.switch input:checked + i::after { transform: translateX(18px); }
.list-row.switch { justify-content: space-between; }

/* Memories */
.memory { text-align: left; width: 100%; }
.quote { font-size: 20px; line-height: 1.5; }
.list { padding: 4px 0; }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 16px; border-bottom: 1px solid rgba(176,122,90,.12); }
.list-row:last-child { border-bottom: 0; }
.list-row .ico { font-size: 20px; }
.list-row .count { margin-left: auto; color: var(--muted); }
.list-row .chev { margin-left: 4px; }
.check { margin-left: auto; color: var(--persimmon); font-weight: 700; }

/* Sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(58, 50, 64, .28); z-index: 40; animation: fade .25s; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); max-height: calc(100% - 28px - var(--safe-t)); background: var(--paper); border-radius: 26px 26px 0 0; z-index: 41; display: flex; flex-direction: column; animation: up .38s cubic-bezier(.2,.9,.3,1.05); box-shadow: 0 -20px 40px -20px rgba(58,50,64,.4); }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 16px 18px 10px; }
.sheet-head .link { color: var(--persimmon); justify-self: start; font-size: 15px; }
.sheet-head .link.strong { justify-self: end; font-weight: 700; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
@keyframes up { from { transform: translate(-50%, 100%); } }
@keyframes fade { from { opacity: 0; } }
textarea, select { width: 100%; border: 0; border-radius: 16px; background: var(--card); padding: 14px; resize: vertical; outline: none; box-shadow: inset 0 0 0 1px rgba(176,122,90,.15); }
.photo-pick { display: grid; place-items: center; min-height: 140px; border-radius: 20px; background: var(--card); box-shadow: inset 0 0 0 1.5px rgba(176,122,90,.2); cursor: pointer; color: var(--persimmon); overflow: hidden; }
.photo-pick img { max-height: 320px; width: auto; border-radius: 12px; margin: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { padding: 7px 14px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 1.5px rgba(176,122,90,.2); font-size: 13px; }
.chip-btn.on { background: var(--persimmon); color: #fff; box-shadow: none; }
.mood-row { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 16px; padding: 12px 14px; }
.moods { display: flex; gap: 8px; }
.mood { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.mood.on { border-color: var(--hanko); color: var(--hanko); transform: rotate(-8deg); }

/* Tidy */
.add-shots { align-self: center; cursor: pointer; }
.tidy-deck { position: relative; height: 470px; perspective: 1100px; }
.clip-card { position: absolute; left: 50%; top: 0; width: min(330px, 92%); margin-left: calc(min(330px, 92%) / -2); background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 18px 30px -14px rgba(176,122,90,.6); display: grid; gap: 10px; height: 440px; box-sizing: border-box; grid-template-rows: auto auto auto 1fr; align-content: start; overflow: hidden;
  transform: translateY(calc(var(--depth) * 14px)) scale(calc(1 - var(--depth) * .05)) rotate(calc(var(--depth) * 2.2deg)); transition: transform .45s cubic-bezier(.2,.9,.3,1.05), opacity .3s; touch-action: none; user-select: none; }
.clip-card[data-top] { cursor: grab; }
.shot { margin: 0; background: #fff; padding: 6px; border-radius: 16px; box-shadow: 0 8px 16px -8px rgba(58,50,64,.35); transform: rotate(-2deg); height: 286px; overflow: hidden; display: grid; place-items: center; }
.shot img { width: 100%; max-height: 274px; object-fit: contain; border-radius: 10px; }
.shot.big { transform: none; max-height: none; }
.shot.big img { max-height: none; }
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.stamp { position: absolute; top: 34px; padding: 6px 14px; border: 3px solid; border-radius: 14px; font-weight: 700; font-size: 20px; opacity: 0; background: rgba(255,250,241,.7); pointer-events: none; }
.stamp.keep { left: 18px; color: var(--matcha); border-color: var(--matcha); transform: rotate(-12deg); }
.stamp.letgo { right: 18px; color: var(--hanko); border-color: var(--hanko); transform: rotate(12deg); }
.stamp.later { left: 50%; translate: -50% 0; top: 70px; color: var(--indigo); border-color: var(--indigo); }
.chest { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 10px; border-radius: 18px; background: linear-gradient(#D9B98F, #C49A6C); box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 10px 20px -12px rgba(120,80,40,.8); }
.drawer { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 10px; border-radius: 10px; background: #F3E3C7; font-size: 10.5px; box-shadow: inset 0 -3px 0 rgba(120,80,40,.25); position: relative; }
.drawer::after { content: ""; position: absolute; bottom: 4px; width: 18px; height: 3px; border-radius: 3px; background: rgba(120,80,40,.4); }
.drawer span { font-size: 18px; }
.drawer.on { box-shadow: 0 0 0 2.5px var(--persimmon), inset 0 -3px 0 rgba(120,80,40,.25); }
.drawer.trash { background: #F6D6DC; }
.summary { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 24px; }
.summary svg { width: 40px; height: 40px; fill: none; stroke: var(--matcha); stroke-width: 1.8; }
.summary h2 { font-size: 26px; }
.shot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shot-grid img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; object-position: top; border-radius: 12px; background: #fff; box-shadow: 0 6px 12px -8px rgba(58,50,64,.5); }
.ocr { white-space: pre-wrap; font-family: var(--font); background: var(--card); border-radius: 14px; padding: 12px; margin: 0; font-size: 13px; }

/* Onboarding */
#onboarding:empty { display: none; }
.onboarding { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column; align-items: center; gap: 18px; padding: calc(40px + var(--safe-t)) 24px calc(24px + var(--safe-b)); overflow-y: auto;
  background-image: radial-gradient(rgba(176,122,90,.07) 1px, transparent 1.2px); background-size: 7px 7px; }
.onboarding > * { width: min(420px, 100%); }
.ob-scene { width: min(280px, 70vw) !important; border-radius: 32px; box-shadow: var(--shadow); margin-top: 6vh; animation: bob 5s ease-in-out infinite; }
.ob-scene.small { width: min(200px, 50vw) !important; margin-top: 2vh; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-.6deg); } }
.ob-title { font-size: 34px; text-align: center; }
.ob-title span { font-size: 22px; color: var(--muted); font-weight: 400; }
.ob-foot { margin-top: auto; display: grid; gap: 10px; }
.dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--paper-deep); }
.dots span.on { background: var(--persimmon); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 90px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 99px; font-size: 13px; opacity: 0; transition: .25s; pointer-events: none; z-index: 80; }
.toast.show { opacity: .92; transform: translate(-50%, 0); }

/* Wide windows (desktop app, tablets): side rail instead of bottom tabs. */
@media (min-width: 900px) {
  .app { max-width: 1040px; display: grid; grid-template-columns: 96px 1fr; }
  #main { padding: 28px 40px 60px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 18px; }
  #main > .page-head, #main > .sample-banner, #main > .segmented, #main > .search, #main > .deck, #main > .deck-foot, #main > #map, #main > .map-stats, #main > .calendar, #main > .timeline, #main > .empty, #main > .section { grid-column: 1 / -1; }
  #main > .day-card { grid-row: span 4; }
  .tabs { position: sticky; top: 0; left: auto; transform: none; width: auto; height: 100vh; grid-template-columns: 1fr; grid-auto-rows: 84px; align-content: start; padding-top: 30px; border-top: 0; border-right: 1px solid rgba(176,122,90,.15); order: -1; }
  .fab { position: static; justify-self: center; margin-top: 20px; }
  .deck { height: 600px; max-width: 460px; margin-inline: auto; width: 100%; }
  #map { height: calc(100vh - 200px); }
  .timeline { grid-template-columns: repeat(2, 1fr); }
  .toast { bottom: 40px; }
}
