#app { min-height: 100dvh; }
.shell { display: block; }
.main { width: 100%; max-width: 480px; margin: 0 auto; padding: calc(var(--safe-t) + .75rem) 1.25rem calc(var(--nav-h) + var(--safe-b) + 1.5rem); }
.page > * + * { margin-top: 1.5rem; }

/* แถบนำทางล่าง (มือถือ) */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center; padding: 0 .75rem calc(.5rem + var(--safe-b)); pointer-events: none; }
.bottom-nav .dock { pointer-events: auto; width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-card); padding: .35rem .25rem; height: 64px; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .25rem; color: var(--ink-mute); font-size: .6875rem; font-weight: 600; border-radius: 14px; min-height: 48px; justify-content: center; }
.nav-item .ms { font-size: 1.5rem; }
.nav-item[aria-current='page'] { color: var(--primary); }
.nav-item[aria-current='page'] .ms { font-variation-settings: 'FILL' 1; }
.nav-fab { position: relative; top: -22px; display: flex; flex-direction: column; align-items: center; color: var(--primary); font-size: .6875rem; font-weight: 600; gap: 4px; }
.nav-fab .disc { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #D97706, #78350F); box-shadow: var(--shadow-float); border: 3px solid var(--canvas); }
.nav-fab .disc .ms { font-size: 2rem; }

/* แถบข้าง (แท็บเล็ต/เดสก์ท็อป) */
.rail { display: none; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
  .rail { display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100dvh; padding: 1.5rem 1rem; border-right: 1px solid var(--line); background: var(--canvas-2); }
  .rail .brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-head); font-weight: 600; font-size: 1.125rem; padding: 0 .5rem 1.25rem; color: var(--primary-ink); }
  .rail .brand img { width: 36px; height: 36px; border-radius: 10px; }
  .rail a, .rail button.rail-link { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; border-radius: 14px; color: var(--ink-soft); font-weight: 600; width: 100%; text-align: left; }
  .rail a:hover, .rail button.rail-link:hover { background: var(--amber-tint); }
  .rail a[aria-current='page'] { background: var(--amber-wash); color: var(--primary-ink); }
  .rail .spacer { flex: 1; }
  .rail .rail-add { margin-bottom: 1rem; justify-content: center; background: linear-gradient(135deg, #D97706, #78350F); color: #fff; box-shadow: var(--shadow-float); }
  .rail .rail-add:hover { background: linear-gradient(135deg, #D97706, #78350F); filter: brightness(1.06); }
  .bottom-nav { display: none; }
  .main { max-width: 1040px; padding: 2rem 2.5rem 3rem; }
  .cols-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.5rem; align-items: start; }
  .cols-2 > * + * { margin-top: 0; }
  .cols-2 .col > * + * { margin-top: 1.5rem; }
  .page > .cols-2 { margin-top: 1.5rem; }
}
@media (min-width: 600px) and (max-width: 899px) { .main { max-width: 640px; } }

/* หัวหน้าทั่วไป */
.page-head { display: flex; align-items: center; gap: .75rem; }
.page-head h1 { font-size: 1.5rem; flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-soft); position: relative; flex: none; }
.icon-btn:hover { background: var(--amber-tint); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .6875rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--canvas); }

/* โมดอล/ชีต */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--canvas); border-radius: 24px 24px 0 0; padding: 1.25rem 1.25rem calc(1.5rem + var(--safe-b)); animation: rise .22s ease; }
.sheet .sheet-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.sheet .sheet-head h2 { flex: 1; font-size: 1.25rem; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 24px; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + .75rem); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; padding: 0 1rem; }
@media (min-width: 900px) { #toasts { bottom: 1.5rem; } }
.toast { pointer-events: auto; background: var(--ink); color: var(--canvas); padding: .7rem 1.1rem; border-radius: var(--r-pill); font-weight: 600; font-size: .875rem; box-shadow: var(--shadow-float); max-width: 92vw; animation: rise .2s ease; }
.toast.error { background: var(--danger); color: #fff; } .toast.success { background: var(--jade); color: #fff; }
