/* GTNH Tracker — Catppuccin themes, full palettes from https://catppuccin.com/palette
   Latte (light), Frappé, Macchiato and Mocha. Each flavour defines its 26 palette colours
   plus its own main/secondary accent; the semantic variables further down map onto them. */

:root,
[data-theme="mocha"] {
    --ctp-rosewater: #f5e0dc; --ctp-flamingo: #f2cdcd; --ctp-pink: #f5c2e7; --ctp-mauve: #cba6f7;
    --ctp-red: #f38ba8; --ctp-maroon: #eba0ac; --ctp-peach: #fab387; --ctp-yellow: #f9e2af;
    --ctp-green: #a6e3a1; --ctp-teal: #94e2d5; --ctp-sky: #89dceb; --ctp-sapphire: #74c7ec;
    --ctp-blue: #89b4fa; --ctp-lavender: #b4befe;
    --ctp-text: #cdd6f4; --ctp-subtext1: #bac2de; --ctp-subtext0: #a6adc8;
    --ctp-overlay2: #9399b2; --ctp-overlay1: #7f849c; --ctp-overlay0: #6c7086;
    --ctp-surface2: #585b70; --ctp-surface1: #45475a; --ctp-surface0: #313244;
    --ctp-base: #1e1e2e; --ctp-mantle: #181825; --ctp-crust: #11111b;

    --theme-accent: var(--ctp-mauve);
    --theme-accent-2: var(--ctp-lavender);
}

[data-theme="macchiato"] {
    --ctp-rosewater: #f4dbd6; --ctp-flamingo: #f0c6c6; --ctp-pink: #f5bde6; --ctp-mauve: #c6a0f6;
    --ctp-red: #ed8796; --ctp-maroon: #ee99a0; --ctp-peach: #f5a97f; --ctp-yellow: #eed49f;
    --ctp-green: #a6da95; --ctp-teal: #8bd5ca; --ctp-sky: #91d7e3; --ctp-sapphire: #7dc4e4;
    --ctp-blue: #8aadf4; --ctp-lavender: #b7bdf8;
    --ctp-text: #cad3f5; --ctp-subtext1: #b8c0e0; --ctp-subtext0: #a5adcb;
    --ctp-overlay2: #939ab7; --ctp-overlay1: #8087a2; --ctp-overlay0: #6e738d;
    --ctp-surface2: #5b6078; --ctp-surface1: #494d64; --ctp-surface0: #363a4f;
    --ctp-base: #24273a; --ctp-mantle: #1e2030; --ctp-crust: #181926;

    --theme-accent: var(--ctp-blue);
    --theme-accent-2: var(--ctp-sapphire);
}

[data-theme="frappe"] {
    --ctp-rosewater: #f2d5cf; --ctp-flamingo: #eebebe; --ctp-pink: #f4b8e4; --ctp-mauve: #ca9ee6;
    --ctp-red: #e78284; --ctp-maroon: #ea999c; --ctp-peach: #ef9f76; --ctp-yellow: #e5c890;
    --ctp-green: #a6d189; --ctp-teal: #81c8be; --ctp-sky: #99d1db; --ctp-sapphire: #85c1dc;
    --ctp-blue: #8caaee; --ctp-lavender: #babbf1;
    --ctp-text: #c6d0f5; --ctp-subtext1: #b5bfe2; --ctp-subtext0: #a5adce;
    --ctp-overlay2: #949cbb; --ctp-overlay1: #838ba7; --ctp-overlay0: #737994;
    --ctp-surface2: #626880; --ctp-surface1: #51576d; --ctp-surface0: #414559;
    --ctp-base: #303446; --ctp-mantle: #292c3c; --ctp-crust: #232634;

    --theme-accent: var(--ctp-teal);
    --theme-accent-2: var(--ctp-green);
}

[data-theme="latte"] {
    --ctp-rosewater: #dc8a78; --ctp-flamingo: #dd7878; --ctp-pink: #ea76cb; --ctp-mauve: #8839ef;
    --ctp-red: #d20f39; --ctp-maroon: #e64553; --ctp-peach: #fe640b; --ctp-yellow: #df8e1d;
    --ctp-green: #40a02b; --ctp-teal: #179299; --ctp-sky: #04a5e5; --ctp-sapphire: #209fb5;
    --ctp-blue: #1e66f5; --ctp-lavender: #7287fd;
    --ctp-text: #4c4f69; --ctp-subtext1: #5c5f77; --ctp-subtext0: #6c6f85;
    --ctp-overlay2: #7c7f93; --ctp-overlay1: #8c8fa1; --ctp-overlay0: #9ca0b0;
    --ctp-surface2: #acb0be; --ctp-surface1: #bcc0cc; --ctp-surface0: #ccd0da;
    --ctp-base: #eff1f5; --ctp-mantle: #e6e9ef; --ctp-crust: #dce0e8;

    /* Pink is pale on a light background: deepen it a little for fills, more for text. */
    --theme-accent: color-mix(in srgb, var(--ctp-pink) 80%, var(--ctp-text));
    --theme-accent-text: color-mix(in srgb, var(--ctp-pink) 50%, var(--ctp-text));
    --theme-accent-2: var(--ctp-flamingo);
    --theme-accent-ink: #ffffff;
    --theme-shadow: rgba(76, 79, 105, .18);
    /* Blocky bevels: a light theme needs a softer dark edge and a stronger light one. */
    --theme-outline: var(--ctp-overlay1);
    --theme-bevel-hi: rgba(255, 255, 255, .85);
    --theme-bevel-lo: rgba(76, 79, 105, .30);
    --theme-drop: rgba(76, 79, 105, .25);
    --theme-scheme: light;
}

:root {
    --bg: var(--ctp-mantle);
    --panel: var(--ctp-base);
    --panel-2: var(--ctp-surface0);
    --card-bg: var(--ctp-mantle); /* task cards on the board */
    --line: var(--ctp-surface1);
    --hover-line: var(--ctp-overlay0);
    --hover-bg: var(--ctp-surface1);
    --avatar: var(--ctp-surface2);
    --text: var(--ctp-text);
    --muted: var(--ctp-subtext0);
    --accent: var(--theme-accent); /* main colour: headings, column titles and borders, buttons, links */
    --accent-text: var(--theme-accent-text, var(--accent)); /* the main colour when used for text */
    --accent-2: var(--theme-accent-2); /* secondary: tints panels such as the board columns */
    --column-bg: color-mix(in srgb, var(--accent-2) 12%, var(--panel));
    --warn: var(--ctp-peach);
    --accent-ink: var(--theme-accent-ink, var(--ctp-crust));
    --danger: var(--ctp-red);
    --ok: var(--ctp-green);
    --shadow: var(--theme-shadow, rgba(0, 0, 0, .45));
    --radius: 6px;
    color-scheme: var(--theme-scheme, dark);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

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

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { color: var(--accent-text); }

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

input:not([type="checkbox"]), select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 7px 9px;
}

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

label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); font-size: 14px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; }

.logo {
    display: inline-grid;
    place-items: center;
    width: 30px; height: 30px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800;
    font-size: 13px;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
}

/* ---------- buttons ---------- */
.btn {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: var(--hover-line); background: var(--hover-bg); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 3px 9px; font-size: 12px; }

.icon-btn {
    background: none; border: 0; cursor: pointer;
    color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px;
}
.icon-btn:hover { color: var(--danger); }

.error { color: var(--danger); margin: 6px 0; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 340px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 28px;
}
.login-card h1 { font-size: 20px; margin-bottom: 20px; }
.login-card .btn { width: 100%; margin-top: 16px; padding: 9px; }

/* ---------- top bar & toolbar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

.toolbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 12px 20px 0;
}
.tier-filter { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    cursor: pointer;
    font-size: 12px; font-weight: 600;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tier); }
.chip.active { border-color: var(--tier, var(--accent)); background: var(--panel-2); box-shadow: 0 0 0 1px var(--tier, var(--accent)) inset; }
.chip-count { color: var(--muted); font-weight: 400; }

/* ---------- board ---------- */
.board {
    display: grid;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    gap: 16px;
    padding: 16px 20px 24px;
    align-items: start;
    overflow-x: auto;
}

.column {
    background: var(--column-bg);
    border: 1px solid var(--accent);
    border-radius: 10px;
    display: flex; flex-direction: column;
    min-height: 200px;
    transition: box-shadow .15s;
}
.column.drop { box-shadow: 0 0 0 2px var(--accent); }

.column-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.column-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-text); }
.count { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: 12px; }

.card-list { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 120px; flex: 1; }
.card-list:has(.card) .empty { display: none; }
.empty { color: var(--muted); text-align: center; margin: 24px 0; font-size: 13px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-left: 4px solid var(--tier);
    border-radius: var(--radius);
    padding: 9px 10px;
    cursor: grab;
    user-select: none;
}
.card:hover { border-color: var(--hover-line); border-left-color: var(--tier); }
.card.dragging { opacity: .45; }
.card.is-done .card-title { color: var(--muted); text-decoration: line-through; }

.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.card-title { word-break: break-word; }

.tier-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 11px; font-weight: 700;
    letter-spacing: .03em;
}

.avatar {
    display: inline-grid; place-items: center;
    width: 24px; height: 24px; flex: none;
    border-radius: 50%;
    background: var(--avatar);
    font-size: 10px; font-weight: 700;
}

.progress { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.progress .bar { flex: 1; height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--ok); }
.progress-label { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- dialogs ---------- */
dialog {
    width: min(620px, calc(100vw - 24px));
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
}
dialog::backdrop { background: color-mix(in srgb, var(--ctp-crust) 75%, transparent); }
dialog h2 { font-size: 17px; margin-bottom: 14px; }
dialog h3 { font-size: 14px; margin: 14px 0 8px; }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row > label { flex: 1; }
.row > label.inline { flex: 0 0 auto; margin-bottom: 18px; }

.dialog-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.spacer { flex: 1; }

.materials { border-top: 1px solid var(--line); margin-top: 6px; }
.material-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.material { display: flex; align-items: center; gap: 6px; }
.material .m-name { flex: 1; }
.material .m-qty { width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.material .m-sep { color: var(--muted); }
.material.complete .m-name { color: var(--muted); text-decoration: line-through; }
.material input[type="checkbox"], label.inline input[type="checkbox"], label.inline input[type="radio"] { width: 16px; height: 16px; accent-color: var(--ok); }
.material-add { display: flex; gap: 6px; margin-top: 8px; }
.material-add input:first-child { flex: 1; }
.material-add input[type="number"] { width: 90px; }

.user-list { list-style: none; margin: 0; padding: 0; }
.user-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.user-name { flex: 1; }
.user-name small { color: var(--muted); }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pill.muted { background: var(--panel-2); color: var(--muted); }

/* ---------- toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--panel-2);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    padding: 10px 16px;
    z-index: 1000;
    box-shadow: 0 6px 24px var(--shadow);
}
.toast.ok { border-color: var(--ok); }

@media (max-width: 860px) {
    .board { grid-template-columns: 1fr; }
    .row { flex-direction: column; align-items: stretch; }
    .topbar { flex-wrap: wrap; }
}

/* ---------- flash, auth extras ---------- */
.flash { animation: flash-out 5s forwards; }
@keyframes flash-out { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.muted { color: var(--muted); }
.login-card p.muted { margin: -8px 0 16px; }
.btn.block { display: block; width: 100%; text-align: center; text-decoration: none; }
a.btn { text-decoration: none; display: inline-block; color: var(--text); }
a.btn.primary { color: var(--accent-ink); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 0; }
.login-card .below { margin-top: 14px; text-align: center; }
.login-card .below .link-btn { width: auto; margin: 0; }

/* ---------- admin page ---------- */
.crumb { color: var(--muted); font-weight: 400; }
.page { max-width: 980px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { font-size: 16px; }
.error-box { border-color: var(--danger); color: var(--danger); margin: 0; }
.link-box { border-color: var(--accent); }
.link-box p { margin: 0 0 6px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.inline-form select { width: auto; margin: 0 0 0 6px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; width: 1%; white-space: nowrap; }
.table td.actions form { margin: 0; }
.table select { width: auto; padding: 4px 8px; }
.table tr.is-disabled td:first-child { color: var(--muted); text-decoration: line-through; }

.status { font-size: 12px; font-weight: 600; }
.status.on { color: var(--ok); }
.status.off { color: var(--danger); }
.status.warn { color: var(--warn); }

.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
    width: 260px; padding: 10px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow);
    display: flex; flex-direction: column; gap: 8px; text-align: left; white-space: normal;
}
.temp-pw { display: flex; gap: 6px; }
.temp-pw input { padding: 4px 8px; font-size: 13px; }

select:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- theme picker ---------- */
.theme-picker {
    display: inline-flex; align-items: center; gap: 2px; flex: none;
    padding: 4px; margin: 0;
    background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.theme-option {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px; border: 0; border-radius: 999px;
    background: transparent; color: var(--muted); font-size: 13px; line-height: 1.2;
    cursor: pointer; transition: background-color .15s, color .15s;
}
.theme-option:hover { color: var(--text); }
.theme-option[aria-checked="true"] { background: var(--panel-2); color: var(--text); }
.theme-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Each dot is that theme's own main colour, whichever theme is showing. */
.theme-option .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.theme-option[data-theme-option="latte"] .dot { background: #ea76cb; }
.theme-option[data-theme-option="frappe"] .dot { background: #81c8be; }
.theme-option[data-theme-option="macchiato"] .dot { background: #8aadf4; }
.theme-option[data-theme-option="mocha"] .dot { background: #cba6f7; }
@media (max-width: 720px) {
    .theme-option { padding: 7px; }
    .theme-option .label { display: none; } /* dots only; names stay in the tooltip */
}
.login-page .theme-picker { position: fixed; top: 14px; right: 16px; }

/* ---------- assignees + task meta ---------- */
.task-meta { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 10px; }
.meta-row { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.meta-label { flex: 0 0 72px; color: var(--muted); font-size: 12px; }
.assignees { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.person-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px 2px 2px; border-radius: 999px;
    background: var(--panel-2); font-size: 13px;
}
.person-chip .avatar { width: 20px; height: 20px; font-size: 9px; }
.assign-menu .menu-body { left: 0; right: auto; max-height: 300px; overflow-y: auto; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.check-row:hover { background: var(--hover-bg); }
.check-row input[type=checkbox] { width: auto; margin: 0; }

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { width: 22px; height: 22px; font-size: 9px; border: 2px solid var(--card-bg); }
.avatar-stack .avatar + .avatar { margin-left: -7px; }
.avatar-stack .avatar.more { background: var(--panel); color: var(--muted); }

/* ---------- reactions ---------- */
.reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.reactions.compact { margin-top: 8px; }
.card { position: relative; }
/* No reactions yet: the react button floats in the corner on hover instead of taking a row. */
.reactions.compact:not(:has(.reaction-chip)) { position: absolute; right: 8px; bottom: 8px; margin: 0; }
.reactions.compact:not(:has(.reaction-chip)) .react-btn { opacity: 0; }
.card:hover .reactions.compact .react-btn,
.card:focus-within .reactions.compact .react-btn,
.reactions.compact .react-btn:focus-visible { opacity: 1; }
.reaction-chip, .react-btn {
    display: inline-flex; align-items: center; gap: 4px;
    height: 24px; padding: 0 8px; margin: 0; width: auto;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--panel); color: var(--text);
    font: inherit; font-size: 12px; line-height: 1; cursor: pointer;
}
.reaction-chip .emo { font-size: 14px; }
.reaction-chip .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.reaction-chip:hover, .react-btn:hover { border-color: var(--hover-line); background: var(--hover-bg); }
.reaction-chip.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.reaction-chip.mine .n { color: var(--text); }
.react-btn { color: var(--muted); padding: 0 7px; }

.reaction-popover {
    position: fixed; z-index: 100;
    margin: 0; padding: 6px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 10px 30px var(--shadow);
}
.quick-row { display: flex; gap: 2px; }
.quick-emoji {
    width: 34px; height: 34px; margin: 0; padding: 0;
    display: grid; place-items: center;
    border: 0; border-radius: 6px; background: none; color: var(--text);
    font-size: 20px; cursor: pointer;
}
.quick-emoji:hover { background: var(--hover-bg); }
.quick-emoji.more { font-size: 18px; font-weight: 700; color: var(--muted); }
.quick-emoji:disabled { opacity: .5; cursor: progress; }
.reaction-popover emoji-picker { margin-top: 6px; height: 340px; }

/* emoji-picker-element, themed with the active Catppuccin flavour */
emoji-picker {
    --background: var(--panel-2);
    --border-color: var(--line);
    --button-active-background: var(--ctp-surface2);
    --button-hover-background: var(--hover-bg);
    --indicator-color: var(--accent);
    --input-border-color: var(--line);
    --input-font-color: var(--text);
    --input-placeholder-color: var(--muted);
    --outline-color: var(--accent);
    --category-font-color: var(--muted);
    --border-radius: 6px;
}

/* ---------- notes thread ---------- */
.thread { margin-top: 6px; }
.note-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.note {
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 8px 10px;
}
.note.mine { border-left: 3px solid var(--accent); }
.note-head { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.note-head .avatar { width: 22px; height: 22px; font-size: 9px; }
.note-head time { color: var(--muted); }
.note-head .link-btn { font-size: 12px; }
.link-btn.danger:hover { color: var(--danger); }
.note-body { font-size: 14px; }
.note-reactions { margin-top: 6px; }
.note-text { white-space: pre-wrap; word-break: break-word; }
.empty-notes { padding: 4px 0; }
.note-image { position: relative; display: block; width: fit-content; max-width: 100%; margin: 6px 0; }
.note-image img {
    display: block; max-width: 100%; height: auto;
    border: 1px solid var(--line); border-radius: var(--radius);
}
.note-image:hover img { border-color: var(--accent); }
.note-image .image-delete {
    position: absolute; top: 6px; right: 6px;
    width: 26px; height: 26px; border-radius: 50%;
    background: color-mix(in srgb, var(--ctp-crust) 80%, transparent); color: var(--text);
    opacity: 0;
}
.note-image:hover .image-delete, .note-image .image-delete:focus-visible { opacity: 1; }
.composer textarea, .note-edit { resize: vertical; margin: 0; }
.composer textarea.drop, .note-edit.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
.notes-tools { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; }
.notes-tools .btn:disabled { opacity: .5; cursor: not-allowed; }
.attach-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.attach-strip img { width: 64px; height: 48px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; }

/* ---------- card preview ---------- */
.card-desc {
    margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4;
    white-space: pre-line; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-materials ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.card-materials li { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.card-materials .m-check { flex: none; width: 12px; text-align: center; color: var(--muted); }
.card-materials .m-item { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-materials .m-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.card-materials li.ok { color: var(--muted); }
.card-materials li.ok .m-check { color: var(--ok); }
.card-materials li.more { color: var(--muted); padding-left: 18px; }
.card-materials .progress { margin-top: 6px; }
.card-people { display: flex; align-items: center; gap: 6px; margin-top: 8px; min-width: 0; font-size: 12px; color: var(--muted); }
.card-people .names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- full-screen task view ---------- */
dialog.task-view {
    width: 100vw; height: 100vh; height: 100dvh;
    max-width: none; max-height: none; margin: 0; padding: 0;
    border: 0; border-radius: 0;
    background: var(--bg);
    overflow-y: auto; overscroll-behavior: contain;
}
dialog.task-view::backdrop { background: var(--bg); }
.tv-bar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    background: var(--panel); border-bottom: 1px solid var(--line);
}
.tv-bar .btn { flex: none; }
input.tv-title {
    flex: 1; min-width: 0; margin: 0; padding: 6px 8px;
    font-size: 20px; font-weight: 600;
    background: transparent; border-color: transparent;
}
input.tv-title:hover { border-color: var(--line); }
input.tv-title:focus { background: var(--panel-2); }
.tv-saved { flex: none; font-size: 12px; min-width: 40px; }
.tv-body {
    display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start;
    max-width: 1320px; margin: 0 auto; padding: 20px;
}
.tv-main, .tv-side {
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
}
.tv-side { position: sticky; top: 76px; }
.tv-side .row { margin-bottom: 4px; }
.tv-section + .tv-section { margin-top: 20px; }
.tv-main h3, .tv-side h3 { font-size: 14px; margin: 0 0 8px; }
.tv-side .materials h3 { margin-top: 14px; }
#tv-description { margin: 0; resize: vertical; min-height: 70px; }
.task-view .note-list { max-height: none; overflow: visible; }
.task-view .task-meta { margin: 6px 0 0; }
@media (max-width: 900px) {
    .tv-body { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
    .tv-main, .tv-side { padding: 12px; }
    .tv-side { position: static; }
    .tv-bar { padding: 8px 12px; gap: 8px; }
    input.tv-title { font-size: 17px; }
}
.tv-side .material .m-qty { width: 62px; }
.tv-main, .tv-side { min-width: 0; }
.material input:not([type="checkbox"]), .material-add input { min-width: 0; }

/* ---------- cog + slide-in account menu ---------- */
.cog-btn { display: inline-grid; place-items: center; width: 38px; height: 36px; padding: 0; }
.cog-btn svg { transition: transform .3s ease; }
.cog-btn:hover svg { transform: rotate(60deg); }

dialog.side-menu {
    position: fixed; inset: 0 0 0 auto;
    width: min(320px, 88vw); height: 100vh; height: 100dvh;
    max-width: none; max-height: none; margin: 0; padding: 0;
    border: 0; border-left: 1px solid var(--line); border-radius: 0;
    background: var(--panel);
    box-shadow: -12px 0 40px var(--shadow);
    display: flex; flex-direction: column;
}
dialog.side-menu:not([open]) { display: none; }
dialog.side-menu[open] { animation: menu-in .22s ease-out; }
dialog.side-menu.closing { animation: menu-out .18s ease-in forwards; }
dialog.side-menu::backdrop { background: color-mix(in srgb, var(--ctp-crust) 60%, transparent); }
@keyframes menu-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes menu-out { from { transform: none; } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
    dialog.side-menu[open], dialog.side-menu.closing { animation: none; }
}

.side-menu-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 18px 16px 14px 20px; border-bottom: 1px solid var(--line);
}
.side-menu-head strong { display: block; font-size: 15px; }
.side-menu-head .muted { font-size: 12px; }
.side-menu-close { font-size: 22px; line-height: 1; padding: 0 4px; }
.side-menu-close:hover { color: var(--text); }
.side-menu-items { display: flex; flex-direction: column; padding: 10px; gap: 2px; }
.side-menu-items form { margin: 0; }
.side-menu-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 11px 12px; margin: 0;
    border: 0; border-radius: var(--radius); background: none;
    color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none;
    cursor: pointer;
}
.side-menu-item > svg { flex: none; color: var(--muted); }
.side-menu-item:hover > svg { color: inherit; }
.side-menu-item:hover, .side-menu-item:focus-visible { background: var(--hover-bg); }
.side-menu-item.current { background: var(--panel-2); }
.side-menu-item.danger:hover { color: var(--danger); }
.side-menu-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- dashboard ---------- */
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.dashboard-page { max-width: 1320px; }
.dashboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .dashboard { grid-template-columns: minmax(0, 1fr); } }
.dash-heading { font-size: 15px; margin-bottom: 10px; }
.dash-counts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; color: var(--muted); font-size: 13px; }
.dash-counts strong { color: var(--text); font-size: 15px; }
.dash-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px; margin: 0 -8px; border-radius: var(--radius);
    color: var(--text); text-decoration: none;
}
a.dash-row:hover, a.dash-row:focus-visible { background: var(--hover-bg); }
.dash-row .tier-badge { flex: none; margin-top: 1px; min-width: 44px; text-align: center; }
.dash-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-title { word-break: break-word; }
.dash-title.is-done { color: var(--muted); text-decoration: line-through; }
.dash-meta { font-size: 12px; color: var(--muted); }
.dash-meta .status-doing { color: var(--accent-text); }
.dash-meta .status-done { color: var(--ok); }

/* ---------- MOTD (dashboard + editor preview) ---------- */
.motd-panel { border-left: 4px solid var(--accent); }
.motd { line-height: 1.55; word-break: break-word; }
.motd > :first-child { margin-top: 0; }
.motd > :last-child { margin-bottom: 0; }
.motd h1, .motd h2, .motd h3 { margin: 14px 0 6px; line-height: 1.25; }
.motd h1 { font-size: 22px; }
.motd h2 { font-size: 18px; }
.motd h3 { font-size: 15px; }
.motd p, .motd ul, .motd ol, .motd blockquote, .motd pre { margin: 0 0 10px; }
.motd ul, .motd ol { padding-left: 22px; }
.motd a { color: var(--accent-text); }
.motd code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.motd pre { background: var(--panel-2); padding: 10px; border-radius: var(--radius); overflow-x: auto; }
.motd pre code { background: none; padding: 0; }
.motd blockquote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); }
.motd hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.motd-meta { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.motd-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .motd-editor { grid-template-columns: minmax(0, 1fr); } }
.motd-editor textarea { margin-top: 4px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.motd-help { font-size: 12px; margin: 6px 0 0; line-height: 1.7; }
.motd-help code { background: var(--panel-2); padding: 1px 4px; border-radius: 3px; }
.label-like { display: block; color: var(--muted); font-size: 12px; }
.motd-preview {
    margin-top: 4px; min-height: 120px; padding: 10px 12px;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.motd-preview:empty::before { content: 'Nothing to show – the MOTD is hidden.'; color: var(--muted); }

/* ---------- subtasks ---------- */

.subtask-group { display: flex; flex-direction: column; gap: 6px; margin-left: 12px; padding-left: 8px; border-left: 2px solid var(--line); }
.group-parent {
    display: flex; align-items: center; gap: 6px; min-width: 0;
    background: none; border: 0; padding: 0 2px; color: var(--muted); font: inherit; font-size: 12px;
    text-align: left; cursor: pointer;
}
.group-parent:hover, .group-parent:focus-visible { color: var(--text); }
.group-parent:hover .group-title { text-decoration: underline; }
.group-arrow { flex: none; }
.group-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.nest-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
.card-subtasks { margin-top: 8px; }

.picker { position: relative; display: block; flex: 1; min-width: 0; }
.picker input { width: 100%; padding-right: 28px; }
.picker-clear {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: 0; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 6px; cursor: pointer;
}
.picker-clear:hover { color: var(--text); }
.picker-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 20;
    list-style: none; margin: 0; padding: 4px; max-height: 260px; overflow-y: auto;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow);
}
.picker-list li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.picker-list li.active, .picker-list li:hover { background: var(--hover-bg); }
.picker-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-status { flex: none; color: var(--muted); font-size: 11px; }

.meta-row.meta-top { align-items: flex-start; }
.subtask-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.subtask-link {
    display: flex; align-items: baseline; gap: 6px; width: 100%; min-width: 0;
    background: none; border: 0; padding: 2px 0; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.subtask-link:hover .subtask-title { text-decoration: underline; }
.subtask-list .m-check { flex: none; width: 12px; text-align: center; color: var(--muted); }
.subtask-list li.ok .m-check { color: var(--ok); }
.subtask-list li.ok .subtask-title { color: var(--muted); text-decoration: line-through; }
.subtask-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- read-only tasks (not yours, not assigned to you) ---------- */

.card.locked { cursor: pointer; }
input.tv-title[readonly]:hover { border-color: transparent; }
input.tv-title[readonly]:focus { background: transparent; outline: none; }
.tv-section textarea[readonly] { background: transparent; border-color: transparent; resize: none; }
.tv-side select:disabled, .picker input:disabled { opacity: .7; cursor: not-allowed; }
.material.read-only { gap: 8px; font-size: 13px; }
.material.read-only .m-check { flex: none; width: 14px; text-align: center; color: var(--muted); }
.material.read-only.complete .m-check { color: var(--ok); }
.material.read-only .m-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material.read-only .m-count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- new task: assign people ---------- */

.create-assignees { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.create-assignees legend { padding: 0; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.assign-list { display: flex; flex-wrap: wrap; gap: 2px 10px; max-height: 132px; overflow-y: auto; }
.assign-list .check-row { font-size: 13px; }
.assign-list .avatar { width: 20px; height: 20px; font-size: 9px; }

/* ---------- admin: bulk sign-up links ---------- */
.inline-form { flex-wrap: wrap; }
.inline-form input.max-uses { width: 110px; margin: 0 0 0 6px; }
.table td .copy-row { margin-top: 0; min-width: 260px; }
.table td .copy-row input { padding: 4px 8px; font-size: 12px; }

/* ---------- admin: audit log ---------- */
.page.page-wide { max-width: 1280px; }
.audit-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.audit-filters .picker { flex: 1 1 240px; }
/* Every control in the row the same height (date inputs otherwise come out squashed). */
.audit-filters input, .audit-filters select, .audit-filters .btn { height: 36px; margin: 0; }
.audit-filters .btn { display: inline-flex; align-items: center; padding: 0 14px; text-decoration: none; }
.audit-filters select, .audit-filters input[type="date"] { width: auto; padding: 0 9px; }
.audit-filters label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 13px; }
.audit-table td { vertical-align: top; font-size: 13px; }
.audit-when { white-space: nowrap; }
.audit-when .muted { display: block; font-size: 11px; }
.audit-action { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
    background: color-mix(in srgb, var(--cat) 18%, var(--panel)); color: var(--text); border: 1px solid color-mix(in srgb, var(--cat) 45%, transparent); }
.audit-task { --cat: var(--ctp-blue); }
.audit-account { --cat: var(--ctp-green); }
.audit-admin { --cat: var(--ctp-peach); }
.audit-subject { max-width: 260px; overflow-wrap: anywhere; }
.audit-subject a { color: var(--accent-text); }
.audit-details { overflow-wrap: anywhere; }
.audit-details div + div { margin-top: 2px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.btn.disabled { opacity: .45; pointer-events: none; }

/* ---------- "new since you last opened it": a light sweeping along the bottom border ---------- */
.card.is-unseen { border-bottom-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card.is-unseen::after {
    content: '';
    position: absolute; left: 0; right: -1px; bottom: -1px; height: 2px;
    border-bottom-right-radius: var(--radius);
    background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent) no-repeat;
    background-size: 35% 100%;
    animation: unseen-sweep 2.4s ease-in-out infinite;
    pointer-events: none;
}
/* With a 35%-wide highlight, -60% and 160% put it just outside the left and right edges. */
@keyframes unseen-sweep {
    from { background-position: -60% 0; }
    to { background-position: 160% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .card.is-unseen::after { animation: none; background: var(--accent); }
}
.picker-list .avatar { width: 20px; height: 20px; font-size: 9px; flex: none; }

/* =====================================================================
   Blocky look: square corners and two-tone bevelled edges, like a
   game inventory screen. Raised parts (columns, panels, buttons, menus)
   are light on the top/left and dark on the bottom/right; sunken parts
   (task cards, inputs, chosen options) are the reverse. Colours come
   from the active theme, so every theme keeps its palette.
   ===================================================================== */

:root {
    --px: 2px; /* one "pixel" of the bevel */
    --outline: var(--theme-outline, var(--ctp-crust));
    --bevel-hi: var(--theme-bevel-hi, rgba(255, 255, 255, .16));
    --bevel-lo: var(--theme-bevel-lo, rgba(0, 0, 0, .45));
    --raised: inset var(--px) var(--px) 0 var(--bevel-hi), inset calc(-1 * var(--px)) calc(-1 * var(--px)) 0 var(--bevel-lo);
    --sunken: inset var(--px) var(--px) 0 var(--bevel-lo), inset calc(-1 * var(--px)) calc(-1 * var(--px)) 0 var(--bevel-hi);
    --drop: 4px 4px 0 var(--theme-drop, rgba(0, 0, 0, .4)); /* hard shadow under floating things */
}

/* Reactions (chips, the react button and the emoji popover) keep their original rounded style. */
:not(.reaction-chip, .react-btn, .reaction-popover, .reaction-popover *),
:not(.reaction-chip, .react-btn, .reaction-popover, .reaction-popover *)::before,
:not(.reaction-chip, .react-btn, .reaction-popover, .reaction-popover *)::after { border-radius: 2px !important; } /* just off square */

/* Raised panels */
.column, .panel, .login-card, .topbar, .tv-bar {
    border: var(--px) solid var(--outline);
    box-shadow: var(--raised);
}
.topbar, .tv-bar { border-width: 0 0 var(--px); }
.column.drop { box-shadow: var(--raised); outline: 3px solid var(--accent); outline-offset: 1px; }
.column-head { border-bottom: var(--px) solid var(--outline); box-shadow: 0 var(--px) 0 var(--bevel-hi); }

/* Floating raised things get a hard pixel shadow too */
dialog:not(.task-view):not(.side-menu), .menu-body, .picker-list {
    border: var(--px) solid var(--outline);
    box-shadow: var(--raised), var(--drop);
}
.toast { border-width: var(--px); box-shadow: var(--raised), var(--drop); }
dialog.side-menu { border-left: var(--px) solid var(--outline); box-shadow: var(--raised), -4px 0 0 var(--theme-drop, rgba(0, 0, 0, .4)); }
dialog.task-view { border: 0; box-shadow: none; }

/* Task cards are sunken slots in the column */
.card {
    border: var(--px) solid var(--outline);
    border-left: 4px solid var(--tier);
    box-shadow: var(--sunken);
}
.card:hover {
    border-color: var(--outline); border-left-color: var(--tier);
    background: color-mix(in srgb, var(--card-bg) 90%, var(--text)); /* slot highlight */
}
.card.is-unseen::after { bottom: calc(-1 * var(--px)); height: var(--px); }
.note { border: var(--px) solid var(--outline); box-shadow: var(--sunken); }
.note.mine { border-left: 4px solid var(--accent); }

/* Buttons: raised, pressed in while clicked */
.btn, .chip {
    border: var(--px) solid var(--outline);
    box-shadow: var(--raised);
}
.btn:hover, .chip:hover { border-color: var(--outline); }
.btn.primary { border-color: var(--outline); }
.btn:active:not(.disabled), .chip:active { box-shadow: var(--sunken); }
.chip.active { box-shadow: var(--sunken); border-color: var(--tier, var(--accent)); }

/* Inputs are sunken */
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    border: var(--px) solid var(--outline);
    box-shadow: var(--sunken);
}
input.tv-title:not(:focus), .tv-section textarea[readonly] { border-color: transparent; box-shadow: none; }

/* Theme switch: a sunken tray with the chosen theme raised */
.theme-picker { border: var(--px) solid var(--outline); box-shadow: var(--sunken); }
.theme-option[aria-checked="true"] { box-shadow: var(--raised); }

/* Small blocky details */
.tier-badge { box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25), inset 2px 2px 0 rgba(255, 255, 255, .25); }
.progress .bar { height: 7px; border: 1px solid var(--outline); box-shadow: inset 1px 1px 0 var(--bevel-lo); }
.subtask-group { border-left-width: var(--px); }
/* Columns keep the theme's main colour as their border (with the bevel inside it). */
.column { border-color: var(--accent); }
.column-head { border-bottom-color: color-mix(in srgb, var(--accent) 45%, var(--outline)); }
