:root {
    --bg-grey: #e2e5e4;
    --bg-white: #ffffff;
    --text-primary: #333333;
    --text-muted: #666666;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-grey);
}

body.state-off {
    background-color: #000;
}

body.state-off .grid-container {
    opacity: 0;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: minmax(0, 80vh) minmax(0, 20vh);
    width: 100vw;
    height: 100vh;
    opacity: 1;
}

.content-loop {
    grid-column: 1 / span 4;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
    overflow: hidden;
}

.sidebar {
    grid-column: 5;
    grid-row: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    color: var(--text-primary);
    transition: transform 0.6s ease-in-out, box-shadow 0.6s ease-in-out;
    transform-style: preserve-3d;
    position: relative;
    overflow-y: hidden;
    word-break: break-word;
}

.sidebar h1 { font-size: 2rem; font-weight: 300; margin-bottom: 16px; color: var(--text-primary); line-height: 1.2; }
.sidebar h2 { font-size: 1.5rem; font-weight: 500; margin-bottom: 12px; color: var(--text-primary); line-height: 1.3; }
.sidebar h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 10px; color: var(--text-primary); line-height: 1.3; }
.sidebar h4 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.sidebar p { margin-bottom: 18px; line-height: 1.7; font-size: 1.1rem; color: var(--text-muted); font-weight: 300; }
.sidebar p:last-child { margin-bottom: 0; }
.sidebar ul { list-style-type: none; padding-left: 0; margin-bottom: 20px; color: var(--text-primary); }
.sidebar ul > li { position: relative; padding-left: 20px; margin-bottom: 12px; font-weight: 400; font-size: 1.05rem; line-height: 1.5; }
.sidebar ul > li::before { 
    content: '•'; 
    position: absolute; left: 0; top: 0px; 
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1.4;
}
.sidebar ol { padding-left: 24px; margin-bottom: 20px; color: var(--text-primary); }
.sidebar ol > li { margin-bottom: 10px; font-weight: 400; font-size: 1.05rem; line-height: 1.5; }
.sidebar blockquote { 
    border-left: 4px solid #741011; 
    background: rgba(116, 16, 17, 0.04);
    padding: 12px 16px; 
    margin-bottom: 20px; 
    border-radius: 0 8px 8px 0;
    font-size: 1.05rem;
    color: #444444;
}
.sidebar hr { border: none; border-top: 1px solid #e2e5e4; margin: 20px 0; }
.sidebar strong, .sidebar b { font-weight: 700; }
.sidebar em, .sidebar i { font-style: italic; }
.sidebar u { text-decoration: underline; text-underline-offset: 3px; }
.sidebar s, .sidebar strike { text-decoration: line-through; }
.sidebar a { color: #741011; text-decoration: underline; }

.box {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px 25px;
    background-color: var(--bg-white);
    border-right: 1px solid #d4d4d4;
    overflow: hidden;
    transition: transform 0.6s ease-in-out, box-shadow 0.6s ease-in-out;
    transform-style: preserve-3d;
    position: relative;
}
.box:last-child {
    border-right: none;
}

.box-content-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    height: 100%;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: 300;
}

.slide-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    will-change: opacity, transform;
    transform: translateZ(0);
}

.slide-image.active {
    opacity: 1;
}

#clock-time {
    font-size: 4rem;
    font-weight: 100;
    line-height: 1;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}
#clock-time span {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-muted);
}

#clock-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    line-height: 1;
}

.qr-container {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 75px;
    height: 75px;
}

.qr-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

#error-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 100;
    font-size: 2rem;
    letter-spacing: 0.1em;
    opacity: 0;
    pointer-events: none;
}
#error-overlay.visible {
    opacity: 1;
}

/* --- Home Assistant UI Elements --- */
.album-art {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.6);
    flex-shrink: 0;
}

.default-art {
    background: linear-gradient(135deg, rgba(116,16,17,0.1), rgba(0,0,0,0.05));
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.06);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.progress-bar-fill {
    height: 100%;
    background: #741011;
    width: 0%;
    transition: width 1s linear;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(116, 16, 17, 0.5);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.flip-up {
    transform: perspective(1200px) translateZ(400px) rotateY(90deg);
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
    z-index: 100;
}