:root {
    --bg: #f4f5f7;
    --panel: #ebecf0;
    --card: #fff;
    --text: #1f2328;
    --muted: #6b7280;
    --line: #d0d4da;
    --accent: #2563eb;
    --accent-text: #fff;
    --danger: #c42b1c;
    --soon: #b45309;
    --soon-bg: #fef3c7;
    --overdue-bg: #fde2e0;
    --radius: 8px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #16181c;
    --panel: #1f2228;
    --card: #2a2e35;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --line: #3a3f47;
    --accent: #5b8def;
    --danger: #f07167;
    --soon: #fbbf24;
    --soon-bg: #3d3018;
    --overdue-bg: #45201d;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-weight: normal; }
.error { color: var(--danger); margin: .25rem 0; }
.spacer { flex: 1; }
.pad { padding: 1rem; }

input, textarea, select, button {
    font: inherit;
    color: inherit;
}

input, textarea, select {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
}

input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
    padding: .45rem .9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
    cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.subtle { background: none; border-color: transparent; }
button.subtle:hover { border-color: var(--line); }
button.icon { padding: .1rem .4rem; color: var(--muted); }

/* ---- space picker */

.picker { max-width: 28rem; margin: 12vh auto 2rem; padding: 0 1rem; }
.picker h1 { font-size: 2rem; }
.picker-new { display: flex; gap: .5rem; margin: 1.25rem 0 .5rem; }
.picker-new input { flex: 1; }
.picker-list { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.picker-list a {
    display: block;
    padding: .7rem .9rem;
    margin-bottom: .4rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
}
.picker-list a:hover { border-color: var(--accent); }

/* ---- board */

/* Three columns with equal sides, so the space name sits in the true centre. */
.topbar {
    display: grid;
    grid-template-columns: 1fr minmax(0, auto) 1fr;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--card);
}
.topbar-title { min-width: 0; text-align: center; }
.topbar h1 { font-size: 1.2rem; white-space: nowrap; }
.topbar-end { display: flex; justify-content: flex-end; }
.rename.title { width: min(20rem, 60vw); font-size: 1.1rem; font-weight: 600; text-align: center; }

/* The space name is the way to the other spaces; the chevron says so. */
.space-switch {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    max-width: 100%;
    padding: .15rem .6rem;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}
.space-switch:hover { background: var(--panel); }
.space-name { overflow: hidden; text-overflow: ellipsis; }
.chevron { color: var(--muted); font-size: .8em; }

/* ---- the ⋯ menu */

.menu { position: relative; }
.menu.corner { position: absolute; top: .6rem; right: 1rem; }
.menu-button { padding: .1rem .6rem; font-size: 1.2rem; line-height: 1.3; border-color: transparent; background: none; }
.menu-button:hover, .menu-button[aria-expanded="true"] { background: var(--panel); }
.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + .35rem);
    z-index: 5;
    min-width: 15rem;
    padding: .35rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: .35rem 0; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .45rem .6rem; }
.menu-item:hover { background: var(--panel); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem .6rem; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; padding: .2rem .6rem; font-size: .8rem; background: var(--card); }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--accent); color: var(--accent-text); }

.banner { padding: .5rem 1rem; background: var(--overdue-bg); margin: 0; }

.tagbar { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .6rem 1rem 0; }

.board {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    padding: 1rem;
    overflow-x: auto;
    min-height: calc(100vh - 4rem);
}

.column {
    flex: 0 0 18rem;
    background: var(--panel);
    border-radius: var(--radius);
    padding: .6rem;
}
.column-new { background: none; padding: 0; }
.column-new input { background: var(--panel); border-style: dashed; }

.column-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .5rem; min-height: 1.9rem; }
.column-head h2 { font-size: .95rem; flex: 1; cursor: text; overflow-wrap: anywhere; }
.column-head .rename { flex: 1; padding: .2rem .4rem; }
.section-handle { cursor: grab; color: var(--muted); letter-spacing: -2px; padding: 0 .15rem; user-select: none; touch-action: none; }
.count { color: var(--muted); font-size: .8rem; }

/* An empty list still needs height, or nothing can be dropped into it. */
.todo-list { display: flex; flex-direction: column; gap: .45rem; min-height: 2.5rem; }

.todo {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid transparent;
    border-radius: 6px;
    padding: .55rem .65rem;
    cursor: pointer;
}
.todo:hover { border-color: var(--accent); }
.todo h3 { font-size: .95rem; font-weight: 500; overflow-wrap: anywhere; }
.todo-description {
    margin: .25rem 0 0;
    color: var(--muted);
    font-size: .85rem;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.todo-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; align-items: center; }
.expiry { font-size: .78rem; color: var(--muted); }
.todo.soon { border-left-color: var(--soon); }
.todo.soon .expiry { color: var(--soon); }
.todo.overdue { border-left-color: var(--danger); background: var(--overdue-bg); }
.todo.overdue .expiry { color: var(--danger); font-weight: 600; }

.tag {
    padding: .05rem .45rem;
    border-radius: 999px;
    font-size: .78rem;
    background: var(--panel);
    border: 1px solid var(--line);
}
.tag.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.quick-add { margin-top: .5rem; }
.quick-add input { background: transparent; border-color: transparent; }
.quick-add input:focus { background: var(--card); }

/* Sortable's classes while dragging */
.sortable-ghost { opacity: .35; }
.sortable-chosen .todo { border-color: var(--accent); }

/* ---- editor dialog */

.overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / .4);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 1rem 1rem;
    overflow-y: auto;
    z-index: 10;
}
.dialog {
    width: 100%;
    max-width: 32rem;
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    box-shadow: 0 10px 40px rgb(0 0 0 / .3);
}
.dialog label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 500; }
.dialog .row { display: flex; gap: .75rem; }
.dialog .row label { flex: 1; }
.dialog-actions { display: flex; gap: .5rem; margin-top: .25rem; }

/* ---- phones: sections stack instead of scrolling sideways */

@media (max-width: 640px) {
    .board { flex-direction: column; align-items: stretch; overflow-x: visible; }
    .column { flex: none; }
    .dialog .row { flex-direction: column; }
}
