/* Mobile-first refinements and controls layered over the base theme. */
.section-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.top-toolbar {
    position: sticky;
    top: 72px;
    z-index: 4;
    display: flex;
    justify-content: center;
    padding: 8px max(3vw, 16px);
    border-bottom: 1px solid var(--divider);
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 2px 5px rgba(0, 0, 0, .08);
    backdrop-filter: blur(8px);
}
.top-toolbar .section-controls {
    width: min(1180px, 100%);
    margin: 0;
    flex-wrap: nowrap;
}

.waste-calendar-bar {
    border-bottom: 1px solid var(--divider);
    background: #f8fcfe;
}
.waste-calendar-inner {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 8px 0;
}
.waste-collections {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.waste-collection {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 0;
    color: #424242;
}
.waste-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #eceff1;
    color: #455a64;
}
.waste-yellow .waste-icon { background: #fff8cf; color: #8a6d00; }
.waste-paper .waste-icon { background: #e1f5fe; color: #0277bd; }
.waste-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.waste-copy { display: grid; min-width: 0; line-height: 1.2; }
.waste-copy strong { overflow-wrap: anywhere; font-size: 13px; font-weight: 500; }
.waste-copy > span { color: var(--primary-dark); font-size: 13px; }
.waste-calendar-warning {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    text-align: center;
}

.brand { color: inherit; text-decoration: none; }
.app-icon { display: block; width: 42px; height: 42px; border-radius: 9px; flex: none; }
.brand:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 3px; }
.icon-button { padding: 0; line-height: 1; }
.icon-button svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-button.danger { color: var(--danger); }
.global-history-button { background: #e1f5fe; color: var(--primary-dark); }
.global-history-button:hover { background: #b3e5fc; }

.filter-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--primary);
    border-radius: 20px;
    color: var(--primary-dark);
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.filter-button > span[aria-hidden="true"] { font-size: 13px; }
.filter-button > span:not([aria-hidden="true"]),
.view-button > span:not([aria-hidden="true"]) { font-size: 13px; }
.filter-button.active { color: #fff; background: var(--primary); }
.view-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #9e9e9e;
    border-radius: 20px;
    background: #fff;
    color: #424242;
    font-size: 13px;
    white-space: nowrap;
}
.compact-view .view-button { border-color: var(--primary); background: #e1f5fe; color: var(--primary-dark); }
.view-label-mobile, .filter-label-mobile { display: none; }
.compact-view .task-card .card-actions,
.compact-view .task-card .task-meta,
.compact-view .task-card .due-date,
.compact-view .task-card .description { display: none; }
.compact-view .task-card h3 { margin-bottom: 0; }
.compact-view .task-footer { margin-top: 6px; padding-top: 6px; }

.task-card > form {
    display: flex;
    justify-content: flex-end;
}

.complete {
    width: auto;
    min-height: 36px;
    padding: 7px 13px;
    line-height: 1.2;
}

.task-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.task-heading h3 { min-width: 0; }
.task-heading .card-actions { flex: none; gap: 10px; margin: -4px -4px 4px 0; }
.task-heading .card-actions .open-delete { display: none; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 5px; }
.task-meta .badge { margin-right: 0; margin-left: auto; }
.task-meta.inline-description { align-items: flex-start; flex-wrap: nowrap; }
.task-meta.inline-description .description { min-width: 0; margin: 0; }
.task-meta.inline-description .badge { flex: none; }
.action-icon { display: inline-block; }
.take-over-icon {
    display: inline-block;
    width: 24px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}
.dialog-take-over-icon { width: 44px; height: 38px; }

@media (max-width: 720px) {
    body { padding-bottom: env(safe-area-inset-bottom); }
    .toast { top: calc(101px + env(safe-area-inset-top)); }
    main { margin: 6px auto 0; padding: 0 6px 24px; }
    .app-bar { padding: 0 8px; padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
    .top-toolbar {
        top: calc(52px + env(safe-area-inset-top));
        justify-content: flex-start;
        padding: 4px 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .top-toolbar::-webkit-scrollbar { display: none; }
    .waste-calendar-inner { width: 100%; padding: 5px 6px; }
    .waste-collections { gap: 3px; }
    .waste-collection { justify-content: flex-start; gap: 5px; }
    .waste-icon { width: 28px; height: 28px; }
    .waste-icon svg { width: 17px; height: 17px; }
    .waste-copy strong, .waste-copy > span { font-size: 11px; }
    .waste-calendar-warning { margin-top: 3px; font-size: 10px; }
    .brand { gap: 6px; }
    .app-icon { width: 30px; height: 30px; border-radius: 7px; }
    .brand h1 { font-size: 18px; }
    .brand small { display: none; }
    .user { gap: 4px; font-size: 13px; }
    .user .avatar { width: 28px; height: 28px; font-size: 12px; }
    .text-button { min-height: 36px; padding: 5px 6px; font-size: 12px; }
    .panel, .flash { padding: 10px; border-radius: 5px; }
    .section-title { align-items: flex-start; gap: 4px; flex-wrap: wrap; }
    .section-title .overline { margin-bottom: 1px; }
    .section-title h2 { margin-bottom: 2px; font-size: 18px; }
    .section-controls { width: 100%; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
    .top-toolbar .section-controls { width: max-content; min-width: 100%; flex-wrap: nowrap; margin: 0; }
    .top-toolbar .section-controls { gap: 4px; }
    .top-toolbar .count { min-width: 30px; height: 34px; padding: 0 7px; font-size: 12px; }
    .top-toolbar .icon-button { width: 36px; height: 36px; }
    .filter-button { min-height: 36px; padding: 5px 9px; gap: 5px; }
    .view-button { min-height: 36px; padding: 5px 9px; gap: 5px; }
    .view-label-full, .filter-label-full { display: none; }
    .view-label-mobile, .filter-label-mobile { display: inline; }
    .view-button, .filter-button { font-size: 13px; }
    .task-grid { gap: 7px; }
    .task-card { padding: 9px 10px; }
    .task-card.mine { padding-top: 7px; }
    .task-heading { gap: 5px; }
    .task-heading h3 { margin: 1px 0 3px; font-size: 16px; line-height: 1.22; }
    .task-heading .card-actions { gap: 7px; margin: -3px -3px 1px 0; }
    .task-heading .icon-button { position: relative; width: 34px; height: 34px; }
    .task-heading .icon-button::after { content: ""; position: absolute; inset: -4px; }
    .task-heading .icon-button svg { width: 18px; height: 18px; }
    .task-meta { gap: 5px; margin: 0 0 3px; font-size: 12px; line-height: 1.2; }
    .task-meta .badge { padding: 2px 7px; font-size: 11px; }
    .task-meta .due-date { margin: 0; font-size: 12px; }
    .description { display: block; margin: 0 0 4px; overflow: visible; font-size: 13px; line-height: 1.25; -webkit-line-clamp: unset; }
    .assignment { margin: 0; padding: 0; }
    .assignment .avatar { width: 27px; height: 27px; font-size: 12px; }
    .assignment strong { font-size: 13px; line-height: 1.15; }
    .task-actions .action-label { display: none; }
    .task-actions .action-icon { font-size: 22px; line-height: 1; }
    .task-actions .forward,
    .task-actions .take-over,
    .task-actions .complete {
        box-sizing: border-box;
        flex: 0 0 40px;
        width: 40px;
        min-width: 40px;
        max-width: 40px;
        height: 40px;
        min-height: 40px;
        max-height: 40px;
        padding: 0;
    }
    .task-actions .take-over-icon { width: 28px; height: 24px; }
    .complete { min-height: 36px; padding: 6px 9px; }
    input, select, textarea { min-height: 46px; font-size: 16px; }
    textarea { min-height: 90px; }
    .person-picks { gap: 9px; }
    .person-picks label > span { min-height: 44px; padding-right: 13px; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .button, .form-actions button { width: 100%; min-height: 46px; }
    .modal { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px 18px; }
    .identity-list button { min-height: 52px; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions button { min-height: 46px; width: 100%; }
}

@media (max-width: 380px) {
    .count { display: grid; }
    .filter-button { width: auto; justify-content: center; }
}

[hidden] { display: none !important; }

.task-grid { grid-template-columns: 1fr; align-items: start; }
.task-card { padding: 12px 14px; }
.task-card.mine { padding-top: 9px; }
.task-card.overdue { border-top: 4px solid var(--danger); padding-top: 9px; }
.task-card.due-today { border-top: 4px solid #fb8c00; padding-top: 9px; }
.task-card.as-needed { border-top: 4px solid #9e9e9e; padding-top: 9px; }
.task-card.due-future { border-top: 4px solid #43a047; padding-top: 9px; }
.card-actions { margin-bottom: 4px; }
.task-card h3 { margin-bottom: 5px; }
.description {
    flex: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 5px;
    line-height: 1.35;
}
.due-date { margin-top: 2px; }
.task-card.overdue .due-date {
    width: fit-content;
    padding: 3px 7px;
    border-radius: 4px;
    background: #fde8e7;
    color: #a52a22;
}
.task-card.due-today .due-date {
    width: fit-content;
    padding: 3px 7px;
    border-radius: 4px;
    background: #fff3e0;
    color: #a64b00;
}
.task-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid #eee;
    margin-top: 9px;
    padding-top: 9px;
}
.task-footer .assignment { border: 0; margin: 0; padding: 0; min-width: 0; }
.task-footer .assignment strong { overflow-wrap: anywhere; font-size: 15px; }
.task-footer form { display: block; flex: none; }
.task-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; flex: none; }
.task-actions button { width: auto; min-height: 36px; padding: 7px 11px; line-height: 1.2; white-space: nowrap; }
.forward { color: var(--primary-dark); background: #e1f5fe; }
.take-over { color: #8a4b08; background: #fff3e0; }
.icon-button.whatsapp-icon { color: #1da851; }
.icon-button.whatsapp-icon.disabled { color: #aaa; cursor: not-allowed; opacity: .65; }
.member-settings { display: grid; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--divider); }
.member-settings h3 { margin: 0; }
.member-setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--divider); border-radius: 5px; }
.member-setting.paused { background: #f5f5f5; }
.member-setting > form:first-child { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.member-setting .person-status-form { display: block; }
.member-setting .person-status-form button { min-width: 110px; }
.member-settings button { min-height: 43px; }
.people-list > .paused, .person-picks label.paused { opacity: .65; }
.management-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}
.tool-button {
    min-height: 42px;
    background: #fff;
    border: 1px solid var(--primary);
    color: var(--primary-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.tool-button:hover { background: #e1f5fe; }
#task-editor .form-actions .delete-button { margin-right: auto; }
.forms:has(> [hidden] + [hidden]) { display: none; }
.forms:has(#people-panel[hidden]) #task-editor,
.forms:has(#task-editor[hidden]) #people-panel { grid-column: 1 / -1; }
.history-dialog { text-align: left; }
.history-list { list-style: none; padding: 0; margin: 8px 0 20px; max-height: 52vh; overflow-y: auto; }
.history-list li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid #eee; }
.history-list li > span:last-child { display: grid; }
.history-list small { color: var(--muted); }
.history-dialog > button { display: block; margin-left: auto; }
.field-hint { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; }
.login-password { text-align: left; }
.identity-list button > span:last-child { display: grid; }
.identity-list button small { color: var(--muted); font-size: 11px; }
.login-error { padding: 8px 10px; border-radius: 4px; background: #fde8e7; color: #a52a22; font-size: 13px; }
.login-page { min-height: 100dvh; background: var(--primary); }
.login-shell { min-height: 100dvh; display: grid; place-items: center; margin: 0 auto; padding: 20px; }
.login-card { width: min(430px, 100%); text-align: center; }
.login-card h1 { margin: 8px 0 24px; color: var(--primary-dark); font-size: 28px; font-weight: 500; }
.login-card h2 { margin-bottom: 6px; }
.login-card > p { color: var(--muted); }
.login-app-icon { display: block; margin: 0 auto; border-radius: 13px; }
.login-submit { min-height: 44px; }
.toast {
    position: fixed;
    top: 86px;
    left: 50%;
    z-index: 15;
    width: max-content;
    max-width: calc(100vw - 32px);
    margin: 0;
    padding: 11px 18px;
    transform: translateX(-50%);
    background: rgba(50, 50, 50, .88);
    border: 0;
    border-radius: 5px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
    color: #fff;
    text-align: center;
    pointer-events: none;
    animation: toast-fade 3s ease forwards;
}
.toast.error { background: rgba(165, 42, 34, .9); }
@keyframes toast-fade {
    0%, 82% { opacity: 1; }
    100% { opacity: 0; }
}

@media (max-width: 720px) {
    .toast { top: calc(101px + env(safe-area-inset-top)); }
    .task-card { padding: 9px 10px; }
    .task-card.mine { padding-top: 7px; }
    .task-heading h3 { margin: 1px 0 3px; font-size: 16px; line-height: 1.22; }
    .task-heading .card-actions { margin: -3px -3px 1px 0; }
    .description {
        display: block;
        margin: 0 0 4px;
        overflow: visible;
        font-size: 13px;
        line-height: 1.25;
        -webkit-line-clamp: unset;
    }
    .task-footer { margin-top: 5px; padding-top: 5px; gap: 6px; }
    .task-footer .avatar { width: 40px; height: 40px; font-size: 16px; }
    .task-footer .assignment strong { font-size: 16px; }
    .task-actions { gap: 10px; }
    .task-actions button { min-height: 36px; padding: 6px 9px; font-size: 13px; }
    .management-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
    .tool-button { min-height: 46px; padding: 8px; }
    /* 15 px zusätzlicher Rand plus 8 px Flex-Abstand = halbe Buttonhöhe (23 px). */
    #task-editor .form-actions .delete-button { margin-top: 15px; margin-right: 0; }
}

@media (max-width: 390px) {
    .management-actions { grid-template-columns: 1fr; }
    .task-footer { align-items: center; flex-direction: row; }
    .task-footer .assignment { flex: 1 1 auto; }
    .task-actions { justify-content: flex-end; margin-left: auto; }
    .member-setting { grid-template-columns: 1fr; }
    .member-setting > form:first-child { grid-template-columns: 1fr; }
    .member-settings button { width: 100%; }
}
