/* ===== Tehillim Yachad - Minimal Blue + Black ===== */

:root {
    /* Core palette — black, white, gray, ONE blue accent */
    --bg:           #ffffff;
    --bg-soft:      #f7f9f9;
    --surface:      #ffffff;
    --line:         #eff3f4;
    --line-strong:  #cfd9de;
    --ink:          #0f1419;
    --ink-soft:     #536471;
    --muted:        #8899a6;

    --primary:        #1d9bf0;
    --primary-dark:   #1a8cd8;
    --primary-soft:   #e8f5fd;
    --primary-text:   #1d9bf0;

    --success:        #00ba7c;
    --success-soft:   #def1e6;
    --success-text:   #00754d;

    --danger:         #f4212e;
    --danger-soft:    #fdebec;

    --shadow-xs: 0 0 0 1px rgba(15, 20, 25, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 20, 25, 0.06);
    --shadow:    0 8px 28px rgba(15, 20, 25, 0.10);
    --shadow-lg: 0 24px 56px rgba(15, 20, 25, 0.18);

    --r-sm:  8px;
    --r:     14px;
    --r-lg:  18px;
    --r-pill:999px;

    --font: 'Heebo', -apple-system, 'Segoe UI', system-ui, sans-serif;

    --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    direction: rtl;
    font-size: 15.5px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--ink); font-weight: 800; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; line-height: 1.25; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-dark); }

.icon { width: 22px; height: 22px; flex-shrink: 0; }

/* ============ Logged-in shell: sidebar + main + mobile bar ============ */

body.has-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

.sidebar {
    grid-column: 1;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 16px 14px 16px 18px;
    border-inline-end: 1px solid var(--line-strong);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    z-index: 20;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    padding: 10px 14px;
    margin-bottom: 8px;
    font-weight: 800;
    font-size: 1.15rem;
}
.brand-mark { display: inline-flex; align-items: center; color: var(--primary); }
.brand-mark .icon { width: 26px; height: 26px; stroke-width: 2.2; }
.brand-text { font-weight: 800; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--r-pill);
    color: var(--ink);
    font-weight: 500;
    font-size: 1.05rem;
    transition: background 0.12s ease;
}
.nav-item:hover { background: var(--bg-soft); color: var(--ink); }
.nav-item.active { font-weight: 800; }
.nav-item.active .icon { stroke-width: 2.5; }
.nav-item .icon { color: var(--ink); }
.nav-count {
    margin-inline-start: auto;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 1px 8px;
    border-radius: var(--r-pill);
    min-width: 22px;
    text-align: center;
    line-height: 1.5;
}
.nav-count:empty, .nav-count[hidden] { display: none; }

.side-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r);
    margin-bottom: 4px;
    text-decoration: none;
    color: var(--ink);
    transition: background 0.12s;
}
.user-card:hover { background: var(--bg-soft); color: var(--ink); }
.user-card.active { background: var(--primary-soft); }
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.user-info { min-width: 0; flex: 1; }
.user-name { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-handle { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main {
    grid-column: 2;
    min-width: 0;
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
    padding: 20px 24px 80px;
}

.foot {
    grid-column: 2;
    text-align: center;
    padding: 16px 16px 32px;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.7;
}
.foot .foot-mail {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    direction: ltr;
    display: inline-block;
}
.foot .foot-mail:hover { text-decoration: underline; }
body.guest .foot .foot-mail { color: var(--primary); }

.mobile-bar { display: none; }

/* ============ Guest (logged-out) layout ============ */

body.guest .main { max-width: 740px; margin: 0 auto; padding: 24px 20px 60px; }
.guest-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}
.guest-top .brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.15rem; }
.guest-top nav { display: flex; gap: 12px; align-items: center; }
.guest-top nav a { color: var(--ink); font-weight: 600; }
.guest-top nav a:hover { color: var(--primary); }
body.guest .foot { text-align: center; padding: 24px 16px 40px; color: var(--muted); font-size: 0.85rem; }

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 80px 20px 36px;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 14px; font-weight: 900; letter-spacing: -0.02em; }
.hero .lead { font-size: 1.1rem; color: var(--ink-soft); max-width: 520px; margin: 0 auto; }
.hero .cta { margin-top: 28px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.how {
    background: var(--bg-soft);
    border-radius: var(--r-lg);
    padding: 28px;
    border: 1px solid var(--line);
    max-width: 640px;
    margin: 24px auto 0;
}
.how h2 { margin-top: 0; }
.how ol { margin: 0; padding-inline-start: 20px; line-height: 1.85; }
.how ol li { margin-bottom: 6px; color: var(--ink-soft); }
.how ol li::marker { color: var(--primary); font-weight: 800; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: scale(0.98); }

.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.dark:hover { background: #2a2f36; }

.btn.success { background: var(--success); color: #fff; border-color: var(--success); }
.btn.success:hover { background: var(--success-text); }

.btn.danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger-outline:hover { background: var(--danger-soft); }

.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { background: #c81e2b; }

.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--ink); }

.btn.small { padding: 6px 14px; font-size: 0.85rem; }
.btn.big { padding: 13px 24px; font-size: 1rem; }
.btn.block { display: flex; width: 100%; }
.btn .icon { width: 18px; height: 18px; }

.link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font: inherit; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ===== Password input with eye toggle ===== */
.password-field { position: relative; }
.password-field input { padding-inline-start: 44px !important; }
.password-field .pw-toggle {
    position: absolute;
    bottom: 8px;
    inset-inline-start: 6px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    transition: background 0.12s, color 0.12s;
}
.password-field .pw-toggle:hover { background: var(--bg-soft); color: var(--ink); }
.password-field .pw-toggle .icon { width: 20px; height: 20px; }
.password-field .pw-toggle .pw-off { display: none; }
.password-field .pw-toggle[aria-pressed="true"] .pw-on  { display: none; }
.password-field .pw-toggle[aria-pressed="true"] .pw-off { display: inline-flex; }

/* ===== Cards & forms ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 28px;
    margin-bottom: 16px;
}
.card.narrow { max-width: 440px; margin: 32px auto; }
.card h1 { margin-top: 0; font-size: 1.5rem; }

.card form label {
    display: block;
    margin: 14px 0;
    font-weight: 600;
    color: var(--ink-soft);
    font-size: 0.92rem;
}
.card form input, .card form select, .card form textarea {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r);
    font: inherit;
    background: var(--bg);
    margin-top: 6px;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.card form input:focus, .card form select:focus, .card form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 540px) { .row-2 { grid-template-columns: 1fr; } }

.toggle-group { display: flex; gap: 8px; margin-top: 6px; }
.toggle-group label {
    flex: 1;
    margin: 0 !important;
    padding: 12px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r);
    cursor: pointer;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    transition: all 0.12s;
    background: var(--bg);
}
.toggle-group label:hover { border-color: var(--primary); }
.toggle-group input[type="radio"] { width: auto; margin: 4px 0 0; padding: 0; accent-color: var(--primary); }
.toggle-group input[type="radio"]:checked + .toggle-content { color: var(--primary); }
.toggle-group label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.toggle-content { display: flex; flex-direction: column; gap: 2px; }
.toggle-content strong { font-weight: 700; color: var(--ink); font-size: 0.95rem; }
.toggle-content small { color: var(--muted); font-size: 0.82rem; font-weight: 400; }

.card form button[type="submit"] { margin-top: 20px; width: 100%; padding: 13px; font-size: 1rem; }

.errors {
    background: var(--danger-soft);
    border: 1px solid #f5c0c4;
    padding: 10px 14px;
    border-radius: var(--r);
    color: #8c1a22;
    margin: 12px 0;
    font-weight: 500;
    font-size: 0.9rem;
}
.errors div + div { margin-top: 3px; }

.muted { color: var(--muted); font-size: 0.9rem; }
small.muted { display: block; margin-top: 4px; }

/* ===== Page head ===== */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.empty {
    background: var(--bg-soft);
    border: 1.5px dashed var(--line-strong);
    padding: 48px 20px;
    text-align: center;
    border-radius: var(--r-lg);
    color: var(--muted);
}

/* ===== Feed / Room cards ===== */
.feed { display: flex; flex-direction: column; gap: 12px; }
.room-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }

.room-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    transition: background 0.12s, border-color 0.12s;
    overflow: hidden;
}
.room-card:hover { background: var(--bg-soft); border-color: var(--line-strong); }
.room-card a { display: block; padding: 18px 22px; text-decoration: none; color: inherit; position: relative; }

.room-card h3.room-title {
    margin: 0 0 4px;
    font-size: 1.15rem;
    color: var(--ink);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.room-card .title-text { font-weight: 800; line-height: 1.25; }
.room-card .ded { color: var(--primary); font-size: 0.95rem; margin-bottom: 8px; font-weight: 500; }
.room-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.85rem;
    color: var(--muted);
    margin: 8px 0 10px;
    align-items: center;
}
.room-card .meta > span { display: inline-flex; align-items: center; gap: 4px; line-height: 1.2; }
.room-card .meta .icon { width: 14px; height: 14px; flex-shrink: 0; }
.room-card .my-progress {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-soft);
    color: var(--primary-text);
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 0.82rem;
    font-weight: 700;
}
.room-card.is-member { border-color: var(--primary); }
.room-card.is-member::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    inset-inline-end: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary-soft);
    color: var(--primary-text);
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; flex-shrink: 0; }
.badge.done    { background: var(--success-soft); color: var(--success-text); }
.badge.urgent  { background: #fef2f2; color: var(--danger); }
.badge.warm    { background: #fff7e6; color: #a35a00; }
.badge.member  { background: var(--primary); color: #fff; }
.badge.private { background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line-strong); }
.badge.closed  { background: #f0f0f0; color: var(--ink-soft); }
/* Pinned badge — in-palette (Twitter blue) instead of the off-theme amber. */
.badge.pinned  {
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge.pinned .icon { width: 12px; height: 12px; }

/* Small admin pill shown next to creator names */
.admin-tag-mini {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    line-height: 1.5;
    vertical-align: middle;
    margin-inline-start: 4px;
}
.admin-tag-mini .icon { width: 10px; height: 10px; }

/* Pinned room cards get a subtle primary-blue accent stripe on the left */
.room-card.is-pinned { box-shadow: inset 4px 0 0 var(--primary); }

/* ===== Progress bar ===== */
.progress { background: var(--line); border-radius: var(--r-pill); height: 6px; overflow: hidden; }
.progress .bar { background: var(--success); height: 100%; width: 0; transition: width 0.6s ease; border-radius: var(--r-pill); }
.progress.big { height: 10px; }

/* Two-tone progress: blue "taken" layer + green "done" layer on top.
   The done bar overlays the taken bar (both anchored to the start). */
.progress.two-tone { position: relative; background: var(--line); }
.progress.two-tone .bar { position: absolute; top: 0; inset-inline-start: 0; height: 100%; }
.progress.two-tone .taken-bar { background: var(--primary); }
.progress.two-tone .done-bar  { background: var(--success); z-index: 2; }
.progress.big .bar { background: linear-gradient(90deg, var(--primary), var(--success)); }

/* ===== Room view ===== */
.room-header {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    margin-bottom: 16px;
}
.room-header h1 { margin: 0; font-size: 1.5rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-header .title-text { line-height: 1.3; }
.room-header .ded.big { font-size: 1.05rem; color: var(--primary); margin: 4px 0 14px; font-weight: 500; }
.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    align-items: center;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.92rem;
}
.meta-row > span { display: inline-flex; align-items: center; gap: 4px; line-height: 1.2; }
.meta-row .icon { width: 14px; height: 14px; flex-shrink: 0; }
.meta-row code {
    background: var(--bg-soft);
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    font-family: 'SF Mono', Menlo, monospace;
    font-weight: 600;
    color: var(--ink);
    font-size: 0.85rem;
}
.progress-text {
    font-size: 0.92rem;
    color: var(--ink-soft);
    margin-top: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.progress-text strong { color: var(--ink); font-weight: 700; }
.pct-pill {
    display: inline-block;
    background: var(--success-soft);
    color: var(--success-text);
    padding: 2px 12px;
    border-radius: var(--r-pill);
    font-weight: 700;
    font-size: 0.82rem;
    margin-inline-start: auto;
}

.owner-tools { display: inline-flex; gap: 6px; margin-inline-start: auto; align-items: center; }
.share-btn { padding: 8px 18px; gap: 6px; }
.share-btn .icon { width: 16px; height: 16px; }
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn .icon { width: 18px; height: 18px; }

.closed-banner {
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    padding: 14px 18px;
    margin-bottom: 14px;
    color: var(--ink-soft);
    display: flex;
    gap: 10px;
    align-items: center;
}
.closed-banner .icon { color: var(--ink-soft); }

.view-toggle {
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 18px 0 14px;
    flex-wrap: wrap;
    background: var(--bg-soft);
    padding: 4px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line);
    width: fit-content;
}
.tab {
    background: transparent;
    border: none;
    padding: 8px 18px;
    border-radius: var(--r-pill);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: var(--ink-soft);
    transition: background 0.12s, color 0.12s;
    font-size: 0.92rem;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }
/* "Take whole book" — separate class so the view-tab click handler ignores it.
   Inline-flex with proper baseline alignment so icon + text sit on one line. */
.take-whole-book-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--primary);
    border-radius: var(--r-pill);
    background: var(--primary-soft);
    color: var(--primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: background 0.12s, color 0.12s, opacity 0.12s;
    white-space: nowrap;
}
.take-whole-book-btn:hover:not([disabled]) { background: var(--primary); color: #fff; }
.take-whole-book-btn .twb-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.take-whole-book-btn .twb-icon .icon { width: 16px; height: 16px; display: block; }
.take-whole-book-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

#tehillimIndex {
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    font: inherit;
    margin-inline-start: auto;
    background: var(--bg);
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
}

/* ===== Chapter grid ===== */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
    margin: 12px 0;
}
.ch {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    padding: 10px 6px 8px;
    text-align: center;
    cursor: pointer;
    font: inherit;
    transition: transform 0.1s ease, border-color 0.12s, background 0.15s;
    min-height: 66px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    position: relative;
}
.ch:hover { transform: translateY(-1px); border-color: var(--primary); z-index: 2; }
.ch:active { transform: scale(0.96); }
.ch .n { font-weight: 800; font-size: 1.35rem; color: var(--ink); line-height: 1; }
.ch .who {
    font-size: 0.7rem;
    color: var(--muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.ch.free:hover { background: var(--primary-soft); border-color: var(--primary); }
.ch.taken { background: var(--bg-soft); border-color: var(--line); }
.ch.taken .n { color: var(--ink-soft); }
.ch.mine { background: var(--primary-soft); border-color: var(--primary); }
.ch.mine .n { color: var(--primary); }
.ch.mine .who { color: var(--primary); }
.ch.done { background: var(--success-soft); border-color: var(--success); }
.ch.done .n { color: var(--success-text); }
.ch.done .who { color: var(--success-text); }
.ch-check {
    position: absolute;
    top: 4px;
    left: 6px;
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
}
.ch-check .icon { width: 14px; height: 14px; stroke-width: 3; }
.ch[disabled], .ch.disabled { cursor: not-allowed; opacity: 0.6; }
.ch[disabled]:hover { transform: none; border-color: var(--line); }

/* ===== Days view ===== */
.days-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.day {
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    transition: border-color 0.12s, background 0.15s;
}
.day:hover { border-color: var(--line-strong); }
.day.mixed { border-color: var(--primary); }
.day.mine { border-color: var(--primary); background: var(--primary-soft); }
.day.done { border-color: var(--success); background: var(--success-soft); }

.day-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.day-title { display: flex; flex-direction: column; gap: 1px; }
.day-num { font-size: 1.05rem; font-weight: 800; color: var(--ink); }
.day-range { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.day-head .btn { margin-inline-start: auto; }
.day-done-badge {
    margin-inline-start: auto;
    background: var(--success);
    color: #fff;
    padding: 3px 12px;
    border-radius: var(--r-pill);
    font-size: 0.78rem;
    font-weight: 700;
}
.day-others { color: var(--ink-soft); font-size: 0.86rem; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.day-others .muted-label { color: var(--muted); }
.day-mini { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 10px; }
.day-mini .mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 26px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink);
}
.day-mini .mini.taken { background: var(--bg-soft); color: var(--ink-soft); }
.day-mini .mini.mine { background: var(--primary); color: #fff; border-color: var(--primary); }
.day-mini .mini.done { background: var(--success); color: #fff; border-color: var(--success); }

/* ===== Legend ===== */
.legend {
    margin-top: 18px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--ink-soft);
}
.legend-item { display: flex; gap: 6px; align-items: center; }
.legend-item .dot { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--line); display: inline-block; }
.legend-item .dot.free { background: var(--bg); }
.legend-item .dot.mine { background: var(--primary); border-color: var(--primary); }
.legend-item .dot.taken { background: var(--bg-soft); border-color: var(--line-strong); }
.legend-item .dot.done { background: var(--success); border-color: var(--success); }

.share { display: flex; gap: 10px; align-items: center; }

/* Admin users table (legacy — kept in case anything else uses it) */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); }
.admin-table th { background: var(--bg-soft); color: var(--ink-soft); font-weight: 700; font-size: 0.82rem; position: sticky; top: 0; }
.admin-table tbody tr:hover { background: var(--bg-soft); }
.admin-table td .badge { font-size: 0.72rem; padding: 2px 8px; }
.hidden { display: none !important; }

/* ===== Admin users page (redesigned) ===== */
.admin-head { margin-bottom: 18px; }
.admin-head h1 { margin: 0 0 6px; font-size: 1.6rem; }
.admin-head p.muted { margin: 0; font-size: 0.94rem; line-height: 1.5; max-width: 640px; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.admin-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    text-align: center;
}
.admin-stat-num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
}
.admin-stat-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 600;
}
.admin-stat--primary { background: var(--primary-soft); border-color: var(--primary); }
.admin-stat--primary .admin-stat-num { color: var(--primary); }
.admin-stat--guest { background: #fff7e6; border-color: #f5d28a; }
.admin-stat--guest .admin-stat-num { color: #7a4c00; }

.admin-toolbar {
    margin-bottom: 14px;
}
.admin-toolbar input[type="search"] {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--ink);
}
.admin-toolbar input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.admin-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.admin-card:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(29, 155, 240, 0.08); }

.admin-avatar {
    width: 48px; height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
}
.admin-avatar.admin { background: var(--primary); color: #fff; }
.admin-avatar.guest { background: #ffb020; color: #fff; }

.admin-body { flex: 1; min-width: 0; }
.admin-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.admin-name strong { font-size: 1rem; color: var(--ink); }
.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.4;
}
.role-pill .icon { width: 11px; height: 11px; }
.role-admin { background: var(--primary); color: #fff; }
.role-guest { background: #fff7e6; color: #7a4c00; }
.role-self  { background: var(--bg-soft); color: var(--ink-soft); border: 1px dashed var(--line-strong); }

.admin-handle { color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }

.admin-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    color: var(--ink-soft);
    font-size: 0.82rem;
}
.admin-metric { display: inline-flex; align-items: center; gap: 4px; }
.admin-metric .icon { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; }
.admin-metric b { color: var(--ink); font-weight: 700; }
.admin-metric--done .icon { color: var(--success-text); }
.admin-metric--done b { color: var(--success-text); }

.admin-delete {
    background: transparent;
    border: 1px solid transparent;
    width: 40px; height: 40px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.admin-delete:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.admin-delete .icon { width: 18px; height: 18px; }
.admin-delete.is-loading { opacity: 0.5; cursor: progress; }

.admin-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Profile logout card */
.profile-logout h2 { color: var(--danger); margin-top: 0; }
.profile-logout p { margin: 4px 0 14px; }
.profile-logout .btn { display: inline-flex; align-items: center; gap: 8px; }
.profile-logout .btn .icon { width: 18px; height: 18px; }

/* Friendly empty state with illustration */
.empty-state {
    text-align: center;
    padding: 36px 20px 32px;
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
    margin: 8px 0;
}
.empty-state-illustration {
    margin: 0 auto 14px;
    width: 120px;
    height: 120px;
    opacity: 0.95;
}
.empty-state-illustration svg { width: 100%; height: 100%; }
.empty-state-title { margin: 0 0 6px; font-size: 1.15rem; color: var(--ink); }
.empty-state-sub { margin: 0 auto 16px; max-width: 380px; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.empty-state .btn { display: inline-flex; align-items: center; gap: 6px; }

/* Inline Hebrew date hint (next to "in 3 days") */
.hdate { color: var(--ink-soft); font-weight: 500; font-size: 0.92em; margin-inline-start: 2px; }

/* Live filter input on long lists (dashboard, etc) */
.list-search {
    position: relative;
    margin-bottom: 12px;
}
.list-search input[type="search"] {
    width: 100%;
    padding: 10px 38px 10px 14px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--ink);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23677581' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.35-4.35'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-inline-end: 38px;
    padding-inline-start: 14px;
}
.list-search input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.list-search-empty {
    display: block;
    text-align: center;
    color: var(--muted);
    padding: 16px;
    font-size: 0.9rem;
}

/* Loading skeletons */
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--bg-soft) 0%, #f0f3f5 50%, var(--bg-soft) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
    display: block;
}
.skeleton-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    margin-bottom: 12px;
}
.skeleton-card .skel-title { height: 18px; width: 60%; margin-bottom: 10px; }
.skeleton-card .skel-line  { height: 12px; width: 100%; margin-bottom: 8px; }
.skeleton-card .skel-line.short { width: 40%; }
.skeleton-card .skel-bar   { height: 8px; width: 100%; margin-top: 14px; border-radius: var(--r-pill); }

/* Guest CTA — shown only on the profile page for guest users.
   Visually prominent; encourages upgrading to a real account so chapters and
   memberships persist across devices and cookie clears. */
.guest-cta {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: linear-gradient(180deg, #fff7e6 0%, #fffbf0 100%);
    border: 1.5px solid #f5d28a;
    border-radius: var(--r-lg);
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(245, 210, 138, 0.25);
}
.guest-cta-icon {
    flex-shrink: 0;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: #f5b042;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.guest-cta-icon .icon { width: 22px; height: 22px; }
.guest-cta-body { flex: 1; min-width: 0; }
.guest-cta-body h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--ink); }
.guest-cta-body p  { margin: 0 0 12px; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.55; }
.guest-cta-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.guest-cta-actions .btn.primary { display: inline-flex; align-items: center; gap: 6px; }
.guest-cta-actions .btn.primary .icon { width: 16px; height: 16px; }
@media (max-width: 540px) {
    .guest-cta { flex-direction: column; align-items: stretch; }
    .guest-cta-actions .btn.primary { width: 100%; justify-content: center; }
}

/* 403 "no admin permissions" full-page state */
.forbidden-page {
    max-width: 520px;
    margin: 24px auto;
    padding: 40px 28px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}
.forbidden-illustration {
    width: 140px;
    height: 140px;
    margin: 0 auto 18px;
}
.forbidden-illustration svg { width: 100%; height: 100%; }
.forbidden-page h1 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    color: var(--ink);
}
.forbidden-page .muted {
    margin: 0 auto 22px;
    max-width: 380px;
    color: var(--muted);
    line-height: 1.6;
}
.forbidden-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.forbidden-meta {
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
}
.forbidden-meta strong { color: var(--ink); }
@media (max-width: 540px) {
    .forbidden-page { padding: 28px 18px; }
    .forbidden-illustration { width: 110px; height: 110px; }
    .forbidden-actions .btn.primary { width: 100%; }
}

/* Pin-room button in room owner-tools — palette-aligned (Twitter blue) */
.pin-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pin-btn .icon { width: 14px; height: 14px; }
.pin-btn[data-pinned="1"] {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pin-btn[data-pinned="1"]:hover { background: #1a8cd8; border-color: #1a8cd8; }

/* Mobile-only admin shortcut on profile page.
   Desktop already has the "ניהול" link in the sidebar — this is the mobile equivalent. */
.admin-mobile-link {
    display: none;  /* hidden by default; @media below makes it visible on mobile */
    align-items: center;
    gap: 10px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--r-lg);
    padding: 14px 18px;
    margin-bottom: 14px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.98rem;
    box-shadow: 0 2px 8px rgba(29, 155, 240, 0.18);
}
.admin-mobile-link:hover { background: #1a8cd8; }
.admin-mobile-link .icon { width: 20px; height: 20px; flex-shrink: 0; }
@media (max-width: 860px) {
    .admin-mobile-link { display: inline-flex; }
}

/* "Back to top" floating button — appears on long pages after scroll */
.back-to-top {
    position: fixed;
    bottom: 96px;            /* clear the mobile bar */
    inset-inline-end: 16px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.18s, transform 0.18s, background 0.12s;
    z-index: 55;
}
.back-to-top.visible {
    opacity: 0.92;
    transform: translateY(0);
    pointer-events: auto;
}
.back-to-top:hover { background: var(--primary); opacity: 1; }
.back-to-top svg { width: 20px; height: 20px; }
@media (min-width: 861px) { .back-to-top { bottom: 24px; } }

/* Room-type buttons — two independent rounded pill buttons, side by side.
   Default visual = regular is highlighted; clicking yahrzeit makes IT obviously
   highlighted instead. No shared container — each is its own button. */
.type-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.type-tab {
    flex: 1 1 0;
    min-width: 140px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 18px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 2px solid var(--line);
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
    white-space: nowrap;
}
.type-tab .icon { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.type-tab:hover { border-color: var(--primary); color: var(--ink); }
.type-tab:active { transform: scale(0.98); }
.type-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(29, 155, 240, 0.30);
}
.type-tab.active:hover { color: #fff; }
@media (max-width: 540px) {
    .type-tab { padding: 12px 14px; font-size: 0.9rem; gap: 6px; }
    .type-tab .icon { width: 16px; height: 16px; }
}

/* ===== Memorial Room (חדר יארצייט) ===== */

/* Create page */
.memorial-create-head { margin-bottom: 20px; }
.memorial-eyebrow {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.memorial-create-head h1 { margin: 0 0 8px; font-size: 1.7rem; }
.memorial-create-head p.muted { margin: 0; line-height: 1.6; }

.memorial-preview {
    background: var(--bg-soft);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    margin: 6px 0 18px;
}
.memorial-preview-label { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 10px; }
.memorial-preview-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.mem-letter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink);
    font-family: 'Frank Ruhl Libre', serif;
}
.mem-letter-chip--neshama {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.memorial-date-fieldset { border: none; padding: 0; margin: 0 0 16px; }
.memorial-date-fieldset legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.memorial-date-input { margin-top: 10px; }
.memorial-date-input input { width: 100%; }
.memorial-date-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.memorial-date-toggle > label { flex: 1; min-width: 140px; }

.memorial-privacy { display: block; margin-bottom: 18px; }

/* View page */
.memorial-header {
    background: linear-gradient(180deg, var(--primary-soft) 0%, var(--surface) 100%);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 32px 26px 26px;
    margin-bottom: 18px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.memorial-header::before {
    content: '✡';
    position: absolute;
    top: 14px;
    inset-inline-start: 18px;
    font-size: 1.6rem;
    color: var(--primary);
    opacity: 0.25;
}
.memorial-header-top { margin-bottom: 22px; }
.memorial-header .memorial-eyebrow {
    font-size: 0.85rem;
    padding: 5px 14px;
    background: rgba(255,255,255,0.85);
    color: var(--primary);
    letter-spacing: 0.06em;
}
.memorial-name {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 2.6rem;
    font-weight: 700;
    margin: 12px 0 6px;
    color: var(--ink);
    line-height: 1.2;
}
.memorial-date {
    color: var(--ink-soft);
    font-size: 0.95rem;
    font-weight: 600;
    background: rgba(255,255,255,0.7);
    display: inline-block;
    padding: 4px 14px;
    border-radius: var(--r-pill);
}

.memorial-progress { margin: 22px 0 20px; }
.memorial-progress .progress { margin-bottom: 8px; height: 10px; }
.memorial-progress .progress .bar { background: var(--primary); }
.memorial-progress-text {
    color: var(--ink-soft);
    font-size: 0.92rem;
}
.memorial-progress-text strong { color: var(--ink); }

.memorial-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
.memorial-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 14px;
    font-weight: 600;
    font-size: 0.92rem;
}
.memorial-actions .btn .icon,
.memorial-actions .whatsapp-icon { width: 16px; height: 16px; flex-shrink: 0; }
.memorial-actions .btn.primary { grid-column: 1 / -1; }
.memorial-actions #whatsappBtn {
    background: #25D366;
    color: #fff;
    border-color: #25D366;
}
.memorial-actions #whatsappBtn:hover { background: #1faa50; border-color: #1faa50; }
.memorial-actions #whatsappBtn .whatsapp-icon { color: #fff; }
.whatsapp-icon { display: inline-flex; align-items: center; }
@media (max-width: 540px) {
    .memorial-actions { grid-template-columns: 1fr; }
}

.memorial-letters-section { margin-top: 18px; }
.memorial-section-head { margin-bottom: 14px; text-align: center; }
.memorial-section-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.memorial-section-head p { margin: 0; font-size: 0.88rem; }

.memorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.memorial-tile {
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s, border-color 0.12s, box-shadow 0.12s;
    font-family: inherit;
    color: var(--ink);
    position: relative;
}
.memorial-tile:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(29, 155, 240, 0.12);
}
.memorial-tile:active { transform: translateY(0); }

.mem-tile-position {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.04em;
}
.mem-tile-letter {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
    margin: 2px 0;
}
.mem-tile-verses { font-size: 0.78rem; color: var(--muted); }
.mem-tile-taker, .mem-tile-status-text {
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mem-tile-status-text { background: var(--bg-soft); color: var(--muted); }
.mem-tile-taker { background: var(--bg-soft); color: var(--ink-soft); }

.memorial-tile.status-mine {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.memorial-tile.status-mine .mem-tile-letter { color: var(--primary); }
.memorial-tile.status-mine .mem-tile-taker { background: var(--primary); color: #fff; }

.memorial-tile.status-done {
    border-color: var(--success);
    background: var(--success-soft);
}
.memorial-tile.status-done .mem-tile-letter { color: var(--success-text); }
.memorial-tile.status-done .mem-tile-taker { background: var(--success-text); color: #fff; }

.memorial-tile.status-taken {
    background: var(--bg-soft);
    border-style: dashed;
}

/* Subtle distinguish for the נשמה suffix tiles */
.memorial-tile.is-neshama {
    background: linear-gradient(180deg, transparent 0%, rgba(29, 155, 240, 0.04) 100%);
}
.memorial-tile.is-neshama::after {
    content: '';
    position: absolute;
    top: 6px;
    inset-inline-end: 6px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.5;
}

.memorial-meta-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
    padding: 16px 0;
    color: var(--muted);
    font-size: 0.88rem;
    border-top: 1px solid var(--line);
}
.memorial-meta-footer code {
    background: var(--bg-soft);
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    font-family: 'SF Mono', Menlo, monospace;
    font-weight: 600;
    color: var(--ink);
    font-size: 0.85rem;
}
.memorial-footer-actions { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.memorial-footer-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.memorial-footer-actions .btn .icon { width: 14px; height: 14px; }

/* Modal-specific tweaks for memorial */
.invite-memorial .memorial-name-display {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 2rem;
    margin: 10px 0 4px;
    color: var(--ink);
    line-height: 1.2;
}

.memorial-modal-letter {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Frank Ruhl Libre', serif;
    font-weight: 700;
    font-size: 1.8rem;
}

@media (max-width: 540px) {
    .memorial-name { font-size: 2rem; }
    .memorial-header { padding: 22px 16px; }
    .memorial-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
    .memorial-tile { padding: 10px 6px; }
    .mem-tile-letter { font-size: 2.1rem; }
    .mem-tile-verses { font-size: 0.72rem; }
    .mem-tile-position { font-size: 0.65rem; }
    .mem-tile-taker, .mem-tile-status-text { font-size: 0.7rem; }
}

@media (max-width: 540px) {
    .admin-card { gap: 10px; padding: 12px; }
    .admin-avatar { width: 40px; height: 40px; font-size: 1.1rem; }
    .admin-name strong { font-size: 0.95rem; }
    .admin-metrics { gap: 4px 10px; font-size: 0.78rem; }
}

/* ===== Search page ===== */
.search-form { margin-bottom: 18px; }
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-input-wrap .icon-search-input {
    position: absolute;
    inset-inline-start: 16px;
    color: var(--muted);
    pointer-events: none;
    width: 18px; height: 18px;
}
.search-input-wrap input {
    width: 100%;
    padding: 14px 48px 14px 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-pill);
    font: inherit;
    font-size: 1rem;
    background: var(--bg-soft);
    transition: border-color 0.15s, background 0.15s;
}
.search-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-tips {
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--bg-soft);
    border-radius: var(--r);
    color: var(--ink-soft);
    font-size: 0.88rem;
}

/* ===== Profile page ===== */
.profile-head {
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    margin-bottom: 18px;
}
.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 2rem;
    flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-info h1 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-info .handle { color: var(--muted); font-size: 0.95rem; }
.admin-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--primary); color: #fff;
    font-size: 0.78rem; font-weight: 700;
    padding: 3px 10px; border-radius: 999px;
    line-height: 1;
}
.admin-badge svg { width: 13px; height: 13px; }
.profile-info .guest-note {
    margin-top: 6px;
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 600;
}
@media (max-width: 720px) {
    .profile-head {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 24px 18px;
        gap: 12px;
    }
    .profile-avatar { width: 80px; height: 80px; font-size: 2.2rem; }
    .profile-info { width: 100%; }
}

/* ===== Invite landing (public) ===== */
.invite-page { max-width: 540px; margin: 24px auto; }
.invite-app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--primary-soft, #E8F5FD);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 10px 14px;
    border-radius: var(--r-md, 10px);
    margin-bottom: 12px;
    font-weight: 600;
}
.invite-app-bar .btn.small { padding: 6px 14px; font-size: 0.9rem; }
.invite-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 28px;
    margin-bottom: 16px;
}
.invite-card .pre-title {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.invite-card h1 { font-size: 1.7rem; margin: 0 0 8px; }
.invite-card .ded { color: var(--primary); font-weight: 600; margin: 0 0 12px; font-size: 1.05rem; }
.invite-card .by   { color: var(--muted); font-size: 0.92rem; }
.invite-stats {
    display: flex;
    gap: 18px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
    color: var(--ink-soft);
    font-size: 0.92rem;
}
.invite-stats > div { display: flex; flex-direction: column; }
.invite-stats strong { font-size: 1.1rem; color: var(--ink); }

.how-list { list-style: none; padding: 0; margin: 0; }
.how-list li {
    display: flex;
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}
.how-list li:first-child { border-top: 0; }
.how-list .step-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.how-list .step-text { line-height: 1.5; }

.choice-btn {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface);
    cursor: pointer;
    text-decoration: none;
    color: var(--ink);
    text-align: start;
    font: inherit;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    width: 100%;
    margin-bottom: 10px;
}
.choice-btn:last-of-type { margin-bottom: 0; }
.choice-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--ink); }
.choice-btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.choice-btn.primary:hover { background: var(--primary-dark); color: #fff; }
.choice-btn .choice-text { flex: 1; min-width: 0; }
.choice-btn .choice-text strong { display: block; font-size: 1.05rem; font-weight: 800; margin-bottom: 3px; line-height: 1.3; }
.choice-btn .choice-text small { display: block; color: var(--muted); font-size: 0.88rem; font-weight: 500; line-height: 1.4; }
.choice-btn.primary .choice-text small { color: rgba(255,255,255,0.88); }
.choice-btn .icon { width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px; color: var(--ink); }
.choice-btn.primary .icon { color: #fff; }
.choice-btn:hover .icon { color: var(--primary); }
.choice-btn.primary:hover .icon { color: #fff; }

.or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line-strong);
}

.guest-card {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px 20px;
}
.guest-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.guest-card p { margin: 0 0 14px; color: var(--ink-soft); font-size: 0.9rem; line-height: 1.5; }
.guest-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r);
    font: inherit;
    background: var(--surface);
    margin-bottom: 12px;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.guest-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* Banner for guest users in the shell */
.guest-banner {
    background: #fff7e6;
    border: 1px solid #f4d28a;
    border-radius: var(--r);
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    color: #7a4c00;
    font-size: 0.92rem;
}
.guest-banner a { color: #7a4c00; font-weight: 700; text-decoration: underline; }

/* ===== Share modal contents ===== */
.share-url-box {
    display: flex;
    gap: 6px;
    margin: 10px 0;
}
.share-url-box input {
    flex: 1;
    min-width: 0;
    padding: 11px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r);
    font: inherit;
    background: var(--bg-soft);
    color: var(--ink-soft);
    font-size: 0.88rem;
    direction: ltr;
    text-align: start;
}
.share-platforms { display: flex; gap: 8px; margin: 12px 0 6px; }
.share-platforms a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 14px;
    border-radius: var(--r);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: opacity 0.12s, transform 0.12s;
}
.share-platforms a:hover { transform: translateY(-1px); }
.share-platforms .wa { background: #25d366; color: #fff; }
.share-platforms .tg { background: #2aabee; color: #fff; }
.share-platforms .sms { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line-strong); }
.share-platforms .icon { width: 18px; height: 18px; }
.share-code-line { font-size: 0.9rem; color: var(--ink-soft); }
.share-code-line code { background: var(--bg-soft); padding: 3px 10px; border-radius: 6px; font-family: 'SF Mono', Menlo, monospace; font-weight: 700; color: var(--ink); }

/* ===== Tehillim reader page ===== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.tehillim-page { max-width: 760px; margin: 0 auto; }

/* Font size A-/A+ pill */
.font-controls {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 2px;
    margin-inline-start: 8px;
}
.font-controls button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 10px;
    color: var(--ink-soft);
    border-radius: var(--r-pill);
    font: inherit;
    font-weight: 700;
}
.font-controls button:hover:not(:disabled) { background: var(--surface); color: var(--primary); }
.font-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
.font-controls .a-small { font-size: 0.85rem; }
.font-controls .a-large { font-size: 1.05rem; }

/* Apply font scale via CSS variable (set by JS from localStorage) */
.tehillim-text, .modal-body-text {
    font-size: calc(1.45rem * var(--tehillim-scale, 1));
    line-height: calc(2.05 * var(--tehillim-scale, 1));
}

.tehillim-head {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
    padding: 12px 0;
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}
.tehillim-navbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    padding: 8px 14px;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    flex-shrink: 0;
}
.tehillim-navbtn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.tehillim-navbtn .icon { width: 18px; height: 18px; }
.chapter-picker { flex: 1; min-width: 0; }
.chapter-picker select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-pill);
    font: inherit;
    background: var(--surface);
    font-weight: 700;
    color: var(--ink);
    font-size: 1rem;
    text-align: center;
    cursor: pointer;
}
.chapter-picker select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.tehillim-foot {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin: 20px 0 8px;
}
.tehillim-foot .btn { flex: 1; padding: 12px; gap: 6px; }
.tehillim-foot .btn .icon { width: 18px; height: 18px; }

.tehillim-text {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 32px 36px;
    margin: 12px 0;
    font-family: 'Frank Ruhl Libre', 'David Libre', 'Times New Roman', serif;
    font-size: calc(1.55rem * var(--tehillim-scale, 1));
    line-height: calc(2.05 * var(--tehillim-scale, 1));
    color: var(--ink);
    text-align: justify;
    min-height: 200px;
}
.tehillim-text .tehillim-chapter-head {
    text-align: center;
    font-family: var(--font);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary);
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
    margin-bottom: 18px;
    letter-spacing: 0.02em;
}
.tehillim-text .verse {
    display: inline;
}
.tehillim-text .verse-num {
    color: var(--primary);
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 0.78em;
    font-weight: 700;
    margin: 0 6px 0 2px;
    padding: 0 6px;
    background: var(--primary-soft);
    border-radius: 4px;
    vertical-align: 0.15em;
    white-space: nowrap;
}
.tehillim-loading { text-align: center; color: var(--muted); padding: 60px 20px; }
.tehillim-error   { text-align: center; color: var(--danger); padding: 60px 20px; }

/* Reader modal — used by the room flow to read a single chapter and mark it done */
.modal-reader {
    max-width: 760px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.modal-body-text {
    overflow-y: auto;
    flex: 1;
    padding: 22px 26px 26px;
    font-family: 'Frank Ruhl Libre', 'David Libre', 'Times New Roman', serif;
    font-size: 1.45rem;
    line-height: 2.0;
    color: var(--ink);
    text-align: justify;
}
.modal-body-text .verse { display: inline; }
.modal-body-text .verse-num {
    color: var(--primary);
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 0.78em;
    font-weight: 700;
    margin: 0 6px 0 2px;
    padding: 0 6px;
    background: var(--primary-soft);
    border-radius: 4px;
    vertical-align: 0.15em;
    white-space: nowrap;
}
.modal-body-text .tehillim-chapter-head {
    text-align: center;
    font-family: var(--font);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary);
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}
.modal-reader .modal-actions { border-top: 1px solid var(--line); }

@media (max-width: 720px) {
    .tehillim-text { padding: 22px 20px; font-size: calc(1.35rem * var(--tehillim-scale, 1)); line-height: calc(1.95 * var(--tehillim-scale, 1)); border-radius: var(--r); }
    .tehillim-head { padding: 10px 0; gap: 6px; }
    .tehillim-navbtn { padding: 8px 10px; font-size: 0.9rem; }
    .tehillim-navbtn .lbl { display: none; }
    .modal-reader { max-height: 100vh; height: 100%; border-radius: 0; }
    .modal-body-text { font-size: 1.3rem; line-height: 1.95; padding: 18px 18px; }
}

/* ===== Notifications page ===== */
.notif-list { list-style: none; padding: 0; margin: 0; }
.notif {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 8px;
    padding: 14px 18px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    transition: background 0.12s;
}
.notif.unread { background: var(--primary-soft); border-color: var(--primary); }
.notif-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}
.notif-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.notif-icon.success { background: var(--success-soft); color: var(--success-text); }
.notif-icon.warm    { background: #fff7e6; color: #a35a00; }
.notif-icon.danger  { background: var(--danger-soft); color: var(--danger); }
.notif-icon .icon { width: 20px; height: 20px; }
.notif-body { flex: 1; min-width: 0; }
.notif-text { line-height: 1.5; font-size: 0.95rem; }
.notif-text a { color: var(--primary); font-weight: 700; }
.notif-text strong { color: var(--ink); font-weight: 700; }
.notif-time { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.notif-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.notif-actions .btn { padding: 7px 16px; font-size: 0.9rem; }
.notif.resolved { opacity: 0.6; }
.notif.resolved .notif-actions { display: none; }
.notif-list-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

/* ===== Danger zone (edit page) ===== */
.danger-zone {
    margin-top: 24px;
    padding: 18px 22px;
    border: 1.5px solid var(--danger-soft);
    border-radius: var(--r-lg);
    background: var(--danger-soft);
}
.danger-zone h2 { color: var(--danger); margin-top: 0; }
.danger-zone p { color: #8c1a22; margin: 4px 0 12px; font-size: 0.92rem; }
.danger-zone .btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 25, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    animation: fadeIn 0.15s ease forwards;
    padding: 16px;
}
.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(8px);
    animation: slideUp 0.18s ease forwards;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head .modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modal-head .modal-icon .icon { width: 22px; height: 22px; }
.modal-head .modal-icon.success { background: var(--success-soft); color: var(--success-text); }
.modal-head .modal-icon.danger  { background: var(--danger-soft); color: var(--danger); }
.modal-head .modal-title { flex: 1; }
.modal-head h2 { margin: 0 0 2px; font-size: 1.1rem; }
.modal-head .sub { color: var(--muted); font-size: 0.88rem; }
.modal-close {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--muted);
    transition: background 0.12s, color 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.modal-close:hover { background: var(--bg-soft); color: var(--ink); }
.modal-close .icon { width: 18px; height: 18px; }
.day-done-badge .icon { width: 12px; height: 12px; stroke-width: 3; }
.modal-body { padding: 16px 20px; color: var(--ink-soft); font-size: 0.95rem; }
.modal-body p { margin: 0 0 8px; }
.modal-actions { padding: 12px 20px 18px; display: flex; flex-direction: column; gap: 8px; }
.modal-actions .btn { width: 100%; padding: 12px; font-size: 0.95rem; }

@keyframes fadeIn { to { opacity: 1; } }
@keyframes slideUp { to { transform: translateY(0); } }

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: var(--ink);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--r-pill);
    font-size: 0.92rem;
    font-weight: 500;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success-text); }
.toast.warn    { background: #b35d00; }
.toast.danger  { background: var(--danger); }

/* ============ Mobile (sidebar → bottom nav) ============ */
@media (max-width: 860px) {
    body.has-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main {
        grid-column: 1 / -1;
        /* Bottom padding must clear the fixed mobile-bar (~76px including safe-area) plus
           breathing room so the last item in a page isn't hugging the bar. */
        padding: 16px 14px calc(90px + env(safe-area-inset-bottom));
        max-width: 100%;
        margin: 0;
        width: 100%;
    }
    .foot { display: none; }

    .mobile-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg);
        border-top: 1px solid var(--line-strong);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        z-index: 60;
        justify-content: space-around;
        /* Defensive: avoid being collapsed when mobile browsers (e.g. iOS Safari) hide
           their address bar — without explicit min-height the bar can momentarily
           shrink to 0 on transition and leave a visible "gap" below the content. */
        min-height: calc(60px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        /* Promote to its own compositor layer — prevents subpixel flicker / disappearance
           during scroll on mobile Chrome where fixed elements sometimes detach. */
        will-change: transform;
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
    }
    .mob-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 8px;
        border-radius: 12px;
        color: var(--ink-soft);
        font-size: 0.72rem;
        font-weight: 600;
        flex: 1;
        min-width: 0;
    }
    .mob-item .icon { width: 22px; height: 22px; }
    .mob-item.active { color: var(--primary); }
    .mob-icon-wrap { position: relative; display: inline-flex; }
    .mob-badge {
        position: absolute;
        top: -5px;
        inset-inline-end: -8px;
        background: var(--danger);
        color: #fff;
        font-size: 0.65rem;
        font-weight: 800;
        padding: 0 5px;
        min-width: 16px;
        text-align: center;
        border-radius: var(--r-pill);
        line-height: 1.5;
        border: 2px solid var(--bg);
    }
    .mob-badge:empty, .mob-badge[hidden] { display: none; }
    .mob-item.create-fab {
        background: var(--primary);
        color: #fff;
        border-radius: 50%;
        width: 52px;
        height: 52px;
        flex: 0 0 52px;
        margin-top: -16px;
        padding: 0;
        box-shadow: var(--shadow);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0;
    }
    .mob-item.create-fab .icon { width: 26px; height: 26px; }
    .mob-item.create-fab span { display: none; }

    .hero { padding: 36px 14px 24px; }
    .card { padding: 22px 18px; }
    .room-header { padding: 18px; }
    .chapters-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 5px; }
    .ch { min-height: 56px; padding: 7px 4px; }
    .ch .n { font-size: 1.15rem; }
    .ch .who { font-size: 0.62rem; }
    .toast { bottom: 100px; }

    /* Modal becomes bottom sheet */
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        animation: slideUpSheet 0.22s ease forwards;
    }
    @keyframes slideUpSheet { to { transform: translateY(0); } }
}
