/* ===== חלוקות תהילים ומשניות — design system ===== */
:root {
    --ink: #14203a; --ink-2: #39455f; --muted: #6b7489;
    --paper: #f8f5ee; --card: #ffffff; --line: #e7e0d0; --line-2: #d9d0bb;
    --gold: #a8812f; --gold-2: #c9a94e; --gold-soft: #f5ecd6;
    --blue: #1f4fd1; --blue-2: #173da6; --blue-soft: #e9effd;
    --green: #22804f; --green-soft: #e2f3e8;
    --amber: #b7791f; --amber-soft: #fbefd6;
    --red: #b42318;
    --radius: 18px; --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(20,32,58,.05), 0 8px 28px rgba(20,32,58,.07);
    --serif: 'Frank Ruhl Libre', 'David Libre', Georgia, serif;
    --sans: 'Assistant', 'Segoe UI', Arial, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --ink: #eef1f7; --ink-2: #c5cbd8; --muted: #9aa3b5;
        --paper: #0f1524; --card: #161e31; --line: #263049; --line-2: #333e5a;
        --gold: #d9b865; --gold-2: #d9b865; --gold-soft: #2b2617;
        --blue: #6f95ff; --blue-2: #9cb6ff; --blue-soft: #1b2847;
        --green: #4cc38a; --green-soft: #15301f;
        --amber: #e2a94a; --amber-soft: #33270f;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
button { font: inherit; }

/* top bar */
.ch-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; max-width: 920px; margin: 0 auto; }
.ch-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.ch-brand i { color: var(--gold-2); }
.ch-top-link { color: var(--muted); text-decoration: none; font-size: .92em; }
.ch-top-link:hover { color: var(--ink); }

.ch-wrap { max-width: 920px; margin: 0 auto; padding: 0 16px 64px; }

/* hero card */
.ch-hero { background: var(--card); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 34px 32px 28px; text-align: center; position: relative; overflow: hidden; }
.ch-hero::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.ch-kicker { display: inline-flex; align-items: center; gap: 8px; font-size: .9em; color: var(--gold); font-weight: 700; letter-spacing: .02em; }
.ch-prefix { font-family: var(--serif); font-size: 1.25em; color: var(--ink-2); margin-top: 10px; }
.ch-name { font-family: var(--serif); font-size: clamp(2em, 6vw, 2.9em); font-weight: 700; line-height: 1.2; margin: 2px 0 6px; }
.ch-note { color: var(--muted); margin: 0 auto 4px; max-width: 560px; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; color: var(--muted); font-size: .9em; margin-top: 12px; }
.ch-meta span { display: inline-flex; align-items: center; gap: 6px; }

/* progress */
.ch-progress { margin: 22px auto 0; max-width: 560px; }
.ch-progress-nums { display: flex; justify-content: space-between; align-items: baseline; font-size: .95em; color: var(--muted); margin-bottom: 8px; }
.ch-progress-nums strong { font-size: 1.6em; color: var(--ink); font-weight: 800; }
.ch-bar { height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; display: flex; }
.ch-bar-done { background: var(--green); transition: width .5s ease; }
.ch-bar-taken { background: var(--amber); opacity: .55; transition: width .5s ease; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-top: 10px; font-size: .85em; color: var(--muted); }
.ch-legend-top { justify-content: flex-start; margin: -4px 6px 12px; }
.ch-legend-top > span { display: inline-flex; align-items: center; }
.ch-dot { display: inline-block; width: 11px; height: 11px; border-radius: 4px; margin-left: 5px; vertical-align: -1px; }
.ch-dot.free { border: 1.5px solid var(--line-2); background: var(--card); }
.ch-dot.taken { background: var(--amber); }
.ch-dot.done { background: var(--green); }
.ch-dot.mine { background: var(--blue); }

/* buttons */
.ch-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 24px; }
.ch-btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 22px; font-weight: 700; font-size: 1em; cursor: pointer; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s; }
.ch-btn:active { transform: translateY(1px); }
.ch-btn-primary { background: var(--blue); color: #fff; box-shadow: 0 6px 18px rgba(31,79,209,.28); }
.ch-btn-primary:hover { background: var(--blue-2); }
.ch-btn-wa { background: #1fa855; color: #fff; box-shadow: 0 6px 18px rgba(31,168,85,.25); }
.ch-btn-wa:hover { background: #178a45; }
.ch-btn-ghost { background: transparent; color: var(--ink-2); border: 1.5px solid var(--line-2); }
.ch-btn-ghost:hover { border-color: var(--ink-2); }
.ch-btn-sm { padding: 8px 14px; font-size: .9em; border-radius: 10px; }
.ch-btn-done { background: var(--green); color: #fff; }
.ch-btn[disabled] { opacity: .55; cursor: default; }
@media (prefers-color-scheme: dark) { .ch-btn-primary, .ch-btn-done { color: #0f1524; } }

/* sections */
.ch-section { margin-top: 26px; }
.ch-section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--serif); font-size: 1.35em; font-weight: 700; margin: 0 4px 12px; }
.ch-section-title small { font-family: var(--sans); font-size: .62em; color: var(--muted); font-weight: 400; }
.ch-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* my units */
.ch-mine { border: 1.5px solid var(--blue); background: var(--blue-soft); }
.ch-mine-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ch-mine-row:last-child { border-bottom: 0; }
.ch-mine-name { font-weight: 700; flex: 1; min-width: 140px; }
.ch-mine-row.is-done .ch-mine-name::after { content: ' ✓ נלמד'; color: var(--green); font-weight: 600; font-size: .9em; }

/* the grid */
.ch-group { margin-bottom: 18px; }
.ch-group-title { font-weight: 700; color: var(--ink-2); margin: 0 4px 8px; font-size: .95em; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.ch-grid.wide { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.ch-u { position: relative; min-height: 54px; border-radius: var(--radius-sm); border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink); cursor: pointer; padding: 6px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25; transition: transform .12s, border-color .12s, box-shadow .12s; }
.ch-u:hover { border-color: var(--blue); box-shadow: 0 4px 12px rgba(31,79,209,.12); transform: translateY(-1px); }
.ch-u-label { font-weight: 800; font-size: 1.02em; }
.ch-u-sub { font-size: .74em; color: var(--muted); margin-top: 2px; }
.ch-u.taken { background: var(--amber-soft); border-color: transparent; cursor: default; }
.ch-u.taken .ch-u-label { color: var(--amber); }
.ch-u.done { background: var(--green-soft); border-color: transparent; cursor: default; }
.ch-u.done .ch-u-label { color: var(--green); }
.ch-u.done::after { content: '✓'; position: absolute; top: 3px; left: 7px; font-size: .75em; color: var(--green); font-weight: 800; }
.ch-u.mine { border: 2px solid var(--blue); cursor: pointer; }
.ch-u.taken:hover, .ch-u.done:hover { transform: none; box-shadow: none; }
.ch-u.mine:hover { box-shadow: 0 4px 12px rgba(31,79,209,.18); }
.ch-closed .ch-u.free { cursor: default; opacity: .6; }

/* Mishnayot by perek: one masechet per row */
.ch-rows .ch-group { display: grid; grid-template-columns: 104px 1fr; gap: 10px; align-items: start; margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ch-rows .ch-group:first-child { padding-top: 0; }
.ch-rows .ch-group:last-child { border-bottom: 0; padding-bottom: 0; }
.ch-rows .ch-group-title { margin: 9px 0 0; font-size: .92em; line-height: 1.3; }
.ch-rows .ch-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.ch-rows .ch-u { min-height: 42px; }

/* complete */
.ch-complete { margin-top: 22px; background: var(--green-soft); border: 1px solid var(--green); color: var(--ink); border-radius: var(--radius); padding: 18px; text-align: center; }
.ch-complete strong { font-family: var(--serif); font-size: 1.3em; display: block; color: var(--green); }

/* ad */
.ch-ad { margin: 24px auto 0; max-width: 340px; }
.ch-ad .ad-slot { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 10px 6px; }
.ch-ad .ad-slot:not(:has(.ec-ad a)) { display: none; }
.ch-ad .ad-slot-label { font-size: .72em; color: var(--muted); margin-bottom: 6px; }
.ch-ad .ec-ad img { border-radius: 10px; }
.ch-ad .ec-ad-credit { display: block; margin-top: 4px; }

/* admin */
.ch-admin { border: 1.5px dashed var(--gold); background: var(--gold-soft); margin-bottom: 18px; }
.ch-admin > summary { list-style: none; cursor: pointer; }
.ch-admin > summary::-webkit-details-marker { display: none; }
.ch-admin > summary h3::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: .75em; color: var(--muted); margin-inline-start: auto; transition: transform .2s; }
.ch-admin[open] > summary h3::after { transform: rotate(180deg); }
.ch-admin[open] > summary { margin-bottom: 10px; }
.ch-admin h3 { margin: 0; font-size: 1.05em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ch-admin-sum { font-weight: 400; font-size: .85em; color: var(--muted); }
.ch-admin-share { width: 100%; padding: 15px; margin-bottom: 12px; font-size: 1.05em; }
.ch-admin-actions { justify-content: flex-start; margin-top: 4px; }
.ch-admin .ch-linkbox .ch-input { font-size: .88em; }
.ch-admin p { margin: 4px 0 12px; color: var(--ink-2); font-size: .93em; }
.ch-admin .ch-linkbox { display: flex; gap: 8px; margin-bottom: 12px; }
.ch-input, .ch-select, .ch-textarea { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line-2); border-radius: 12px; padding: 11px 13px; }
.ch-input:focus, .ch-select:focus, .ch-textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.ch-admin-list { font-size: .9em; max-height: 260px; overflow: auto; background: var(--card); border-radius: 12px; border: 1px solid var(--line); }
.ch-admin-list table { width: 100%; border-collapse: collapse; }
.ch-admin-list td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.ch-admin-list tr:last-child td { border-bottom: 0; }

/* modal */
.ch-modal { position: fixed; inset: 0; background: rgba(10,16,30,.5); display: none; align-items: flex-end; justify-content: center; z-index: 1000; padding: 0; }
.ch-modal.open { display: flex; }
.ch-sheet { background: var(--card); width: 100%; max-width: 460px; border-radius: 24px 24px 0 0; padding: 24px 22px 26px; box-shadow: 0 -10px 40px rgba(0,0,0,.2); animation: chUp .22s ease; }
@media (min-width: 600px) { .ch-modal { align-items: center; } .ch-sheet { border-radius: 24px; } }
@keyframes chUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.ch-sheet h3 { font-family: var(--serif); font-size: 1.5em; margin: 0 0 4px; }
.ch-sheet p { margin: 0 0 14px; color: var(--muted); }
.ch-sheet label { display: block; font-weight: 700; font-size: .92em; margin-bottom: 6px; }
.ch-sheet .ch-actions { margin-top: 16px; }
.ch-sheet .ch-btn { flex: 1; }
.ch-success { text-align: center; }
.ch-success .ch-big { font-size: 2.4em; line-height: 1; margin-bottom: 6px; color: var(--green); }

/* toast */
.ch-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(30px); background: var(--ink); color: var(--paper); padding: 11px 20px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 1100; }
.ch-toast.show { opacity: 1; transform: translateX(-50%); }
.ch-sticky:not([hidden]) ~ .ch-toast { bottom: 92px; }

/* floating take bar */
.ch-sticky { position: fixed; bottom: 0; left: 0; right: 0; z-index: 900; display: flex; gap: 10px; justify-content: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); animation: chUp .2s ease; }
.ch-sticky .ch-btn-primary { flex: 1; max-width: 360px; }
.ch-sticky .ch-btn-wa { padding: 13px 18px; font-size: 1.15em; }
.ch-wrap:has(~ .ch-sticky) { padding-bottom: 110px; }

/* footer */
.ch-foot { text-align: center; color: var(--muted); font-size: .88em; margin-top: 36px; }
.ch-foot a { color: var(--muted); }

/* new-chaluka form */
.ch-form { display: grid; gap: 18px; }
.ch-field label { display: block; font-weight: 700; margin-bottom: 7px; }
.ch-field .ch-hint { font-size: .85em; color: var(--muted); margin-top: 5px; }
.ch-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.ch-choice { position: relative; }
.ch-choices[data-sizes] { grid-template-columns: repeat(3, 1fr); }
.ch-choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.ch-choice span { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; min-height: 64px; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 10px; font-weight: 700; background: var(--card); transition: all .12s; }
.ch-choice span small { font-weight: 400; color: var(--muted); font-size: .8em; }
.ch-choice input:checked + span { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 3px var(--blue-soft); }
.ch-choice input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.ch-error { background: #fdecea; color: var(--red); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
@media (prefers-color-scheme: dark) { .ch-error { background: #3a1512; color: #ffb4ab; } }

/* landing */
.lp2-hero { text-align: center; padding: 36px 8px 10px; }
.lp2-hero h1 { font-family: var(--serif); font-size: clamp(2.1em, 6.5vw, 3.4em); line-height: 1.15; margin: 10px 0 14px; }
.lp2-hero h1 em { font-style: normal; color: var(--gold); }
.lp2-hero p { color: var(--ink-2); font-size: 1.12em; max-width: 600px; margin: 0 auto; }
.lp2-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 34px; }
.lp2-step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.lp2-step b { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; align-items: center; justify-content: center; background: var(--gold-soft); color: var(--gold); font-size: 1.05em; margin-bottom: 8px; }
.lp2-step h3 { margin: 0 0 4px; font-size: 1.1em; }
.lp2-step p { margin: 0; color: var(--muted); font-size: .95em; }
.lp2-demo { margin-top: 30px; }
.lp2-demo .ch-grid { pointer-events: none; }
.lp2-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.lp2-kind { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.lp2-kind h3 { font-family: var(--serif); margin: 0 0 6px; font-size: 1.3em; }
.lp2-kind ul { margin: 0; padding-right: 18px; color: var(--ink-2); }

.ch-hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 560px) {
    body { font-size: 16px; }
    .ch-top { padding: 12px 16px; }
    .ch-hero { padding: 28px 18px 22px; border-radius: 22px; }
    .ch-actions .ch-btn { flex: 1 1 100%; }
    .ch-hide-sm { display: none; }
    .ch-hero-actions .ch-btn { flex: 1 1 0; padding-inline: 12px; }
    .ch-hero-actions .ch-btn-wa { flex-grow: 1.7; }
    .ch-hero-actions #takeNext { flex: 1 1 100%; padding: 15px; font-size: 1.05em; }
    .ch-admin-actions .ch-btn { flex: 1 1 calc(50% - 10px); }
    .ch-admin-actions .ch-btn-wa { flex-basis: 100%; }
    .ch-mine-name { flex-basis: 100%; }
    .ch-mine-row .ch-btn { flex: 1 1 0; }
    .ch-rows { padding: 12px; }
    .ch-rows .ch-group { grid-template-columns: 62px 1fr; gap: 6px; padding: 7px 0; }
    .ch-rows .ch-grid { grid-template-columns: repeat(auto-fill, minmax(31px, 1fr)); gap: 4px; }
    .ch-rows .ch-u { min-height: 33px; padding: 0; border-radius: 8px; }
    .ch-rows .ch-u-label { font-size: .9em; }
    .ch-rows .ch-u.done::after { top: 0; left: 3px; font-size: .62em; }
    .ch-rows .ch-group-title { margin-top: 6px; font-size: .82em; }
    .ch-choice span { min-height: 50px; padding: 8px 6px; }
    .lp2-demo .ch-grid { grid-template-columns: repeat(10, 1fr) !important; gap: 4px !important; }
    .lp2-demo .ch-u { min-height: 28px !important; border-radius: 7px; padding: 0; }
    .lp2-demo .ch-u-label { font-size: .68em !important; }
    .lp2-demo .ch-u.done::after { display: none; }
    .lp2-step { display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; padding: 16px; }
    .lp2-step b { grid-row: span 2; margin: 0; }
    .lp2-steps { gap: 10px; margin-top: 26px; }
    .ch-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
    .ch-u { min-height: 46px; padding: 4px; }
    .ch-grid.wide .ch-u { min-height: 58px; }
    .ch-grid.wide { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
