:root {
  --cream: #FFF8F2;
  --paper: #F3EEE6;
  --card: #FFFCFA;
  --blush: #F2A9A5;
  --blush-deep: #E88B86;
  --berry: #D9302C;
  --moon: #F2D52E;
  --navy: #1F3A7A;
  --peri: #5C8FD0;
  --brown: #6B3A2A;
  --muted: #A07868;
  --line: #EFE4D8;
  --tab-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  background: var(--cream);
  color: var(--brown);
  font-family: "Nunito", "Noto Sans CJK TC", ui-rounded, "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  background:
    radial-gradient(circle at 10% 6%, rgba(242,213,46,0.22) 0 2px, transparent 2.6px),
    radial-gradient(circle at 90% 4%, rgba(242,169,165,0.35) 0 1.8px, transparent 2.2px),
    radial-gradient(ellipse 120% 40% at 50% -6%, rgba(242,169,165,0.22), rgba(255,248,242,0) 62%),
    var(--cream);
}

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: 0.04em; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: block;
  background: #E8E4DC;
  box-shadow: 0 0 0 2px #FFF8F2, 0 0 0 3.5px #F2D52E;
}
.sync { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--muted); }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: #CFC3B8; }
.sync.ok i { background: #7BBF8A; }
.sync.busy i { background: var(--moon); }
.sync.off i { background: #D9CFC6; }
.sync.err i { background: var(--blush-deep); }

/* summary card */
.summary {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid rgba(239,228,216,0.9);
  border-radius: 22px; padding: 12px 14px;
  box-shadow: 0 8px 22px rgba(107,58,42,0.06);
  margin-bottom: 14px;
}
.ring-wrap { position: relative; width: 74px; height: 74px; flex: 0 0 74px; }
.ring-wrap svg { display: block; transform: rotate(-90deg); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring-label .num { font-weight: 800; font-size: 20px; }
.ring-label .den { font-weight: 700; font-size: 10px; color: var(--muted); margin-top: 2px; }
.summary-copy { flex: 1; min-width: 0; }
.summary-copy h2 { font-size: 15px; font-weight: 800; }
.summary-copy h2 .year { color: var(--navy); }
.sec-bars { display: flex; flex-direction: column; gap: 5px; margin-top: 7px; }
.sec-bar { display: grid; grid-template-columns: 92px 1fr 30px; align-items: center; gap: 7px; font-size: 10.5px; font-weight: 700; color: var(--muted); }
.sec-bar .nm { display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.sec-bar .nm i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.sec-bar .track { height: 6px; border-radius: 999px; background: var(--paper); overflow: hidden; }
.sec-bar .track span { display: block; height: 100%; border-radius: 999px; }
.sec-bar .ct { text-align: right; }

/* section */
.section { margin-bottom: 14px; }
.section-h { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 7px; }
.section-h .title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 800; }
.section-h .title i { width: 10px; height: 10px; border-radius: 50%; }
.section-h .title small { font-weight: 700; color: var(--muted); font-size: 12px; }
.section-h .count { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: auto; margin-right: 10px; }
.add-btn {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #FFFDFB; font-size: 12px; font-weight: 800; color: var(--brown);
}
.list {
  list-style: none;
  background: var(--card); border: 1px solid rgba(239,228,216,0.9);
  border-radius: 22px; padding: 4px 12px;
  box-shadow: 0 8px 22px rgba(107,58,42,0.06);
}
.section.yarn .list { border-top: 4px solid #F2A9A5; }
.section.lume .list { border-top: 4px solid #F2D52E; }
.section.atelier .list { border-top: 4px solid #5C8FD0; }

.item { display: flex; gap: 10px; padding: 11px 2px 10px; align-items: flex-start; }
.item + .item { border-top: 1px dashed var(--line); }
.check {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #E3CFC4; background: #FFFDFB; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
}
.check svg { width: 14px; height: 14px; opacity: 0; }
.item.done .check { background: var(--blush); border-color: var(--blush); }
.section.lume .item.done .check { background: #EBCF2A; border-color: #EBCF2A; }
.section.atelier .item.done .check { background: var(--peri); border-color: var(--peri); }
.item.done .check svg { opacity: 1; }
.body { flex: 1; min-width: 0; }
.title-row { display: flex; align-items: flex-start; gap: 6px; }
.item-title { flex: 1; font-size: 14.5px; font-weight: 800; line-height: 1.4; word-break: break-word; }
.item.done .item-title { color: #B08A7A; text-decoration: line-through; text-decoration-color: rgba(176,138,122,0.6); }
.edit-btn {
  flex: 0 0 auto; width: 30px; height: 26px; border: none; background: transparent;
  color: #C4A090; display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.note { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 1px; line-height: 1.45; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px;
  border-radius: 999px; border: none; background: var(--paper);
  font-size: 11.5px; font-weight: 700; color: #8A5A48;
}
.chip .cal { display:block; flex:0 0 13px; }
.chip.none { color: #B9A69B; }
.stepper { display: inline-flex; align-items: center; gap: 2px; height: 24px; border-radius: 999px; background: var(--paper); padding: 0 2px; }
.stepper button {
  width: 24px; height: 22px; border: none; background: transparent; border-radius: 999px;
  font-size: 15px; font-weight: 800; color: #8A5A48; line-height: 1;
}
.stepper button:disabled { opacity: 0.3; }
.stepper .val { min-width: 44px; text-align: center; font-size: 11.5px; font-weight: 800; color: var(--brown); }
.empty { padding: 16px 4px; text-align: center; font-size: 12.5px; color: var(--muted); font-weight: 600; }

.quote {
  text-align: center; font-family: "Noto Serif CJK TC", serif;
  font-size: 11.5px; line-height: 1.7; color: #8A5A48; padding: 4px 14px 6px; letter-spacing: 0.04em;
}

/* placeholder pages */
.soon {
  margin-top: 40px; text-align: center;
  background: var(--card); border: 1px solid rgba(239,228,216,0.9); border-radius: 26px;
  padding: 26px 18px 28px; box-shadow: 0 8px 22px rgba(107,58,42,0.06);
}
.soon img { width: 150px; border-radius: 22px; box-shadow: 0 0 0 3px #FFFDFB, 0 8px 18px rgba(31,58,122,0.18); }
.soon h2 { font-size: 18px; font-weight: 800; margin-top: 16px; }
.soon p { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 480px; margin: 0 auto;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 8px 8px env(safe-area-inset-bottom);
  display: flex; justify-content: space-around;
  background: rgba(255,252,250,0.96); border-top: 1px solid #F0E4DA;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tab {
  flex: 1; border: none; background: transparent; color: #C4A090;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
}
.tab svg { width: 26px; height: 26px; padding: 4px; border-radius: 10px; box-sizing: border-box; }
.tab.active { color: #C45C58; }
.tab.active svg { background: #FDECEC; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(107,58,42,0.28); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 480px; margin: 0 auto;
  background: #FFFDFB; border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(107,58,42,0.16);
  max-height: 92dvh; overflow-y: auto;
}
.sheet .handle { width: 42px; height: 5px; border-radius: 999px; background: #EADDD2; margin: 2px auto 12px; }
.sheet h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); background: #FFF8F2; border-radius: 14px;
  padding: 10px 12px; font-size: 16px; font-weight: 600; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blush); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }
.sheet-actions .spacer { flex: 1; }
.pill {
  height: 40px; padding: 0 18px; border-radius: 999px; border: none;
  font-size: 14px; font-weight: 800;
}
.pill.primary { background: var(--blush); color: var(--brown); box-shadow: 0 3px 0 #E39A96; }
.pill.ghost { background: #FFF8F2; border: 1.5px solid var(--line); }
.pill.danger { background: transparent; color: #C2453F; }
.order-row { display: flex; gap: 8px; margin: 2px 0 12px; }
.order-row button {
  flex: 1; height: 36px; border-radius: 12px; border: 1.5px solid var(--line); background: #FFF8F2;
  font-size: 13px; font-weight: 800;
}
.order-row button:disabled { opacity: 0.35; }

/* celebration */
.celebrate {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,248,242,0.55);
  animation: fade 0.2s ease-out;
}
.celebrate-card {
  width: 270px; text-align: center;
  background: #FFFDFB; border: 1.5px solid rgba(242,169,165,0.6); border-radius: 28px;
  padding: 16px 16px 18px;
  box-shadow: 0 16px 40px rgba(107,58,42,0.18);
  animation: pop 0.45s cubic-bezier(.2,1.4,.4,1);
}
.celebrate-art { border-radius: 20px; overflow: hidden; }
.celebrate-art img { width: 100%; display: block; }
.celebrate-text { font-size: 19px; font-weight: 800; margin-top: 12px; }
.celebrate-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 4px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%); z-index: 35;
  background: rgba(107,58,42,0.92); color: #FFF8F2; font-size: 12.5px; font-weight: 700;
  padding: 9px 16px; border-radius: 999px; white-space: nowrap;
}
