:root {
    color-scheme: light dark;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    background: #f5f6f8;
    color: #1f2933;
}

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-size: 2rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-email {
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: #616e7c;
}

.logout-btn {
    border: none;
    background: #e4e7eb;
    color: #495057;
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    cursor: pointer;
}

.auth-screen {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 340px;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.6rem;
}

.auth-card h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: #616e7c;
    font-weight: 500;
}

.auth-error {
    color: #c92a2a;
    font-size: 0.85rem;
    margin: 0 0 0.75rem;
}

.auth-info {
    color: #2b8a3e;
    font-size: 0.85rem;
    margin: 0 0 0.75rem;
}

.auth-submit {
    display: block;
    width: 100%;
    border: none;
    background: #1f6feb;
    color: white;
    font-size: 0.95rem;
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-switch {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: #1f6feb;
    font-size: 0.85rem;
    padding: 0.3rem;
    cursor: pointer;
}

.trash-btn {
    border: none;
    background: #e4e7eb;
    color: #495057;
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: #e4e7eb;
    color: #616e7c;
}

.status.online {
    background: #d3f9d8;
    color: #2b8a3e;
}

.status.offline {
    background: #ffe3e3;
    color: #c92a2a;
}

.settings-menu {
    position: relative;
}

.settings-btn {
    border: none;
    background: #e4e7eb;
    color: #495057;
    font-size: 0.95rem;
    line-height: 1;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 999px;
    cursor: pointer;
}

.settings-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    min-width: 220px;
    z-index: 20;
    overflow: hidden;
}

.settings-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.settings-item:hover {
    background: #f1f3f5;
}

.google-import-lists {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
}

.google-import-lists li {
    padding: 0.3rem 0;
}

.breadcrumbs {
    margin: 1rem 0;
    font-size: 0.9rem;
}

.breadcrumbs a {
    color: #1f6feb;
    cursor: pointer;
}

.breadcrumbs .sep {
    margin: 0 0.35rem;
    color: #9aa5b1;
}

.up-btn {
    border: none;
    background: #e4e7eb;
    color: #1f2933;
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.5rem;
}

.composer {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.composer input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cbd2d9;
    border-radius: 6px;
    font-size: 1rem;
}

.composer button {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    background: #1f6feb;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.composer button.toggle {
    background: #e4e7eb;
    color: #1f2933;
}

.composer button.toggle.active {
    background: #f7b32b;
    color: #1f2933;
}

.composer-bar {
    margin-bottom: 1rem;
}

.show-hidden {
    display: block;
    font-size: 0.85rem;
    color: #616e7c;
    margin-bottom: 0.75rem;
}

.items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.item {
    background: white;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.8rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.item.hidden-row {
    opacity: 0.5;
}

.item.drag-over {
    outline: 2px dashed #1f6feb;
    outline-offset: 2px;
}

.item-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.drag-handle {
    display: flex;
    align-items: center;
    color: #9aa5b1;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.item-title-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.item-text {
    cursor: pointer;
}

.item.done .item-text {
    text-decoration: line-through;
    color: #9aa5b1;
}

.item-notes-preview {
    font-size: 0.75rem;
    color: #9aa5b1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-icon {
    color: #7048e8;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.list-icon {
    color: #1f6feb;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.child-count {
    font-size: 0.7rem;
    color: #616e7c;
    background: #e4e7eb;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    min-width: 1em;
    text-align: center;
}

.unsynced-count {
    font-size: 0.7rem;
    color: #fff;
    background: #c92a2a;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    min-width: 1em;
    text-align: center;
    margin-left: 0.35rem;
}

.more-btn,
.edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #9aa5b1;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0.25rem;
    border-radius: 4px;
}

.more-btn:hover,
.edit-btn:hover {
    background: #f1f3f5;
    color: #495057;
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.item-actions button {
    border: none;
    background: #f1f3f5;
    color: #495057;
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
    cursor: pointer;
}

.item-actions .remove {
    color: #c92a2a;
}

.notes {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #cbd2d9;
    font-family: inherit;
    font-size: 0.85rem;
    min-height: 3rem;
    resize: vertical;
}

.picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.6rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.picker-current {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.picker-current-label {
    color: #9aa5b1;
}

.picker-current-text {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-search {
    display: flex;
    gap: 0.4rem;
}

.picker-search input {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.5rem;
    border: 1px solid #cbd2d9;
    border-radius: 4px;
    font-size: 0.8rem;
}

.show-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid #cbd2d9;
    background: white;
    color: #616e7c;
    border-radius: 4px;
    padding: 0.3rem;
    cursor: pointer;
}

.show-all-btn.active {
    background: #1f6feb;
    border-color: #1f6feb;
    color: white;
}

.picker-results {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.picker-results button {
    border: 1px solid #cbd2d9;
    background: white;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.picker .hint {
    font-size: 0.75rem;
    color: #9aa5b1;
}

.empty {
    color: #9aa5b1;
    text-align: center;
    margin-top: 2rem;
}

.confirm-remove {
    margin-top: 0.5rem;
    padding: 0.6rem;
    background: #fff5f5;
    border: 1px solid #ffc9c9;
    border-radius: 6px;
    font-size: 0.85rem;
}

.confirm-remove p {
    margin: 0 0 0.5rem;
}

.confirm-children {
    display: block;
    margin-bottom: 0.5rem;
}

.confirm-actions {
    display: flex;
    gap: 0.5rem;
}

.confirm-actions button {
    border: none;
    background: #e4e7eb;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
}

.confirm-actions button.remove {
    background: #c92a2a;
    color: white;
}

.editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 20;
}

.editor {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.editor.editor-large {
    max-width: 640px;
}

.editor h2 {
    margin-top: 0;
}

.editor-field {
    display: block;
    margin-bottom: 0.75rem;
}

.editor-field span {
    display: block;
    font-size: 0.8rem;
    color: #616e7c;
    margin-bottom: 0.25rem;
}

.editor-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem;
    border: 1px solid #cbd2d9;
    border-radius: 4px;
    font-size: 1rem;
}

.editor-type {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.editor-type-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.editor-notes-field .notes {
    min-height: 4rem;
    transition: min-height 0.15s ease;
}

.editor-notes-field .notes.notes-large {
    min-height: 12rem;
}

.editor.editor-large .editor-notes-field .notes {
    min-height: 16rem;
}

.editor-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.editor-type button,
.editor-secondary-actions button,
.editor-actions button {
    border: none;
    background: #e4e7eb;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}

.editor-secondary-actions .remove {
    color: #c92a2a;
}

.editor-meta {
    font-size: 0.75rem;
    color: #9aa5b1;
    margin-bottom: 1rem;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.trash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1rem 0;
}

.trash-header button {
    border: none;
    background: #e4e7eb;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
}

.trash-item .item-main {
    cursor: default;
}

.admin-user-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-user-row {
    background: white;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.admin-user-email {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.admin-user-status {
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.admin-user-status.status-pending {
    background: #fff3bf;
    color: #7d5a00;
}

.admin-user-status.status-approved {
    background: #d3f9d8;
    color: #2b8a3e;
}

.admin-user-status.status-disabled {
    background: #ffe3e3;
    color: #c92a2a;
}

.admin-user-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: #d0ebff;
    color: #1864ab;
}

.admin-user-you {
    font-size: 0.75rem;
    color: #9aa5b1;
}

.admin-user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.admin-user-actions button {
    border: none;
    background: #e4e7eb;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.admin-user-actions button.remove {
    color: #c92a2a;
}

@media (max-width: 600px) {
    .app {
        padding-bottom: 6rem;
    }

    .composer-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
        background: #f5f6f8;
        box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.1);
        z-index: 10;
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background: #1f2933;
        color: #f5f6f8;
    }
    .item {
        background: #323f4b;
    }
    .composer input {
        background: #323f4b;
        color: #f5f6f8;
        border-color: #52606d;
    }
    .composer button.toggle {
        background: #52606d;
        color: #f5f6f8;
    }
    .item-actions button {
        background: #3e4c59;
        color: #cbd2d9;
    }
    .notes {
        background: #3e4c59;
        color: #f5f6f8;
        border-color: #52606d;
    }
    .picker {
        background: #2c3947;
    }
    .picker-results button,
    .picker-search input,
    .show-all-btn {
        background: #3e4c59;
        border-color: #52606d;
        color: #f5f6f8;
    }
    .show-all-btn.active {
        background: #1f6feb;
        border-color: #1f6feb;
    }
    .status {
        background: #3e4c59;
        color: #cbd2d9;
    }
    .trash-btn,
    .up-btn,
    .child-count,
    .trash-header button,
    .confirm-actions button,
    .editor-type button,
    .editor-secondary-actions button,
    .editor-actions button {
        background: #3e4c59;
        color: #cbd2d9;
    }
    .confirm-remove {
        background: #3e2a2a;
        border-color: #5c2b2b;
    }
    .editor {
        background: #323f4b;
        color: #f5f6f8;
    }
    .editor-field input {
        background: #3e4c59;
        color: #f5f6f8;
        border-color: #52606d;
    }
    .composer-bar {
        background: #1f2933;
    }
    .auth-card {
        background: #323f4b;
        color: #f5f6f8;
    }
    .auth-card h2 {
        color: #cbd2d9;
    }
    .user-email,
    .logout-btn {
        background: transparent;
        color: #cbd2d9;
    }
    .settings-btn {
        background: #3e4c59;
        color: #cbd2d9;
    }
    .settings-dropdown {
        background: #323f4b;
        border-color: #52606d;
    }
    .settings-item {
        color: #f5f6f8;
    }
    .settings-item:hover {
        background: #3e4c59;
    }
    .item-notes-preview {
        color: #9aa5b1;
    }
    .drag-handle,
    .more-btn,
    .edit-btn {
        color: #9aa5b1;
    }
    .more-btn:hover,
    .edit-btn:hover {
        background: #3e4c59;
        color: #f5f6f8;
    }
    .admin-user-row {
        background: #323f4b;
    }
    .admin-user-actions button {
        background: #3e4c59;
        color: #cbd2d9;
    }
}
