* {
    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;
    overflow: hidden;
    touch-action: manipulation;
}

.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;
}

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);
}

.tab-button:hover {
    background: #2b2b2b;
}

.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);
}

.list-tab:hover {
    background: #2d2d2d;
}

.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;
}

.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;
}

/* 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;
}
