:root {
  --ink: #43324a;
  --muted: #8d7a95;
  --pink: #ff6fae;
  --pink-2: #ff9ac4;
  --pink-d: #d9418a;
  --pink-l: #ffe6f1;
  --lav: #8b7cf6;
  --lav-d: #5f4fd6;
  --lav-l: #ece8ff;
  --mint: #22a97b;
  --mint-l: #d9f6ea;
  --sky: #2f8fdb;
  --sky-l: #ddeeff;
  --lemon: #c98a0b;
  --lemon-l: #fff1c9;
  --red: #dc3f5a;
  --red-l: #ffe1e6;
  --card: rgba(255, 255, 255, 0.9);
  --line: #f1dfea;
  --shadow: 0 2px 0 rgba(120, 70, 110, 0.05), 0 10px 28px rgba(120, 70, 110, 0.13);
  --radius: 26px;
  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; }
body {
  font-family: 'Mali', 'Noto Sans Thai', 'Leelawadee UI', system-ui, sans-serif;
  color: var(--ink);
  background: #ffeaf4;
  line-height: 1.55;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .6em; }
a { color: var(--pink-d); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(139, 124, 246, .55); outline-offset: 2px; border-radius: 12px; }
.ic { flex: none; vertical-align: -0.2em; }

#bg { position: fixed; inset: 0; z-index: -1; background: #ffeaf4 center / cover no-repeat; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  margin: 10px 12px 0; padding: 7px 8px 7px 12px;
  background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 999px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--pink-d); text-decoration: none; white-space: nowrap; }
.brand img { width: 34px; height: 34px; border-radius: 11px; box-shadow: 0 2px 6px rgba(221, 63, 134, .3); }
.topnav { display: none; gap: 2px; margin-left: auto; }
.topnav a { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; position: relative; transition: background .15s; }
.topnav a:hover { background: var(--pink-l); }
.topnav a.active { background: linear-gradient(135deg, #ff8cc2, #ff63a5); color: #fff; box-shadow: 0 3px 10px rgba(221, 63, 134, .3); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .92rem; padding-right: 4px; }
.who span { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-btn { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; padding: 5px 11px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 700; font-size: .8rem; line-height: 1.3; cursor: pointer; box-shadow: 0 2px 0 #ecd2e0; transition: transform .1s, border-color .15s; }
.lang-btn:hover { border-color: var(--lav); }
.lang-btn:active { transform: translateY(2px); box-shadow: none; }
.lang-btn + .who { margin-left: 4px; }
.login-lang { position: absolute; top: 14px; right: 14px; z-index: 5; margin-left: 0; }

.page { width: 100%; max-width: 960px; margin: 0 auto; padding: 14px 12px 112px; display: flex; flex-direction: column; gap: 14px; }
.page > * { animation: rise .45s var(--ease) both; }
.page > :nth-child(2) { animation-delay: .05s; } .page > :nth-child(3) { animation-delay: .1s; }
.page > :nth-child(4) { animation-delay: .15s; } .page > :nth-child(5) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 30;
  display: flex; justify-content: space-around; gap: 2px; padding: 6px;
  background: var(--card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 28px; box-shadow: 0 12px 34px rgba(120, 70, 110, .22);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 6px; border-radius: 22px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 700; position: relative; transition: background .2s, color .2s; }
.tabbar a .ic { transition: transform .25s var(--ease); }
.tabbar a.active { background: linear-gradient(160deg, var(--pink-l), var(--lav-l)); color: var(--pink-d); }
.tabbar a.active .ic { transform: translateY(-2px) scale(1.12); }
.dot { position: absolute; top: 2px; right: 20%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; font-weight: 700; box-shadow: 0 0 0 2px #fff; }
.topnav .dot { top: -2px; right: 0; }

@media (min-width: 760px) {
  .tabbar { display: none; }
  .topnav { display: flex; }
  .who span { display: none; }
  .topnav + .who { margin-left: 6px; }
  .topnav + .lang-btn { margin-left: 8px; }
  .page { padding: 22px 16px 44px; }
  .topbar { margin: 14px auto 0; width: calc(100% - 32px); max-width: 960px; }
}

/* ---------- cards & basics ---------- */
.card {
  background: var(--card); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.icon-chip { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--t, var(--pink-l)); color: var(--c, var(--pink-d)); }
.icon-chip.pink { --t: var(--pink-l); --c: var(--pink-d); }
.icon-chip.lav { --t: var(--lav-l); --c: var(--lav-d); }
.icon-chip.mint { --t: var(--mint-l); --c: var(--mint); }
.icon-chip.sky { --t: var(--sky-l); --c: var(--sky); }
.icon-chip.lemon { --t: var(--lemon-l); --c: var(--lemon); }
.icon-chip.red { --t: var(--red-l); --c: var(--red); }

.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  padding: 10px 20px; border-radius: 999px; background: #fff; color: var(--ink);
  box-shadow: 0 3px 0 #ecd2e0, 0 8px 16px rgba(120, 60, 100, 0.09);
  transition: transform .1s, box-shadow .1s, filter .15s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 1.3;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 #ecd2e0; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary { background: linear-gradient(160deg, #ff93c6, #ff5fa2); color: #fff; box-shadow: 0 3px 0 #cf3a7f, 0 10px 18px rgba(221, 63, 134, 0.28); }
.btn.primary:active { box-shadow: 0 0 0 #cf3a7f; }
.btn.good { background: linear-gradient(160deg, #62dcb2, #25b184); color: #fff; box-shadow: 0 3px 0 #178a64, 0 10px 18px rgba(34, 169, 123, 0.25); }
.btn.good:active { box-shadow: 0 0 0 #178a64; }
.btn.lav { background: linear-gradient(160deg, #a89bff, #7b68ee); color: #fff; box-shadow: 0 3px 0 #5846c4, 0 10px 18px rgba(91, 70, 200, .25); }
.btn.danger { background: #fff; color: var(--red); box-shadow: 0 3px 0 #f3c3cb; }
.btn.small { padding: 6px 14px; font-size: .88rem; box-shadow: 0 2px 0 #ecd2e0; }
.btn.small.primary { box-shadow: 0 2px 0 #cf3a7f; }
.btn.small.good { box-shadow: 0 2px 0 #178a64; }
.btn.block { width: 100%; }
.btn.round { width: 42px; height: 42px; padding: 0; border-radius: 50%; }

label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 700; font-size: .9rem; min-width: 0; }
input, select, textarea {
  font: inherit; color: var(--ink); width: 100%; min-width: 0; max-width: 100%; padding: 11px 14px;
  border: 2px solid var(--line); border-radius: 16px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink-2); box-shadow: 0 0 0 4px rgba(255, 111, 174, 0.16); }
input[type='checkbox'], input[type='radio'] { width: auto; accent-color: var(--pink); transform: scale(1.2); }
input::placeholder, textarea::placeholder { color: #c3b2c8; }
textarea { resize: vertical; min-height: 80px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 42px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form .two > * { min-width: 0; }
/* date/time pickers (esp. Android) are wide: wrap to one column instead of overflowing the card */
.form .two.keep { grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); }
input[type='date'], input[type='time'] { padding-left: 11px; padding-right: 8px; font-size: .95rem; min-height: 46px; }
@media (max-width: 480px) { .form .two:not(.keep) { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.err { color: var(--red); font-weight: 700; min-height: 1.2em; font-size: .92rem; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px 3px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--mint-l); color: #12704f; }
.badge.warn { background: var(--lemon-l); color: #7a5600; }
.badge.info { background: var(--sky-l); color: #1b5d99; }
.badge.bad { background: var(--red-l); color: #b02a43; }
.badge.mute { background: #f2e9ef; color: #7a6677; }
.badge.pink { background: var(--pink-l); color: var(--pink-d); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 8px 15px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: .92rem; cursor: pointer; user-select: none; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.seg label:hover { border-color: var(--pink-2); }
.seg input:checked + label { background: var(--pink-l); border-color: var(--pink); color: var(--pink-d); }
.seg input:focus-visible + label { box-shadow: 0 0 0 4px rgba(255, 111, 174, 0.25); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips a, .chips button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: rgba(255, 255, 255, .88); text-decoration: none; color: var(--ink); font-weight: 700; font-size: .9rem; border: 2px solid transparent; font-family: inherit; cursor: pointer; position: relative; box-shadow: 0 2px 8px rgba(120, 70, 110, .08); transition: all .15s; }
.chips a:hover, .chips button:hover { border-color: var(--lav); }
.chips a.active, .chips button.active { background: linear-gradient(160deg, #a89bff, #7b68ee); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(91, 70, 200, .3); }
.chips .dot { top: -5px; right: -3px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 8px 4px 10px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll > * { flex: none; }

/* ---------- login ---------- */
.login-wrap { position: relative; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 410px; text-align: center; padding: 8px 22px 26px; overflow: hidden; position: relative; background: #fff; }
.login-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 150px; background: linear-gradient(135deg, #ffd3e8, #dcd5ff); z-index: 0; }
.login-card::after { content: ''; position: absolute; left: -10%; right: -10%; top: 118px; height: 60px; background: #fff; border-radius: 50% 50% 0 0 / 100% 100% 0 0; z-index: 0; }
.login-card > * { position: relative; z-index: 1; }
.login-card .mascot { display: block; margin: 14px auto 0; filter: drop-shadow(0 8px 10px rgba(120, 60, 100, .22)); }
.login-card h1 { background: linear-gradient(90deg, var(--pink-d), var(--lav-d)); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 8px 0 0; font-size: 1.9rem; }
.login-card .form { text-align: left; margin-top: 16px; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 0; overflow: hidden; position: relative; background: #fff; }
.hero-band { position: relative; background: linear-gradient(135deg, #ffd9ec, #e3dcff); padding: 14px 16px 0; }
.hero-band::after { content: ''; position: absolute; left: -10%; right: -10%; bottom: -1px; height: 26px; background: #fff; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.hero-body { padding: 0 16px 18px; }
.mascot-row { display: flex; align-items: flex-end; justify-content: center; gap: 6px; position: relative; z-index: 1; }
.mascot-row .mascot { filter: drop-shadow(0 6px 8px rgba(120, 60, 100, .2)); flex: none; }
.bubble { background: #fff; border-radius: 20px 20px 20px 6px; padding: 9px 14px; font-weight: 700; font-size: .88rem; text-align: left; box-shadow: 0 6px 16px rgba(120, 60, 100, .12); max-width: 188px; margin-bottom: 38px; line-height: 1.4; }
.hello { margin-top: 4px; font-weight: 700; color: var(--muted); }
.hello b { color: var(--ink); }
.clock { font-size: 3.1rem; font-weight: 700; letter-spacing: 1px; line-height: 1.1; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, var(--pink-d), var(--lav-d)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.date-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: .86rem; color: var(--muted); }
.mascot.sleepy { animation: bob 3.2s ease-in-out infinite; }
.mascot.happy { animation: hop 2.6s ease-in-out infinite; }
.mascot .wave { transform-origin: 112px 104px; animation: wave 1.1s ease-in-out infinite; }
@keyframes wave { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(16deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes hop { 0%, 85%, 100% { transform: translateY(0); } 92% { transform: translateY(-7px); } }

.ring-wrap { position: relative; width: 224px; height: 224px; margin: 14px auto 6px; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .track { stroke: #fbe3ef; }
.ring .prog { stroke: var(--pink); transition: stroke-dashoffset 1s var(--ease); }
.ring-wrap.out .track { stroke: var(--lav-l); } .ring-wrap.out .prog { stroke: var(--lav); }
.ring-wrap.done .track { stroke: var(--mint-l); } .ring-wrap.done .prog { stroke: var(--mint); }
.ring-label { position: absolute; left: 0; right: 0; bottom: -2px; text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); }
.scan-btn {
  /* fixed size + explicit position: no dependence on "inset" stretching, which some mobile browsers don't do for <button> */
  position: absolute; left: 27px; top: 27px; width: 170px; height: 170px; padding: 0 0 6px; border-radius: 50%; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; color: #fff; font-size: 1.08rem; line-height: 1.25;
  background: radial-gradient(circle at 30% 25%, #ffb3d6, #ff5fa2 70%);
  /* the 3D edge is drawn INSIDE the circle (not as an offset outer shadow) so the circle stays exactly centred in the ring */
  box-shadow: inset 0 -8px 0 rgba(168, 30, 98, .30), inset 0 3px 0 rgba(255, 255, 255, .45), 0 14px 26px rgba(221, 63, 134, .32);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform .1s, box-shadow .1s;
}
.scan-btn::before, .scan-btn::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(255, 111, 174, 0.45); animation: pulse 2.6s ease-out infinite; pointer-events: none; }
.scan-btn::after { animation-delay: 1.3s; }
@keyframes pulse { 0% { transform: scale(.94); opacity: .9; } 100% { transform: scale(1.25); opacity: 0; } }
.scan-btn:active { transform: scale(.96); box-shadow: inset 0 -3px 0 rgba(168, 30, 98, .30), inset 0 3px 0 rgba(255, 255, 255, .4), 0 6px 12px rgba(221, 63, 134, .3); }
.scan-btn .ic { filter: drop-shadow(0 2px 2px rgba(150, 30, 90, .35)); }
.scan-btn.out { background: radial-gradient(circle at 30% 25%, #c4baff, #7b68ee 70%); box-shadow: inset 0 -8px 0 rgba(62, 44, 170, .34), inset 0 3px 0 rgba(255, 255, 255, .4), 0 14px 26px rgba(91, 70, 200, .32); }
.scan-btn.out::before, .scan-btn.out::after { border-color: rgba(123, 104, 238, 0.45); }
.scan-btn.out:active { box-shadow: inset 0 -3px 0 rgba(62, 44, 170, .34), inset 0 3px 0 rgba(255, 255, 255, .35), 0 6px 12px rgba(91, 70, 200, .3); }
.scan-btn.done { background: radial-gradient(circle at 30% 25%, #9cf0d2, #25b184 70%); box-shadow: inset 0 -8px 0 rgba(14, 100, 70, .30), inset 0 3px 0 rgba(255, 255, 255, .4), 0 14px 26px rgba(40, 150, 110, .28); cursor: default; }
.scan-btn.done::before, .scan-btn.done::after { display: none; }
.scan-btn.done:active { transform: none; }
.shift-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 14px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.shift-line span { display: inline-flex; align-items: center; gap: 5px; }

.times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.time-tile { background: #fff; border-radius: 20px; padding: 10px 4px 12px; border: 2px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.time-tile .icon-chip { width: 30px; height: 30px; border-radius: 10px; }
.time-tile small { color: var(--muted); font-weight: 700; font-size: .78rem; }
.time-tile b { font-size: 1.3rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.times.has-ot { grid-template-columns: repeat(4, 1fr); gap: 6px; } /* a 4th tile (OT) once the shift is over */
.times.has-ot .time-tile { padding-inline: 2px; }
.times.has-ot .time-tile b { font-size: 1.1rem; }
.times.has-ot .time-tile small { font-size: .72rem; }
.banner { border-radius: 20px; padding: 11px 14px; font-weight: 700; font-size: .92rem; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); }
.banner.info { background: var(--sky-l); color: #1b5d99; }
.banner.warn { background: var(--lemon-l); color: #7a5600; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.wday { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.wdot { width: 100%; max-width: 38px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: #f7eef3; color: #c7b6c3; font-size: .8rem; }
.wdot.ok { background: var(--mint-l); color: var(--mint); } .wdot.warn { background: var(--lemon-l); color: var(--lemon); }
.wdot.info { background: var(--sky-l); color: var(--sky); } .wdot.bad { background: var(--red-l); color: var(--red); }
.wday.today { color: var(--pink-d); } .wday.today .wdot { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--pink); }
.wday.today.waiting .wdot { animation: blink 1.6s ease-in-out infinite; background: var(--pink-l); color: var(--pink-d); }
@keyframes blink { 50% { transform: scale(1.08); } }

.result-modal { text-align: center; position: relative; overflow: hidden; margin: -20px -18px; padding: 8px 20px 22px; }
.result-modal::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 120px; background: linear-gradient(135deg, #ffd9ec, #e3dcff); }
.result-modal > * { position: relative; }
.result-modal .mascot { display: block; margin: 8px auto 0; }
.result-modal h2 { margin-top: 6px; font-size: 1.35rem; }
.result-modal .big { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; background: linear-gradient(90deg, var(--pink-d), var(--lav-d)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.confetti i { position: fixed; left: 50%; top: 58%; width: 9px; height: 15px; border-radius: 2px; z-index: 100; pointer-events: none; animation: burst var(--d) cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes burst { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 45% { transform: translate(var(--x), var(--y)) rotate(calc(var(--r) * .5)); opacity: 1; } 100% { transform: translate(calc(var(--x) * 1.3), 340px) rotate(var(--r)); opacity: 0; } }

/* ---------- lists / tables ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: #fff; border: 2px solid var(--line); border-radius: 20px; transition: border-color .15s, transform .15s; position: relative; }
.item.s-ok { border-left: 6px solid #7fdcbb; } .item.s-warn { border-left: 6px solid #f6c453; }
.item.s-info { border-left: 6px solid #8cc9ff; } .item.s-bad { border-left: 6px solid #ff8da1; }
.item .date { width: 48px; text-align: center; flex: none; line-height: 1.15; }
.item .date b { display: block; font-size: 1.45rem; }
.item .date small { color: var(--muted); font-weight: 700; }
.item.weekend .date b { color: var(--pink-d); }
.item .grow { flex: 1; min-width: 0; }
.item .times-line { font-variant-numeric: tabular-nums; font-weight: 700; }
.item.clickable { cursor: pointer; }
.item.clickable:hover { border-color: var(--pink-2); transform: translateY(-1px); }
.item.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px rgba(139, 124, 246, .5); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 2px solid var(--line); border-radius: 20px; padding: 10px 8px 11px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stat .icon-chip { width: 32px; height: 32px; border-radius: 11px; margin-bottom: 3px; }
.stat b { font-size: 1.55rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); font-weight: 700; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .h { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal .c { aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: .92rem; background: #f8f0f5; color: #bba8b8; border: 0; font-family: inherit; position: relative; }
.cal .c.e { background: none; }
.cal .c.ok { background: var(--mint-l); color: #12704f; } .cal .c.warn { background: var(--lemon-l); color: #7a5600; }
.cal .c.info { background: var(--sky-l); color: #1b5d99; } .cal .c.bad { background: var(--red-l); color: #b02a43; }
.cal .c.tap { cursor: pointer; }
.cal .c.today { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--pink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

.scroll-x { overflow-x: auto; border-radius: 16px; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; font-size: .92rem; min-width: 560px; }
.table th { text-align: left; padding: 10px 12px; background: var(--pink-l); color: #6d3b57; font-weight: 700; position: sticky; top: 0; white-space: nowrap; font-size: .85rem; }
.table td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: #fffafc; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fff0f7; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th:first-child { border-top-left-radius: 14px; } .table th:last-child { border-top-right-radius: 14px; }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.month-nav h2 { margin: 0; text-align: center; flex: 1; font-size: 1.2rem; }

.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-weight: 600; }
.empty .mascot { opacity: .95; margin-bottom: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label.field { min-width: 140px; flex: 1; }

.skel i { display: block; height: 14px; border-radius: 7px; margin: 10px 0; background: linear-gradient(90deg, #f3e6ee 25%, #fff 37%, #f3e6ee 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skel i:nth-child(1) { width: 40%; height: 18px; } .skel i:nth-child(2) { width: 90%; } .skel i:nth-child(3) { width: 65%; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- leave ---------- */
.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .type-grid { grid-template-columns: repeat(4, 1fr); } }
.type-grid input { position: absolute; opacity: 0; pointer-events: none; }
.type-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px; border-radius: 20px; background: #fff; border: 2px solid var(--line); cursor: pointer; font-weight: 700; font-size: .9rem; transition: all .15s; user-select: none; }
.type-tile:hover { border-color: var(--pink-2); }
.type-grid input:checked + .type-tile { border-color: var(--pink); background: #fff7fb; box-shadow: 0 0 0 4px rgba(255, 111, 174, .14); transform: translateY(-2px); }
.type-grid input:focus-visible + .type-tile { box-shadow: 0 0 0 4px rgba(139, 124, 246, .4); }
.days-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--lav-l); color: var(--lav-d); font-weight: 700; }

/* ---------- profile / backgrounds ---------- */
.profile { padding: 0; overflow: hidden; }
.profile-banner { height: 92px; background: linear-gradient(120deg, #ffb3d4, #c9bdff 70%, #b4e1ff); position: relative; }
.profile-banner::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .5), transparent 40%); }
.profile-body { display: flex; align-items: flex-start; gap: 14px; padding: 0 18px 18px; margin-top: -34px; position: relative; }
.profile-body .avatar { border: 4px solid #fff; box-shadow: 0 6px 14px rgba(120, 60, 100, .2); }
.profile-body .meta { padding-top: 42px; min-width: 0; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.bg-opt { border: 3px solid transparent; border-radius: 20px; padding: 3px; background: none; cursor: pointer; font: inherit; color: var(--ink); text-align: center; transition: all .15s; position: relative; }
.bg-opt:hover { transform: translateY(-2px); }
.bg-opt .thumb { display: block; height: 78px; border-radius: 15px; background-color: #f3e6ee; background-position: center; background-size: cover; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7), 0 3px 8px rgba(120, 60, 100, .15); }
.bg-opt .name { display: block; font-size: .78rem; font-weight: 700; padding: 5px 0 2px; }
.bg-opt.active { border-color: var(--pink); background: var(--pink-l); }
.bg-opt .tick { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--pink); color: #fff; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(221, 63, 134, .4); }
.bg-opt.upload .thumb { display: grid; place-items: center; background: #fff; color: var(--pink-d); border: 2px dashed var(--pink-2); box-shadow: none; }

/* ---------- modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(67, 50, 74, .5); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto; background: #fff; border-radius: 30px 30px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: sheet .3s var(--ease); }
.modal h2 { margin-bottom: 12px; font-size: 1.25rem; }
.confirm-msg { font-size: 1.05rem; margin-bottom: 16px; font-weight: 600; }
@media (min-width: 640px) { .modal-wrap { align-items: center; padding: 20px; } .modal { border-radius: 30px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(60px); opacity: 0; } }

#toasts { position: fixed; top: 12px; left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 18px 10px 14px; border-radius: 999px; background: #fff; box-shadow: 0 10px 28px rgba(120, 60, 100, .22); font-weight: 700; animation: drop .3s var(--ease); max-width: 92vw; }
.toast.ok .ic { color: var(--mint); } .toast.bad { color: var(--red); } .toast.bad .ic { color: var(--red); }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes drop { from { transform: translateY(-24px); opacity: 0; } }

/* ---------- scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 80; background: radial-gradient(circle at 50% 0, #4a3358, #241a2b 70%); color: #fff; display: flex; flex-direction: column; }
.scanner-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: max(14px, env(safe-area-inset-top)) 16px 12px; font-size: 1.1rem; }
.scanner-top .btn { background: rgba(255, 255, 255, .15); color: #fff; box-shadow: none; backdrop-filter: blur(6px); }
.scanner-top .row { gap: 8px; }
.scanner-view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; border-radius: 28px 28px 0 0; }
.scanner.nocam .scanner-view { display: none; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 50%; top: 50%; width: min(68vw, 290px); aspect-ratio: 1; transform: translate(-50%, -50%); box-shadow: 0 0 0 100vmax rgba(36, 26, 43, .6); border-radius: 28px; }
.scanner .frame i { position: absolute; width: 38px; height: 38px; border: 5px solid #ff9ac4; animation: breathe 1.8s ease-in-out infinite; }
.scanner .frame i:nth-child(1) { left: -3px; top: -3px; border-right: 0; border-bottom: 0; border-top-left-radius: 28px; }
.scanner .frame i:nth-child(2) { right: -3px; top: -3px; border-left: 0; border-bottom: 0; border-top-right-radius: 28px; }
.scanner .frame i:nth-child(3) { left: -3px; bottom: -3px; border-right: 0; border-top: 0; border-bottom-left-radius: 28px; }
.scanner .frame i:nth-child(4) { right: -3px; bottom: -3px; border-left: 0; border-top: 0; border-bottom-right-radius: 28px; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: .8; } }
.scanner .line { position: absolute; left: 8%; right: 8%; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, #ff9ac4, transparent); box-shadow: 0 0 14px #ff9ac4; animation: sweep 2s ease-in-out infinite alternate; }
@keyframes sweep { from { top: 8%; } to { top: 92%; } }
.scanner-msg { padding: 14px 20px; text-align: center; font-weight: 700; min-height: 3.4em; display: flex; align-items: center; justify-content: center; gap: 8px; }
.scanner.nocam .scanner-msg { flex: 1; font-size: 1.1rem; flex-direction: column; }
.scanner-msg.bad { color: #ffb0bf; }
.scanner-bottom { padding: 6px 16px max(18px, env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 10px; }
.scanner .btn.photo { color: var(--pink-d); }

/* ---------- admin ---------- */
.admin-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { --p: 0; width: 112px; height: 112px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--mint) calc(var(--p) * 1%), #f3e6ee 0); position: relative; }
.donut::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: #fff; }
.donut > div { position: relative; text-align: center; line-height: 1.1; }
.donut b { font-size: 1.6rem; } .donut small { display: block; color: var(--muted); font-weight: 700; font-size: .72rem; }
.admin-hero .stats { flex: 1; min-width: 240px; grid-template-columns: repeat(3, 1fr); }
.qr-box { width: min(76vw, 300px); padding: 12px; background: #fff; border-radius: 24px; display: inline-block; box-shadow: 0 8px 24px rgba(120, 60, 100, .15); border: 2px solid var(--line); }
.qr-slot { width: 100%; display: grid; place-items: center; }
.qr-slot svg { display: block; } /* size is set by fitQr(): a whole number of device pixels per QR module, so edges stay even */

/* ---------- QR poster: on-screen preview, tablet display and print (A4/A5, portrait/landscape) ---------- */
.qr-page { width: 100%; max-width: 980px; margin: 0 auto; padding: 14px 12px 40px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr-controls { width: 100%; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; padding: 12px 14px; }
.qr-controls .group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qr-controls .seg label { padding: 6px 13px; }
.qr-page .banner { width: 100%; }

.poster {
  container-type: inline-size; position: relative; overflow: hidden; background: #fff; color: var(--ink);
  width: min(100%, calc((100dvh - 190px) * var(--pwn) / var(--phn)), 1000px); aspect-ratio: var(--pwn) / var(--phn);
  border-radius: 26px; box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column;
}
.p-band { position: relative; flex: none; height: 24cqw; background: linear-gradient(135deg, #ffd3e8, #e0d8ff 60%, #cfe8ff); }
.p-band::before, .p-band::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.p-band::before { width: 22cqw; height: 22cqw; left: -6cqw; top: -8cqw; }
.p-band::after { width: 14cqw; height: 14cqw; right: 6cqw; top: 4cqw; background: rgba(255, 255, 255, .35); }
.p-mascot { position: absolute; left: 50%; bottom: -9cqw; width: 21cqw; transform: translateX(-50%); z-index: 2; filter: drop-shadow(0 1cqw 1.2cqw rgba(120, 60, 100, .25)); }
.p-mascot svg, .p-mascot img { width: 100%; height: auto; display: block; animation: none; }
.p-main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; padding: 9.5cqw 7cqw 3cqw; }
.p-company { margin: 0; font-size: 6cqw; line-height: 1.15; background: linear-gradient(90deg, var(--pink-d), var(--lav-d)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.p-title { margin: 1.2cqw 0 0; font-size: 3.2cqw; font-weight: 700; color: var(--muted); }
.p-title b { color: var(--pink-d); }
.qr-frame { position: relative; width: 50cqw; padding: 3cqw; background: #fff; border-radius: 4.6cqw; border: .5cqw solid var(--line); box-shadow: 0 1.4cqw 4cqw rgba(120, 60, 100, .16); }
.qr-frame i { position: absolute; width: 7cqw; height: 7cqw; border: 1cqw solid var(--pink); }
.qr-frame i:nth-child(1) { left: -1.6cqw; top: -1.6cqw; border-right: 0; border-bottom: 0; border-top-left-radius: 5cqw; }
.qr-frame i:nth-child(2) { right: -1.6cqw; top: -1.6cqw; border-left: 0; border-bottom: 0; border-top-right-radius: 5cqw; border-color: var(--lav); }
.qr-frame i:nth-child(3) { left: -1.6cqw; bottom: -1.6cqw; border-right: 0; border-top: 0; border-bottom-left-radius: 5cqw; border-color: var(--lav); }
.qr-frame i:nth-child(4) { right: -1.6cqw; bottom: -1.6cqw; border-left: 0; border-top: 0; border-bottom-right-radius: 5cqw; }
.p-steps { list-style: none; padding: 0; margin: 0; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3cqw; }
.p-steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1cqw; padding: 4cqw 1cqw 2.6cqw; background: #fff7fb; border: .4cqw solid var(--line); border-radius: 3cqw; font-size: 2.15cqw; font-weight: 700; line-height: 1.35; }
.p-steps .n { position: absolute; left: 50%; top: -2.4cqw; transform: translateX(-50%); width: 4.8cqw; height: 4.8cqw; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 2.6cqw; background: linear-gradient(145deg, #ff9ac4, #ff6fae); box-shadow: 0 .6cqw 1.2cqw rgba(221, 63, 134, .35); }
.p-steps .ln { display: block; white-space: nowrap; }
.p-steps .ic { color: var(--lav-d); display: grid; }
.p-steps .ic svg { width: 5.2cqw; height: 5.2cqw; }
.p-foot { flex: none; padding: 2.4cqw 4cqw 2.8cqw; font-size: 2.1cqw; font-weight: 700; color: var(--muted); border-top: .3cqw dashed var(--line); }
.p-foot b { color: var(--pink-d); }
.p-count { margin-top: 2cqw; }

/* picture mascots carry empty margin around the character, so draw them larger than the built-in cat */
.poster.has-img .p-mascot { width: 32cqw; bottom: -13cqw; }
.poster.has-img .p-main { padding-top: 12cqw; }

/* landscape: left panel (mascot, name, steps) + big QR on the right */
.poster.landscape { display: grid; grid-template-columns: 44% 1fr; grid-template-rows: auto auto 1fr auto; grid-template-areas: 'mascot qr' 'head qr' 'steps qr' 'foot foot'; text-align: left; }
.poster.landscape::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 44%; background: linear-gradient(160deg, #ffd9ec, #e6dfff 70%, #d3ebff); }
.poster.landscape > *, .poster.landscape .p-main > * { position: relative; }
.poster.landscape .p-main { display: contents; }
.poster.landscape .p-band { grid-area: mascot; height: auto; background: none; overflow: visible; padding-top: 2.4cqw; }
.poster.landscape .p-band::before, .poster.landscape .p-band::after { display: none; }
.poster.landscape .p-mascot { position: static; transform: none; width: 15cqw; margin: 0 auto; }
.poster.landscape .p-head { grid-area: head; text-align: center; padding: 0 3cqw; }
.poster.landscape .p-company { font-size: 4.8cqw; }
.poster.landscape .p-title { font-size: 2.5cqw; }
.poster.landscape .p-qr { grid-area: qr; display: grid; place-items: center; align-content: center; padding: 3cqw; }
.poster.landscape .qr-frame { width: 44cqw; }
.poster.landscape .p-steps { grid-area: steps; grid-template-columns: 1fr; align-content: center; gap: 1.5cqw; padding: 2cqw 4cqw; width: auto; }
.poster.landscape .p-steps li { flex-direction: row; text-align: left; gap: 1.6cqw; padding: 1.2cqw 1.6cqw 1.2cqw 5.6cqw; font-size: 1.9cqw; }
.poster.landscape .p-steps .ln { white-space: nowrap; }
.poster.landscape .p-steps .ic svg { width: 3.4cqw; height: 3.4cqw; }
.poster.landscape .p-steps .n { left: 1.6cqw; top: 50%; transform: translateY(-50%); width: 3.2cqw; height: 3.2cqw; font-size: 1.9cqw; }
.poster.landscape .p-foot { grid-area: foot; font-size: 1.7cqw; padding: 1.2cqw 4cqw 2.2cqw; background: #fff; }

.countdown { height: 8px; background: var(--pink-l); border-radius: 8px; overflow: hidden; margin-top: 14px; }
.countdown i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--lav)); transition: width 1s linear; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 700; color: #fff; background: linear-gradient(145deg, var(--a, #ff9ac4), var(--b, #ff6fae)); box-shadow: 0 3px 8px rgba(120, 60, 100, .2); }

@media print {
  html, body { background: #fff !important; }
  #bg, .topbar, .tabbar, .no-print, #toasts { display: none !important; }
  .qr-page { display: block; padding: 0; max-width: none; margin: 0; }
  /* fixed = relative to the printable page area, so the poster fills the sheet whatever margins the print dialog uses */
  .poster { position: fixed !important; inset: 0 !important; width: auto !important; height: auto !important; aspect-ratio: auto !important; border-radius: 0; box-shadow: none; margin: 0; break-inside: avoid; }
  .poster, .poster * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .qr-slot svg[data-modules] { width: 100% !important; height: auto !important; }
  .card { box-shadow: none; border: 2px solid #eee; backdrop-filter: none; background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.poster.landscape.has-img .p-mascot { width: 15.5cqw; }
