:root {
    --bg: #0e1320;
    --bg-card: rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.07);
    --text: #f5f5f5;
    --text-dim: #b6b9c5;
    --accent: #d4af37;
    --accent-2: #8ab4f8;
    --border: rgba(255,255,255,0.08);
    --danger: #ef5350;
    --success: #4caf50;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Assistant', sans-serif; }
body { min-height: 100vh; }

/* ===== DISPLAY (index.html) ===== */
.display-body {
    background: radial-gradient(ellipse at top, #1a2140 0%, var(--bg) 55%);
    overflow: hidden;
    height: 100vh;
}

#display-root {
    display: grid;
    grid-template-rows: auto 1fr auto auto auto;
    height: 100vh;
    padding: 1.5vh 2vw;
    gap: 1.5vh;
}

.display-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 2vw;
    padding: 0 1vw;
}
.display-header.header-2col {
    grid-template-columns: 1fr auto;
}

.display-header .brand { text-align: right; }
.display-header h1 {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: clamp(2rem, 3.5vw, 3.5rem);
    font-weight: 900;
    color: var(--accent);
    margin: 0;
    line-height: 1.1;
}
.display-header .sub {
    font-size: clamp(0.9rem, 1.3vw, 1.4rem);
    color: var(--text-dim);
    margin-top: 0.4rem;
}
.display-header .sep { margin: 0 0.5rem; opacity: 0.5; }

.clock {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.3rem;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}
#current-time {
    font-size: clamp(3rem, 6vw, 6rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--text);
}
#current-seconds {
    font-size: clamp(1.5rem, 2.5vw, 2.5rem);
    font-weight: 600;
    color: var(--text-dim);
}

.room-switcher {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.room-switcher button {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font: inherit;
    font-size: clamp(0.85rem, 1vw, 1.1rem);
    cursor: pointer;
    transition: all 0.2s;
}
.room-switcher button:hover { background: var(--bg-card-hover); }
.room-switcher button.active {
    background: var(--accent);
    color: #0e1320;
    border-color: var(--accent);
    font-weight: 700;
}

.display-main {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 1.5vw;
    min-height: 0;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: clamp(1rem, 1.8vw, 1.8rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.card h2 {
    margin: 0 0 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--accent);
    color: var(--accent);
    font-size: clamp(1.4rem, 2vw, 2.2rem);
    font-weight: 700;
    font-family: 'Frank Ruhl Libre', serif;
    flex: 0 0 auto;
}
.scroll-viewport {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 96%, transparent 100%);
            mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 96%, transparent 100%);
}
.scroll-inner {
    will-change: transform;
}
.scroll-inner.scrolling {
    animation-name: sz-scroll-up;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
@keyframes sz-scroll-up {
    0%   { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(0, -50%, 0); }
}
/* A visual gap between the original content and its clone so transition is smooth */
.scroll-inner[data-cloned="1"] > [data-clone="1"] {
    margin-top: 1rem;
}

.zmanim-card table, .tefillot-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(1rem, 1.4vw, 1.6rem);
}
.zmanim-card td, .tefillot-card td {
    padding: 0.55rem 0.3rem;
    border-bottom: 1px solid var(--border);
}
.zmanim-card tr:last-child td, .tefillot-card tr:last-child td { border-bottom: none; }
.zmanim-card td:first-child, .tefillot-card td:first-child {
    text-align: right;
    font-weight: 600;
    color: var(--text);
}
.zmanim-card td:last-child, .tefillot-card td:last-child {
    text-align: left;
    direction: ltr;
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tefillot-card .room-block {
    margin-bottom: 1.2rem;
}
.tefillot-card .room-block:last-child { margin-bottom: 0; }
.tefillot-card .room-block h3,
.tefillot-card .prayer-block h3 {
    margin: 0 0 0.4rem;
    font-size: clamp(1.1rem, 1.5vw, 1.7rem);
    color: var(--accent-2);
    font-weight: 600;
    font-family: 'Frank Ruhl Libre', serif;
}
.tefillot-card .prayer-block {
    margin-bottom: 0.9rem;
}
.tefillot-card .prayer-block:last-child { margin-bottom: 0; }
.tefillot-card .prayer-block td.ptime {
    width: 30%;
    font-weight: 700;
    color: var(--accent);
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
}
.tefillot-card .prayer-block td.proom {
    color: var(--text);
}
.tefillot-card .shabbat-shared {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    padding: 0.5rem 0.8rem;
    background: rgba(212,175,55,0.08);
    border-radius: 8px;
    font-size: clamp(0.95rem, 1.3vw, 1.4rem);
}
.tefillot-card .shabbat-shared > div {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}
.tefillot-card .shabbat-shared b {
    color: var(--accent);
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.zmanim-card td .ov {
    color: var(--accent);
    margin-inline-start: 0.2rem;
}

.display-header .sub.omer {
    font-size: clamp(0.85rem, 1.1vw, 1.2rem);
    color: var(--accent);
    margin-top: 0.2rem;
    font-weight: 600;
}

#memorial-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: clamp(1rem, 1.3vw, 1.5rem);
}
#memorial-list li {
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--border);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}
#memorial-list li:last-child { border-bottom: none; }
#memorial-list .mem-name { font-weight: 600; }
#memorial-list .mem-date { color: var(--text-dim); direction: ltr; font-size: 0.9em; }
#memorial-list .mem-today { color: var(--accent); font-weight: 800; }

.announcements-container {
    background: var(--accent);
    color: #0e1320;
    padding: 0.5rem 0;
    overflow: hidden;
    white-space: nowrap;
    border-radius: 10px;
    display: none;
}
#announcements-ticker {
    font-size: clamp(1rem, 1.4vw, 1.6rem);
    font-weight: 700;
    display: inline-block;
    padding-right: 100%;
    animation: ticker 60s linear infinite;
}
@keyframes ticker {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.display-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: clamp(0.9rem, 1.1vw, 1.2rem);
    padding: 0.4rem 0;
}

.mentions-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: clamp(0.95rem, 1.3vw, 1.4rem);
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    background: rgba(138, 180, 248, 0.08);
    border: 1px solid rgba(138, 180, 248, 0.25);
}
.mentions-bar .mention {
    color: var(--accent-2);
    font-weight: 600;
    padding: 0.1rem 0.6rem;
}
.mentions-bar .mention + .mention {
    border-inline-start: 1px solid rgba(138, 180, 248, 0.3);
}

/* mobile */
@media (max-width: 900px) {
    #display-root { grid-template-rows: auto auto 1fr auto auto; }
    .display-header { grid-template-columns: 1fr; gap: 0.5rem; text-align: center; }
    .display-header .brand { text-align: center; }
    .display-main { grid-template-columns: 1fr; }
    .room-switcher { justify-content: center; }
}

/* ===== ADMIN (admin.html) ===== */
.admin-body {
    background: #f4f6fa;
    color: #1c1f2a;
    font-family: 'Assistant', sans-serif;
    padding: 0;
    min-height: 100vh;
}
.admin-topbar {
    background: #0e1320;
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-topbar h1 { margin: 0; font-size: 1.4rem; font-family: 'Frank Ruhl Libre', serif; color: var(--accent); }
.admin-topbar .actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.login-box {
    max-width: 420px;
    margin: 5rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.08);
}
.login-box h2 { margin-top: 0; color: #0e1320; font-family: 'Frank Ruhl Libre', serif; }
.login-box .hint { color: #666; font-size: 0.9rem; margin-top: 1rem; }

.tab-bar {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    border-bottom: 2px solid #e6e9f0;
    margin-bottom: 1.5rem;
}
.tab-bar button {
    background: transparent;
    border: none;
    padding: 0.75rem 1.2rem;
    font: inherit;
    font-size: 1rem;
    color: #555;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.tab-bar button.active {
    color: #0e1320;
    font-weight: 700;
    border-bottom-color: var(--accent);
    background: #fff;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.panel {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.panel h2 { margin-top: 0; font-family: 'Frank Ruhl Libre', serif; }
.panel h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; font-family: 'Frank Ruhl Libre', serif; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.95rem; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font: inherit;
    font-size: 1rem;
    border: 1px solid #d0d4dd;
    border-radius: 6px;
    background: #fff;
    color: #1c1f2a;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212,175,55,0.15);
}
.field .desc { color: #777; font-size: 0.85rem; margin-top: 0.25rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.btn {
    background: #0e1320;
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    font: inherit;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: #1c2544; }
.btn-primary { background: var(--accent); color: #0e1320; font-weight: 700; }
.btn-primary:hover { background: #b89327; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c73d3a; }
.btn-ghost { background: transparent; color: #0e1320; border: 1px solid #d0d4dd; }
.btn-ghost:hover { background: #f4f6fa; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.list-item {
    display: grid;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid #e6e9f0;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: #fafbfd;
}
.list-item .head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.list-item .head strong { font-size: 1.05rem; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}
table.data-table th, table.data-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #e6e9f0;
    text-align: right;
}
table.data-table th { background: #f4f6fa; font-weight: 700; font-size: 0.9rem; }
table.data-table input {
    width: 100%;
    padding: 0.3rem 0.45rem;
    border: 1px solid #d0d4dd;
    border-radius: 4px;
    font: inherit;
    font-size: 0.95rem;
}
table.data-table .col-actions { width: 80px; text-align: center; }

.status-bar {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: #0e1320;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.25s;
    z-index: 999;
    pointer-events: none;
}
.status-bar.show { opacity: 1; }
.status-bar.success { background: var(--success); }
.status-bar.error { background: var(--danger); }

.unsaved-indicator {
    background: #fff3cd;
    color: #856404;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border-right: 4px solid #ffc107;
    display: none;
    margin-bottom: 1rem;
}
.unsaved-indicator.show { display: block; }

.zmanim-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0.5rem;
}
.zmanim-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.7rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e6e9f0;
    border-radius: 6px;
    background: #fafbfd;
}
.zmanim-row .zm-default {
    color: #888;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    min-width: 9ch;
    text-align: left;
}
.zmanim-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}
.zmanim-row input[type="checkbox"]:checked ~ .zm-label { color: #0e1320; }
.zmanim-row:has(input[type="checkbox"]:checked) {
    border-color: var(--accent);
    background: #fff8e1;
}
.zmanim-row .zm-ov-label { white-space: nowrap; }

.minyan-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.minyan-list > label {
    font-weight: 600;
    font-size: 0.95rem;
}
.minyan-rows {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.minyan-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem;
    align-items: center;
}
.minyan-row input {
    width: 100%;
    padding: 0.4rem 0.55rem;
    border: 1px solid #d0d4dd;
    border-radius: 4px;
    font: inherit;
}

.sp-times {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.sp-time-row {
    display: grid;
    grid-template-columns: 1fr 1.4fr 0.8fr auto;
    gap: 0.4rem;
    align-items: center;
}
.sp-time-row input, .sp-time-row select {
    padding: 0.4rem 0.55rem;
    border: 1px solid #d0d4dd;
    border-radius: 4px;
    font: inherit;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #888;
    font-style: italic;
}

.file-drop {
    border: 2px dashed #d0d4dd;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    background: #fafbfd;
    cursor: pointer;
    transition: all 0.2s;
}
.file-drop:hover, .file-drop.drag { border-color: var(--accent); background: #fff8e1; }
.file-drop input { display: none; }

.small { font-size: 0.88rem; color: #666; }
code.inline { background: #f4f6fa; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.92em; }

.kbd {
    background: #e6e9f0;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 0.9em;
}

/* ===== THEMES ===== */
/* Light theme */
html[data-theme="light"], body[data-theme="light"] {
    --bg: #f5f5f5;
    --bg-card: rgba(0, 0, 0, 0.04);
    --bg-card-hover: rgba(0, 0, 0, 0.08);
    --text: #1a2140;
    --text-dim: #555555;
    --accent: #b8860b;
    --accent-2: #1976d2;
    --border: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .display-body {
    background: radial-gradient(ellipse at top, #ffffff 0%, var(--bg) 55%);
}

/* Blue theme */
html[data-theme="blue"], body[data-theme="blue"] {
    --bg: #0a192f;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.09);
    --text: #e6f1ff;
    --text-dim: #8892b0;
    --accent: #64ffda;
    --accent-2: #4db8ff;
    --border: rgba(255, 255, 255, 0.1);
}

body[data-theme="blue"] .display-body {
    background: radial-gradient(ellipse at top, #112240 0%, var(--bg) 55%);
}

/* ===== LAYOUTS ===== */
/* 2 Columns Layout */
#display-root[data-layout="2col"] .display-main {
    grid-template-columns: 1fr 1.5fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "zmanim tefillot"
        "memorial tefillot";
}

#display-root[data-layout="2col"] .zmanim-card { grid-area: zmanim; }
#display-root[data-layout="2col"] .tefillot-card { grid-area: tefillot; }
#display-root[data-layout="2col"] .memorial-card { grid-area: memorial; }

/* Horizontal Layout */
#display-root[data-layout="horizontal"] .display-main {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
        "zmanim tefillot"
        "memorial memorial";
}

#display-root[data-layout="horizontal"] .zmanim-card { grid-area: zmanim; }
#display-root[data-layout="horizontal"] .tefillot-card { grid-area: tefillot; }
#display-root[data-layout="horizontal"] .memorial-card { grid-area: memorial; }

/* Wood theme */
html[data-theme="wood"], body[data-theme="wood"] {
    --bg: #4b3017;
    --bg-card: rgba(0, 0, 0, 0.4);
    --bg-card-hover: rgba(0, 0, 0, 0.5);
    --text: #fdf5e6;
    --text-dim: #deb887;
    --accent: #ffd700;
    --accent-2: #ff8c00;
    --border: rgba(255, 215, 0, 0.2);
}

body[data-theme="wood"] .display-body {
    background: radial-gradient(ellipse at center, #6e4624 0%, var(--bg) 100%);
}

/* Marble theme */
html[data-theme="marble"], body[data-theme="marble"] {
    --bg: #e8e8e8;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --text: #2f4f4f;
    --text-dim: #696969;
    --accent: #8b0000;
    --accent-2: #000080;
    --border: rgba(139, 0, 0, 0.3);
}

body[data-theme="marble"] .display-body {
    background: radial-gradient(ellipse at top, #ffffff 0%, var(--bg) 70%);
}
