:root {
    color-scheme: light dark;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #15171c;
    --muted: #6b7280;
    --border: #e2e4e9;
    --accent: #2563eb;
    --accent-text: #ffffff;
    --open: #d97706;
    --closed: #16a34a;
    --moving: #2563eb;
    --error: #dc2626;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #1a1d23;
        --text: #f3f4f6;
        --muted: #9ca3af;
        --border: #2a2e36;
        --accent: #3b82f6;
        --open: #f59e0b;
        --closed: #22c55e;
        --moving: #60a5fa;
        --error: #f87171;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

main {
    flex: 1;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding-top: 24px;
}

.view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.view[hidden] { display: none; }

h1 { margin: 24px 0 0; font-size: 32px; }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }
a { color: var(--accent); }
code { font-size: 0.9em; }

.card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    --state: var(--muted);
}

.card[data-state="open"] { --state: var(--open); }
.card[data-state="closed"] { --state: var(--closed); }
.card[data-state="opening"], .card[data-state="closing"] { --state: var(--moving); }

.label { color: var(--muted); font-size: 15px; }
.state { font-size: 30px; font-weight: 700; color: var(--state); }

/* Garage door: panels slide up as the door opens. */
.door {
    flex: none;
    width: 72px;
    height: 64px;
    border: 4px solid var(--state);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    padding: 4px 4px 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.door span {
    flex: 1;
    background: var(--state);
    border-radius: 2px;
    opacity: 0.85;
    transition: transform 0.6s ease;
}

.card[data-state="open"] .door span { transform: translateY(-120px); }
.card[data-state="opening"] .door span,
.card[data-state="closing"] .door span { transform: translateY(-24px); }
.card[data-state="unavailable"] .door span { opacity: 0.3; }

.action {
    width: 100%;
    min-height: 88px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 22px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

.action.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.action:active { transform: scale(0.98); }
.action:disabled { opacity: 0.55; }
.action[hidden] { display: none; }

.message { min-height: 1.4em; margin: 0; text-align: center; }
.message.ok { color: var(--closed); }
.message.error { color: var(--error); }

.form { display: flex; flex-direction: column; gap: 14px; }

.form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 15px; }

.form input {
    font: inherit;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
    padding: 16px 0;
}

.link {
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
    padding: 0;
}

.link[hidden] { display: none; }
