﻿/* ========== DESIGN TOKENS ========== */
:root {
    /* === Tła === */
    --color-bg-body: #f2f3f5;
    --color-bg-app: #eceff3;
    --color-bg-panel: #f6f7f9;
    --color-bg-content: #f8f6ef;
    --color-bg-input: #ffffff;

    /* === Teksty === */
    --color-text-primary: #111111;
    --color-text-secondary: #333333;
    --color-text-muted: #6b7280;

    /* === Ramki === */
    --color-border-default: #d7dbe3;
    --color-border-input: #cfd5df;

    /* === Akcent (Sherlock Navy) === */
    --color-accent: #1b3a5c;
    --color-accent-bg-hover: #E8EEF5;
    --color-accent-border-hover: #5C7FA3;

    /* === Sukces === */
    --color-success-bg: #e7f6ec;
    --color-success-border: #7fcf9b;
    --color-success-text: #145c2e;
    --color-success-icon: #4caf50;

    /* === Błąd === */
    --color-danger: #dc2626;

    /* === Dark mode preparation (Etap 1) === */
    --color-on-accent: #ffffff;
    --color-risk-low: #16a34a;
    --color-risk-med: #d97706;

    /* Row backgrounds (Etap 4b dark mode) */
    --color-row-inbox-base: #f5eddc;
    --color-row-inbox-hover: #ecdcc0;
    --color-row-outbox-base: #e2eef8;
    --color-row-outbox-hover: #ccdff0;
}

/* ===== DARK MODE PALETTE (Etap 2) ===== */
[data-theme="dark"] {
    /* Backgrounds — grafitowe tło */
    --color-bg-body: #1a1a1a;
    --color-bg-app: #242424;
    --color-bg-panel: #2a2a2a;
    --color-bg-content: #1f1f1f;
    --color-bg-input: #333333;

    /* Texts — jasne ale nie oślepiające */
    --color-text-primary: #e5e5e5;
    --color-text-secondary: #c0c0c0;
    --color-text-muted: #8a8a8a;

    /* Borders — widoczne ale nie razi */
    --color-border-default: #404040;
    --color-border-input: #4a4a4a;

    /* Accent — Sherlock Navy jaśniejszy dla kontrastu */
    --color-accent: #4a7ba8;
    --color-accent-bg-hover: #2a3a50;
    --color-accent-border-hover: #6a8fb0;

    /* Success — jaśniejsza zieleń */
    --color-success-bg: #1a2e22;
    --color-success-border: #3a7a4f;
    --color-success-text: #6fd68a;
    --color-success-icon: #5ac96a;

    /* Danger — jaśniejsza czerwień */
    --color-danger: #f26260;

    /* On-accent — biały tekst zostaje */
    --color-on-accent: #ffffff;

    /* Risk badges — jaśniejsze dla kontrastu na ciemnym tle */
    --color-risk-low: #2dcf65;
    --color-risk-med: #f5a23a;

    /* Row backgrounds (Etap 4b) — ciemne odpowiedniki */
    --color-row-inbox-base: #3a2f1f;
    --color-row-inbox-hover: #4a3d28;
    --color-row-outbox-base: #1f2e40;
    --color-row-outbox-hover: #2a3d55;
}

/* ========== RESET / BAZA ========== */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-feature-settings: "cv11", "ss03", "calt";
    background: var(--color-bg-body);
    color: var(--color-text-primary);
}

.hidden {
    display: none !important;
}

/* ========== KONTENER APLIKACJI ========== */
.app-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    min-height: 0;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    padding: 7.6px;
    background: var(--color-bg-app);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ========== HEADER (Sherlock + flagi) ========== */
.app-header {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-panel);
}

.app-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ===== FLAGI JĘZYKÓW ===== */
.language-bar {
    display: flex;
    gap: 6px;
    align-items: center;
}

.lang-flag {
    width: 20px;
    height: 12px;
    object-fit: cover;
    cursor: pointer;
    border-radius: 2px;
    opacity: 0.75;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

    .lang-flag:hover {
        opacity: 1;
    }

    .lang-flag.active {
        opacity: 1;
        box-shadow: 0 0 0 1px var(--color-success-icon);
    }

/* ===== IKONA USTAWIEŃ (ZĘBATKA) ===== */
.settings-icon {
    font-size: 16px;
    cursor: pointer;
    user-select: none;
    opacity: 0.75;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

    .settings-icon:hover {
        opacity: 1;
    }

    .settings-icon:active {
        transform: scale(0.95);
    }

/* ===== THEME TOGGLE ICON (Etap 3 dark mode) ===== */
.theme-toggle-icon {
    cursor: pointer;
    user-select: none;
    opacity: 0.9;
    transition: opacity 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-icon:hover {
    opacity: 1;
}

.theme-toggle-icon:active {
    transform: scale(0.9);
}

/* Tryb jasny aktywny → pokazuje CIEMNE kółeczko (kliknij = pójdziesz w ciemny) */
:root {
    --theme-toggle-fill: #1a1a1a;
    --theme-toggle-border: #1b3a5c;
}

/* Tryb ciemny aktywny → pokazuje JASNE kółeczko (kliknij = wrócisz do jasnego) */
[data-theme="dark"] {
    --theme-toggle-fill: #ffffff;
    --theme-toggle-border: #ffffff;
}

/* ========== MAIN (okno + klucz) ========== */
.main-area {
    margin-top: 7.6px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 0;
}

/* okno aktywne */
.content-window {
    flex: 1 1 0;
    min-height: 0;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-content);
    padding: 10px;
    overflow: hidden;
    position: relative;
}

.content-placeholder {
    font-size: 12px;
    color: var(--color-text-muted);
    text-align: center;
    padding: 20px;
    line-height: 1.5;
}

/* ========== BANNER "TWÓJ SHERLOCK ID" ========== */
.share-id-banner {
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: 8px;
    padding: 20px;
    margin: 24px auto 0 auto;
    max-width: 360px;
}

.share-id-title {
    color: var(--color-accent);
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 8px;
}

.share-id-desc {
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.share-id-value {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    color: var(--color-text-primary);
    background: var(--color-bg-content);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 14px;
    text-align: center;
    letter-spacing: 0.02em;
}

.share-id-actions {
    display: flex;
    gap: 8px;
}

.share-id-btn {
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

.share-id-btn-primary {
    background: var(--color-accent);
    color: #fff;
    border: none;
}

.share-id-btn-secondary {
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
}

.share-id-hint {
    font-size: 11px;
    color: var(--color-success-icon);
    display: block;
    text-align: center;
    margin-top: 8px;
    min-height: 14px;
}

/* === Etykiety pod ikonami akcji (B.2) === */
.action-label {
    font-size: 10px;
    font-weight: 400;
    color: var(--color-text-muted);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    pointer-events: none;
    user-select: none;
}

/* === Toggle Switch (B.4 — Powiadomienia) === */
.notif-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    cursor: pointer;
    vertical-align: middle;
}

.notif-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.notif-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-border-default);
    border-radius: 30px;
    transition: background 0.2s ease;
}

.notif-toggle-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}

.notif-toggle input:checked + .notif-toggle-slider {
    background: var(--color-accent);
}

.notif-toggle input:checked + .notif-toggle-slider::before {
    transform: translateX(22px);
}

.notif-toggle input:disabled + .notif-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.notif-toggle input:disabled {
    cursor: not-allowed;
}

.notif-toggle:has(input:disabled) {
    cursor: not-allowed;
}

/* pasek aktywnego klucza */
.active-key-bar {
    margin-top: 7.6px;
    height: 35px;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-panel);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    color: var(--color-text-muted);
}

/* monospace dla Sherlock ID i kluczy */
#settingsSherlockId {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    letter-spacing: 0.02em;
}

#contactSherlockIdInput {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    letter-spacing: 0.02em;
}

/* ========== PRZYCISKI AKCJI (2 rzędy po 4) ========== */
.action-buttons {
    margin-top: 7.6px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7.6px;
}

.action-btn i {
    color: var(--color-accent);
    font-size: 22px;
}

.action-btn {
    height: 60px;
    border-radius: 4px;
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-input);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    cursor: pointer;
    transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease, border-color 120ms ease;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

    .action-btn:active {
        transform: translateY(1px);
        background: var(--color-accent-bg-hover);
        border-color: var(--color-accent-border-hover);
        box-shadow: 0 0 0 2px rgba(27, 58, 92, 0.18);
    }

    .action-btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.25);
        border-color: var(--color-accent-border-hover);
    }

/* ===== IKONY PRZYCISKÓW ===== */
.btn-icon {
    max-width: 20px;
    max-height: 20px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    pointer-events: none;
}

#btnContacts .btn-icon,
#btnDelete .btn-icon,
#btnGallery .btn-icon {
    max-width: 26px;
    max-height: 26px;
}

#modeBtn .btn-icon,
#modeBtn svg {
    max-width: 26px;
    max-height: 26px;
}

#btnEncrypt {
    touch-action: manipulation;
}

#btnEncrypt .btn-icon,
#btnDecrypt .btn-icon {
    max-width: 30px;
    max-height: 30px;
}

#btnCamera .btn-icon,
#btnSave .btn-icon {
    max-width: 35px;
    max-height: 35px;
}

.key-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
    pointer-events: none;
    filter: grayscale(1) brightness(0);
}

/* ========== MODALE – BAZA ========== */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    display: block;
    padding: 0;
    z-index: 999;
}

.modal-sheet {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background: var(--color-bg-app);
    border: 0;
    border-radius: 4px;
    box-shadow: none;
    padding: 7.6px;
    display: flex;
    flex-direction: column;
    gap: 7.6px;
}

    .modal-sheet.small {
        min-height: unset;
        width: 247px;
    }

/* v68: #communityModal — wycentrowany, auto-height, capped width.
   Override globalnego .modal-sheet (full-height) bez zmian innych modali. */
#communityModal.modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#communityModal .modal-sheet.small {
    position: relative;
    width: 90%;
    max-width: 320px;
    height: auto;
    min-height: unset;
}

.modal-header {
    height: 30px;
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-panel);
    border-radius: 4px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-input {
    height: 22px;
    width: 90px;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    padding: 0 6px;
    font-size: 12px;
    background: var(--color-bg-input);
    color: var(--color-text-primary);
}

/* ===== PRZYCISKI ✓ / ✕ ===== */
.icon-btn {
    width: 22px;
    height: 22px;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    background: var(--color-bg-input);
    display: grid;
    place-items: center;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    opacity: 0.9;
    color: var(--color-text-primary);
}

    .icon-btn.confirm {
        background: var(--color-success-bg);
        border-color: var(--color-success-border);
        color: var(--color-success-text);
    }

    .icon-btn.cancel {
        background: #fbeaea;
        border-color: #e0a1a1;
        color: #7a1f1f;
    }

    .icon-btn:active {
        transform: translateY(1px);
    }

.close-x {
    font-size: 12px;
}

/* ===== MODAL BODY ===== */
.modal-body {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-content);
    padding: 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ===== LISTA KONTAKTÓW ===== */
.list {
    height: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    .list::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

.contact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 2px;
    border: 0;
    background: transparent;
    border-radius: 4px;
    user-select: none;
    cursor: pointer;
}

    .contact-row:hover {
        background: rgba(225, 235, 255, 1);
    }

    .contact-row.active {
        padding: 6px;
        background: rgba(235, 242, 255, 0.8);
        border: 1px solid var(--color-border-default);
    }

.contact-name {
    font-size: 12px;
    font-weight: 600;
}

.contact-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ===== WERYFIKACJA ===== */
.verify-dot {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--color-border-input);
    background: #ffd7a8;
    display: grid;
    place-items: center;
    font-size: 10px;
    cursor: pointer;
}

    .verify-dot.verified {
        background: #b7f3c6;
    }

.trash-btn {
    width: 16px;
    height: 16px;
    border: 0;
    background: transparent;
    display: grid;
    place-items: center;
    font-size: 13px;
    cursor: pointer;
    opacity: 0.75;
}

    .trash-btn:active {
        opacity: 1;
    }

.verify-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
}

/* ===== WERYFIKACJA: MODAL ===== */
#verifyModal.modal-overlay {
    background: transparent;
    display: block;
    padding: 0;
}

#verifyModal .modal-sheet.small.verify-float {
    position: absolute;
    top: 7.6px;
    left: 7.6px;
    right: 7.6px;
    width: auto;
    height: auto;
    min-height: 0;
    background: var(--color-border-default);
}

#verifyModal .verify-row {
    display: flex;
    gap: 7.6px;
    align-items: center;
}

#verifyModal .verify-input {
    flex: 1;
    width: auto;
}

#verifyModal .verify-handle {
    cursor: grab;
}

    #verifyModal .verify-handle:active {
        cursor: grabbing;
    }

/* ===== DUPLIKAT: MINI OSTRZEŻENIE ===== */
#dupModal.modal-overlay {
    background: transparent;
    display: block;
    padding: 0;
}

#dupModal .modal-sheet.small.dup-sheet {
    position: absolute;
    top: 7.6px;
    left: 7.6px;
    right: 7.6px;
    width: auto;
    height: auto;
    min-height: 0;
    background: #fff4ea;
    border: 1px solid #f0b27a;
}

#dupModal .dup-text {
    font-size: 12px;
    font-weight: 600;
    color: #8a4b12;
}

/* ===== POCZTA KONTAKTU ===== */
.mail-toolbar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    justify-items: center;
}

/* ===== DISAPPEARING TIMER ===== */
.disappear-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.disappear-toggle {
    font-size: 22px !important;
    filter: grayscale(0);
    position: relative; /* kotwica dla .clock-hands-overlay (dark mode) */
}

.disappear-toggle.active {
    color: var(--color-danger);
    filter: none;
    transform: scale(1.1);
}

/* Dark-mode-only overlay: białe wskazówki SVG przykrywają ciemne wskazówki PNG-a routine.png.
   PNG (kolorowy) zostaje nieruszony w light mode; w dark mode tylko wskazówki dostają biały
   kontur, by były czytelne na ciemnym tle. pointer-events:none → klik trafia w button. */
.clock-hands-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
}

[data-theme="dark"] .clock-hands-overlay {
    display: block;
}

.disappear-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-bg-input);
    border: 1px solid #c0c4cc;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    padding: 6px 0;
    z-index: 9999;
    min-width: 130px;
    white-space: nowrap;
}

.disappear-menu .disappear-option {
    display: block;
    width: 100%;
    padding: 9px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    color: var(--color-text-secondary);
    font-family: inherit;
    line-height: 1.3;
}

.disappear-menu .disappear-option:hover {
    background: #eef1f6;
}

.disappear-menu .disappear-option.selected {
    font-weight: 700;
    color: var(--color-danger);
    background: #fef2f2;
}

.mail-window {
    flex: 1;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-content);
    padding: 10px;
    overflow: hidden;
}

.mail-key-btn {
    height: 22px;
    padding: 0 8px;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    background: var(--color-bg-input);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
}

#mailModal .modal-header {
    gap: 6px;
}

#mailTitle {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mailModal .modal-actions {
    flex-shrink: 0;
}

#mailModal .mail-key-btn {
    height: 22px;
    padding: 0 6px;
    font-size: 10px;
    white-space: nowrap;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== KLUCZ: MODAL ===== */
#keyModal.modal-overlay {
    background: transparent;
    display: block;
    padding: 0;
}

#keyModal .modal-sheet.small.key-float {
    position: absolute;
    top: 7.6px;
    left: 7.6px;
    right: 7.6px;
    width: auto;
    height: 220px;
    min-height: 0;
    overflow: visible;
    background: #e2e6ec;
}

#keyModal .key-body {
    position: relative;
    flex: 1;
    background: var(--color-bg-content);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#keyModal .key-row {
    display: flex;
    gap: 7.6px;
    align-items: center;
    margin-bottom: 7.6px;
}

#keyModal .key-input {
    width: 100%;
    flex: 1;
    font-size: 14px;
    font-weight: 400;
}

#keyModal .key-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    #keyModal .key-list::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

.key-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-input);
    border-radius: 4px;
    user-select: none;
}

.key-text {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.key-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.key-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--color-border-input);
    background: var(--color-border-default);
    cursor: pointer;
}

    .key-dot.active {
        background: #7ee19b;
        border-color: #59c67c;
    }

.key-trash {
    width: 16px;
    height: 16px;
    border: 0;
    background: transparent;
    display: grid;
    place-items: center;
    font-size: 13px;
    cursor: pointer;
    opacity: 0.75;
}

    .key-trash:active {
        opacity: 1;
    }

/* ===== Inline notatka pod kluczem ===== */
.key-note-row {
    position: absolute;
    left: 12px;
    right: 12px;
    z-index: 999;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-input);
}

.key-note-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
}

.key-note-counter {
    font-size: 12px;
    color: var(--color-text-muted);
}

.key-note-actions {
    display: flex;
    gap: 6px;
}

.key-note-btn {
    width: 26px;
    height: 20px;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

    .key-note-btn:active {
        transform: translateY(1px);
    }

.key-note-textarea {
    width: 100%;
    height: 38px;
    resize: none;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    padding: 6px;
    font-size: 14px;
    outline: none;
}

    .key-note-textarea:focus {
        border-color: var(--color-accent-border-hover);
        box-shadow: 0 0 0 2px rgba(27, 58, 92, 0.15);
    }

/* ===== INPUT CLEAN FIX ===== */
input,
textarea {
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

    input:focus,
    textarea:focus {
        outline: none !important;
        box-shadow: none !important;
    }

    input:invalid,
    textarea:invalid {
        box-shadow: none !important;
    }

input {
    -webkit-text-decoration-skip: none;
    text-decoration: none;
}

/* ===== MAIN: tryby (tekst / zdjęcie) ===== */
.main-text {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text-primary);
    outline: none;
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

#mainImage {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}

/* ===== POCZTA: HARD STOP na poziomy scroll ===== */
#mailMessages,
#mailOutboxList,
.mail-window {
    overflow-x: hidden !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

    #mailMessages > *,
    #mailOutboxList > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    #mailMessages *,
    #mailOutboxList * {
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

#mailMessages {
    height: 100%;
    max-height: 100%;
}

#mailMessages,
#mailOutboxList {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    #mailOutboxList > * {
        margin-bottom: 3px;
    }

    #mailMessages::-webkit-scrollbar,
    #mailOutboxList::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }

    #mailOutboxList div {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    #mailOutboxList div::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }

/* ===== MODAL LOGOWANIA ===== */
#authModal.modal-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#authModal .modal-sheet {
    width: 100%;
    height: 100%;
    background: var(--color-bg-app);
    border-radius: 4px;
    padding: 7.6px;
    display: flex;
    flex-direction: column;
    gap: 7.6px;
}

#authModal .modal-header {
    height: 30px;
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-panel);
    border-radius: 4px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#authModal .modal-title {
    font-size: 14px;
    font-weight: 700;
}

#authModal .modal-body {
    flex: 1;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-content);
    padding: 10px;
    overflow: hidden;
}

#authModal .modal-input {
    height: 22px;
    width: 100%;
    border: 1px solid var(--color-border-input);
    border-radius: 4px;
    padding: 0 6px;
    font-size: 12px;
    background: var(--color-bg-input);
    box-sizing: border-box;
}

#authModal .action-btn {
    height: 40px;
    font-size: 12px;
}

/* ===== PRZYCISKI W POCZCIE ===== */
.mail-tab {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    outline: none;
}

    .mail-tab:focus {
        outline: none;
    }

    .mail-tab:active {
        transform: scale(0.95);
    }

/* ===== KAMERA ===== */
.camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.capture-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    border: 4px solid var(--color-bg-input);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

    .capture-btn:active {
        transform: translateX(-50%) scale(0.95);
    }

.capture-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--color-bg-input);
    border: 3px solid var(--color-text-primary);
}

/* ===== USTAWIENIA: TABY ===== */
.settings-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7.6px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.settings-tab {
    height: 40px;
    font-size: 8px;
    padding: 4px 2px;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    width: 100%;
    min-width: 0;
    color: var(--color-text-primary);
}



.settings-content {
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    .settings-content::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

.settings-panel {
    display: block;
}

    .settings-panel.hidden {
        display: none;
    }

.settings-inline-center {
    padding: 20px 10px;
    text-align: center;
}

    .settings-inline-center .modal-input {
        width: 100%;
        max-width: 220px;
        margin: 0 auto;
        display: block;
    }
/* ===== SUBSKRYPCJA ===== */
.sub-current {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 13px;
}

.sub-current-label {
    color: var(--color-text-muted);
}

.sub-current-name {
    font-weight: 700;
    color: var(--color-success-text);
}

.sub-plan {
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-input);
    padding: 8px 10px;
    margin-bottom: 7.6px;
}

.sub-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.sub-plan-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-primary);
}

.sub-plan-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
}

.sub-plan-details {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.sub-plan-status {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    padding: 4px 0;
    border-radius: 4px;
}

    .sub-plan-status.sub-active {
        background: var(--color-success-bg);
        color: var(--color-success-text);
        border: 1px solid var(--color-success-border);
    }

.sub-plan.inactive {
    opacity: 0.45;
    pointer-events: none;
}

.sub-plan.active-plan {
    border-color: var(--color-success-border);
    border-width: 2px;
    box-shadow: 0 0 0 1px rgba(127,207,155,0.3);
}

.sub-plan-btn {
    width: 100%;
    height: 28px;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-input);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

    .sub-plan-btn:active {
        background: var(--color-accent-bg-hover);
        border-color: var(--color-accent-border-hover);
    }

.sub-days {
    margin-top: 4px;
    padding: 6px 10px;
    font-size: 10px;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-input);
    display: flex;
    justify-content: space-between;
}

/* ===== STRIPE BADGE (#16 z raportu PM/2026/001) ===== */
.stripe-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    margin-top: 16px;
    background: var(--color-bg-content);
    border: 1px solid var(--color-border-default);
    border-radius: 6px;
    color: var(--color-text-secondary);
    font-size: 11px;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.stripe-badge:hover {
    opacity: 1;
}

.stripe-badge-logo {
    height: 18px;
    width: auto;
    flex: 0 0 auto;
    color: #425466;
}

.stripe-badge-text {
    line-height: 1.3;
    text-align: left;
}

/* Dark mode — logo Stripe jasne i dobrze widoczne */
[data-theme="dark"] .stripe-badge-logo {
    color: #ffffff;
    opacity: 1;
}

/* ===== PRYWATNOŚĆ ===== */
.privacy-content {
    padding: 4px;
}

.privacy-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--color-text-primary);
}

.privacy-heading {
    font-size: 15px;
    font-weight: 700;
    margin-top: 10px;
    margin-bottom: 4px;
    color: var(--color-text-secondary);
}

.privacy-section {
    font-size: 13px;
    line-height: 1.5;
    color: #555;
}
/* ===== AUTO-LOCK GRID ===== */
.autolock-option {
    width: 45px;
    height: 45px;
    border: 1px solid var(--color-border-default);
    border-radius: 6px;
    background: #f0f1f4;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    margin: 0 auto;
}
.autolock-option.selected {
    background: rgba(76, 175, 80, 0.15);
    color: var(--color-success-icon);
    border: 2px solid var(--color-success-icon);
}
@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}
.autolock-fade {
    animation: fadeOut 2s forwards;
}

/* ===== MIKROFON AKTYWNY ===== */
.speech-active {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 2px rgba(231,76,60,0.3) !important;
}

/* ===== UNREAD ENVELOPE ICON ===== */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.2; }
}
.envelope-icon {
    display: inline-block;
    width: 14px;
    height: 10px;
    flex: 0 0 auto;
    vertical-align: middle;
    animation: blink 1.2s ease-in-out infinite;
}
.envelope-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================= C.5 — Toast + Confirm ============================= */

/* Container dla stosu toastow */
#toastContainer {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

/* Pojedynczy toast */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: 400px;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  line-height: 1.4;
  color: #ffffff;
  pointer-events: auto;
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}
.toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-error {
  background: var(--color-danger);
}

.toast-info {
  background: var(--color-accent);
}

.toast-success {
  background: #16a34a;
}

.toast-text {
  flex: 1;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
}

.toast-close:hover {
  color: #ffffff;
}

/* Mobile — stack od gory, pelna szerokosc */
@media (max-width: 480px) {
  #toastContainer {
    top: 8px;
    right: 8px;
    left: 8px;
    max-width: none;
  }
  .toast {
    max-width: none;
    min-width: 0;
  }
}

/* Confirm overlay */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-dialog {
  background: #ffffff;
  border-radius: 10px;
  padding: 20px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.confirm-message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-primary);
  margin-bottom: 18px;
  word-break: break-word;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-width: 80px;
}

.confirm-btn-ok {
  background: var(--color-accent);
  color: #ffffff;
  border: 1px solid var(--color-accent);
}

.confirm-btn-ok:hover {
  opacity: 0.9;
}

.confirm-btn-cancel {
  background: #ffffff;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.confirm-btn-cancel:hover {
  background: var(--color-bg-content);
}

/* ============================= C.4 — Contacts empty state ============================= */

.contacts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  color: var(--color-text-muted);
}

.contacts-empty-arrow {
  font-size: 28px;
  color: var(--color-accent);
  opacity: 0.6;
  line-height: 1;
  margin-bottom: 16px;
  animation: contacts-empty-arrow-bounce 2s ease-in-out infinite;
}

@keyframes contacts-empty-arrow-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.contacts-empty-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
  opacity: 0.6;
}

.contacts-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.contacts-empty-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-muted);
  max-width: 280px;
}

/* === Pre-launch v3: Settings Legal Row (inline w panelach, NIE fixed/sticky/absolute) === */
.settings-legal-row {
  text-align: center;
  padding: 10px 8px 4px 8px;
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
}
.settings-legal-row .settings-legal-link {
  background: transparent;
  border: 0;
  color: #6b7280;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  font-size: 11px;
  font-family: inherit;
}
.settings-legal-row .settings-legal-link:hover {
  color: #1B3A5C;
}

/* === Pre-launch v3: Legal Modals (Impressum + Privacy popup) === */
.legal-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  box-sizing: border-box;
}
.legal-modal.hidden { display: none; }
.legal-modal-content {
  background: #ffffff;
  color: #1B3A5C;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  position: relative;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, sans-serif;
}
.legal-modal-close {
  position: absolute;
  top: 8px; right: 12px;
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
  padding: 4px 8px;
  z-index: 1;
}
.legal-modal-close:hover { color: #ef4444; }
.legal-modal-body {
  padding: 32px 24px 24px 24px;
  overflow-y: auto;
  flex: 1;
}
.legal-modal-body h3 {
  margin-top: 0;
  color: #1B3A5C;
  font-size: 18px;
}
.legal-modal-body h4 {
  margin-top: 16px;
  margin-bottom: 6px;
  color: #1B3A5C;
  font-size: 14px;
}
.legal-modal-body p {
  margin: 0 0 8px 0;
  font-size: 13px;
  line-height: 1.5;
  color: #1F2937;
}
/* Recykling Privacy w modalu (klonowany .privacy-content) */
.legal-modal-body .privacy-title {
  font-size: 18px;
  font-weight: 600;
  color: #1B3A5C;
  margin-bottom: 12px;
}
.legal-modal-body .privacy-heading {
  margin-top: 16px;
  margin-bottom: 6px;
  color: #1B3A5C;
  font-size: 14px;
  font-weight: 600;
}
.legal-modal-body .privacy-section {
  margin: 0 0 8px 0;
  font-size: 13px;
  line-height: 1.5;
  color: #1F2937;
}

/* === Pre-launch v3: Dark mode (wzorzec [data-theme="dark"]) === */
[data-theme="dark"] .settings-legal-row {
  border-top-color: #374151;
}
[data-theme="dark"] .settings-legal-row .settings-legal-link {
  color: var(--color-text-muted);
}
[data-theme="dark"] .settings-legal-row .settings-legal-link:hover {
  color: var(--color-accent);
}
[data-theme="dark"] .legal-modal {
  background: rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .legal-modal-content {
  background: #1F2937;
  color: #e5e5e5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
[data-theme="dark"] .legal-modal-close {
  color: #9ca3af;
}
[data-theme="dark"] .legal-modal-close:hover {
  color: #FCA5A5;
}
[data-theme="dark"] .legal-modal-body h3,
[data-theme="dark"] .legal-modal-body h4,
[data-theme="dark"] .legal-modal-body .privacy-title,
[data-theme="dark"] .legal-modal-body .privacy-heading {
  color: #93c5fd;
}
[data-theme="dark"] .legal-modal-body p,
[data-theme="dark"] .legal-modal-body .privacy-section {
  color: #e5e5e5;
}

[data-theme="dark"] .key-dot:not(.active) {
  border: 2px solid var(--color-text-primary);
  background: transparent;
}