:root {
    color-scheme: dark;
    --bg: #000;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --green: #30d158;
    --red: #ff453a;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-glow: inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 0 28px rgba(255, 255, 255, 0.035);
    --glass-blur: blur(12px);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(1100px 520px at 8% -8%, rgba(10, 132, 255, 0.2), transparent 55%),
        radial-gradient(900px 480px at 92% 0%, rgba(48, 209, 88, 0.12), transparent 50%),
        radial-gradient(700px 420px at 50% 110%, rgba(255, 255, 255, 0.05), transparent 55%),
        var(--bg);
    background-attachment: fixed;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-glow), 0 10px 28px rgba(0, 0, 0, 0.28);
    border-radius: 18px;
}

.lisek-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 18px 14px 96px;
}

.page-title {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-sub {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
}

.auth-panel {
    padding: 22px 18px 20px;
}

.auth-actions {
    margin: 18px 0 14px;
}

.pin-box {
    margin: 12px 0 18px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.pin-label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pin-value {
    margin-top: 8px;
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 0.28em;
    font-variant-numeric: tabular-nums;
}

.field-label {
    display: block;
    margin: 14px 0 8px;
    font-size: 13px;
    color: var(--muted);
}

.field {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.field.file {
    padding: 10px;
}

.field.textarea {
    resize: vertical;
    min-height: 88px;
}

.field:focus {
    outline: none;
    border-color: rgba(10, 132, 255, 0.55);
}

.emoji-btn:disabled {
    opacity: 1;
    cursor: default;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.emoji-btn {
    height: 42px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    font-size: 22px;
    cursor: pointer;
}

.emoji-btn.is-selected {
    border-color: rgba(10, 132, 255, 0.7);
    background: rgba(10, 132, 255, 0.18);
    box-shadow: inset 0 0 18px rgba(10, 132, 255, 0.18);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    border: 0;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-block {
    width: 100%;
    margin-top: 10px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--glass-border);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px dashed rgba(255, 255, 255, 0.18);
}

.hint {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.hint.center { text-align: center; }

.error {
    margin: 12px 0 0;
    color: var(--red);
    font-size: 13px;
}

.toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 12px;
    align-items: start;
    padding: 16px;
    margin-bottom: 12px;
}

.qr-bar {
    padding: 10px;
    margin-bottom: 12px;
}

.qr-bar .btn {
    min-height: 44px;
    font-weight: 600;
}

.toolbar-title {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
}

.toolbar-actions {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    gap: 8px;
    justify-self: end;
}

.session-chip {
    grid-column: 1;
    grid-row: 2;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-self: start;
    align-self: end;
    margin: 0;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 12px;
}

.members-bar {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    align-self: end;
    gap: 6px;
    max-width: 100%;
}

.members-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
}

.member-emoji {
    width: 27px;
    height: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    font-size: 14px;
    line-height: 1;
    opacity: 0.72;
}

.member-emoji.is-me {
    opacity: 1;
    border-color: rgba(10, 132, 255, 0.7);
    background: rgba(10, 132, 255, 0.16);
    box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.28);
    transform: scale(1.08);
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.icon-btn.danger:hover {
    border-color: rgba(255, 69, 58, 0.45);
    color: var(--red);
}

.filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 6px;
    align-items: center;
    padding: 6px;
    margin-bottom: 12px;
}

.filter-sort-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 13px;
    font-weight: 700;
}

.filter-btn {
    min-height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.25;
    padding: 6px 4px;
}

.filter-count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}

.filter-btn.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.list {
    overflow: hidden;
    padding: 4px 0;
}

.item-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.item-row:last-child {
    border-bottom: 0;
}

.item-row.is-open {
    background: rgba(255, 255, 255, 0.03);
}

.item-photo,
.item-photo-fallback {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
}

.item-photo-fallback {
    display: grid;
    place-items: center;
    font-size: 22px;
}

.item-body {
    min-width: 0;
}

.item-name {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.3;
    word-break: break-word;
}

.item-note {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.item-note-full {
    white-space: pre-wrap;
    word-break: break-word;
}

.spoiler-btn {
    margin-left: 6px;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.item-qty {
    text-align: right;
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-top: 0;
    line-height: 1.15;
}

.item-qty-empty {
    color: var(--muted);
    font-weight: 500;
}

.item-qty-emoji {
    display: block;
    margin-top: 4px;
    font-size: 10px;
}

.empty {
    margin: 18px 8px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.modal[hidden] { display: none; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: end center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.modal-sheet {
    position: relative;
    width: min(560px, 100%);
    max-height: min(88vh, 820px);
    max-height: min(88dvh, 820px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 16px;
    border-radius: 22px 22px 0 0;
    z-index: 1;
}

.modal-sheet-tall {
    max-height: min(92vh, 900px);
    max-height: min(92dvh, 900px);
}

.modal-sheet .modal-head {
    flex-shrink: 0;
}

.modal-sheet > .hint {
    flex-shrink: 0;
}

.modal-sheet-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 8px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}

.qr-wrap {
    display: grid;
    place-items: center;
    padding: 12px;
    border-radius: 16px;
    background: #fff;
}

.qr-wrap img {
    display: block;
    width: 220px;
    height: 220px;
}

.edit-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 42px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font: inherit;
}

.edit-name {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-weight: 600;
}

.edit-meta {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.section-mini {
    margin: 18px 0 8px;
    font-size: 15px;
}

.edit-row-archive {
    grid-template-columns: 44px minmax(0, 1fr) 42px 42px;
}

.edit-row-archive:not(:has(.edit-purge-btn)) {
    grid-template-columns: 44px minmax(0, 1fr) 42px;
}

.session-expiry {
    margin: -4px 0 12px;
    padding: 0 4px;
}

.edit-restore-btn,
.edit-archive-btn,
.edit-purge-btn {
    width: 38px;
    height: 38px;
}

.qty-display {
    margin: 4px 0 14px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    text-align: center;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.numpad button {
    min-height: 52px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
    font-size: 20px;
    font-weight: 650;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.numpad button:active {
    background: rgba(255, 255, 255, 0.12);
}

.qty-actions {
    margin-top: 12px;
}

.note-box {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.photo-preview {
    margin-top: 10px;
}

.photo-preview img {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

@media (min-width: 720px) {
    .modal {
        place-items: center;
    }

    .modal-sheet {
        border-radius: 22px;
        margin: 20px;
    }

    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 480px) {
    .emoji-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .page-title {
        font-size: 22px;
    }

    .filter-btn {
        font-size: 12px;
        padding: 0 4px;
    }
}
