:root {
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1a1a1a;
    --muted: #6b7280;
    --border: #e2e5e9;
    --accent: #2563eb;
    --danger: #dc2626;
    --toast-bg: #22a55a;
    --prio-1: #dc2626;
    --prio-2: #f59e0b;
    --prio-3: #2563eb;
    --prio-4: #6b7280;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--card);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
}
.topbar #btn-home,
.topbar #btn-add,
.topbar #btn-projects {
    flex: none;
}
.topbar #btn-projects {
    margin-left: auto;
}

.priority-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.priority-nav-btn {
    flex: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px 10px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.priority-nav-btn .num {
    font-size: 18px;
    font-weight: 800;
}
.priority-nav-btn .lbl {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
}
.priority-nav-btn .cnt {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    background: var(--bg);
    border-radius: 8px;
    padding: 0 6px;
    min-width: 16px;
}
.priority-nav-btn.prio-1 { color: var(--prio-1); }
.priority-nav-btn.prio-2 { color: var(--prio-2); }
.priority-nav-btn.prio-3 { color: var(--prio-3); }
.priority-nav-btn.prio-4 { color: var(--prio-4); }
.priority-nav-btn.active { background: var(--bg); border-bottom-color: currentColor; }

.task-row .title a {
    color: var(--accent);
    text-decoration: underline;
    word-break: break-all;
}

.proj-badge {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--muted);
    margin-right: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.search-wrap {
    flex: none;
    width: 130px;
}
.search-wrap input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 13px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
}
.icon-btn:hover { background: var(--bg); }

.mail-import-btn { color: #22A55A; }
.mail-import-btn:hover { background: #22A55A; color: white; }
.mail-import-btn.busy { opacity: 0.5; pointer-events: none; }

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 12px;
}


/* Project grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.project-tile {
    background: var(--card);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: transform .1s ease;
}
.project-tile:active { transform: scale(0.97); }
.project-tile .name { font-weight: 600; font-size: 15px; }
.project-tile .count { color: var(--muted); font-size: 13px; margin-top: 4px; }
.project-tile .count-num { font-weight: 700; color: var(--accent); }

/* Task list */
.priority-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    overflow-x: auto;
}
.priority-tab {
    flex: none;
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.priority-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.task-row {
    background: var(--card);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-left: 4px solid var(--prio-4);
}
.task-row.prio-1 { border-left-color: var(--prio-1); }
.task-row.prio-2 { border-left-color: var(--prio-2); }
.task-row.prio-3 { border-left-color: var(--prio-3); }
.task-row.prio-4 { border-left-color: var(--prio-4); }
.task-row.done .title { text-decoration: line-through; color: var(--muted); }
.task-row .check.checked { background: var(--accent); border-color: var(--accent); }

.task-row .check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex: none;
}
.task-row .check:hover { border-color: var(--accent); }
.task-row .title {
    flex: 1;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}
.task-row .thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    flex: none;
}
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 30px 10px;
}

/* Neue-Aufgabe-Button im Header, links neben dem Start-Symbol */
.fab-inline {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 20px;
    line-height: 1;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* Toast */
.toast {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--toast-bg);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 100;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
    background: var(--card);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 0;
}
@media (min-width: 640px) {
    .modal { align-items: center; }
    .modal-card { border-radius: 16px; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.modal-body { padding: 14px 16px; }
.modal-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.field-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin: 12px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.field-label:first-child { margin-top: 0; }

select, textarea, input[type=text] {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 15px;
    font-family: inherit;
    background: var(--bg);
}
textarea { resize: vertical; }
.task-project-select { font-weight: 700; }
.task-title-preview {
    width: 100%;
    min-height: 220px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 15px;
    font-family: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: text;
}
.task-title-preview a {
    color: var(--accent);
    text-decoration: underline;
}

.priority-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.prio-btn {
    padding: 10px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: var(--card);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.prio-btn.prio-1.selected { background: var(--prio-1); color: white; border-color: var(--prio-1); }
.prio-btn.prio-2.selected { background: var(--prio-2); color: white; border-color: var(--prio-2); }
.prio-btn.prio-3.selected { background: var(--prio-3); color: white; border-color: var(--prio-3); }
.prio-btn.prio-4.selected { background: var(--prio-4); color: white; border-color: var(--prio-4); }

.image-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0;
}
.image-strip .img-wrap {
    position: relative;
    width: 72px;
    height: 72px;
}
.image-strip img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}
.image-strip .remove-img {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
}

.file-chip {
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    color: var(--text);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    padding: 4px;
    overflow: hidden;
    word-break: break-all;
}
.image-strip .file-chip {
    width: 72px;
    height: 72px;
    font-size: 11px;
}
.task-row .file-chip {
    width: 40px;
    height: 40px;
    font-size: 18px;
    flex: none;
}

.attach-row {
    margin: 10px 0;
    display: flex;
    gap: 8px;
}

.btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-danger { background: var(--danger); color: white; }
.hidden { display: none !important; }

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: zoom-out;
}
.lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 6px;
}

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--card);
    border-radius: 14px;
    padding: 28px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.login-card h1 {
    text-align: center;
    font-size: 22px;
    margin: 0 0 18px;
}
.login-error {
    background: #fee2e2;
    color: var(--danger);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 14px;
    text-align: center;
}
.password-field {
    position: relative;
}
.password-field input {
    padding-right: 42px;
}
.eye-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 8px;
}
.login-submit {
    width: 100%;
    margin-top: 18px;
    padding: 12px;
    font-size: 15px;
}

/* Project manage list */
.project-manage-list { display: flex; flex-direction: column; gap: 6px; }
.project-manage-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border-radius: 8px;
    padding: 8px 10px;
}
.project-manage-row input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 4px;
}
.project-manage-row .count {
    color: var(--muted);
    font-size: 12px;
    flex: none;
}
.project-manage-row .move-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
}
.inline-add { display: flex; gap: 8px; margin-top: 4px; }
.inline-add input { flex: 1; }
