:root {
    color-scheme: light dark;
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #1b1d21;
    --muted: #6b7280;
    --line: #e3e5e9;
    --accent: #2f6df6;
    --danger: #c0392b;
    --live: #17924a;
    --screen: #101215;
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --card: #1c1f24;
        --ink: #e8eaed;
        --muted: #9aa1ab;
        --line: #2b2f36;
        --accent: #6d9bff;
        --danger: #ef6b5c;
        --live: #47c77f;
        --screen: #06070a;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1.25rem;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.brand { font-weight: 650; text-decoration: none; color: var(--ink); letter-spacing: .01em; }
.topbar nav { display: flex; gap: 1rem; }
.topbar a { color: var(--accent); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

main { max-width: 880px; margin: 0 auto; padding: 1.25rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.card--narrow { max-width: 460px; }

h1 { font-size: 1.15rem; margin: 0 0 1rem; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }

.muted { color: var(--muted); font-size: .875rem; }
.hint { color: var(--muted); font-size: .8rem; margin: -.35rem 0 .35rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.breakable { word-break: break-all; }
.live { color: var(--live); font-style: normal; font-size: .75rem; font-weight: 600; margin-left: .4rem; }

/* The clock preview */
.screen {
    background: var(--screen);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
.frame {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .35rem;
    color: #f2f4f8;
}
.frame + .frame { border-top: 1px solid rgba(255, 255, 255, .08); }
.frame__icon {
    flex: none;
    min-width: 3.4rem;
    text-align: center;
    padding: .2rem .4rem;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    color: #b9c2d0;
}
.frame__text { font-size: 1.05rem; letter-spacing: .01em; }
.screen__empty, .screen__note { color: #8b94a3; font-size: .8rem; margin: .35rem .35rem 0; }
.screen__empty { margin: 0; }

/* Forms */
label { display: block; font-size: .85rem; font-weight: 600; margin: .85rem 0 .3rem; }
input[type=text], input[type=password], input[type=time], input[type=number],
input[type=datetime-local], select {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
}
button {
    padding: .5rem .9rem;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
button:hover { filter: brightness(1.07); }
button.danger { background: none; color: var(--danger); font-weight: 500; padding: 0; }
button.danger:hover { text-decoration: underline; filter: none; }
.btn-link { color: var(--muted); text-decoration: none; align-self: center; }
.btn-link:hover { text-decoration: underline; }

.stack > button { margin-top: 1rem; }
.card--narrow form button { margin-top: 1rem; }

.inline { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.inline label { margin: 0; }
.inline input { width: auto; flex: 1 1 12rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > div { flex: 1 1 8rem; }
.row > div label { margin-top: 0; }
.row--actions { margin-top: 1.25rem; align-items: center; }

.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.checkbox input { width: auto; }

.daypicker { display: flex; flex-wrap: wrap; gap: .4rem; }
.daypicker__day {
    display: flex;
    align-items: center;
    gap: .3rem;
    margin: 0;
    padding: .35rem .55rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-weight: 500;
    font-size: .8rem;
    cursor: pointer;
}
.daypicker__day input { margin: 0; }

/* Children */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.chip {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .5rem .3rem .7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .85rem;
}
.chip form { display: flex; }
.chip__x { background: none; color: var(--muted); padding: 0 .2rem; font-size: 1rem; line-height: 1; }
.chip__x:hover { color: var(--danger); filter: none; }

/* Slot table */
.slots { width: 100%; border-collapse: collapse; font-size: .875rem; }
.slots th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: 0 .5rem .4rem 0;
    font-weight: 600;
}
.slots td { padding: .5rem .5rem .5rem 0; border-top: 1px solid var(--line); vertical-align: middle; }
.row--off { opacity: .5; }
.row--live td { background: color-mix(in srgb, var(--live) 10%, transparent); }

.days { display: flex; gap: .15rem; }
.day {
    display: grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 3px;
    font-size: .65rem;
    color: var(--muted);
    background: var(--bg);
}
.day--on { background: var(--accent); color: #fff; font-weight: 700; }

.actions { display: flex; gap: .75rem; align-items: center; white-space: nowrap; }
.actions a { color: var(--accent); text-decoration: none; }
.actions a:hover { text-decoration: underline; }

/* Flash */
.flash { padding: .7rem .9rem; border-radius: 7px; margin: 0 0 1.25rem; font-size: .9rem; }
.flash--ok { background: color-mix(in srgb, var(--live) 15%, transparent); color: var(--live); }
.flash--error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

@media (max-width: 620px) {
    .slots thead { display: none; }
    .slots tr { display: grid; grid-template-columns: auto 1fr; gap: .2rem .6rem; padding: .6rem 0; border-top: 1px solid var(--line); }
    .slots td { border: 0; padding: 0; }
    .slots td:nth-child(5) { grid-column: 1 / -1; font-weight: 600; }
    .slots td:nth-child(3), .actions { grid-column: 1 / -1; }
}

.sr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline select { flex: 1 1 14rem; width: auto; }

/* LaMetric icons. They are drawn for an 8x8 LED grid, so scale them with hard
   edges and sit them on black, the way the device shows them. */
.icon {
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 5px;
    background: #000;
    image-rendering: pixelated;
    object-fit: contain;
}
.icon--lg { width: 40px; height: 40px; border-radius: 6px; }
.icon--missing {
    display: grid;
    place-items: center;
    border: 1px dashed var(--line);
    background: transparent;
    color: var(--muted);
    font-size: .85rem;
}
.frame .icon--missing { border-color: rgba(255, 255, 255, .25); color: #8b94a3; }

.iconcell { display: flex; align-items: center; gap: .5rem; }
.iconcell .mono { color: var(--muted); font-size: .75rem; }

.iconfield { display: flex; align-items: center; gap: .7rem; }
.iconfield input { flex: 1; }

/* .hint pulls up under a single field; after a .row it needs its own space. */
.row + .hint { margin-top: .45rem; }
