:root {
  --paper: #fbf6ee; --card: #fffdf9; --line: #eee3d6; --ink: #4b3a33; --mute: #a8968a; --soft: #7e6c62;
  --rose: #df5f79; --rose-bg: #fce3e7;
  --caramel: #c4863a; --caramel-bg: #faebd2;
  --sage: #4f9677; --we: #f4ede3; --we-n: #b98c93;
  --leave: #8f7fd3; --trip: #3f98c2; --other: #ec8c57;
  --hand: 'LXGW WenKai', 'PingFang SC', 'Hiragino Sans GB', serif;
  --num: 'Fredoka', 'PingFang SC', sans-serif;
  --sans: 'PingFang SC', -apple-system, 'Microsoft YaHei', sans-serif;
  --shadow: 0 1px 0 rgba(75, 58, 51, .04), 0 6px 18px rgba(120, 90, 70, .08);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .35  0 0 0 0 .25  0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --z-tag: 2; --z-fab: 20; --z-modal: 30;
}
* { box-sizing: border-box; margin: 0; padding: 0 }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body {
  font-family: var(--sans); color: var(--ink); background-color: var(--paper); min-height: 100dvh;
  background-image: var(--noise);
}
button { font: inherit; color: inherit }
a { color: inherit }
.num { font-family: var(--num); font-variant-numeric: tabular-nums }
svg.i { flex: none; display: inline-block; vertical-align: -3px }
.app { max-width: 1660px; margin: 0 auto; padding: 34px 34px 40px }
.print-only { display: none }

/* ---------- header ---------- */
.hero { background: var(--card); border-radius: 26px; padding: 22px 28px 18px; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative }
.hero .tape { position: absolute; top: -11px; left: 46%; width: 120px; height: 24px; transform: rotate(-2deg); border-radius: 2px; opacity: .9;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 6px, transparent 6px 12px), #f5c6cf }
.row1 { display: flex; align-items: center; gap: 20px }
.cats { display: flex; margin: -34px 0 -8px -6px }
.ct { position: relative; margin-right: -10px }
.ct img { display: block; width: 80px; height: auto; filter: drop-shadow(0 3px 5px rgba(75,58,51,.22)) }
.ct span { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); font: 12px var(--hand); color: var(--soft); background: var(--card);
  padding: 0 6px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap }
.title { margin-left: 18px; min-width: 0 }
.title h1 { font: 700 30px/1.1 var(--hand); letter-spacing: 1px; text-wrap: balance }
.title p { font-size: 12.5px; color: var(--mute); margin-top: 6px }
.yswitch { margin-left: 30px; display: flex; align-items: center; gap: 4px }
.ibtn { width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer;
  transition: transform 160ms var(--ease-out) }
.ibtn:active, .btn:active { transform: scale(.97) }
.yswitch .y { padding: 0 12px; text-align: center; min-width: 108px }
.yswitch .y b { display: block; font: 600 30px/1 var(--num); letter-spacing: .5px; font-variant-numeric: tabular-nums }
.yswitch .y small { font: 12px var(--hand); color: var(--mute) }
.actions { margin-left: auto; display: flex; gap: 10px }
.btn { display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 14px; padding: 11px 18px; font: 600 14px var(--sans); cursor: pointer;
  transition: transform 160ms var(--ease-out); white-space: nowrap }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line) }
.btn.primary { background: var(--ink); color: #fff7ee }
.btn.rose { background: var(--rose); color: #fff }
.row2 { display: flex; align-items: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; padding-top: 16px; border-top: 1.5px dashed var(--line) }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; padding: 7px 12px; font-size: 13px; color: var(--soft); background: var(--paper) }
.chip b { font: 600 16px var(--num); color: var(--ink); font-variant-numeric: tabular-nums }
.chip.cd { background: var(--rose-bg); color: var(--rose) }
.chip.cd b { color: var(--rose) }
.chip.warn { background: var(--caramel-bg); color: #9a6526 }
.legend { margin-left: auto; display: flex; gap: 14px; font-size: 12px; color: var(--soft); align-items: center }
.legend span { display: inline-flex; align-items: center; gap: 5px }
.lg-tag { width: 16px; height: 16px; display: inline-grid; place-items: center; font: 700 9.5px/1 var(--hand); color: #fff; border-radius: 50% }
.lg-term { color: var(--sage); font-weight: 600 }
.lg-we { width: 16px; height: 12px; border-radius: 4px; background: var(--we) }

/* ---------- layout ---------- */
.main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; margin-top: 26px; align-items: start }
.months { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px 16px }
.month { background: var(--card); border-radius: 20px; padding: 16px 11px 10px; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; scroll-margin-top: 24px }
.month::before { content: ''; position: absolute; top: -9px; left: 50%; width: 64px; height: 18px; margin-left: -32px; transform: rotate(var(--r, -3deg)); border-radius: 2px; opacity: .85;
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,.55) 0 5px, transparent 5px 10px), var(--tape) }
.mh { display: flex; align-items: baseline; gap: 8px; margin: 2px 5px 10px }
.mh .mn { font: 600 26px/1 var(--num) }
.mh .cn { font: 700 15px var(--hand) }
.mh .lm { font-size: 11px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.mh .cnt { margin-left: auto; align-self: center; font-size: 11px; color: var(--rose); background: var(--rose-bg); padding: 2px 8px; border-radius: 99px; white-space: nowrap }
.wk, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px }
.wk span { font: 12px var(--hand); color: var(--mute); text-align: center; padding: 0 0 5px }
.wk span:nth-child(n+6) { color: #d58a99 }
.d { position: relative; height: 56px; display: flex; flex-direction: column; align-items: center; padding-top: 13px; border-radius: 10px; cursor: default; min-width: 0 }
@media (hover: hover) and (pointer: fine) { .d:not(.pad):hover { box-shadow: inset 0 0 0 1.5px #d9c9bb } }
.d .n { font: 500 15px/1 var(--num); font-variant-numeric: tabular-nums }
.d .lu { font-size: 9.5px; color: var(--mute); margin-top: 4px; white-space: nowrap; letter-spacing: -.2px; max-width: 100%; overflow: hidden }
.d.we { background: var(--we) } .d.we .n { color: var(--we-n) }
.d.off { background: var(--rose-bg) } .d.off .n { color: var(--rose) }
.d.work { background: var(--caramel-bg) } .d.work .n { color: var(--caramel) }
.d .tag { position: absolute; top: -4px; right: -4px; z-index: var(--z-tag); width: 16px; height: 16px; display: grid; place-items: center; font: 700 9.5px/1 var(--hand);
  border-radius: 50%; color: #fff; background: var(--rose); box-shadow: 0 0 0 2px var(--card); font-style: normal }
.d.work .tag { background: var(--caramel) }
.lu.term { color: var(--sage) !important; font-weight: 600 }
.lu.fest { color: var(--rose) !important; font-weight: 600 }
.lu.lm { color: var(--soft) !important }
.d.pad { visibility: hidden }
.d.today { box-shadow: inset 0 0 0 2px var(--ink) !important }
.d.today .n { font-weight: 600 }
.d.ping { animation: ping 900ms var(--ease-out) 2 }
@keyframes ping { 50% { transform: scale(1.12) } }

/* ---------- side ---------- */
.card { background: var(--card); border-radius: 20px; padding: 18px; border: 1px solid var(--line); margin-bottom: 18px; box-shadow: var(--shadow) }
.card h3 { font: 700 17px var(--hand); display: flex; align-items: center; gap: 7px; margin-bottom: 14px }
.card h3 small { margin-left: auto; font: 12px var(--sans); color: var(--mute) }
.hol { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1.5px dashed var(--line) }
.hol:first-of-type { border-top: 0; padding-top: 0 }
.hol .nm { font: 700 15px var(--hand); width: 52px; flex: none }
.hol .rg { font-size: 12.5px; color: var(--soft); line-height: 1.7 }
.hol .rg b { font: 500 13.5px var(--num); color: var(--rose); font-variant-numeric: tabular-nums }
.hol .rg .w { color: var(--caramel) }
.hol .ct2 { margin-left: auto; font-size: 11px; color: var(--rose); background: var(--rose-bg); padding: 2px 8px; border-radius: 99px; white-space: nowrap }
.empty { font: 14px/1.8 var(--hand); color: var(--soft); text-align: center; padding: 8px 4px 2px }
.empty .big { display: block; color: var(--mute); margin-bottom: 6px }
.src { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--soft); text-decoration: none }
.src:hover { color: var(--ink); text-decoration: underline }
.foot { margin-top: 20px; display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); text-align: center }

/* ---------- mobile month strip ---------- */
.mstrip { display: none; gap: 6px; overflow-x: auto; margin: 14px -16px -2px; padding: 0 16px 2px; scrollbar-width: none }
.mstrip::-webkit-scrollbar { display: none }
.mstrip button { flex: none; padding: 6px 12px; border-radius: 10px; background: var(--paper); border: 0; font: 13px var(--hand); color: var(--soft); cursor: pointer }
.mstrip button.on { background: var(--ink); color: #fff7ee }
.mstrip button.has { position: relative }
.mstrip button.has::after { content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--rose) }
.mstrip button.on.has::after { background: #fff7ee }

/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .main { grid-template-columns: minmax(0, 1fr) }
  .side { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px }
  .side .card { margin: 0 }
}
@media (max-width: 1180px) { .months { grid-template-columns: repeat(3, minmax(0, 1fr)) } .legend { margin-left: 0; width: 100% } }
@media (max-width: 920px) {
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .row1 { flex-wrap: wrap } .title { order: 5; width: 100%; margin: 6px 0 0 } .yswitch { margin-left: auto }
}
@media (max-width: 700px) {
  .app { padding: 40px 14px calc(96px + env(safe-area-inset-bottom)) }
  .hero { padding: 16px 16px 14px; border-radius: 22px }
  .hero .tape { left: 60%; width: 80px }
  .row1 { gap: 8px }
  .cats { margin: -40px 0 0 -4px }
  .ct img { width: 52px } .ct span { display: none }
  .title h1 { font-size: 23px } .title p { display: none }
  .actions { margin-left: auto; order: 2 } .actions .lbl, .actions .print { display: none }
  .actions .btn { padding: 0; width: 36px; height: 36px; justify-content: center; border-radius: 12px }
  .yswitch { margin-left: 0; order: 3 } .yswitch .y { min-width: 0; padding: 0 6px } .yswitch .y b { font-size: 22px } .yswitch .y small { display: none }
  .yswitch .ibtn { width: 30px; height: 30px }
  .legend { display: none }
  .row2 { gap: 6px; margin-top: 12px; padding-top: 12px } .chip { font-size: 11.5px; padding: 5px 9px } .chip b { font-size: 14px }
  .chip.hm { display: none }
  .mstrip { display: flex }
  .main { gap: 16px; margin-top: 22px }
  .months { grid-template-columns: minmax(0, 1fr); touch-action: pan-y }
  .month { padding: 18px 12px 12px }
  .mh .mn { font-size: 32px } .mh .cn { font-size: 18px }
  .d { height: 70px; padding-top: 16px } .d .n { font-size: 19px } .d .lu { font-size: 11px }
  .d .tag { width: 18px; height: 18px; font-size: 10.5px }
  .side { grid-template-columns: minmax(0, 1fr) }
}
@media (prefers-reduced-motion: reduce) { .d.ping { animation: none } }

/* ---------- print: one A4 landscape page, like the PDF ---------- */
@page { size: A4 landscape; margin: 7mm 8mm }
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact }
  body { background: #fff }
  .app { max-width: none; padding: 0 }
  .hero { box-shadow: none; border: 0; padding: 0; border-radius: 0 }
  .hero .tape, .yswitch .ibtn, .actions, .mstrip, .side, .foot, .chip.cd, .cats { display: none !important }
  .row1 { gap: 10px } .title { margin-left: 0 } .title h1 { font-size: 20px } .title p { font-size: 9px; margin-top: 2px }
  .yswitch { margin-left: 8px } .yswitch .y b { font-size: 22px } .yswitch .y small { font-size: 9px }
  .row2 { margin-top: 0; padding-top: 0; border: 0; position: absolute; top: 0; right: 0; gap: 4px }
  .chip { padding: 2px 6px; font-size: 8.5px; background: none } .chip b { font-size: 11px }
  .chip.hm { display: inline-flex }
  .legend { width: auto; margin-left: 6px; font-size: 8.5px; gap: 8px }
  .lg-tag { width: 11px; height: 11px; font-size: 7px }
  .hero { position: relative }
  .main { display: block; margin-top: 3mm }
  .months { grid-template-columns: repeat(4, 1fr) !important; gap: 2.2mm 3mm }
  .month { box-shadow: none; border-radius: 3mm; padding: 1.6mm 1.6mm 1mm; break-inside: avoid; display: block !important }
  .month::before { display: none }
  .mh { margin: 0 1mm 1mm; gap: 4px } .mh .mn { font-size: 14px } .mh .cn { font-size: 10px } .mh .lm { font-size: 7px } .mh .cnt { font-size: 7px; padding: 0 5px }
  .wk span { font-size: 7.5px; padding-bottom: 1px }
  .wk, .grid { gap: 1px }
  .d { height: 7.3mm; padding-top: 1.3mm; border-radius: 1.6mm }
  .d .n { font-size: 10px } .d .lu { font-size: 6px; margin-top: 1px }
  .d .tag { width: 10px; height: 10px; font-size: 6.5px; top: -2px; right: -2px; box-shadow: 0 0 0 1px #fff }
  .d.today { box-shadow: none !important }
  .print-only { display: block }
  .print-foot { margin-top: 2.2mm; font-size: 8px; color: var(--soft); line-height: 1.6; display: flex; flex-wrap: wrap; gap: 0 12px }
  .print-foot b { color: var(--ink) }
}

/* ================= step 4: my plans ================= */
.d { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none }
.months.pick .d:not(.pad) { cursor: cell }
.d.sel { box-shadow: inset 0 0 0 2px var(--trip) !important; background-image: linear-gradient(rgba(63,152,194,.10), rgba(63,152,194,.10)) }
.d.has { cursor: pointer }
.bar { position: absolute; height: 5px; left: -1px; right: -1px; pointer-events: none }
.bar.s { left: 5px; border-top-left-radius: 4px; border-bottom-left-radius: 4px }
.bar.e { right: 5px; border-top-right-radius: 4px; border-bottom-right-radius: 4px }
.c-leave { background: var(--leave) } .c-trip { background: var(--trip) } .c-other { background: var(--other) }
.lg-bar { width: 16px; height: 5px; border-radius: 3px; display: inline-block }
.more { position: absolute; bottom: 1px; right: 3px; font: 600 8px/1 var(--num); color: var(--soft) }

/* side cards */
.card h3 a, .card h3 .lnk { margin-left: auto; font: 13px var(--sans); color: var(--soft); text-decoration: none; background: none; border: 0; cursor: pointer }
.quota { display: flex; align-items: center; gap: 16px }
.quota .txt b { font: 600 28px var(--num); color: var(--leave) }
.quota .txt b.over { color: var(--rose) }
.quota .txt span { color: var(--mute); font-size: 13px }
.quota .txt p { font-size: 12.5px; color: var(--soft); margin-top: 2px }
.qset { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 12px; background: var(--paper); border-radius: 14px; font-size: 13px; color: var(--soft) }
.stepper { margin-left: auto; display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px }
.stepper button { width: 32px; height: 32px; border: 0; background: none; display: grid; place-items: center; color: var(--ink); cursor: pointer }
.stepper button:disabled { color: var(--line); cursor: default }
.stepper b { font: 600 16px var(--num); min-width: 28px; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums }
.hint { font-size: 11.5px; color: var(--mute); margin-top: 8px; padding-left: 2px; line-height: 1.6 }
.plan { display: flex; gap: 11px; align-items: center; padding: 9px 8px; border-radius: 14px; margin: 0 -6px; width: calc(100% + 12px); border: 0; background: none; text-align: left; cursor: pointer;
  transition: background-color 150ms ease }
@media (hover: hover) and (pointer: fine) { .plan:hover { background: var(--paper) } }
.plan.past { opacity: .55 }
.stk { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none }
.s-leave { background: #eeeafb; color: var(--leave) } .s-trip { background: #e2f1f8; color: var(--trip) } .s-other { background: #fcede3; color: var(--other) }
.plan .tx { min-width: 0 }
.plan .t { font: 700 15px var(--hand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.plan .dt { font-size: 11.5px; color: var(--mute); margin-top: 2px }
.plan .k { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; flex: none }
.k-leave { background: #eeeafb; color: #7564c4 } .k-trip { background: #e2f1f8; color: #2d80a8 } .k-other { background: #fcede3; color: #d0733e }
.sug { padding: 11px 0; border-top: 1.5px dashed var(--line) }
.sug:first-of-type { border-top: 0; padding-top: 0 }
.sug .hd { display: flex; align-items: baseline; gap: 8px; font-size: 13px }
.sug .hd b { font: 700 15px var(--hand) }
.sug .hd .ask { color: var(--mute); font-size: 12px }
.sug .hd .gain { margin-left: auto; font-size: 12.5px; color: var(--rose); font-weight: 600 }
.sug .strip { display: flex; gap: 2px; margin: 8px 0 5px }
.sug .strip i { flex: 1; height: 9px; border-radius: 3px; background: var(--rose-bg) }
.sug .strip i.w { background: var(--we) } .sug .strip i.l { background: var(--leave) }
.sug .ft { display: flex; align-items: center; font-size: 11.5px; color: var(--mute) }
.sug .ft button { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; color: var(--leave); font-weight: 600; font-size: 12px; background: none; border: 0; cursor: pointer; padding: 4px 0 }
.sug .ft .done { margin-left: auto; color: var(--sage); display: inline-flex; align-items: center; gap: 3px }

/* floating add button on phones */
.fab { display: none; position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: var(--z-fab); width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: var(--rose); color: #fff; place-items: center; box-shadow: 0 10px 24px rgba(223, 95, 121, .38); cursor: pointer; transition: transform 160ms var(--ease-out) }
.fab:active { transform: scale(.95) }

/* drag hint toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: var(--z-modal); transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff7ee; padding: 10px 16px; border-radius: 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px rgba(60,40,30,.25);
  transition: opacity 200ms ease, transform 200ms var(--ease-out); max-width: calc(100vw - 32px) }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto }
.toast button { background: none; border: 0; color: #f5c6cf; font-weight: 600; cursor: pointer; padding: 2px 0; white-space: nowrap }

/* ---------- plan dialog ---------- */
dialog.mask { border: 0; padding: 0; background: none; max-width: none; max-height: none; width: 100%; height: 100%; inset: 0; position: fixed; overflow: auto; overscroll-behavior: contain }
dialog.mask:not([open]) { display: none }
dialog.mask[open] { display: grid; padding: 64px 12px 24px }
dialog.mask::backdrop { background: rgba(60, 44, 38, .32) }
dialog.mask[open] .modal { animation: pop 220ms var(--ease-out) }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98) } }
.modal { width: min(480px, calc(100vw - 24px)); background: var(--card); border-radius: 26px; padding: 26px 28px 24px; box-shadow: 0 24px 60px rgba(60,40,30,.25); position: relative; margin: auto }
.modal h2 { font: 700 22px var(--hand); margin-bottom: 18px }
.modal .peek { position: absolute; top: -50px; right: 30px; width: 74px; transform: rotate(4deg); filter: drop-shadow(0 3px 4px rgba(75,58,51,.18)); pointer-events: none }
.f { margin-bottom: 15px; border: 0 }
.f > label, .f > legend { display: block; font-size: 12px; color: var(--mute); margin-bottom: 6px }
.inp { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px; font: 16px var(--hand); color: var(--ink); background: var(--paper); outline: none; transition: border-color 150ms ease }
.inp:focus { border-color: var(--soft) }
.inp::placeholder { color: #c9b9ad }
.types { display: flex; gap: 8px }
.types button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 0; border-radius: 12px; border: 1.5px solid var(--line); background: none; font: 14px var(--sans); cursor: pointer; color: var(--soft) }
.modal[data-type=leave] .types .on { border-color: var(--leave); background: #eeeafb; color: #6655bd; font-weight: 600 }
.modal[data-type=trip] .types .on { border-color: var(--trip); background: #e2f1f8; color: #2d80a8; font-weight: 600 }
.modal[data-type=other] .types .on { border-color: var(--other); background: #fcede3; color: #c86a35; font-weight: 600 }
.dates { display: flex; align-items: center; gap: 8px }
.dates .inp { text-align: center; font-family: var(--num); font-size: 15px; min-width: 0; padding: 10px 8px; -webkit-appearance: none; appearance: none; min-height: 46px }
.use { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); margin: -4px 0 12px; cursor: pointer }
.use input { width: 17px; height: 17px; accent-color: var(--leave) }
.calc { background: var(--paper); border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.75; color: var(--soft) }
.calc b { color: var(--rose); font-family: var(--num); font-size: 15px }
.calc .warn { color: var(--rose); font-weight: 600; display: inline-flex; align-items: center; gap: 4px }
.calc .mute { color: var(--mute) }
.calc .strip { display: flex; gap: 3px; margin-top: 8px; flex-wrap: wrap }
.calc .strip i { flex: 1 0 22px; max-width: 40px; height: 24px; border-radius: 6px; background: var(--rose-bg); font: 600 11px var(--num); display: grid; place-items: center; color: var(--rose); font-style: normal }
.calc .strip i.w { background: var(--we); color: var(--we-n) }
.calc .strip i.l { background: var(--leave); color: #fff }
.calc .strip i.x { background: #ece6df; color: var(--soft) }
.icons { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px }
.icons button { aspect-ratio: 1; border-radius: 11px; display: grid; place-items: center; background: var(--paper); color: var(--soft); cursor: pointer; border: 0; padding: 0 }
.modal[data-type=leave] .icons .on { background: #eeeafb; color: var(--leave); box-shadow: inset 0 0 0 2px var(--leave) }
.modal[data-type=trip] .icons .on { background: #e2f1f8; color: var(--trip); box-shadow: inset 0 0 0 2px var(--trip) }
.modal[data-type=other] .icons .on { background: #fcede3; color: var(--other); box-shadow: inset 0 0 0 2px var(--other) }
.mbtns { display: flex; gap: 10px; align-items: center; margin-top: 20px }
.mbtns .sp { flex: 1 }
.btn.del { background: none; color: var(--mute); padding-left: 4px; padding-right: 4px }
.btn.del.armed { color: var(--rose) }
.err { color: var(--rose); font-size: 13px; min-height: 0 }
.err:empty { display: none }

@media (max-width: 700px) {
  .fab { display: grid }
  .toast { left: 16px; right: 88px; transform: translateY(10px); bottom: calc(28px + env(safe-area-inset-bottom)); max-width: none }
  .toast.show { transform: translateY(0) }
  .actions .add { display: none }
  .bar { height: 6px }
  .modal { padding: 22px 18px 18px; border-radius: 24px }
  .modal .peek { width: 62px; top: -42px }
  .icons { grid-template-columns: repeat(6, 1fr) }
}
@media print { .bar, .more, .fab, .toast, dialog { display: none !important } }

/* ================= sticky banner + scrolling months (screens wider than phones) ================= */
@media screen and (min-width: 701px) {
  /* medium widths: whole page scrolls, banner stays pinned */
  .app { padding-top: 0 }
  .top { position: sticky; top: 0; z-index: 15; margin: 0 -34px; padding: 34px 34px 14px; background-color: var(--paper); background-image: var(--noise) }
  .main { margin-top: 12px }
  .month { scroll-margin-top: 260px }
}
@media screen and (min-width: 1321px) and (min-height: 640px) {
  /* wide desktop: banner fixed, months and side cards scroll on their own */
  html, body { height: 100%; overflow: hidden }
  .app { height: 100dvh; display: flex; flex-direction: column; padding-bottom: 0 }
  .top { position: static; margin: 0; padding: 34px 0 0; background: none; flex: none }
  .main { flex: 1; min-height: 0; margin-top: 8px; align-items: stretch }
  .months, .side { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #e2d3c4 transparent }
  .months { align-content: start; padding: 20px 8px 28px; margin: 0 -8px }
  .side { padding: 20px 8px 28px; margin-right: -8px }
  .month { scroll-margin-top: 20px }
  .foot { flex: none; margin: 0; padding: 10px 0 14px }
}
@media print { .top { position: static !important; margin: 0 !important; padding: 0 !important; background: none !important } html, body { height: auto !important; overflow: visible !important } .app { height: auto !important; display: block !important } }

/* ================= step 5: login + sync status ================= */
body.booting .login, body.booting .app { visibility: hidden }
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px }
.lwrap { position: relative; padding-top: 80px; width: min(420px, 100%) }
.lcats { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: center; z-index: 1; pointer-events: none }
.lcats .ct { margin: 0 -8px; filter: drop-shadow(0 3px 4px rgba(75,58,51,.18)) }
.lcats .ct img { width: 112px; filter: none }
.lcats .ct span { top: -20px; bottom: auto; border: 0; background: none; font-size: 13px }
.lcard { background: var(--card); border-radius: 28px; padding: 62px 36px 28px; text-align: center; box-shadow: 0 18px 50px rgba(120,90,70,.15); border: 1px solid var(--line) }
.lcard h2 { font: 700 26px var(--hand); margin-bottom: 6px }
.lcard > p { font: 15px var(--hand); color: var(--soft) }
.pins { position: relative; display: flex; gap: 12px; justify-content: center; margin: 26px 0 10px; cursor: text }
.pins span { width: 56px; height: 64px; border-radius: 16px; border: 1.5px solid var(--line); display: grid; place-items: center; background: var(--paper); transition: border-color 150ms ease }
.pins span.on::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--ink) }
.pins span.cur { border-color: var(--soft) }
.pins input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px; color: transparent; caret-color: transparent; cursor: text }
.pins.bad span { border-color: var(--rose) }
.pins.shake { animation: shake 360ms var(--ease-out) }
@keyframes shake { 20% { transform: translateX(-8px) } 40% { transform: translateX(7px) } 60% { transform: translateX(-4px) } 80% { transform: translateX(2px) } }
.lmsg { min-height: 20px; font-size: 13px; color: var(--rose); margin-bottom: 12px }
.lcard .btn { width: 100%; justify-content: center; padding: 14px; font-size: 15px }
.lcard .btn:disabled { opacity: .6; cursor: default }
.lcard small { display: block; margin-top: 14px; font-size: 12px; color: var(--mute) }
.foot { flex-wrap: wrap }
.foot .sep { color: var(--line) }
.foot .lnk { background: none; border: 0; color: var(--mute); font-size: 12px; cursor: pointer; padding: 2px 0; text-decoration: underline; text-underline-offset: 2px }
.foot .lnk.armed { color: var(--rose) }
.sync { display: inline-flex; align-items: center; gap: 4px }
.sync.warn { color: var(--caramel) }
@media (max-width: 700px) {
  .lcats .ct img { width: 92px }
  .lcard { padding: 56px 22px 24px }
  .pins span { width: 52px; height: 60px }
}
@media (prefers-reduced-motion: reduce) { .pins.shake { animation: none } }
@media print { .login, .foot { display: none !important } }
.netchip { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 7px 12px; border-radius: 12px; background: var(--caramel-bg); color: #9a6526; font-size: 12.5px }
@media print { .netchip { display: none !important } }

/* ================= step 6: backup ================= */
.bk p { font-size: 13px; color: var(--soft); line-height: 1.7; margin-bottom: 12px }
.bk .row { display: flex; gap: 8px }
.bk .row .btn { flex: 1; justify-content: center; padding: 10px 8px }
.bk .last { display: block; margin-top: 10px; font-size: 12px; color: var(--mute) }
.bk .last.warn { color: var(--caramel) }
.ifile { display: flex; align-items: center; gap: 10px; background: var(--paper); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; color: var(--soft); line-height: 1.6 }
.ifile b { color: var(--ink); font-weight: 600 }
.ifile svg { flex: none }
.mode { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px; margin-bottom: 8px; cursor: pointer; font-size: 14px; line-height: 1.5; transition: border-color 150ms ease, background-color 150ms ease }
.mode input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--rose); flex: none }
.mode small { font-size: 12px; color: var(--mute) }
.mode:has(input:checked) { border-color: var(--rose); background: #fff6f7 }
.imp .calc b.minus { color: var(--caramel) }
.imp .calc .warn { color: var(--caramel) }
.btn.rose.armed { background: #c9445f }
.btn:disabled { opacity: .55; cursor: default }
