:root {
    --limud-text: #1a1a1a;
    --limud-muted: #5c5c5c;
    --limud-border: #e2e2e2;
    --limud-accent: #1b6ec2;
    --limud-surface: #fafafa;
    --limud-bg: #fff;
    --diff-add: #15803d;
    --diff-add-bg: color-mix(in srgb, #16a34a 12%, transparent);
    --diff-del: #b91c1c;
    --diff-del-bg: color-mix(in srgb, #dc2626 10%, transparent);
    --diff-changed: #d97706;
}

html, body {
    font-family: system-ui, sans-serif;
    margin: 0;
    color: var(--limud-text);
    background: #fff;
}

#blazor-error-ui {
    display: none;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    text-align: center;
    font-weight: bold;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

.catalog-shell {
    margin: 1rem auto;
    max-width: 720px;
    padding: 0 0.5rem;
}

.catalog-shell header {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--limud-border);
    padding-bottom: 0.75rem;
}

.catalog-brand {
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.catalog-shell nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.catalog-links {
    list-style: none;
    padding: 0;
}

.catalog-links li {
    margin-bottom: 0.35rem;
}

.catalog-badge {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--diff-changed);
    margin: 0.25rem 0;
}

.catalog-inspect {
    margin-top: 1.5rem;
    border: 1px solid var(--limud-border);
    padding: 0.75rem;
    border-radius: 4px;
}

.catalog-json {
    font-size: 0.75rem;
    overflow: auto;
    max-height: 20rem;
    background: var(--limud-surface);
    padding: 0.5rem;
}

.author-thumb {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: cover;
    border-radius: 50%;
    vertical-align: middle;
    background: var(--limud-surface);
}

.author-thumb--large {
    width: 6rem;
    height: 6rem;
}

.author-thumb--empty {
    display: inline-block;
    background: var(--limud-border);
}

.author-merge-list li {
    margin-bottom: 1rem;
    list-style: none;
}

.author-merge-pair {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.author-merge-side {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.limud-shell {
    margin: 1rem;
    max-width: 960px;
}

.limud-shell:has(.calendar-page) {
    max-width: none;
}

.limud-shell header {
    margin-bottom: 1rem;
}

.limud-shell nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.limud-shell nav a.active {
    font-weight: 600;
}

/* Shared form controls (main shell) */
.form-field,
.program-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--limud-muted);
}

.form-field input:not([type="checkbox"]):not([type="radio"]),
.form-field select,
.form-field textarea,
.program-field input:not([type="checkbox"]):not([type="radio"]),
.program-field select,
.limud-shell .calendar-meta input:not([type="checkbox"]):not([type="radio"]) {
    font: inherit;
    font-size: 1rem;
    color: var(--limud-text);
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 6px;
    min-height: 2.5rem;
    max-width: 100%;
    box-sizing: border-box;
    background: var(--limud-bg);
}

.form-field input:focus-visible,
.form-field select:focus-visible,
.form-field textarea:focus-visible,
.program-field input:focus-visible,
.program-field select:focus-visible,
.limud-shell .calendar-meta input:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--limud-accent) 45%, transparent);
    outline-offset: 1px;
    border-color: color-mix(in srgb, var(--limud-accent) 55%, var(--limud-border));
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 550;
    font-family: inherit;
    line-height: 1.25;
    text-decoration: none;
    border: 1px solid transparent;
    background: var(--limud-accent);
    color: #fff;
    cursor: pointer;
    box-sizing: border-box;
}

.btn:hover:not(:disabled),
a.btn:hover {
    background: color-mix(in srgb, var(--limud-accent) 88%, #000);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-ghost,
a.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 550;
    font-family: inherit;
    line-height: 1.25;
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--limud-accent);
    cursor: pointer;
    box-sizing: border-box;
}

.btn-ghost:hover:not(:disabled),
a.btn-ghost:hover {
    background: color-mix(in srgb, var(--limud-accent) 8%, var(--limud-bg));
    border-color: color-mix(in srgb, var(--limud-accent) 25%, var(--limud-border));
}

.secondary,
button.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 550;
    font-family: inherit;
    line-height: 1.25;
    border: 1px solid var(--limud-border);
    background: var(--limud-bg);
    color: var(--limud-text);
    cursor: pointer;
    box-sizing: border-box;
}

.secondary:hover:not(:disabled),
button.secondary:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--limud-accent) 35%, var(--limud-border));
    background: color-mix(in srgb, var(--limud-accent) 4%, var(--limud-bg));
}

.secondary:disabled,
button.secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.due-list {
    list-style: none;
    padding: 0;
}

.due-page h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.due-alert {
    color: #b00020;
}

.due-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.due-card {
    border: 1px solid var(--limud-border);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    background: var(--limud-surface);
}

.due-card-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

.due-display {
    font-size: 1.05rem;
    font-weight: 500;
}

.due-status {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: #eee;
    color: var(--limud-muted);
}

.due-status-due {
    background: #e8f1fb;
    color: var(--limud-accent);
}

.due-status-overdue {
    background: #fdecea;
    color: #b00020;
}

.due-status-catching-up {
    background: #fff4e5;
    color: #b26a00;
}

.due-status-completed,
.due-status-skipped,
.due-status-caught-up {
    background: #eee;
    color: var(--limud-muted);
}

.due-titles {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.due-on {
    font-size: 0.85rem;
    color: var(--limud-muted);
}

.due-section {
    margin-bottom: 1.25rem;
}

.due-section-heading {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--limud-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.due-section-backlog .due-section-heading {
    color: #b26a00;
}

.due-expand-btn {
    font-size: 0.85rem;
    padding: 0.1rem 0.35rem;
}

.due-list-expanded {
    margin: 0.5rem 0 0.75rem 0.75rem;
    padding-left: 0;
    border-left: 2px solid #eee;
}

.due-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Material 3–style split button (leading action + trailing menu) */
.m3-split-button {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    vertical-align: middle;
}

.m3-split-button__controls {
    display: inline-flex;
    align-items: stretch;
    gap: 2px;
}

.m3-split-button__leading,
.m3-split-button__trailing {
    margin: 0;
    padding: 0;
    border: none;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.25;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.m3-split-button__leading {
    padding: 0.5rem 1rem;
    border-radius: 8px 4px 4px 8px;
    white-space: nowrap;
}

.m3-split-button__trailing {
    width: 2.5rem;
    flex-shrink: 0;
    border-radius: 4px 8px 8px 4px;
}

.m3-split-button__icon {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.m3-split-button__trailing[aria-expanded="true"] .m3-split-button__icon {
    transform: rotate(180deg);
}

.m3-split-button--filled .m3-split-button__leading,
.m3-split-button--filled .m3-split-button__trailing {
    background: var(--limud-accent);
    color: #fff;
}

.m3-split-button--filled .m3-split-button__leading:hover:not(:disabled),
.m3-split-button--filled .m3-split-button__trailing:hover:not(:disabled) {
    filter: brightness(1.06);
}

.m3-split-button--outlined .m3-split-button__leading,
.m3-split-button--outlined .m3-split-button__trailing {
    background: #fff;
    color: var(--limud-muted);
    box-shadow: inset 0 0 0 1px var(--limud-border);
}

.m3-split-button--outlined .m3-split-button__leading:hover:not(:disabled),
.m3-split-button--outlined .m3-split-button__trailing:hover:not(:disabled) {
    background: #f6f6f8;
}

.m3-split-button__leading:disabled,
.m3-split-button__trailing:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.m3-split-button__scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: transparent;
}

.m3-split-button__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 50;
    min-width: 12rem;
    padding: 0.35rem 0;
    background: var(--limud-surface, #fff);
    border-radius: 8px;
    box-shadow:
        0 1px 2px rgb(0 0 0 / 12%),
        0 4px 12px rgb(0 0 0 / 14%);
    border: 1px solid var(--limud-border, #e0e0e0);
}

.m3-split-button__menu-item {
    display: block;
    width: 100%;
    text-align: start;
    padding: 0.65rem 1rem;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    color: inherit;
}

.m3-split-button__menu-item:hover:not(:disabled) {
    background: rgb(0 0 0 / 6%);
}

.due-card-actions .m3-split-button,
.study-history-actions .m3-split-button {
    max-width: 100%;
}

.study-history-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 35%);
    z-index: 1000;
}

.modal-panel.partial-progress-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    width: min(28rem, 92vw);
    max-height: 80vh;
    overflow: auto;
    background: var(--limud-surface, #fff);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 32px rgb(0 0 0 / 18%);
}

.partial-progress-modal .partial-progress-tree {
    margin: 0.5rem 0 0;
}

.partial-progress-modal .program-tree > summary {
    cursor: pointer;
}

.due-btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.due-btn-primary {
    background: var(--limud-accent);
    color: #fff;
}

.due-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.due-btn-secondary {
    background: #fff;
    color: var(--limud-accent);
    border: 1px solid var(--limud-border);
}

.due-btn-muted {
    background: #fff;
    color: var(--limud-muted);
    border: 1px solid var(--limud-border);
}

.study-page {
    max-width: 42rem;
    margin: 0 auto;
}

.study-header {
    margin-bottom: 1.5rem;
}

.study-back {
    color: var(--limud-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.study-back:hover {
    color: var(--limud-accent);
}

.study-corpus {
    margin: 0.75rem 0 0.25rem;
    font-size: 0.85rem;
    color: var(--limud-muted);
    text-transform: capitalize;
}

.study-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.study-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    flex: 1 1 12rem;
}

.study-toggle {
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--limud-border);
    background: #fff;
    cursor: pointer;
    color: var(--limud-muted);
}

.study-toggle[aria-pressed="true"] {
    border-color: var(--limud-accent);
    color: var(--limud-accent);
}

.study-hebrew {
    font-size: 1.25rem;
    line-height: 1.75;
    padding: 0.5rem 0 1.5rem;
}

.study-hebrew p {
    margin: 0 0 1rem;
}

.study-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--limud-border);
    color: var(--limud-muted);
    font-size: 0.85rem;
}

.study-chip {
    background: #eee;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.study-sefaria-btn {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    background: var(--limud-accent);
    color: #fff !important;
    text-decoration: none;
    font-size: 0.9rem;
}

.study-attrib {
    width: 100%;
}

.study-empty,
.study-alert {
    color: var(--limud-muted);
}

.study-alert {
    color: #b00020;
}

.study-skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg, #eee, #f5f5f5, #eee);
    background-size: 200% 100%;
    animation: study-shimmer 1.2s infinite;
    border-radius: 4px;
    margin-bottom: 0.65rem;
}

.study-skeleton-line.short {
    width: 60%;
}

@keyframes study-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.locker-page .locker-list {
    list-style: none;
    padding: 0;
}

.locker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--limud-border);
}

.locker-row .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

.locker-row .meta-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: color-mix(in srgb, var(--limud-accent) 12%, var(--limud-bg));
    color: var(--limud-accent);
}

.calendar-shell {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

.calendar-sidebar {
    border-right: 1px solid var(--limud-border);
    padding-right: 1rem;
}

.chip-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1rem 0;
}

.schedule-add-toggle {
    margin: 0 0 1rem;
}

.schedule-add-open {
    width: 100%;
}

.learn-what {
    margin-bottom: 1rem;
}

.learn-what .ask {
    font-size: 1.35rem;
    font-weight: 650;
    margin: 0 0 1rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.learn-what .group {
    margin-bottom: 1rem;
}

.learn-what .group-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--limud-muted, #666);
    margin: 0 0 0.45rem;
}

.learn-what .corpus-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0;
}

.learn-what button.pick {
    min-height: 2.35rem;
    background: var(--limud-surface, #f8f8f8);
    color: inherit;
    border: 1px solid var(--limud-border);
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 550;
    cursor: pointer;
}

.learn-what button.pick.on {
    background: var(--limud-accent);
    color: #fff;
    border-color: var(--limud-accent);
}

.chip {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--limud-border);
    background: var(--limud-surface);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.85rem;
}

.draft-badge {
    color: var(--limud-accent);
    font-weight: 600;
}

.schedule-day-heading {
    font-size: 1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}

.schedule-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
    padding: 0.35rem 0 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--limud-border);
}

.view-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.65rem;
}

.view-tabs .view-tab {
    flex: 1;
    min-height: 2.75rem;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 8px;
    background: var(--limud-surface);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
}

.view-tabs .view-tab.active {
    font-weight: 700;
    background: #fff;
    border-color: var(--limud-accent);
    color: var(--limud-accent);
    box-shadow: 0 0 0 1px var(--limud-accent);
}

.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.date-nav-btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
    font: inherit;
    font-size: 1.1rem;
    border: 1px solid var(--limud-border);
    border-radius: 8px;
    background: var(--limud-surface);
    cursor: pointer;
}

.date-nav-label {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.month-past-loading {
    margin: 0 0 0.35rem;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(4.5rem, auto);
    gap: 0;
    border: 1px solid var(--limud-border);
    border-radius: 4px;
    overflow: hidden;
}

.month-wd {
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    padding: 0.25rem 0.15rem;
    background: var(--limud-surface);
    border-bottom: 1px solid var(--limud-border);
    border-right: 1px solid var(--limud-border);
}

.month-wd:nth-child(7n) {
    border-right: none;
}

.month-cell {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    background: var(--limud-bg);
    border: none;
    border-right: 1px solid var(--limud-border);
    border-bottom: 1px solid var(--limud-border);
    padding: 0.25rem 0.3rem;
    min-height: 4.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.month-cell:nth-child(7n) {
    border-right: none;
}

.month-cell:hover {
    background: var(--limud-surface);
}

.month-cell.outside {
    opacity: 0.55;
    background: color-mix(in srgb, var(--limud-bg) 92%, var(--limud-border));
}

.month-cell.today {
    outline: 2px solid var(--limud-accent, #2563eb);
    outline-offset: -2px;
    z-index: 1;
}

.month-cell.holiday .month-holiday {
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--limud-muted, #64748b);
}

.month-cell .when {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.2rem;
    margin-bottom: 0.15rem;
}

.month-cell .when .d {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.month-cell .when .he {
    font-size: 0.65rem;
    opacity: 0.85;
}

.month-hints {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.hint-line {
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
}

.hint-line.projected {
    opacity: 0.75;
    font-style: italic;
}

.month-cell.diff-add {
    outline: 2px solid color-mix(in srgb, #16a34a 55%, transparent);
}

.month-cell.diff-del {
    outline: 2px solid color-mix(in srgb, #dc2626 45%, transparent);
}

.month-cell.diff-changed {
    outline: 2px solid color-mix(in srgb, #d97706 50%, transparent);
}

.hint-line.diff-add {
    color: #15803d;
}

.hint-line.diff-remove {
    color: #b91c1c;
}

.diff-prefix {
    font-weight: 700;
    margin-inline-end: 0.15rem;
}

.diff-group {
    margin: 0.4rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.diff-group.added {
    border-inline-start: 3px solid var(--diff-add);
}

.diff-group.removed {
    border-inline-start: 3px solid var(--diff-del);
}

.diff-group.changed {
    border-inline-start: 3px solid var(--diff-changed);
}

.diff-label {
    font-size: 0.82rem;
    color: var(--limud-muted);
    padding: 0.35rem 0.65rem 0.1rem;
}

.diff-line {
    display: flex;
    gap: 0.45rem;
    align-items: baseline;
    padding: 0.28rem 0.65rem;
}

.diff-line.today {
    font-weight: 650;
}

.diff-mark {
    flex: 0 0 auto;
    font-weight: 650;
}

.diff-line.diff-add {
    background: var(--diff-add-bg);
}

.diff-line.diff-remove {
    background: var(--diff-del-bg);
}

.timezone-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.timezone-search {
    font: inherit;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 6px;
}

.timezone-select {
    font: inherit;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 6px;
    max-width: 100%;
}

.timezone-use-browser {
    align-self: flex-start;
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

.program-card {
    border: 1px solid var(--limud-border);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.program-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.program-card-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.program-settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 0.75rem;
}

.program-field-wide {
    grid-column: 1 / -1;
}

.program-readonly {
    font-size: 1rem;
    color: var(--limud-text);
}

.settings-page .form-field {
    margin-bottom: 1rem;
}

.program-field-check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    color: var(--limud-text);
}

.program-field-check input {
    width: auto;
    min-height: auto;
}

.program-pane {
    margin-top: 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 8px;
    padding: 0.35rem 0.55rem 0.55rem;
    background: color-mix(in srgb, var(--limud-bg) 92%, #fff);
}

.program-pane > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    list-style: none;
    padding: 0.25rem 0;
}

.program-pane > summary::-webkit-details-marker {
    display: none;
}

.program-pane > summary::before {
    content: "▶";
    font-size: 0.65rem;
    margin-right: 0.25rem;
    color: var(--limud-muted);
}

.program-pane[open] > summary::before {
    content: "▼";
}

.program-pane .pane-summary {
    font-weight: 400;
    color: var(--limud-muted);
    font-size: 0.88rem;
}

.program-tree.program-pane {
    padding-bottom: 0.35rem;
}

.program-advanced {
    font-size: 0.9rem;
}

.program-card-settings {
    margin-top: 0.65rem;
    border: 1px solid var(--limud-border);
    border-radius: 8px;
    padding: 0.35rem 0.55rem 0.55rem;
}

.program-card-settings > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--limud-text);
    list-style: none;
    padding: 0.25rem 0;
}

.program-card-settings > summary::-webkit-details-marker {
    display: none;
}

.program-card-settings > summary::before {
    content: "▶";
    flex-shrink: 0;
    font-size: 0.65rem;
    margin-right: 0.15rem;
    color: var(--limud-muted);
}

.program-card-settings[open] > summary::before {
    content: "▼";
}

.program-card-settings .program-card-settings-label {
    font-weight: 600;
    color: var(--limud-text);
}

.program-card-settings .pane-summary {
    font-weight: 400;
    color: var(--limud-muted);
}

.calendar-meta {
    margin: 1rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--limud-border);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.calendar-meta .form-field {
    font-size: 0.85rem;
    color: var(--limud-muted);
}

.schedule-empty-hint {
    margin: 0.75rem 0 1rem;
}

.learn-how {
    margin: 1.25rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--limud-border);
}

.learn-how .how-title {
    margin: 0 0 0.65rem;
    font-size: 1rem;
    font-weight: 650;
}

.ask-sub {
    margin: 0.35rem 0 0.65rem;
    font-size: 0.88rem;
    color: var(--limud-muted);
    line-height: 1.4;
}

.ics-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--limud-muted);
    margin: 0.5rem 0;
}

.ics-url {
    font: inherit;
    font-size: 0.85rem;
    color: var(--limud-text);
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 6px;
    width: 100%;
}

.segment {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.off-days-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: 0.35rem 0.75rem;
    margin-top: 0.5rem;
}

.off-days-grid label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--limud-text);
    margin: 0;
}

.program-tree {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.program-tree summary {
    cursor: pointer;
    color: var(--limud-accent);
}

.tree-list {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0 0;
}

.tree-list ul {
    list-style: none;
    padding-left: 1.25rem;
    margin: 0.25rem 0;
}

.tree-toggle {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    padding: 0.15rem 0;
    text-align: left;
}

.tree-check {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.1rem 0;
}

@media (max-width: 900px) {
    .calendar-shell {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    .calendar-main {
        order: -1;
    }
    .calendar-sidebar {
        border-right: none;
        padding-right: 0;
        border-top: 1px solid var(--limud-border);
        padding-top: 1rem;
    }
    .schedule-toolbar {
        top: 0;
    }
    .month-grid {
        font-size: 0.68rem;
    }
    .month-cell {
        min-height: 3.25rem;
        padding: 0.2rem;
    }
}

.cal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.schedule-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
}

.list-months select {
    font: inherit;
    min-height: 2.75rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--limud-border);
    border-radius: 8px;
}

.schedule-panel--list .list-schedule {
    display: block;
    column-width: 11rem;
    column-gap: 1.25rem;
    column-fill: auto;
}

.list-row {
    break-inside: avoid;
    page-break-inside: avoid;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.5rem;
    margin: 0 0 0.45rem;
    align-items: start;
}

.list-day {
    font-size: 0.92rem;
}

.list-day .when {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.list-day .list-date {
    font-weight: 600;
}

.list-day .he {
    font-size: 0.82rem;
    color: var(--limud-muted);
}

.list-day .holiday {
    font-size: 0.78rem;
    color: var(--limud-muted);
    margin-top: 0.2rem;
}

.list-item {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.12rem 0;
    font-size: 0.9rem;
    line-height: 1.35;
}

.list-check {
    flex-shrink: 0;
    box-sizing: border-box;
    width: 0.75rem;
    height: 0.75rem;
    margin-top: 0.2rem;
    border: 1px solid #333;
    border-radius: 2px;
    background: #fff;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.list-item-text {
    min-width: 0;
}

.list-empty {
    margin: 0;
    font-size: 0.85rem;
    color: var(--limud-muted);
}

dialog.share-dialog {
    border: 1px solid var(--limud-border);
    border-radius: 14px;
    padding: 1.15rem 1.2rem 1.25rem;
    max-width: 22rem;
    width: calc(100% - 2rem);
    background: #fff;
}

dialog.share-dialog::backdrop {
    background: rgba(28, 28, 28, 0.35);
}

.share-dialog h2 {
    margin: 0 0 0.85rem;
    font-size: 1.05rem;
}

.share-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.share-row p {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: var(--limud-muted);
}

.about-page {
    max-width: 42rem;
}

.about-page .page-title {
    margin-top: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media print {
    @page {
        margin: 0.4in;
    }

    body {
        background: #fff;
    }

    .limud-shell > header,
    .calendar-sidebar,
    .schedule-toolbar,
    .draft-badge,
    .study-alert,
    .meta,
    .month-past-loading,
    .due-card-actions,
    a.due-btn {
        display: none !important;
    }

    .calendar-shell {
        display: block;
    }

    .calendar-page {
        padding: 0;
    }

    .calendar-main {
        padding: 0;
    }

    .schedule-panel--list .list-schedule {
        column-width: 11rem;
        column-gap: 1.25rem;
        column-fill: auto;
    }

    .list-row {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .list-check {
        border-color: #000;
    }

    .month-cell {
        break-inside: avoid;
    }
}

.corpus-tree-picker .tree-level {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 0.35rem 0;
    width: 100%;
    box-sizing: border-box;
}

.corpus-tree-picker .tree-kids {
    flex: 1 1 100%;
    width: 100%;
    padding-inline-start: 0.5rem;
    border-inline-start: 2px solid var(--limud-border);
    margin: 0.25rem 0 0.5rem;
}

.corpus-tree-picker .tree-kids.collapsed {
    display: none;
}

.corpus-tree-picker .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--limud-border);
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: default;
    user-select: none;
    margin: 0;
}

.corpus-tree-picker .chip-branch {
    cursor: pointer;
}

.corpus-tree-picker .chip-title {
    font-weight: 600;
}

.corpus-tree-picker .chip input[type="checkbox"],
.corpus-tree-picker .chip input[type="checkbox"],
.corpus-tree-picker .chip input[type="radio"] {
    margin: 0;
}

.corpus-tree-picker .chip-gutter-wrap {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.corpus-tree-picker .chip-expand-btn {
    background: none;
    border: 1px solid var(--limud-border);
    border-radius: 4px;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    font-size: 0.65rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.corpus-tree-picker .tree-level-gutter {
    align-items: center;
}

    display: flex;
    gap: 0;
    overflow-x: auto;
    border: 1px solid var(--limud-border);
    border-radius: 6px;
    min-height: 12rem;
}

    flex: 0 0 auto;
    min-width: 9rem;
    max-width: 14rem;
    border-right: 1px solid var(--limud-border);
    padding: 0.35rem 0;
}

    border-right: none;
}

    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.35rem;
    font-size: 0.85rem;
}

    background: color-mix(in srgb, var(--limud-accent) 12%, transparent);
}

    background: none;
    border: none;
    width: 1.25rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    color: var(--limud-accent);
}

    display: inline-block;
    width: 1.25rem;
    flex-shrink: 0;
}

    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    min-width: 0;
}

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.corpus-tree-picker .pick-grid {
    gap: 0;
    line-height: 1.2;
}

.corpus-tree-picker .pick-grid .pick-cell {
    margin: 0 -1px -1px 0;
}

.corpus-tree-picker .pick-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 1.65rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid color-mix(in srgb, var(--limud-border) 90%, #888);
    background: var(--limud-bg, #fff);
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 55ms ease-out, box-shadow 55ms ease-out, transform 55ms ease-out,
        border-color 55ms ease-out;
}

.corpus-tree-picker .pick-cell-text {
    pointer-events: none;
}

.corpus-tree-picker .pick-excel-btn.pick-off:hover {
    border-color: color-mix(in srgb, var(--limud-accent) 35%, var(--limud-border));
    background: color-mix(in srgb, var(--limud-accent) 4%, var(--limud-bg, #fff));
}

.corpus-tree-picker .pick-excel-btn.pick-off {
    box-shadow: 0 1px 0 color-mix(in srgb, var(--limud-text) 12%, transparent),
        0 1px 2px color-mix(in srgb, var(--limud-text) 6%, transparent);
}

.corpus-tree-picker .pick-excel-btn.pick-pressing,
.corpus-tree-picker .pick-excel-btn.pick-pressing,
.corpus-tree-picker .pick-excel-btn:active {
    transform: scale(0.97);
    box-shadow: inset 0 1px 3px color-mix(in srgb, var(--limud-text) 16%, transparent);
}

.corpus-tree-picker .pick-excel-btn.pick-on {
    background: color-mix(in srgb, var(--limud-accent) 22%, var(--limud-bg, #fff));
    border-color: color-mix(in srgb, var(--limud-accent) 55%, var(--limud-border));
    box-shadow: inset 0 1px 2px color-mix(in srgb, var(--limud-text) 14%, transparent);
    font-weight: 600;
}

.corpus-tree-picker .pick-excel-btn.pick-mixed {
    background: repeating-linear-gradient(
        -45deg,
        color-mix(in srgb, var(--limud-accent) 12%, var(--limud-bg, #fff)),
        color-mix(in srgb, var(--limud-accent) 12%, var(--limud-bg, #fff)) 4px,
        color-mix(in srgb, var(--limud-accent) 26%, var(--limud-bg, #fff)) 4px,
        color-mix(in srgb, var(--limud-accent) 26%, var(--limud-bg, #fff)) 8px
    );
    border-color: var(--limud-accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--limud-accent) 35%, transparent);
}

.corpus-tree-picker .pick-excel-flat.pick-off {
    background: var(--limud-bg, #fff);
}

.corpus-tree-picker .pick-excel-flat.pick-on {
    background: color-mix(in srgb, var(--limud-accent) 16%, var(--limud-bg, #fff));
    outline: 2px solid color-mix(in srgb, var(--limud-accent) 70%, transparent);
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

.corpus-tree-picker .pick-excel-flat.pick-mixed {
    background: color-mix(in srgb, var(--limud-accent) 10%, var(--limud-bg, #fff));
    outline: 2px dashed var(--limud-accent);
    outline-offset: -2px;
}

.corpus-tree-picker .pick-active {
    outline: 2px solid #217346;
    outline-offset: -2px;
    z-index: 2;
    position: relative;
}

.corpus-tree-picker .pick-cell.chip-title {
    font-weight: 600;
}

.corpus-tree-picker .pick-cell:focus-visible {
    outline: 2px solid var(--limud-accent);
    outline-offset: 1px;
}

.corpus-tree-picker.titles-he .lab-tree-root,
.corpus-tree-picker.titles-he .lab-variant-inner {
    direction: rtl;
}

.corpus-tree-picker.titles-he .tree-level {
    direction: rtl;
}

.corpus-tree-picker.titles-he .pick-grid {
    direction: rtl;
}

.corpus-tree-picker.titles-he .pick-grid .pick-cell {
    margin: 0 0 -1px -1px;
}


/* ---- Calendar onboarding / save bar / links (calendar UX) ---- */
.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.6rem 0.75rem;
    background: #fff;
    border: 1px solid var(--limud-border);
    border-radius: 12px;
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08);
}
.save-bar-status {
    flex: 1 1 auto;
    font-size: 0.9rem;
    color: var(--limud-muted);
}
.save-bar.is-dirty {
    border-color: var(--limud-accent);
}
.save-bar.is-dirty .save-bar-status {
    color: var(--limud-accent);
    font-weight: 600;
}
@media (max-width: 720px) {
    .save-bar {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        margin: 0;
    }
    .calendar-editor {
        padding-bottom: 5rem;
    }
}
.calendar-meta-top {
    margin-bottom: 0.75rem;
}
.links-buttons {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}
.backup-badge {
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    border: 1px solid var(--limud-border);
    background: #fff;
    cursor: pointer;
}
.backup-badge.is-saved {
    color: #1d6b3a;
    border-color: #9fd3b0;
    background: #eefaf1;
}
.backup-badge.is-unsaved {
    color: #8a4b00;
    border-color: #f0c98a;
    background: #fff7e8;
}
dialog.links-dialog {
    max-width: 30rem;
}
.link-tag {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    margin-inline-start: 0.3rem;
    vertical-align: middle;
}
.link-tag.is-private {
    background: #fff1f0;
    color: #a3261a;
}
.link-tag.is-safe {
    background: #eefaf1;
    color: #1d6b3a;
}
.link-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 0 0 auto;
}
.link-actions .btn-like {
    text-decoration: none;
    text-align: center;
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--limud-border);
    border-radius: 8px;
}
.link-howto p {
    font-size: 0.85rem;
}
.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--limud-accent);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}
.save-step,
.setup-wizard {
    max-width: 36rem;
    margin: 1.5rem auto;
    padding: 1.25rem;
    border: 1px solid var(--limud-border);
    border-radius: 14px;
    background: #fff;
}
.save-step-kicker {
    margin: 0;
    color: #1d6b3a;
    font-weight: 600;
}
.save-step-url {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0.75rem 0;
    font-weight: 600;
}
.save-step-url input {
    width: 100%;
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    padding: 0.5rem;
}
.save-step-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.save-step-done {
    color: #1d6b3a;
}
.save-step-skip {
    font-size: 0.85rem;
}
.wizard-steps {
    display: flex;
    gap: 0.75rem;
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--limud-muted);
}
.wizard-steps .is-current {
    color: var(--limud-accent);
    font-weight: 600;
}
.wizard-steps .is-done {
    color: #1d6b3a;
}
.wizard-step-num {
    display: inline-flex;
    width: 1.4rem;
    height: 1.4rem;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 0.75rem;
}
.wizard-chosen {
    list-style: none;
    padding: 0;
}
.wizard-chosen li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--limud-border);
}
.wizard-offdays {
    border: none;
    padding: 0;
    margin: 0.6rem 0 0;
}
.wizard-nav {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 0 0.25rem;
    background: #fff;
}
.wizard-nav-spacer {
    flex: 1;
}
.wizard-skip {
    font-size: 0.85rem;
}
.calendar-empty,
.calendar-restore {
    margin: 1rem 0;
}
.restore-link {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}
.restore-link .form-field {
    flex: 1 1 18rem;
}
@media (max-width: 720px) {
    .save-step,
    .setup-wizard {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: 100dvh;
    }
}

/* Keep the editor inside narrow viewports (iPhone): flex/grid children must be allowed to shrink. */
.calendar-shell > *,
.calendar-sidebar,
.calendar-editor {
    min-width: 0;
    max-width: 100%;
}
.calendar-sidebar input,
.calendar-sidebar select,
.calendar-sidebar textarea {
    max-width: 100%;
    min-width: 0;
}
.cal-row {
    flex-wrap: wrap;
}
.cal-row > :first-child {
    min-width: 0;
    overflow-wrap: anywhere;
}
