/* Family Care — mobile-first, iPhone optimised. Light pastel theme. */
:root {
  --bg: #fff8fb;
  --card: #ffffff;
  --ink: #2b2433;
  --muted: #776e80;
  --line: #efe6ef;
  --shadow: 0 1px 2px rgba(60, 30, 70, .06), 0 4px 14px rgba(60, 30, 70, .06);

  /* Personal identity colours (who). Bar = timeline fill, bg = chips/cards, ink = text, strong = buttons. */
  --person-kvang: #f4a9c0;
  --person-kvang-bg: #fde8ef;
  --person-kvang-ink: #8a2449;
  --person-kvang-strong: #c2416e;
  --person-gift: #8dd3c4;
  --person-gift-bg: #e0f4ef;
  --person-gift-ink: #1c5b50;
  --person-gift-strong: #237a6b;
  --person-father: #9fc8f0;
  --person-father-bg: #e4f0fc;
  --person-father-ink: #1b4d7e;
  --person-father-strong: #2f6fae;

  /* Functional status colours (what state). Never reused for a person. */
  --status-pending: #d98a00;
  --status-pending-bg: #fff6e0;
  --status-danger: #d93a40;
  --status-danger-bg: #fde9ea;
  --status-ok: #1f8a4c;
  --status-ok-bg: #e5f6ec;
  --status-info-bg: #eef1f5;
  --status-info-ink: #3c4b5a;

  /* Neutral app accent (not a person). */
  --accent: #6c4fc4;
  --accent-ink: #5b3fb3;

  /* Overnight (คนนอนเฝ้า) theme, used with 🌙. Not a person colour. */
  --night: #7c6ad6;
  --night-bg: #ece8fb;
  --night-ink: #3b2a7a;

  --radius: 16px;
  --tap: 46px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Thonburi", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
body.has-layer { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #7b5cd6; outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
small { font-size: .85em; }

.fc-boot { padding: 48px 20px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------- login */
.is-login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); background: linear-gradient(180deg, #fff0f6 0%, #f3edff 100%); }
.login { width: 100%; max-width: 380px; text-align: center; transition: opacity .2s; }
.login.busy { opacity: .6; pointer-events: none; }
.login.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.login-brand h1 { font-size: 28px; margin: 8px 0 2px; }
.login-brand p { margin: 0 0 20px; color: var(--muted); }
.login-brand.small { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 18px; }
.login-brand.small h1 { margin: 0; }
.login-logo { font-size: 44px; }
.login-notice { background: var(--status-pending-bg); border-radius: 12px; padding: 10px; }
.login-people { display: grid; gap: 14px; }
.person { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 84px; padding: 14px 20px; border: 0; border-radius: 22px; box-shadow: var(--shadow); font-size: 24px; font-weight: 700; text-align: left; }
.person-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.person-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.person-avatar { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; background: #fff; }
.login-brand .person-kvang { background: var(--person-kvang-bg); }
.login-brand .person-gift { background: var(--person-gift-bg); }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 6px 0 10px; }
.pin-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #9a8aa8; }
.pin-dot.on { background: var(--accent); border-color: var(--accent); }
.pin-msg { min-height: 24px; color: var(--muted); margin: 0 0 14px; }
.pin-msg.err { color: var(--status-danger); font-weight: 600; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto 14px; }
.key { height: 68px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow); font-size: 28px; font-weight: 600; aspect-ratio: 1; justify-self: center; width: 68px; }
.key:active { background: #efe9fd; }
.key-del { background: transparent; box-shadow: none; font-size: 24px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 10px; font-weight: 600; min-height: var(--tap); }

/* ---------------------------------------------------------- app shell */
.is-app { padding-bottom: calc(76px + var(--safe-b)); }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 12px 8px; background: rgba(255, 248, 251, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-title { flex: 1; font-weight: 700; font-size: 17px; text-align: center; }
.me-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-weight: 700; }
.me-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.me-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.badge-btn { border: 0; border-radius: 999px; padding: 8px 12px; min-height: 40px; font-weight: 700; font-size: 15px; }
.badge-btn.urgent { background: var(--status-danger); color: #fff; animation: pulse 2s infinite; }
.badge-btn.pending { background: var(--status-pending); color: #fff; }
.badge-btn.clear { background: var(--status-ok-bg); color: var(--status-ok); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 58, 64, .45); } 50% { box-shadow: 0 0 0 7px rgba(217, 58, 64, 0); } }
@media (prefers-reduced-motion: reduce) { .badge-btn.urgent { animation: none; } }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border: 0; background: transparent; border-radius: 12px; font-size: 22px; line-height: 1; }
.icon-btn:active { background: #f1e8f3; }

.offline { background: #333; color: #fff; padding: 8px 14px; text-align: center; font-size: 14px; }
.main { padding: 12px 12px 24px; max-width: 760px; margin: 0 auto; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tab { border: 0; background: transparent; padding: 8px 2px 10px; min-height: 60px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; line-height: 1.25; text-align: center; }
.tab-icon { font-size: 22px; line-height: 1.1; }
.tab.active { color: var(--accent-ink); }
.tab.active .tab-icon { transform: scale(1.1); }

.section-title { font-size: 19px; margin: 14px 2px 10px; display: flex; align-items: center; gap: 8px; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--status-pending); color: #fff; font-size: 14px; }
.count.urgent { background: var(--status-danger); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card-done { background: var(--status-ok-bg); color: var(--status-ok); font-weight: 600; }
.note { color: var(--muted); font-size: 14px; margin: 6px 0; }
.note.err { color: var(--status-danger); font-weight: 600; }

/* ---------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 10px 16px; border-radius: 14px; border: 1.5px solid transparent; font-weight: 700; font-size: 16px; text-align: center; }
.btn:disabled { opacity: .55; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid #fff; border-top-color: transparent; animation: spin .8s linear infinite; }
.btn-ghost.is-busy::after, .btn-chip.is-busy::after, .seg-opt.is-busy::after { border-color: var(--accent); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-block { width: 100%; margin-top: 10px; }
.btn-small { min-height: 38px; padding: 6px 12px; font-size: 14.5px; border-radius: 11px; }
.btn-primary { background: var(--accent); color: #fff; }
.me-kvang .btn-me, .is-app.me-kvang .btn-me { background: var(--person-kvang-strong); }
.is-app.me-gift .btn-me { background: var(--person-gift-strong); }
.btn-ghost { background: #fff; border-color: #ddd2e4; color: var(--ink); }
.btn-link { background: transparent; color: var(--accent-ink); padding-left: 6px; padding-right: 6px; }
.btn-father { background: var(--person-father-strong); color: #fff; }
.btn-father-ghost { background: var(--person-father-bg); color: var(--person-father-ink); border-color: #bcd7f1; }
.btn-danger { background: var(--status-danger); color: #fff; }
.btn-danger-ghost { background: #fff; color: var(--status-danger); border-color: #f2c4c6; }
.btn-chip { background: #fff; border-color: #ddd2e4; border-radius: 999px; min-height: 40px; padding: 6px 14px; font-size: 15px; }
.btn-chip.on { border-color: var(--accent); background: #f1ecfe; }
.chip-kvang { background: var(--person-kvang-bg); border-color: var(--person-kvang); color: var(--person-kvang-ink); }
.chip-gift { background: var(--person-gift-bg); border-color: var(--person-gift); color: var(--person-gift-ink); }
.chip-father { background: var(--person-father-bg); border-color: var(--person-father); color: var(--person-father-ink); }

/* ---------------------------------------------------------- banners & actions */
.banner { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; border-radius: var(--radius); padding: 14px; margin-bottom: 10px; font-size: 15px; }
.banner-urgent { background: var(--status-danger); color: #fff; box-shadow: 0 4px 14px rgba(217, 58, 64, .3); }
.banner-pending { background: var(--status-pending-bg); color: #6b4300; border: 1.5px solid #f3c56a; }
.banner-icon { font-size: 26px; }
.banner-body { flex: 1; display: flex; flex-direction: column; }
.banner-body strong { font-size: 17px; }
.banner-go { font-size: 26px; opacity: .8; }

.action { border-left: 6px solid #ccc; }
.action-request.from-kvang { border-left-color: var(--person-kvang); }
.action-request.from-gift { border-left-color: var(--person-gift); }
.action-open { border-left-color: var(--status-pending); }
.action-father { border-left-color: var(--status-danger); background: #fffafa; }
.action-overnight { border-left-color: var(--night); }
.action-event { border-left-color: #a59bb0; background: #fcfbfd; }
.action-event.ev-shift_cancelled { border-left-color: var(--status-danger); }
.action-event.ev-shift_accepted, .action-event.ev-father_confirmed { border-left-color: var(--status-ok); }
.action.is-urgent { box-shadow: 0 0 0 2px var(--status-danger), var(--shadow); }
.action-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.kind-chip { font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #f2edf5; }
.kind-request { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.from-gift .kind-request { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.kind-open { background: var(--status-pending-bg); color: #7a4c00; }
.kind-father { background: var(--status-danger-bg); color: #9c1e24; }
.kind-overnight { background: var(--night-bg); color: var(--night-ink); }
.kind-urgent { background: var(--status-danger); color: #fff; }
.action-date { font-size: 14px; color: var(--muted); font-weight: 600; }
.action-title { font-size: 17.5px; margin: 2px 0 4px; line-height: 1.4; }
.action-detail { margin: 0 0 8px; color: var(--muted); font-size: 14.5px; }
.action-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.action-btns .btn-primary, .action-btns .btn-father { flex: 1 1 100%; }

/* ---------------------------------------------------------- week & days */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 6px; }
.week-nav .icon-btn { font-size: 30px; background: #fff; box-shadow: var(--shadow); }
.week-label { text-align: center; display: flex; flex-direction: column; align-items: center; }
.week-label strong { font-size: 18px; }
.week-label .link-btn, .week-label .muted { font-size: 13.5px; padding: 0; min-height: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin: 6px 2px 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 18px; height: 12px; border-radius: 4px; }
.sw-kvang { background: var(--person-kvang); }
.sw-gift { background: var(--person-gift); }
.sw-father { background: var(--person-father); }
.sw-pending { border: 2px dashed var(--status-pending); background: var(--status-pending-bg); }
.sw-gap { background: repeating-linear-gradient(135deg, #fbd2d4 0 4px, #fff 4px 8px); border: 1.5px solid var(--status-danger); }

.days { display: flex; flex-direction: column; }
.day-card { display: block; width: 100%; text-align: left; border: 1.5px solid transparent; padding: 12px 12px 10px; }
.day-card.is-today { border-color: #b9a6ef; }
.day-card.day-urgent { border-color: var(--status-danger); }
.day-card.is-past { opacity: .72; background: #fbfafc; }
.day-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.day-date { display: flex; align-items: center; gap: 8px; font-size: 16.5px; }
.rel { font-size: 12.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f1ecfe; color: var(--accent-ink); }
.rel-today { background: var(--accent-ink); color: #fff; }
.pill { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill-complete { background: var(--status-ok-bg); color: var(--status-ok); }
.pill-incomplete { background: var(--status-pending-bg); color: #7a4c00; }
.pill-urgent { background: var(--status-danger); color: #fff; }
.pill.is-past.pill-incomplete { background: #eee; color: #666; }
.day-bottom { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 14px; }
.day-foot { margin-top: 6px; font-size: 12.5px; }
.night { font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #efedf6; }
.night-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.night-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.night-father { background: var(--person-father-bg); color: var(--person-father-ink); }
.night-none { background: var(--status-danger-bg); color: #9c1e24; }
.appt-chip { padding: 2px 10px; border-radius: 999px; background: var(--status-info-bg); color: var(--status-info-ink); font-weight: 600; }
.pending-chip { padding: 2px 10px; border-radius: 999px; background: var(--status-pending-bg); color: #7a4c00; font-weight: 600; }
.warn-chip { padding: 2px 10px; border-radius: 999px; background: var(--status-danger-bg); color: #9c1e24; font-weight: 600; }

/* ---------------------------------------------------------- timeline */
.tl { position: relative; padding-top: 14px; }
.tl-track { position: relative; height: 34px; border-radius: 10px; background: #f6f2f7; overflow: hidden; box-shadow: inset 0 0 0 1px #ece3ee; }
.tl-big { padding-top: 18px; margin: 8px 0 4px; }
.tl-big .tl-track { height: 58px; border-radius: 12px; }
.tl-grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(120, 100, 130, .14); }
.seg { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.seg + .seg { box-shadow: inset 1.5px 0 0 rgba(255, 255, 255, .9); }
.seg-text { padding: 0 3px; overflow: hidden; text-overflow: ellipsis; }
.seg-kvang { background: var(--person-kvang); color: var(--person-kvang-ink); }
.seg-gift { background: var(--person-gift); color: var(--person-gift-ink); }
.seg-father { background: var(--person-father); color: var(--person-father-ink); }
.seg-pending { background: var(--status-pending-bg); border: 2px dashed var(--status-pending); color: #7a4c00; border-radius: 6px; }
.seg-need-father { background: repeating-linear-gradient(135deg, #fbd2d4 0 6px, #fff3f3 6px 12px); border: 2px solid var(--status-danger); color: #9c1e24; border-radius: 6px; }
.seg-urgent { background: repeating-linear-gradient(135deg, #f7b3b6 0 6px, #fff 6px 12px); border: 2px solid var(--status-danger); color: #8a1218; border-radius: 6px; }
.is-past .seg-gap { filter: grayscale(.7); }
.tl-now { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #2b2433; z-index: 2; }
.tl-now::before { content: ""; position: absolute; top: -3px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: #2b2433; }
.tl-marks { position: absolute; top: 0; left: 0; right: 0; height: 14px; }
.tl-big .tl-marks { height: 18px; }
.tl-mark { position: absolute; transform: translateX(-50%); font-size: 12px; line-height: 1; }
.tl-axis { position: relative; height: 16px; margin-top: 2px; }
.tl-tick { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-tick:first-child { transform: none; }
.tl-tick:last-child { transform: translateX(-100%); }

/* ---------------------------------------------------------- layers */
.layers { position: relative; z-index: 50; }
.layer { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.layer-dialog { align-items: center; padding: 20px; }
.backdrop { position: absolute; inset: 0; background: rgba(40, 20, 50, .38); animation: fade .18s; }
.sheet { position: relative; width: 100%; max-width: 760px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); border-radius: 22px 22px 0 0; padding: 0 14px calc(20px + var(--safe-b)); animation: up .22s ease-out; overscroll-behavior: contain; }
.dialog { position: relative; width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); animation: fade .15s; }
.dialog-msg { font-size: 17px; margin: 0 0 16px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-head { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 8px 0 8px; margin: 0 -2px 4px; }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: #d9cfe0; margin: 0 auto 8px; }
.sheet-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sheet-title { font-size: 19px; margin: 4px 0 2px; }
.sheet-sub { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.block { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin: 12px 0; }
.block-title { font-size: 16.5px; margin: 0 0 8px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.block-title + .row, .block .note + .row { border-top: 0; }
.row-main { flex: 1 1 220px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.row-go { font-size: 22px; color: var(--muted); }
.block-small { display: block; width: 100%; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot-kvang { background: var(--person-kvang); }
.dot-gift { background: var(--person-gift); }
.dot-father { background: var(--person-father); }
.ok-chip { font-size: 12.5px; font-weight: 700; color: var(--status-ok); background: var(--status-ok-bg); padding: 1px 8px; border-radius: 999px; }
.gap-father .row-main { color: #9c1e24; font-weight: 700; }
.gap-pending .row-main { color: #7a4c00; font-weight: 600; }
.seg-row.is-urgent .row-main { color: #8a1218; }
.warn-box { background: var(--status-danger-bg); color: #8a1218; padding: 10px 12px; border-radius: 12px; font-weight: 600; margin: 8px 0; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; background: #f3eef5; padding: 4px; border-radius: 14px; }
.seg-opt { flex: 1 1 auto; min-height: 42px; border: 0; border-radius: 11px; background: transparent; font-weight: 700; font-size: 15px; padding: 6px 10px; }
.seg-opt.on { background: #fff; box-shadow: 0 1px 4px rgba(60, 30, 70, .15); }
.seg-opt.on.chip-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.seg-opt.on.chip-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.seg-opt.on.chip-father { background: var(--person-father-bg); color: var(--person-father-ink); }
.segmented.small .seg-opt { font-size: 14px; min-height: 40px; }
.state-chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: #eee; color: #555; font-weight: 700; }
.state-available { background: var(--status-ok-bg); color: var(--status-ok); }
.state-unavailable, .state-all_day { background: var(--status-danger-bg); color: #9c1e24; }

/* ---------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 8px; }
.field-label { font-weight: 700; font-size: 15px; margin-top: 8px; }
.field-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.input { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1.5px solid #ddd2e4; border-radius: 12px; background: #fff; font-size: 16px; }
.field-row .input { width: auto; flex: 1; }
textarea.input { resize: vertical; }
.range-row { display: flex; align-items: flex-end; gap: 8px; }
.range-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; }
.range-dash { padding-bottom: 12px; font-weight: 700; }
.time-select { width: 100%; min-height: 50px; padding: 8px 10px; border: 1.5px solid #ddd2e4; border-radius: 12px; background: #fff; font-size: 18px; font-variant-numeric: tabular-nums; }
.date-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.date-chip { flex: none; scroll-snap-align: start; width: 62px; min-height: 64px; border-radius: 14px; border: 1.5px solid #ddd2e4; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.date-chip strong { font-size: 20px; }
.date-chip small { font-size: 12px; color: var(--muted); }
.date-chip.on { border-color: var(--accent); background: #f1ecfe; }
.selected-date { font-weight: 700; margin: 2px 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------- appointments & history */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.appt-group { padding-top: 10px; }
.appt-row { cursor: pointer; }
.time-chip { font-size: 13px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: var(--status-info-bg); color: var(--status-info-ink); }
.time-unknown { background: #f1eef3; color: #6b6275; }
.past { margin-top: 14px; }
.past summary { font-weight: 700; padding: 12px 2px; cursor: pointer; min-height: var(--tap); }
.past-item { background: #fff; border-radius: 12px; padding: 0 12px; margin-bottom: 6px; }

.filters { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 8px; }
.filter-row > * { flex: 1; min-width: 0; }
.filter-row label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.hist-list { display: flex; flex-direction: column; gap: 8px; }
.hist-row { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; }
.hist-mini .hist-row { box-shadow: none; border-top: 1px solid var(--line); border-radius: 0; padding: 8px 0; }
.hist-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hist-label { font-weight: 700; }
.hist-time { margin-left: auto; font-size: 13px; }
.hist-summary { margin-top: 2px; }
.hist-date { font-size: 13px; }
.who-chip { font-size: 13px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: #eee; }
.who-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.who-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.who-system { background: #e9eef3; color: #3c4b5a; }
.hist-details summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; padding: 6px 0; }
.hist-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13.5px; }
.kv div { word-break: break-word; }

/* ---------------------------------------------------------- ตารางของฉัน */
.me-chip.small { padding: 2px 10px; font-size: 13px; }
.mine-toggle { margin: 8px 0 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.stat strong { font-size: 28px; line-height: 1.1; }
.stat span { font-weight: 700; font-size: 14px; }
.stat small { color: inherit; opacity: .8; }
.stat-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.stat-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.stat-night { background: var(--night-bg); color: var(--night-ink); }
.mine-day { display: block; width: 100%; text-align: left; border: 1.5px solid transparent; }
.mine-day.is-today { border-color: #b9a6ef; }
.mine-day.is-both { border-left: 6px solid var(--night); }
.mine-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mine-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px; border-radius: 12px; margin-top: 6px; }
.mine-shift-kvang { background: var(--person-kvang-bg); color: var(--person-kvang-ink); }
.mine-shift-gift { background: var(--person-gift-bg); color: var(--person-gift-ink); }
.mine-time { font-size: 18px; font-variant-numeric: tabular-nums; }
/* Keep the green "confirmed" status chip visually separate from Gift's teal row. */
.mine-line .ok-chip, .seg-row .ok-chip { background: #fff; box-shadow: inset 0 0 0 1px #bfe3cc; }
.mine-night { background: var(--night-bg); color: var(--night-ink); }
.mine-moon { font-size: 18px; }
.mine-both { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.mine-empty { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 16px; }
.mine-empty-icon { font-size: 36px; }

/* ---------------------------------------------------------- floating */
.fab { position: fixed; right: 14px; bottom: calc(76px + var(--safe-b)); z-index: 25; border: 0; border-radius: 999px; padding: 14px 18px; min-height: 52px; font-weight: 800; font-size: 16px; color: #fff; background: var(--accent); box-shadow: 0 6px 20px rgba(80, 50, 160, .35); }
.is-app.me-kvang .fab { background: var(--person-kvang-strong); box-shadow: 0 6px 20px rgba(194, 65, 110, .35); }
.is-app.me-gift .fab { background: var(--person-gift-strong); box-shadow: 0 6px 20px rgba(35, 122, 107, .35); }
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(140px + var(--safe-b)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: 520px; padding: 12px 16px; border-radius: 14px; color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); transition: opacity .35s, transform .35s; }
.toast-ok { background: #1f7a45; }
.toast-err { background: #c22f35; }
.toast-warn { background: #8a5a00; }
.toast.out { opacity: 0; transform: translateY(10px); }
.newdata { position: fixed; top: calc(64px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 40; border: 0; border-radius: 999px; padding: 10px 16px; background: #2b2433; color: #fff; font-weight: 700; box-shadow: var(--shadow); }

@media (min-width: 700px) {
  .main { padding: 16px 20px 40px; }
  .action-btns .btn-primary, .action-btns .btn-father { flex: 0 1 auto; }
  .sheet { border-radius: 22px; margin-bottom: 20px; max-height: 88vh; }
  .layer-sheet { align-items: center; }
}
