* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    height: 100vh;
    height: 100dvh; /* track the visible viewport as mobile browser chrome shows/hides */
    overflow: hidden;
    touch-action: manipulation;
    /* Respect iOS notch / home indicator when installed as a PWA */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #2f3542;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #cfd5e3;
    font-size: 14px;
    letter-spacing: 0.2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

header {
    background: #2d2d2d;
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border-bottom: 1px solid #404040;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1f1f1f;
    border: 1px solid #404040;
    color: #cfd5e3;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.user-badge:hover {
    background: #2b2b2b;
    border-color: #3498db;
}

.user-badge-icon {
    font-size: 14px;
    line-height: 1;
}

body.admin-mode .user-badge {
    border-color: #f1c40f;
    color: #f1c40f;
}

#adminToggleBtn {
    padding: 6px 12px;
    font-size: 12px;
}

body.admin-mode #adminToggleBtn {
    background: #f1c40f;
    color: #1a1a1a;
    font-weight: 600;
}

.app-tabs {
    display: flex;
    gap: 8px;
}

.tab-button {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #404040;
    background: #1f1f1f;
    color: #cfd5e3;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-button.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52,152,219,0.35);
}

/* Apply hover only where a true (mouse) pointer exists. On touch tablets a
   tapped element keeps its :hover state ("sticky hover"); because :hover is
   declared after .active with equal specificity, that stuck state used to
   override the active highlight and flicker while scrolling. */
@media (hover: hover) {
    .tab-button:hover {
        background: #2b2b2b;
    }
}

/* The active tab keeps its highlight even if a hover state lingers
   (e.g. a hybrid touch + trackpad device that reports hover: hover). */
.tab-button.active:hover {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52,152,219,0.35);
}

.list-icon {
    width: 24px;
    height: 24px;
    background: #3498db;
    border-radius: 50%;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #e0e0e0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
    gap: 20px;
    min-height: 0;
}

.tab-view {
    display: none;
}

.tab-view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.add-item-section {
    background: #2d2d2d;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid #404040;
}

.add-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.add-list-target {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #b0b0b0;
    white-space: nowrap;
}

.add-item-section h2 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #e0e0e0;
    font-weight: 600;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #b0b0b0;
    font-size: 13px;
}

input[type="text"],
textarea,
select,
input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #404040;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #1a1a1a;
    color: #e0e0e0;
    touch-action: manipulation;
}

input[type="text"]:focus,
textarea:focus,
select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: #666;
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
}

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

.checkbox-label input[type="checkbox"] {
    position: relative;
    top: 18px; /* align with text */
}

#isRecurring {
    position: static;
    top: auto;
    transform: translateY(-2px);
}

#recurrenceOptions {
    background: #252525;
    padding: 15px;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid #404040;
}

#recurrenceOptions > div {
    margin-top: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #3a3a3a;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background: #4a4a4a;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger:hover {
    background: #c0392b;
}

.checklists-section {
    flex: 1;
    display: flex;
    gap: 20px;
    overflow: hidden;
    min-height: 0;
}

.list-tabs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.list-menu {
    display: flex;
    flex-direction: column;
    margin-top: 8px;
}

.list-menu-handle {
    position: relative;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #2d2d2d;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    transition: background 0.2s ease, border-color 0.2s ease;
    touch-action: none;
    user-select: none;
    color: #cfd5e3;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.list-menu-handle::before {
    content: '▼';
    font-size: 10px;
    color: #3498db;
    transition: transform 0.2s ease;
}

.list-menu-handle::after {
    content: 'Menu';
}

.list-menu.expanded .list-menu-handle::before {
    transform: rotate(180deg);
}

.list-menu-handle:hover {
    background: #353535;
    border-color: #3498db;
}

.list-menu-handle:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.list-menu-grip {
    width: 48px;
    height: 4px;
    background: #555;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.list-menu-handle:hover .list-menu-grip {
    background: #3498db;
}

.list-menu.expanded .list-menu-handle {
    background: #1f3a52;
    border-color: #3498db;
}

.list-menu.expanded .list-menu-grip {
    background: #3498db;
}

.list-menu-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
}

.list-menu.expanded .list-menu-panel {
    max-height: 240px;
    opacity: 1;
    padding: 10px 0 4px;
}

.list-tab {
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #404040;
    background: #252525;
    color: #cfd5e3;
    cursor: grab;
    transition: all 0.2s;
    font-weight: 600;
    user-select: none;
}

.list-tab.active {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
    box-shadow: 0 2px 8px rgba(52,152,219,0.35);
}

/* See .tab-button:hover above. This is the bug the user hit: on a tablet the
   stuck hover wiped the active tab's blue fill but left the blue border, and
   flickered on scroll / list switches. Gate hover to real pointers and keep
   the active tab blue regardless. */
@media (hover: hover) {
    .list-tab:hover {
        background: #2d2d2d;
    }
}

.list-tab.active:hover {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
    box-shadow: 0 2px 8px rgba(52,152,219,0.35);
}

.list-tab.drag-over {
    outline: 2px dashed #3498db;
}

.list-actions .btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.checklist-column {
    flex: 1;
    background: #2d2d2d;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #404040;
    min-height: 0;
}

.checklist-column h2 {
    padding: 15px 20px;
    background: #252525;
    border-bottom: 1px solid #404040;
    font-size: 16px;
    color: #e0e0e0;
    font-weight: 600;
}

.checklist-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    min-height: 0;
    max-height: 100%;
}

.checklist-item {
    background: #353535;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

/* Gate on real pointers too — otherwise task cards "stick" highlighted and
   flicker as a finger drags over them while scrolling on a tablet. */
@media (hover: hover) {
    .checklist-item:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.4);
        border-color: #505050;
    }
}

.checklist-item.done {
    opacity: 0.6;
    background: #2a3a2a;
    border-color: #3a4a3a;
}

.checklist-item.drag-over {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52,152,219,0.35);
}

.checklist-item-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.checklist-item input[type="checkbox"] {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.checklist-item-title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    color: #e0e0e0;
    word-wrap: break-word;
    line-height: 1.4;
}

.checklist-item.done .checklist-item-title {
    text-decoration: line-through;
    color: #888;
}

.checklist-item-description {
    margin-left: 30px;
    margin-top: 8px;
    color: #b0b0b0;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.checklist-item.done .checklist-item-description {
    color: #666;
}

.checklist-item-recurrence {
    margin-left: 30px;
    margin-top: 10px;
    font-size: 12px;
    color: #3498db;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
}

.recurrence-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
}

.checklist-item-actions {
    margin-left: 30px;
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    font-size: 14px;
}

/* Scrollbar styling */
.checklist-list::-webkit-scrollbar {
    width: 10px;
}

.checklist-list::-webkit-scrollbar-track {
    background: #252525;
    border-radius: 4px;
}

.checklist-list::-webkit-scrollbar-thumb {
    background: #505050;
    border-radius: 4px;
}

.checklist-list::-webkit-scrollbar-thumb:hover {
    background: #606060;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal {
    background: #1f1f1f;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: 18px;
    width: 320px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal.wide {
    width: 500px;
}

.modal .modal-body textarea {
    min-height: 90px;
}

.modal h3 {
    margin: 0;
    color: #e0e0e0;
    font-size: 16px;
}

.modal-message {
    font-size: 13px;
    color: #e0e0e0;
    line-height: 1.5;
}

.modal-message.danger {
    color: #ff8a80;
}

.modal input {
    width: 100%;
    padding: 10px;
    border: 1px solid #404040;
    border-radius: 4px;
    background: #1a1a1a;
    color: #e0e0e0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #2f3542;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #cfd5e3;
    font-size: 14px;
    letter-spacing: 0.2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ─── Web-only additions ──────────────────────────────────────── */

/* Admin-only elements are hidden unless body.admin-mode is set */
body:not(.admin-mode) .admin-only {
    display: none !important;
}

/* Master-admin-only elements (user management, digests, import/export) are
   hidden for team admins, who only manage their own lists. */
body:not(.master-mode) .master-only {
    display: none !important;
}

/* Items in non-admin mode lose their edit/move/delete buttons */
body:not(.admin-mode) .checklist-item-actions {
    display: none;
}

/* "Who did this" stamp on checked items */
.checklist-item-meta {
    margin-left: 30px;
    margin-top: 6px;
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10001;
    max-width: 90vw;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: #2ecc71;
}

.toast.error {
    border-color: #e74c3c;
}

.list-tab-loc {
    margin-left: 8px;
    padding: 2px 8px;
    background: rgba(241, 196, 15, 0.18);
    border: 1px solid rgba(241, 196, 15, 0.5);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    color: #f1c40f;
    vertical-align: middle;
}

/* Drag affordance — only in admin mode */
body.admin-mode .list-tab[draggable="true"],
body.admin-mode .checklist-item[draggable="true"] {
    cursor: grab;
}
body.admin-mode .list-tab[draggable="true"]:active,
body.admin-mode .checklist-item[draggable="true"]:active {
    cursor: grabbing;
}
body:not(.admin-mode) .list-tab {
    cursor: pointer;
}

/* User management modal */
.user-mgmt-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 8px;
    background: #181818;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid #2d2d2d;
}

.user-row:last-child { border-bottom: 0; }

.user-row-main {
    flex: 1;
    min-width: 0;
}

.user-row-name {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 13px;
}

.user-row-username {
    color: #888;
    font-weight: 400;
    font-size: 12px;
    margin-left: 4px;
}

.user-row-meta {
    margin-top: 4px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.user-row-tag {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(241, 196, 15, 0.15);
    border: 1px solid rgba(241, 196, 15, 0.4);
    color: #f1c40f;
    border-radius: 999px;
}

.user-row-tag.admin {
    background: rgba(231, 76, 60, 0.18);
    border-color: rgba(231, 76, 60, 0.5);
    color: #ff8a80;
}

.user-row-tag.empty {
    background: #2a2a2a;
    border-color: #404040;
    color: #888;
}

.user-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.user-row-actions .btn {
    padding: 4px 10px;
    font-size: 11px;
}

.user-mgmt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
}

.user-mgmt-grid input,
.user-mgmt-grid select {
    padding: 6px 8px;
    font-size: 12px;
}

@media (max-width: 700px) {
    .user-mgmt-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.directory-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.dir-col {
    background: #181818;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 8px;
}

.dir-head {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 6px;
}

.dir-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
}

.dir-name {
    font-size: 12px;
    color: #e0e0e0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-abbrev {
    width: 72px;
    flex-shrink: 0;
    padding: 4px 6px;
    font-size: 12px;
}

.dir-add {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #404040;
}

.dir-add input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    font-size: 12px;
}

.dir-del {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
    border: 1px solid #404040;
    background: #2a2a2a;
    color: #ff8a80;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.dir-del:hover {
    background: #3a2a2a;
    border-color: #e74c3c;
}

.dir-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.dir-edit {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
    border: 1px solid #404040;
    background: #2a2a2a;
    color: #9ec5fe;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.dir-edit:hover { background: #25313f; border-color: #3498db; }
.dir-rename-input { flex: 1; min-width: 0; padding: 4px 6px; font-size: 12px; }

/* Inline editor for a team login (location/team/emails) */
.user-edit {
    background: #181818;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px 12px;
    margin: -2px 0 10px;
}
.user-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}
.user-edit-grid label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: #b0b0b0;
}
.user-edit-grid label:last-child { grid-column: 1 / -1; }
.user-edit-grid select,
.user-edit-grid input {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
}
.user-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
@media (max-width: 700px) {
    .user-edit-grid { grid-template-columns: 1fr; }
}

.exec-access {
    background: #181818;
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 10px;
    margin: -4px 0 10px;
}

.exec-cb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 4px;
}

.exec-cb {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #e0e0e0;
    white-space: nowrap;
}

.exec-cb input {
    width: 14px;
    height: 14px;
}

.exec-access-help {
    font-size: 11px;
    color: #9aa;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* ─── Wide, card-based "Manage Access" modal ─────────────────────── */
.modal.mgmt {
    width: min(1080px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
}

.mgmt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mgmt-head h3 { margin: 0; }

.mgmt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.mgmt-section {
    background: #1f1f1f;
    border: 1px solid #383838;
    border-radius: 8px;
    padding: 14px;
    min-width: 0;
}

.mgmt-section > h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #e0e0e0;
    font-weight: 600;
}

.mgmt-wide { grid-column: 1 / -1; }

.mgmt-section .user-mgmt-list {
    max-height: 300px;
}

.mgmt-add {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #333;
}

.mgmt-add h5 {
    margin: 0 0 8px;
    font-size: 11px;
    color: #b0b0b0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mgmt-tip {
    font-size: 11px;
    color: #888;
    margin: 8px 0 0;
    line-height: 1.5;
}

@media (max-width: 760px) {
    .mgmt-grid { grid-template-columns: 1fr; }
}

/* ─── Phone layout ───────────────────────────────────────────────
   On narrow screens the side-by-side To Do / Done columns become thin,
   cramped strips. Stack them full-width, let the section scroll as one,
   drop the indentation, and use bigger tap targets. */
/* ─── List colors (swatches in the modal + colored tabs) ─────────── */
.swatch[data-color="blue"],   .list-tab[data-color="blue"]   { --lc: #3498db; }
.swatch[data-color="green"],  .list-tab[data-color="green"]  { --lc: #2ecc71; }
.swatch[data-color="amber"],  .list-tab[data-color="amber"]  { --lc: #e0a800; }
.swatch[data-color="red"],    .list-tab[data-color="red"]    { --lc: #e74c3c; }
.swatch[data-color="purple"], .list-tab[data-color="purple"] { --lc: #9b59b6; }
.swatch[data-color="teal"],   .list-tab[data-color="teal"]   { --lc: #1abc9c; }
.swatch[data-color="pink"],   .list-tab[data-color="pink"]   { --lc: #e84393; }
.swatch[data-color="slate"],  .list-tab[data-color="slate"]  { --lc: #7f8c8d; }
.swatch[data-color="orange"], .list-tab[data-color="orange"] { --lc: #e67e22; }
.swatch[data-color="yellow"], .list-tab[data-color="yellow"] { --lc: #f1c40f; }
.swatch[data-color="lime"],   .list-tab[data-color="lime"]   { --lc: #8bc34a; }
.swatch[data-color="cyan"],   .list-tab[data-color="cyan"]   { --lc: #00bcd4; }
.swatch[data-color="indigo"], .list-tab[data-color="indigo"] { --lc: #5c6bc0; }
.swatch[data-color="brown"],  .list-tab[data-color="brown"]  { --lc: #8d6e63; }

.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.swatch {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid transparent; cursor: pointer; padding: 0;
    background: var(--lc, #2a2a2a);
}
.swatch.selected { box-shadow: 0 0 0 2px #1f1f1f, 0 0 0 4px #fff; }
.swatch-none { background: #2a2a2a; border: 1px solid #666; position: relative; }
.swatch-none::after {
    content: ''; position: absolute; left: 3px; right: 3px; top: 50%;
    height: 2px; background: #e74c3c; transform: rotate(-45deg);
}
/* Custom color: rainbow ring until a color is picked, then fills solid (--lc). */
.swatch-custom {
    position: relative;
    overflow: hidden;
    padding: 0;
    background: var(--lc, conic-gradient(from 0deg, #e74c3c, #e67e22, #f1c40f, #2ecc71, #1abc9c, #3498db, #9b59b6, #e84393, #e74c3c));
}
.swatch-custom input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

/* Colored tabs: left accent when inactive, full fill when active. */
.list-tab[data-color] { border-left: 5px solid var(--lc); }
.list-tab.active[data-color] { background: var(--lc); border-color: var(--lc); color: #fff; }

/* ─── Slim MENU handle + compact owner Location/Team filter ───────── */
.list-menu-handle {
    align-self: flex-start;
    width: auto;
    height: auto;
    padding: 6px 16px;
    gap: 6px;
    justify-content: flex-start;
    letter-spacing: 0.5px;
}
.list-menu-grip { display: none; }

/* Filter sits on its own row above the tabs, so the colored tabs use the full
   width and pack several per row instead of being squeezed into a narrow column. */
.list-tabs-row { flex-direction: column; align-items: stretch; gap: 10px; }
.list-filter { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.list-filter select {
    width: auto;
    min-width: 128px;
    max-width: 190px;
    padding: 7px 10px;
    font-size: 13px;
}
/* Shrink the owner scope badge so colored tabs stay compact. */
.list-tab-loc { margin-left: 6px; padding: 1px 6px; font-size: 10px; }

/* Cap the list strip so a big list count never eats the whole screen and pushes
   the To Do / Done section off-view. The strip scrolls within instead. */
.list-tabs {
    max-height: 42vh;
    overflow-y: auto;
    align-content: flex-start;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}

/* Full-admin controls bar: a "Hide lists" toggle + the Location/Team filter. */
.list-tabs-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.lists-toggle {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid #4a4a4a;
    background: #2d2d2d;
    color: #cfd5e3;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.lists-toggle:hover { background: #353535; border-color: #5a5a5a; }

/* The active list's name, shown only while the strip is hidden (keeps context). */
.active-list-name { display: none; }
body.master-mode.lists-hidden .active-list-name {
    display: block;
    font-size: 13px;
    color: #9aa9bd;
    padding: 2px;
}
body.master-mode.lists-hidden .active-list-name b { color: #e0e0e0; }

/* Collapse the strip — only in master mode, so members never get stuck hidden. */
body.master-mode.lists-hidden .list-tabs { display: none; }

@media (max-width: 700px) {
    header { padding: 12px 14px; gap: 10px; }
    header h1 { font-size: 17px; }
    .main-content { padding: 10px; gap: 12px; }

    /* Stack the two columns; the whole section scrolls (not each column). */
    .checklists-section {
        flex-direction: column;
        overflow-y: auto;
        gap: 12px;
        -webkit-overflow-scrolling: touch;
    }
    .checklist-column { flex: 0 0 auto; overflow: visible; }
    .checklist-list { overflow-y: visible; max-height: none; padding: 10px; }
    .checklist-column h2 { padding: 12px 14px; font-size: 15px; }

    /* Roomier cards; reclaim the 30px indent for full-width content. */
    .checklist-item { padding: 14px; margin-bottom: 10px; }
    .checklist-item input[type="checkbox"] { width: 22px; height: 22px; }
    .checklist-item-title { font-size: 16px; }
    .checklist-item-description,
    .checklist-item-recurrence,
    .checklist-item-meta { margin-left: 0; }

    /* Edit / Move / Delete: wrap and fill the row as big tap targets. */
    .checklist-item-actions { margin-left: 0; margin-top: 14px; flex-wrap: wrap; gap: 8px; }
    .checklist-item-actions .btn { flex: 1 1 auto; min-width: 84px; padding: 11px 12px; font-size: 14px; }

    /* List tabs easier to tap. */
    .list-tab { padding: 12px 16px; }
}

@media (max-width: 700px) {
    .directory-editor {
        grid-template-columns: 1fr;
    }
}
