:root {
    --c-free-bg:    #1f7a3a;
    --c-busy-bg:    #a3261c;
    --c-loading-bg: #2a2a2a;
    --c-error-bg:   #4a3000;
    --c-fg:         #ffffff;
    --c-fg-dim:     rgba(255, 255, 255, 0.72);
    --c-divider:    rgba(255, 255, 255, 0.18);
    --c-card-free:  #1f7a3a;
    --c-card-busy:  #a3261c;
    --c-door-bg:    #14202b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, "Segoe UI", "Inter", system-ui, sans-serif;
    color: var(--c-fg);
    background: var(--c-loading-bg);
    transition: background 600ms ease;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    cursor: none;
}

body.state-free   { background: var(--c-free-bg); }
body.state-busy   { background: var(--c-busy-bg); }
body.state-error  { background: var(--c-error-bg); }
body.state-door   { background: var(--c-door-bg); cursor: none; }
body.state-index  { background: #1a1a1a; cursor: auto; }

/* ============================================================ */
/* Einzelraum-Anzeige                                             */
/* ============================================================ */

.view-room {
    height: 100%;
    padding: 6vh 6vw 14vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4vh;
}

.room-name {
    position: absolute;
    top: 4vh;
    left: 6vw;
    right: 6vw;
    font-size: 3.6vh;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--c-fg-dim);
}

.status-label {
    font-size: 22vh;
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.status-detail {
    font-size: 6vh;
    font-weight: 500;
    line-height: 1.1;
    margin-top: 1vh;
    max-height: 14vh;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.status-time {
    font-size: 5vh;
    font-weight: 400;
    color: var(--c-fg-dim);
    margin-top: 1vh;
    font-variant-numeric: tabular-nums;
}

.next {
    border-top: 1px solid var(--c-divider);
    padding-top: 3vh;
}

.next-heading {
    font-size: 2.6vh;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--c-fg-dim);
    margin-bottom: 1vh;
}

.next-title {
    font-size: 5vh;
    font-weight: 600;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.next-time {
    font-size: 4vh;
    font-weight: 400;
    color: var(--c-fg-dim);
    margin-top: 0.5vh;
    font-variant-numeric: tabular-nums;
}

/* ============================================================ */
/* Tür-Anzeige                                                    */
/* ============================================================ */

.view-door {
    height: 100%;
    padding: 5vh 5vw 12vh;
    display: flex;
    flex-direction: column;
    gap: 4vh;
}

.door-heading {
    font-size: 4.5vh;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--c-fg-dim);
}

.door-rooms {
    display: flex;
    flex-direction: column;
    gap: 3vh;
    flex: 1;
}

.door-card {
    flex: 1;
    border-radius: 2.5vh;
    padding: 4vh 5vh;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    column-gap: 5vh;
    row-gap: 1.5vh;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 600ms ease, border-color 600ms ease;
}

.door-card.is-busy {
    background: var(--c-card-busy);
    border-color: transparent;
}

.door-card.is-free {
    background: var(--c-card-free);
    border-color: transparent;
}

.door-arrow {
    grid-column: 1;
    grid-row: 1 / span 2;
    font-size: 18vh;
    line-height: 1;
    align-self: center;
    color: var(--c-fg);
    font-weight: 300;
}

.door-roomname {
    grid-column: 2;
    grid-row: 1;
    font-size: 5.2vh;
    font-weight: 700;
    line-height: 1;
}

.door-roomname .direction {
    display: block;
    font-size: 3vh;
    font-weight: 400;
    color: var(--c-fg-dim);
    margin-top: 0.6vh;
    text-transform: none;
    letter-spacing: 0;
}

.door-status {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
}

.door-status .title {
    font-size: 5vh;
    font-weight: 600;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.door-status .time {
    font-size: 3.8vh;
    color: var(--c-fg-dim);
    margin-top: 0.5vh;
    font-variant-numeric: tabular-nums;
}

.door-status.free .title { color: var(--c-fg); }

.door-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5vh;
    font-weight: 500;
    color: var(--c-fg-dim);
    text-align: center;
    padding: 4vh;
}

/* ============================================================ */
/* Footer (Uhr)                                                   */
/* ============================================================ */

.meta {
    position: fixed;
    bottom: 4vh;
    left: 6vw;
    right: 6vw;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 3.4vh;
    font-weight: 500;
    color: var(--c-fg-dim);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.conn { font-size: 2vh; opacity: 0; transition: opacity 200ms; }
.conn.stale { opacity: 1; }

/* ============================================================ */
/* Landing-Page                                                   */
/* ============================================================ */

.view-index {
    max-width: 60ch;
    margin: 8vh auto;
    padding: 0 2rem;
    color: var(--c-fg);
    cursor: auto;
}
.view-index h1 { font-size: 2rem; margin-bottom: 1rem; }
.view-index p  { color: var(--c-fg-dim); margin-bottom: 1rem; }
.link-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.link-list a {
    display: block;
    padding: 1rem 1.25rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.5rem;
    color: var(--c-fg);
    text-decoration: none;
    font-size: 1.1rem;
}
.link-list a:hover { background: rgba(255,255,255,0.12); }
.link-list .hint { display: block; font-size: 0.85rem; color: var(--c-fg-dim); margin-top: 0.25rem; }

/* ============================================================ */
/* Action-Bar (Touch-Buttons im Raum-View)                       */
/* ============================================================ */

.action-bar {
    position: fixed;
    bottom: 12vh;
    left: 6vw;
    right: 6vw;
    display: flex;
    justify-content: center;
    gap: 2vh;
    z-index: 5;
}

.action-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 1.5vh;
    padding: 2.6vh 5vh;
    font-size: 4.2vh;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 0.4vh 1.5vh rgba(0,0,0,0.25);
    transition: transform 80ms ease, background 200ms ease;
    min-width: 35vw;
    touch-action: manipulation;
}
.action-btn:active { transform: scale(0.97); background: rgba(255,255,255,0.28); }

.action-btn.end {
    background: rgba(0, 0, 0, 0.35);
}
.action-btn.end:active { background: rgba(0,0,0,0.5); }

/* ============================================================ */
/* Sheet (Modal-Overlay für Dauerwahl / Bestätigung)              */
/* ============================================================ */

.sheet {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vh;
}

.sheet-card {
    background: #1a1a1a;
    border-radius: 2vh;
    padding: 5vh;
    max-width: 80vw;
    width: 100%;
    color: #fff;
    box-shadow: 0 1vh 4vh rgba(0,0,0,0.5);
}

.sheet-title {
    font-size: 5vh;
    font-weight: 700;
    margin-bottom: 4vh;
    text-align: center;
}

.sheet-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2vh;
    margin-bottom: 3vh;
}

.dur-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 1.5vh;
    padding: 4vh 2vh;
    font-size: 5vh;
    font-weight: 700;
    background: var(--c-free-bg);
    color: #fff;
    cursor: pointer;
    transition: transform 80ms ease, filter 200ms ease;
    touch-action: manipulation;
}
.dur-btn:active { transform: scale(0.97); filter: brightness(1.2); }
.dur-btn[disabled] { opacity: 0.35; cursor: default; }
.dur-btn.end { background: var(--c-busy-bg); }

.sheet-cancel {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    color: var(--c-fg-dim);
    font-size: 3.5vh;
    width: 100%;
    padding: 2.5vh;
    cursor: pointer;
    border-radius: 1.5vh;
    touch-action: manipulation;
}
.sheet-cancel:active { background: rgba(255,255,255,0.05); }

.sheet-error {
    margin-top: 2vh;
    padding: 2vh;
    border-radius: 1vh;
    background: rgba(163, 38, 28, 0.3);
    color: #fff;
    font-size: 3vh;
    text-align: center;
}
