/* ---------- Cards, buttons, forms, chips, banners ---------- */
.card { background: var(--card); border: 1px solid var(--outline-soft); border-radius: var(--radius); padding: var(--space-4); box-shadow: var(--shadow-1); }
.card + .card { margin-top: var(--space-3); }
.card.flat { box-shadow: none; }
.card h3, .card .h-sub { margin-bottom: var(--space-2); }
.grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.tight { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.hub-section + .hub-section { margin-top: var(--space-5); }

.tile { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); border-radius: var(--radius); background: var(--card); border: 1px solid var(--outline-soft); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-1); min-height: 92px; transition: transform .12s ease, box-shadow .12s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); color: var(--ink); }
.tile .tile-ico { font-size: 1.6rem; line-height: 1; }
.tile .tile-title { font-weight: 600; color: var(--plum-deep); }
.tile .tile-sub { font-size: .82rem; color: var(--ink-faint); }
.tile.premium::after { content: "★"; position: absolute; inset-inline-end: 10px; top: 8px; color: var(--gold-deep); }
.tile { position: relative; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 8px 18px; border: 1px solid transparent; border-radius: 999px; background: var(--plum); color: var(--on-plum); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); color: var(--on-plum); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--plum-deep); border-color: var(--outline); }
.btn.secondary:hover { background: var(--lavender-soft); color: var(--plum-deep); }
.btn.sage { background: var(--sage); color: var(--on-sage); }
.btn.danger { background: var(--danger); color: var(--on-danger); }
.btn.ghost { background: transparent; color: var(--plum); padding-inline: 10px; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .88rem; }
.icon-btn { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; color: var(--ink-soft); font-size: 1.2rem; }
.icon-btn:hover { background: var(--lavender-soft); color: var(--plum-deep); }

label.field { display: block; margin-bottom: var(--space-3); }
label.field > .lbl { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], input[type="password"], input[type="email"], input[type="tel"], input[type="url"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; background: var(--cream); border: 1px solid var(--outline); border-radius: var(--radius-s); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input[type="checkbox"], input[type="radio"] { flex: none; width: 20px; height: 20px; accent-color: var(--plum); vertical-align: middle; } /* flex: none, or a long wrapped label squeezes the box */
input[type="range"] { width: 100%; accent-color: var(--plum); }
.check { display: flex; align-items: flex-start; gap: var(--space-3); padding: 10px 4px; border-bottom: 1px solid var(--outline-soft); }
.check.done .check-text { text-decoration: line-through; color: var(--ink-faint); }
.check-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border-radius: 999px; background: var(--lavender-soft); color: var(--plum-deep); font-size: .82rem; border: 1px solid transparent; }
button.chip { cursor: pointer; }
.chip[aria-pressed="true"], .chip.on { background: var(--plum); color: var(--on-plum); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.caution { background: var(--caution-bg); color: var(--caution); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }

.banner { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid var(--outline-soft); background: var(--lavender-soft); color: var(--ink); margin-bottom: var(--space-3); }
.banner.info { background: var(--lavender-soft); }
.banner.good { background: var(--good-bg); border-color: var(--good); }
.banner.caution { background: var(--caution-bg); border-color: var(--caution); }
.banner.danger { background: var(--danger-bg); border-color: var(--danger); }
.banner .banner-ico { font-size: 1.3rem; line-height: 1.3; }
.banner .banner-body { flex: 1 1 auto; min-width: 0; }
.banner .banner-title { font-weight: 700; display: block; }

.tabs { display: flex; gap: var(--space-2); overflow-x: auto; border-bottom: 1px solid var(--outline-soft); margin-bottom: var(--space-4); padding-bottom: 2px; }
.tabs button { flex: 0 0 auto; border: 0; background: transparent; padding: 10px 16px; border-radius: var(--radius-s) var(--radius-s) 0 0; cursor: pointer; color: var(--ink-soft); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--plum-deep); border-bottom-color: var(--plum); }

.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; align-items: center; gap: var(--space-3); padding: 12px 4px; border-bottom: 1px solid var(--outline-soft); }
.list > li:last-child { border-bottom: 0; }
.list .li-main { flex: 1 1 auto; min-width: 0; }
.list .li-title { font-weight: 600; }
.list .li-sub { font-size: .85rem; color: var(--ink-faint); }

table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--outline-soft); vertical-align: top; }
table.data th { color: var(--plum-deep); font-weight: 700; background: var(--lavender-soft); }
.table-wrap { overflow-x: auto; }

.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--ink-faint); }
.empty .empty-hero { width: 96px; height: auto; opacity: .55; margin: 0 auto var(--space-2); display: block; }
.empty .empty-ico { font-size: 2.4rem; display: block; margin-bottom: var(--space-2); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.page-head p { color: var(--ink-faint); margin: 0; }
.crumbs { font-size: .85rem; margin-bottom: var(--space-2); }
.crumbs a { color: var(--ink-faint); }

.progress { height: 10px; border-radius: 999px; background: var(--outline-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--sage); border-radius: 999px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .stat-n { font-size: 1.7rem; font-weight: 700; color: var(--plum-deep); font-family: var(--font-display); }
.stat .stat-l { font-size: .8rem; color: var(--ink-faint); }

.spark { width: 100%; height: 64px; display: block; }
.spark path { fill: none; stroke: var(--plum); stroke-width: 2; stroke-linejoin: round; }
.spark .band { fill: var(--good-bg); stroke: none; }

/* Modal + toast */
@keyframes modal-back-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-box-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; background: rgb(20 10 25 / 55%); z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--space-4); animation: modal-back-in .15s ease-out; }
.modal { background: var(--cream); border-radius: var(--radius-l); padding: var(--space-5); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-2); animation: modal-box-in .18s ease-out; }
.modal .modal-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); flex-wrap: wrap; }
.toasts { position: fixed; inset-inline: 0; bottom: calc(var(--bottombar-h) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 120; pointer-events: none; padding: 0 var(--space-3); }
@media (min-width: 861px) { .toasts { bottom: 24px; } }
.toast { background: var(--plum-deep); color: var(--cream); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-2); font-size: .92rem; pointer-events: auto; max-width: 92vw; animation: toast-in .18s ease-out; }
:root[data-mode="dark"] .toast { background: var(--plum); color: var(--on-plum); }
.toast-act { margin-inline-start: 8px; background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 999px; padding: 2px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.toast-act:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* Lock screen */
.lock { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); padding: var(--space-5); text-align: center; }
.pin-dots { display: flex; gap: 12px; justify-content: center; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--plum); }
.pin-dots span.on { background: var(--plum); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; }
.pin-pad button { height: 64px; border-radius: 50%; border: 1px solid var(--outline); background: var(--card); font-size: 1.4rem; cursor: pointer; }
.pin-pad button:hover { background: var(--lavender-soft); }

/* Guide reader */
.prose { max-width: 70ch; }
.prose p { line-height: 1.75; }
.prose blockquote { margin: var(--space-3) 0; padding: var(--space-2) var(--space-4); border-inline-start: 4px solid var(--lavender); background: var(--lavender-soft); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.scale { display: flex; gap: 6px; flex-wrap: wrap; }
.scale button { min-width: 44px; min-height: 44px; border-radius: 50%; border: 1px solid var(--outline); background: var(--cream); cursor: pointer; font-weight: 600; }
.scale button[aria-pressed="true"] { background: var(--plum); color: var(--on-plum); border-color: var(--plum); }

/* Large touch buttons, emergency call, key/value lists */
.btn.big { min-height: 64px; font-size: 1.25rem; width: 100%; }
.emergency-call { display: flex; flex-direction: column; gap: var(--space-1, 4px); text-align: center; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--space-4); margin: 0; }
dl.kv dt { font-weight: 600; color: var(--ink-soft); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { margin-top: var(--space-2); } }
