:root {
    color-scheme: light;
    --page: #f6f8fa;
    --surface: #ffffff;
    --surface-alt: #f6f8fa;
    --surface-subtle: #f3f4f6;
    --text: #24292f;
    --muted: #57606a;
    --line: rgba(27, 31, 36, 0.15);
    --primary: #0969da;
    --primary-hover: #1f6feb;
    --accent-2: #1f6feb;
    --waiting: #9a6700;
    --ready: #1a7f37;
    --progress: #0969da;
    --blocked: #cf222e;
    --suspended: #8250df;
    --done: #57606a;
    --page-grad-start: #f6f8fa;
    --page-grad-end: #eef3f8;
    --header-grad-start: rgba(255, 255, 255, 0.98);
    --header-grad-end: rgba(246, 248, 250, 0.94);
    --panel-grad-start: #ffffff;
    --panel-grad-end: #f6f8fa;
    --card-grad-start: #ffffff;
    --card-grad-end: #fbfcfe;
    --field-bg: #ffffff;
    --toast-bg: #ffffff;
    --button-fg: #ffffff;
    --drop-target: rgba(9, 105, 218, 0.2);
    --shadow-color: rgba(140, 149, 159, 0.2);
    --shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
    --column-shadow: 0 1px 3px rgba(140, 149, 159, 0.2);
    --card-shadow: 0 1px 2px rgba(27, 31, 36, 0.06);
    --button-shadow: 0 1px 0 rgba(27, 31, 36, 0.1);
    --heatmap-0: #ebedf0;
    --heatmap-1: #9be9a8;
    --heatmap-2: #40c463;
    --heatmap-3: #30a14e;
    --heatmap-4: #216e39;
}

:root[data-palette="dark"] {
    color-scheme: dark;
    --page: #071428;
    --surface: #081826;
    --surface-alt: #061428;
    --surface-subtle: #0d2234;
    --text: #e6eef6;
    --muted: #97a6b6;
    --line: rgba(255, 255, 255, 0.09);
    --primary: #60a5fa;
    --primary-hover: #7dd3fc;
    --accent-2: #7dd3fc;
    --waiting: #d1a93d;
    --ready: #46a66f;
    --progress: #60a5fa;
    --blocked: #e26058;
    --suspended: #aa7fc0;
    --done: #929aa3;
    --page-grad-start: #041025;
    --page-grad-end: #06122a;
    --header-grad-start: rgba(255, 255, 255, 0.012);
    --header-grad-end: transparent;
    --panel-grad-start: #071226;
    --panel-grad-end: #041121;
    --card-grad-start: #071428;
    --card-grad-end: #061428;
    --field-bg: rgba(255, 255, 255, 0.02);
    --toast-bg: #041827;
    --button-fg: #06202b;
    --drop-target: rgba(96, 165, 250, 0.1);
    --shadow-color: rgba(2, 6, 23, 0.6);
    --shadow: 0 12px 30px rgba(2, 6, 23, 0.58);
    --column-shadow: 0 2px 7px rgba(2, 6, 23, 0.46);
    --card-shadow: 0 1px 3px rgba(2, 6, 23, 0.52);
    --button-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
    --heatmap-0: #161b22;
    --heatmap-1: #0e4429;
    --heatmap-2: #006d32;
    --heatmap-3: #26a641;
    --heatmap-4: #39d353;
}

:root[data-palette="forest"] {
    --page: #f4f8f2;
    --surface: #fcfefb;
    --surface-alt: #eef4ec;
    --surface-subtle: #edf4ea;
    --text: #233127;
    --muted: #5d6f60;
    --line: rgba(53, 82, 60, 0.16);
    --primary: #2f6f4f;
    --primary-hover: #4f8f6b;
    --accent-2: #4f8f6b;
    --waiting: #8b6b12;
    --ready: #2d7148;
    --progress: #276b86;
    --blocked: #ac3f38;
    --suspended: #755181;
    --done: #59645d;
    --page-grad-start: #f4f8f2;
    --page-grad-end: #e5efe4;
    --header-grad-start: rgba(252, 254, 251, 0.98);
    --header-grad-end: rgba(237, 244, 234, 0.94);
    --panel-grad-start: #fcfefb;
    --panel-grad-end: #edf4ea;
    --card-grad-start: #ffffff;
    --card-grad-end: #f5faf2;
    --field-bg: #ffffff;
    --toast-bg: #fcfefb;
    --drop-target: rgba(47, 111, 79, 0.18);
    --shadow-color: rgba(80, 102, 88, 0.18);
    --column-shadow: 0 1px 3px rgba(80, 102, 88, 0.18);
    --card-shadow: 0 1px 2px rgba(53, 82, 60, 0.08);
    --heatmap-0: #e6eee3;
    --heatmap-1: #b6d7b8;
    --heatmap-2: #7cba83;
    --heatmap-3: #4b9658;
    --heatmap-4: #2f6f3f;
}

:root[data-palette="machine-shop"] {
    --page: #f3f3ef;
    --surface: #ffffff;
    --surface-alt: #ecece6;
    --surface-subtle: #ecece6;
    --text: #333333;
    --muted: #6f6f67;
    --line: rgba(51, 51, 51, 0.18);
    --primary: #346734;
    --primary-hover: #006699;
    --accent-2: #006699;
    --waiting: #806315;
    --ready: #346734;
    --progress: #006699;
    --blocked: #a33f3f;
    --suspended: #6a5578;
    --done: #666660;
    --page-grad-start: #f7f7f4;
    --page-grad-end: #e9e9e1;
    --header-grad-start: rgba(255, 255, 255, 0.98);
    --header-grad-end: rgba(243, 243, 239, 0.96);
    --panel-grad-start: #ffffff;
    --panel-grad-end: #ecece6;
    --card-grad-start: #ffffff;
    --card-grad-end: #f7f7f2;
    --field-bg: #ffffff;
    --toast-bg: #ffffff;
    --drop-target: rgba(52, 103, 52, 0.2);
    --shadow-color: rgba(102, 102, 102, 0.16);
    --shadow: 0 2px 8px rgba(70, 70, 64, 0.16);
    --column-shadow: 0 1px 3px rgba(102, 102, 102, 0.2);
    --card-shadow: 0 1px 2px rgba(51, 51, 51, 0.08);
    --heatmap-0: #e4e4dc;
    --heatmap-1: #cfd9cf;
    --heatmap-2: #97b497;
    --heatmap-3: #5f8d5f;
    --heatmap-4: #346734;
}

:root[data-palette="warm-paper"] {
    --page: #fbf7ef;
    --surface: #fffdf8;
    --surface-alt: #f7f0e5;
    --surface-subtle: #f4ede0;
    --text: #3a3127;
    --muted: #746556;
    --line: rgba(98, 78, 58, 0.16);
    --primary: #b35c2e;
    --primary-hover: #8f4e2d;
    --accent-2: #8f4e2d;
    --waiting: #8b681c;
    --ready: #41714c;
    --progress: #98602d;
    --blocked: #ad4038;
    --suspended: #765276;
    --done: #6c6257;
    --page-grad-start: #fbf7ef;
    --page-grad-end: #f3eadc;
    --header-grad-start: rgba(255, 253, 248, 0.98);
    --header-grad-end: rgba(244, 237, 224, 0.94);
    --panel-grad-start: #fffdf8;
    --panel-grad-end: #f4ede0;
    --card-grad-start: #fffdf8;
    --card-grad-end: #fbf4ea;
    --field-bg: #fffdf8;
    --toast-bg: #fffdf8;
    --drop-target: rgba(179, 92, 46, 0.18);
    --shadow-color: rgba(139, 118, 89, 0.18);
    --shadow: 0 2px 8px rgba(98, 78, 58, 0.18);
    --column-shadow: 0 1px 3px rgba(139, 118, 89, 0.22);
    --card-shadow: 0 1px 2px rgba(98, 78, 58, 0.1);
    --heatmap-0: #efe6d8;
    --heatmap-1: #e3c89e;
    --heatmap-2: #d39f62;
    --heatmap-3: #bf773c;
    --heatmap-4: #8f4e2d;
}

:root[data-palette="peachy-delight"] {
    --page: #fff7f3;
    --surface: #fffaf8;
    --surface-alt: #ffe5d9;
    --surface-subtle: #ffe5d9;
    --text: #5e4b52;
    --muted: #866d74;
    --line: rgba(157, 129, 137, 0.2);
    --primary: #9d8189;
    --primary-hover: #f4acb7;
    --accent-2: #f4acb7;
    --waiting: #8b671d;
    --ready: #47735b;
    --progress: #5d708f;
    --blocked: #ad4a53;
    --suspended: #806080;
    --done: #74686c;
    --page-grad-start: #fff7f3;
    --page-grad-end: #ffe5d9;
    --header-grad-start: rgba(255, 250, 248, 0.98);
    --header-grad-end: rgba(255, 229, 217, 0.94);
    --panel-grad-start: #fffaf8;
    --panel-grad-end: #ffdfe1;
    --card-grad-start: #fffdfc;
    --card-grad-end: #fff0eb;
    --field-bg: #fffdfc;
    --toast-bg: #fffaf8;
    --drop-target: rgba(244, 172, 183, 0.28);
    --shadow-color: rgba(157, 129, 137, 0.16);
    --shadow: 0 2px 8px rgba(120, 91, 100, 0.16);
    --column-shadow: 0 1px 3px rgba(157, 129, 137, 0.2);
    --card-shadow: 0 1px 2px rgba(94, 75, 82, 0.09);
    --heatmap-0: #d8e2dc;
    --heatmap-1: #ffe5d9;
    --heatmap-2: #ffcad4;
    --heatmap-3: #f4acb7;
    --heatmap-4: #9d8189;
}

:root[data-palette="contrast"] {
    --page: #ffffff;
    --surface: #ffffff;
    --surface-alt: #eeeeee;
    --surface-subtle: #eeeeee;
    --text: #000000;
    --muted: #333333;
    --line: #000000;
    --primary: #0047ab;
    --primary-hover: #002f73;
    --accent-2: #0047ab;
    --waiting: #715500;
    --ready: #00652e;
    --progress: #0047ab;
    --blocked: #a30000;
    --suspended: #5c2877;
    --done: #333333;
    --page-grad-start: #ffffff;
    --page-grad-end: #ffffff;
    --header-grad-start: #ffffff;
    --header-grad-end: #ffffff;
    --panel-grad-start: #ffffff;
    --panel-grad-end: #ffffff;
    --card-grad-start: #ffffff;
    --card-grad-end: #ffffff;
    --field-bg: #ffffff;
    --toast-bg: #ffffff;
    --drop-target: rgba(0, 71, 171, 0.2);
    --shadow-color: transparent;
    --shadow: none;
    --column-shadow: none;
    --card-shadow: none;
    --button-shadow: none;
    --heatmap-0: #ffffff;
    --heatmap-1: #b8e2c5;
    --heatmap-2: #63bc7c;
    --heatmap-3: #238643;
    --heatmap-4: #005a24;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    min-height: 100%;
    background: linear-gradient(180deg, var(--page-grad-start), var(--page-grad-end));
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    letter-spacing: 0;
}

button,
input,
textarea,
select {
    font: inherit;
    letter-spacing: 0;
}

button {
    min-height: 30px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: var(--button-fg);
    padding: 6px 8px;
    box-shadow: var(--button-shadow);
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
}

button:hover {
    background: var(--primary-hover);
}

button.secondary {
    border-color: var(--line);
    border-style: solid;
    border-width: 1px;
    background: var(--surface);
    color: var(--muted);
}

button.secondary:hover {
    background: var(--surface-subtle);
}

button.danger {
    border-color: var(--blocked);
    background: var(--blocked);
    color: #ffffff;
}

button.danger:hover {
    background: color-mix(in srgb, var(--blocked) 86%, #000000);
}

.auth-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-screen[hidden],
#app-shell[hidden] {
    display: none;
}

.auth-panel {
    width: min(380px, 100%);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--panel-grad-start), var(--panel-grad-end));
    box-shadow: var(--shadow);
    padding: 24px;
}

.auth-brand {
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 700;
}

.auth-panel h1 {
    margin: 0 0 18px;
    font-size: 20px;
}

.auth-form {
    display: grid;
    gap: 9px;
}

.auth-form[hidden] {
    display: none;
}

.auth-form button:first-of-type {
    margin-top: 8px;
}

.auth-feedback { margin: 4px 0; padding: 10px; border: 1px solid var(--blocked); border-radius: 5px; color: var(--text); background: var(--surface-alt); overflow-wrap: anywhere; }
.auth-form [aria-invalid="true"] { border-color: var(--blocked); }
.auth-form button:disabled { opacity: .65; cursor: wait; }

.topbar {
    position: relative;
    flex: 0 0 auto;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, var(--header-grad-start), var(--header-grad-end));
    box-shadow: 0 1px 0 rgba(27, 31, 36, 0.04);
}

#app-shell {
    display: flex;
    height: 100vh;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
}

.brand {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.connection-status::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--waiting);
    content: "";
}

.connection-status.connected::before {
    background: var(--ready);
}

.connection-status.disconnected::before {
    background: var(--blocked);
}

.quick-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.account-summary {
    display: flex;
    align-items: baseline;
    gap: 7px;
    max-width: 220px;
}

.current-user {
    max-width: 160px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--field-bg);
    color: var(--text);
    padding: 7px 9px;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: 2px solid color-mix(in srgb, var(--primary) 18%, transparent);
}

.board-scroll {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100vw;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    padding: 10px;
}

.board {
    display: grid;
    grid-template-columns: repeat(6, minmax(260px, 1fr));
    align-items: start;
    gap: 10px;
    height: 100%;
    min-width: 1610px;
    min-height: 0;
    background: transparent;
}

.column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--surface), var(--surface-alt));
    box-shadow: 0 1px 3px var(--shadow-color);
    padding: 8px;
}

.column-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 8px;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    min-height: var(--column-header-height, 0px);
    padding: 0 0 6px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.column-header > span:first-child { flex-shrink: 0; }
.column-heading { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

.column-count {
    justify-self: end;
    text-align: right;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.column-count.over-limit {
    color: var(--blocked);
}

.column-list {
    display: grid;
    flex: 1 1 auto;
    align-content: start;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 0 0 8px;
    scrollbar-gutter: stable;
}

.column-list:empty {
    min-height: 34px;
}

.column-list.drop-target {
    background: var(--drop-target);
    box-shadow: inset 0 0 0 2px var(--drop-target);
}

.card {
    position: relative;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--card-grad-start), var(--card-grad-end));
    box-shadow: var(--card-shadow);
    padding: 12px 54px 10px 12px;
    cursor: pointer;
    transition: border-color 100ms ease, box-shadow 100ms ease, opacity 100ms ease;
}

.card:hover {
    border-color: var(--line);
    box-shadow: var(--card-shadow);
}

.card.state-waiting {
    opacity: 0.56;
    filter: grayscale(6%);
}

.card.state-waiting:hover {
    opacity: 0.56;
}

.card.time-critical {
    border-color: rgba(234, 88, 12, 0.55);
    border-left: 4px solid #f97316;
    background: linear-gradient(180deg, #fff7ed, #ffedd5);
    box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.16), 0 8px 18px rgba(234, 88, 12, 0.14);
}

:root[data-palette="dark"] .card.time-critical {
    border-color: rgba(251, 146, 60, 0.62);
    background: linear-gradient(180deg, #2a1708, #1f1208);
}

.card.overdue:not(.time-critical) {
    box-shadow: var(--card-shadow);
}

.overdue-label {
    color: var(--blocked);
    font-weight: 700;
}

.card[draggable="true"] {
    cursor: grab;
}

.card.dragging {
    opacity: 0.5;
}

.card-title {
    margin: 0 0 4px;
    overflow-wrap: anywhere;
    padding-right: 0;
    font-size: 0.96rem;
    line-height: 1.3;
}

.recurrence-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.82em;
    line-height: 1;
    vertical-align: 0.04em;
}

.priority {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 20px;
    box-sizing: content-box;
    border-radius: 12px;
    color: #ffffff;
    padding: 0 7px;
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.card-description {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.card-note {
    margin: 7px 0;
    border-left: 3px solid var(--blocked);
    border-radius: 0 4px 4px 0;
    background: color-mix(in srgb, var(--blocked) 7%, transparent);
    padding: 6px 7px;
    color: var(--blocked);
    font-size: 12px;
    line-height: 1.35;
}

.metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.3;
    margin-bottom: 6px;
}

.owner-label {
    color: var(--accent-2);
    font-weight: 700;
}

.claim-review {
    --review-color: color-mix(in srgb, var(--blocked) var(--review-emphasis, 0%), var(--waiting));
    margin-top: 8px;
    border-left: var(--review-border-width, 2px) solid var(--review-color);
    border-radius: 0 4px 4px 0;
    background: color-mix(in srgb, var(--review-color) var(--review-tint, 4%), transparent);
    padding: 8px;
    font-size: 0.84rem;
    line-height: 1.35;
}

.claim-review-gap {
    display: block;
    margin-bottom: 4px;
}

.claim-review p {
    margin: 0 0 7px;
    overflow-wrap: anywhere;
}

.claim-review button {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 0.84rem;
}

.critical-label {
    border: 1px solid rgba(234, 88, 12, 0.28);
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.1);
    color: #c2410c;
    min-height: 20px;
    padding: 1px 7px;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

:root[data-palette="dark"] .critical-label {
    color: #fdba74;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.card-actions button {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 0.9rem;
}

.card-actions button.danger,
.card-actions button.danger:hover {
    background: var(--primary);
    color: var(--button-fg);
}

.editor {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 30;
    width: 360px;
    max-width: 92vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    border-left: 1px solid var(--line);
    background: linear-gradient(180deg, var(--panel-grad-start), var(--panel-grad-end));
    box-shadow: -12px 0 30px var(--shadow-color);
    padding: 16px 16px 32px;
    transform: translateX(105%);
    transition: transform 160ms ease;
}

.editor.open {
    transform: translateX(0);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.editor-header h2 {
    margin: 0;
    font-size: 17px;
}

#editor { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
#editor .editor-header { flex-shrink: 0; }
#task-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.editor-fields { display: grid; gap: 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 2px 16px; }
#task-form > .editor-actions { flex-shrink: 0; margin-top: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 12px 0 max(12px, env(safe-area-inset-bottom)); }
#settings { padding-bottom: max(32px, env(safe-area-inset-bottom)); scroll-padding-bottom: max(16px, env(safe-area-inset-bottom)); }

#settings-form {
    display: grid;
    gap: 8px;
}

#password-form,
.account-settings-section {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.form-help {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.form-status {
    margin: 10px 0 0;
    color: var(--ready);
    font-size: 0.88rem;
    font-weight: 650;
}

.form-status.error {
    color: var(--blocked);
}

.device-code-panel {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-alt);
    padding: 14px;
    text-align: center;
}

.device-code {
    display: block;
    margin-bottom: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(1.5rem, 7vw, 2.2rem);
    font-weight: 750;
    letter-spacing: 0.12em;
}

.password-fields {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}

#task-form label,
#task-form legend {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 650;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row > div {
    display: grid;
    gap: 8px;
}

.scheduled-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

.lead-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px;
    align-items: center;
    gap: 8px;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
}

.checkbox-line input {
    width: auto;
}

#task-sharing-option { min-height: 44px; }

fieldset {
    margin: 6px 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    padding: 10px;
}

.dependency-list {
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 8px;
}

.dependency-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 8px;
    font-weight: 400 !important;
}

.dependency-option input {
    width: auto;
    margin-top: 3px;
}

.dependency-option > label {
    color: var(--text) !important;
    font-weight: 400 !important;
    overflow-wrap: anywhere;
}

.dependency-link {
    min-width: 0;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-decoration: underline;
}

.dependency-link:hover {
    color: var(--primary-hover);
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.weekday-grid label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 400 !important;
}

.weekday-grid input {
    width: auto;
}

#weekday-options[hidden] {
    display: none;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.editor-actions-main {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

#block-note-wrap {
    display: grid;
    gap: 8px;
}

#block-note-wrap[hidden] {
    display: none;
}

.task-context {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
    color: var(--muted);
    font-size: 12px;
}

.task-context[hidden] {
    display: none;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    align-items: center;
    gap: 10px 16px;
}

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(20, 28, 38, 0.38);
}

.history-dialog {
    width: min(760px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--panel-grad-start), var(--panel-grad-end));
    color: var(--text);
    padding: 20px;
    box-shadow: 0 12px 36px rgba(20, 28, 38, 0.24);
}

.history-dialog::backdrop {
    background: rgba(20, 28, 38, 0.34);
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.dialog-header h2 {
    margin: 0 0 5px;
    font-size: 19px;
}

.history-summary {
    color: var(--muted);
    font-size: 12px;
}

.heatmap-scroll {
    overflow-x: auto;
    padding: 4px 0 10px;
}

.heatmap-calendar {
    --heatmap-cell-size: 10px;
    --heatmap-gap: 3px;
    display: grid;
    grid-template-columns: 28px max-content;
    grid-template-rows: 14px var(--heatmap-cell-size) max-content;
    gap: 5px 4px;
    width: max-content;
    min-width: 100%;
}

.heatmap-months {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: repeat(53, var(--heatmap-cell-size));
    column-gap: var(--heatmap-gap);
    height: 14px;
}

.heatmap-month-label {
    width: max-content;
    color: var(--muted);
    font-size: 10px;
    line-height: 14px;
    white-space: nowrap;
}

.heatmap-month-label:last-child {
    justify-self: end;
}

.heatmap-week-summary {
    display: grid;
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: repeat(53, var(--heatmap-cell-size));
    column-gap: var(--heatmap-gap);
}

.heatmap-y-axis {
    display: grid;
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: 16px var(--heatmap-cell-size);
    column-gap: 2px;
}

.heatmap-days {
    display: grid;
    grid-template-rows: repeat(7, var(--heatmap-cell-size));
    row-gap: var(--heatmap-gap);
}

.heatmap-days span {
    color: var(--muted);
    font-size: 9px;
    line-height: var(--heatmap-cell-size);
}

.heatmap-day-summary {
    display: grid;
    grid-template-rows: repeat(7, var(--heatmap-cell-size));
    row-gap: var(--heatmap-gap);
}

.heatmap-grid {
    display: grid;
    grid-column: 2;
    grid-row: 3;
    grid-auto-columns: 10px;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 10px);
    gap: 3px;
    width: max-content;
}

.heatmap-cell {
    width: 10px;
    height: 10px;
    border: 1px solid rgba(32, 37, 43, 0.08);
    border-radius: 2px;
    background: var(--heatmap-0);
}

.heatmap-cell.level-1 {
    background: var(--heatmap-1);
}

.heatmap-cell.level-2 {
    background: var(--heatmap-2);
}

.heatmap-cell.level-3 {
    background: var(--heatmap-3);
}

.heatmap-cell.level-4 {
    background: var(--heatmap-4);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 50;
    max-width: min(420px, calc(100vw - 32px));
    border-radius: 5px;
    border: 1px solid var(--line);
    background: var(--toast-bg);
    color: var(--text);
    padding: 10px 14px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.toast.visible {
    opacity: 1;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* Compact controls leave the task list as the main surface. */
[hidden] { display: none !important; }
.topbar { display: grid; grid-template-columns: auto auto minmax(200px,1fr) auto; gap: 10px; padding: 8px 12px; min-height: 50px; }
.brand { display: flex; align-items: center; gap: 6px; min-width: 0; }
.development-badge { color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font-size: 10px; font-weight: 500; }
.connection-status { margin-left: 0; }
.app-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.topbar button, .topbar select, .quick-add input { height: 33px; min-height: 33px; }
.app-actions > button { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
#desktop-current-user { max-width: 160px; white-space: nowrap; }
.add-task-icon { display: none; }
.header-menu { display: none; position: relative; }
.header-menu > summary { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 6px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.header-menu > summary { width: 44px; color: var(--muted); font-size: 20px; }
.header-menu[open] > summary { background: var(--surface-subtle); }
.account-menu-panel { position: absolute; z-index: 30; right: 0; top: calc(100% + 5px); width: min(260px, calc(100vw - 24px)); padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 6px 24px rgba(0,0,0,.14); }
.account-menu-panel { display: grid; gap: 6px; max-height: calc(100dvh - 70px); overflow-y: auto; }
.account-menu-panel button { min-height: 44px; text-align: left; padding: 10px; }
#account-summary { display: grid; gap: 4px; }
.current-user { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.view-controls { min-width: 0; }
.primary-filters { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; width: 160px; max-width: 100%; }
.project-label { display: none; }
.view-controls label { display: grid; min-width: 0; gap: 3px; color: var(--muted); font-size: 12px; }
.view-controls label.column-picker { display: none; }
#new-task { display: none; }
.view-controls select { width: 100%; min-width: 0; margin: 0; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 44px; }
#my-work { display: none; white-space: nowrap; }
#my-work[aria-pressed="true"] { border-color: var(--primary); background: var(--primary); color: var(--button-fg); }
.view-summary { color: var(--muted); font-size: 12px; margin: 0 auto 0 0; white-space: nowrap; }
.task-tag { border: 1px solid var(--line); border-radius: 12px; padding: 2px 7px; }
.last-completion { flex-basis: 100%; color: var(--text); }
.empty-view { padding: 24px; max-width: 560px; }
.board-scroll.list-layout { overflow-x: hidden; overflow-y: auto; }
.list-layout .board { grid-template-columns: minmax(0,1fr); min-width: 0; height: auto; max-width: 860px; margin: 0 auto; }
.list-layout .column { max-height: none; overflow: visible; }
.list-layout .column-list { max-height: none; overflow: visible; }
.list-layout .card { cursor: pointer; }
.task-actions-dialog { width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; box-sizing: border-box; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface); color: var(--text); }
.task-actions-dialog::backdrop { background: rgba(0,0,0,.3); }
#task-actions-name { overflow-wrap: anywhere; color: var(--muted); }
#task-actions-items { display: grid; gap: 8px; }
#task-actions-items button, .task-actions-dialog .dialog-header button { min-height: 44px; }
.card-actions { align-items: center; }
.list-layout .card-actions > button:first-child:not(.more-actions) { min-width: 100px; }
.card-actions > .more-actions { margin-left: auto; min-width: 60px; }
#app-shell { height: 100dvh; }
@media (max-width:760px) {
    .topbar { grid-template-columns: auto minmax(0,1fr); gap: 0 8px; padding: 6px 10px 0; min-height: 0; }
    #quick-add, #desktop-account-summary, #desktop-settings, #desktop-logout { display: none; }
    .header-menu { display: block; }
    .brand { font-size: 16px; gap: 5px; }
    .app-actions { gap: 4px; grid-column: 2; grid-row: 1; justify-self: end; }
    .app-actions > button { min-height: 44px; padding: 6px 10px; }
    #my-work { display: inline-flex; }
    #new-task { display: inline-flex; align-items: center; justify-content: center; width: 44px; padding: 0; }
    .add-task-label { display: none; }
    .add-task-icon { display: block; font-size: 26px; line-height: 1; }
    .connection-status-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
    input, textarea, select, button { font-size: 16px; }
    button, select { min-height: 44px; }
    .view-controls { grid-column: 1 / -1; grid-row: 2; padding: 6px 0 0; }
    .project-label { display: inline; }
    .view-controls label.column-picker { display: grid; }
    .topbar button, .view-controls select { height: 44px; min-height: 44px; }
    .primary-filters { grid-template-columns: minmax(0,1fr) minmax(0,1fr); width: 100%; max-width: 560px; gap: 8px; }
    .form-row { grid-template-columns: 1fr; }
    .filter-bar { gap: 4px; }
    .board-scroll { padding: 8px; }
    .list-layout .column-list { gap: 10px; }
    .list-layout .card { padding: 10px; }
    .list-layout .card-title { padding-right: 44px; font-size: 16px; line-height: 1.35; }
    .list-layout .priority { box-shadow: none; width: 20px; padding: 0 5px; height: 20px; font-size: 12px; }
    .list-layout .card-description { font-size: 14px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
    .list-layout .card-actions { display: flex; gap: 8px; margin-top: 8px; }
    .list-layout .card-actions button { min-height: 44px; padding: 6px 14px; font-size: 16px; }
    .list-layout .card-actions > button:first-child:not(.more-actions) { flex: 1 1 auto; }
    .list-layout .card-actions > .more-actions { flex: 0 0 70px; }
    .list-layout .claim-review button { min-height: 44px; font-size: 16px; }
    .metadata { overflow-wrap: anywhere; }
}

@media (min-width: 761px) and (max-width: 1100px) {
    .topbar { grid-template-columns: auto minmax(0,1fr) auto; }
    .topbar .app-actions { grid-column: 2 / -1; grid-row: 1; justify-self: end; }
    .view-controls { grid-column: 1; grid-row: 2; }
    #quick-add { grid-column: 2 / -1; grid-row: 2; }
}

.claims-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.view-controls label.claims-filter { display: inline-flex; align-items: center; min-height: 44px; gap: 6px; font-size: 13px; cursor: pointer; }
.column-claims-toggle { min-height: 26px; gap: 4px; font-size: 11px; font-weight: 500; }
.column-heading .column-claims-toggle input { width: 14px; height: 14px; }
.column-history-button { min-height: 26px; padding: 3px 6px; font-size: 11px; }
@media (min-width: 761px) {
    .column-heading { min-height: 26px; }
    .column-count { padding-top: 5px; }
}
.claims-filter input { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--primary); }

/* Explicit date/time dimensions also cover empty native controls on phones. */
.scheduled-inputs label { display: grid; min-width: 0; gap: 4px; }
.scheduled-inputs input { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 46px; height: 46px; padding: 8px 10px; box-sizing: border-box; font-size: 16px; line-height: 1.5; -webkit-appearance: none; appearance: none; }
.scheduled-inputs input::-webkit-date-and-time-value { min-height: 1.5em; height: 1.5em; text-align: left; }
.scheduled-inputs input::-webkit-datetime-edit { padding: 0; }
.history-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; }
.history-dialog .dialog-header { position: sticky; top: -16px; z-index: 1; background: var(--surface); padding: 12px 0; margin: -4px 0 8px; }
.history-dialog .dialog-header button, #history-show-more { min-height: 44px; }
.history-scope { color: var(--muted); margin: 0 0 12px; }
.completion-records { list-style: none; padding: 0; margin: 0; }
.completion-record { display: grid; gap: 5px; padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.completion-record time { color: var(--muted); font-size: .9rem; }
.completion-person { font-size: .9rem; }
.completion-history-note { padding: 12px; border-bottom: 1px solid var(--line); }
.completion-history-note p { margin: 0 0 8px; color: var(--muted); font-size: .9rem; }
.completion-history-note button { min-height: 44px; }
.history-chart { margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history-chart > summary { display: list-item; list-style: disclosure-closed inside; min-height: 32px; cursor: pointer; color: var(--text); font-weight: 650; }
.history-chart[open] > summary { list-style-type: disclosure-open; }
@media (max-width: 760px) { .scheduled-inputs { grid-template-columns: minmax(0, 1fr); } }
