:root {
    --bg: #0d1118;
    --panel: #111827;
    --border: #1c2434;
    --accent: #9ec5ff;
    --accent-strong: #7fb8ff;
    --text: #e8ecf4;
    --muted: #b5becd;
    --danger: #ef9a9a;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
    font-family:
        "IBM Plex Mono", "SFMono-Regular", Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    color: var(--text);
    background:
        radial-gradient(
            circle at 18% 15%,
            rgba(158, 197, 255, 0.1),
            transparent 35%
        ),
        radial-gradient(
            circle at 80% 0%,
            rgba(127, 184, 255, 0.14),
            transparent 35%
        ),
        var(--bg);
}

body {
    max-width: 760px;
    margin: 2rem auto 3rem;
    padding: 0 1.25rem 2.5rem;
    line-height: 1.6;
}

h1 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}

h2 {
    font-size: 1.2rem;
    margin: 1.4rem 0 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

section,
#existing-users-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

button {
    padding: 0.45rem 0.8rem;
    margin: 0.2rem;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--panel), var(--bg));
    color: var(--text);
    max-width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    touch-action: manipulation;
    transition:
        transform 120ms ease,
        box-shadow 120ms ease,
        border-color 120ms ease;
}

button:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(125, 211, 252, 0.25);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

a {
    color: var(--accent-strong);
}

a:hover {
    color: var(--accent);
}

input[type="text"],
input[type="number"],
#export-url,
#delete-range {
    padding: 0.5rem 0.7rem;
    font-size: 1rem;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    transition:
        border-color 120ms ease,
        box-shadow 120ms ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
#export-url:focus,
#delete-range:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

input[type="text"] {
    width: 70%;
    max-width: 340px;
}

input[type="number"] {
    width: 5.2rem;
}

#export-url,
#delete-range {
    width: 100%;
    margin-top: 0.55rem;
}

pre {
    background: var(--bg);
    padding: 0.75rem;
    min-height: 3rem;
    white-space: pre;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--muted);
    box-shadow: var(--shadow);
    max-height: 260px;
    overflow: auto;
}

hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 2rem 0 1.2rem;
}

.top-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.history-mode-label {
    margin-right: 0.5rem;
    color: var(--muted);
}

.mode-btn.active,
.raw-toggle-btn.active,
.theme-btn.active {
    border-color: var(--accent);
    color: var(--accent-strong);
    box-shadow: 0 6px 18px rgba(34, 211, 238, 0.25);
}

.raw-toggle {
    margin-top: 0.4rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.raw-toggle-btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
}

.stat-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem;
    box-shadow: var(--shadow);
}

.stat strong {
    font-size: 1.2rem;
    color: var(--accent-strong);
}

.action-codes-panel,
.wallet-actions-panel,
.theme-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 1rem;
    padding: 0;
    overflow: hidden;
}

.action-codes-panel > summary::-webkit-details-marker,
.wallet-actions-panel > summary::-webkit-details-marker,
.theme-panel > summary::-webkit-details-marker {
    display: none;
}

.action-codes-summary,
.wallet-actions-summary,
.theme-summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    user-select: none;
    list-style: none;
}

.action-codes-summary::marker,
.wallet-actions-summary::marker,
.theme-summary::marker {
    content: "";
}

.action-codes-summary::after,
.wallet-actions-summary::after,
.theme-summary::after {
    content: "›";
    display: inline-block;
    color: var(--muted);
    transform: rotate(0deg);
    transition:
        transform 120ms ease,
        color 120ms ease;
}

.action-codes-summary:hover::after,
.wallet-actions-summary:hover::after,
.theme-summary:hover::after {
    color: var(--accent-strong);
}

.action-codes-summary:focus-visible,
.wallet-actions-summary:focus-visible,
.theme-summary:focus-visible {
    outline: 2px solid rgba(34, 211, 238, 0.35);
    outline-offset: 2px;
    border-radius: 10px;
}

.action-codes-panel[open] .action-codes-summary::after,
.wallet-actions-panel[open] .wallet-actions-summary::after,
.theme-panel[open] .theme-summary::after {
    transform: rotate(90deg);
    color: var(--accent-strong);
}

.action-codes-panel[open] .action-codes-body {
    border-top: 1px solid var(--border);
}

.action-codes-body {
    padding: 0.9rem 1rem 1rem;
}

.action-codes-body-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-codes-toolbar {
    display: flex;
    justify-content: flex-end;
}

.action-codes-hint {
    color: var(--muted);
    font-size: 0.92rem;
    margin: 0;
}

.action-codes-notice {
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 12px;
    padding: 0.65rem 0.75rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.action-codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin: 0;
}

.action-codes-grid--single {
    grid-template-columns: minmax(240px, 420px);
    justify-content: center;
}

.action-codes-empty {
    color: var(--muted);
    margin: 0;
}

.action-code-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.action-code-card--featured {
    padding: 1rem;
    max-width: 420px;
    width: 100%;
}

.action-code-card--featured .action-code-label {
    font-size: 1.05rem;
}

.action-code-card--featured .action-code-amount {
    font-size: 1rem;
}

.action-code-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.action-code-label {
    font-weight: 700;
}

.action-code-label-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.action-code-badge {
    font-size: 0.75rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    background: var(--panel);
}

.action-code-amount {
    color: var(--muted);
    font-size: 0.92rem;
}

.action-code-buttons {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.action-code-buttons button {
    margin: 0;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.action-code-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

.action-code-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-code-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.action-code-form-field input {
    width: 100%;
}

.action-code-form-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.action-code-type-toggle {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.action-code-scope-toggle {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.action-code-confirm {
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 12px;
    padding: 0.6rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-code-canvas {
    width: 100%;
    height: auto;
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
}

.action-code-url {
    width: 100%;
    cursor: copy;
}

.action-code-error {
    color: var(--danger);
}

.wallet-actions,
.wallet-export {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

.wallet-actions-panel[open] .wallet-actions {
    border-top: 1px solid var(--border);
}

.wallet-actions-panel .wallet-actions {
    background: transparent;
    border: 0;
    box-shadow: none;
    margin-top: 0;
    border-radius: 0;
    padding: 0.9rem 1rem 1rem;
}

.theme-panel[open] #theme-section {
    border-top: 1px solid var(--border);
}

.theme-panel #theme-section {
    background: transparent;
    border: 0;
    box-shadow: none;
    margin-top: 0;
    border-radius: 0;
    padding: 0.9rem 1rem 1rem;
}

.theme-panel #theme-section h2 {
    margin-top: 0;
}

.theme-summary #current-theme-name {
    color: var(--accent-strong);
}

.qr-box {
    margin-top: 0.8rem;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.qr-hint {
    color: var(--muted);
    font-size: 0.92rem;
    text-align: center;
}

.qr-box canvas {
    width: 100%;
    max-width: 360px;
    height: auto;
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
}

#qr-url {
    width: 100%;
    max-width: 360px;
    cursor: copy;
}

.wallet-actions {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.wallet-actions .raw-toggle {
    margin-top: 0;
}

.wallet-actions pre {
    margin: 0;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.action-buttons button {
    margin: 0;
}

.pay-options {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pay-options button {
    margin: 0;
}

#existing-users div {
    color: var(--text);
}

.theme-note {
    color: var(--muted);
    margin: 0.1rem 0 0.75rem;
    font-size: 0.95rem;
}

.theme-buttons {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.theme-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.95rem;
}

.theme-buttons .theme-btn {
    flex: 1 1 160px;
    min-width: 0;
}

@media (max-width: 640px) {
    body {
        margin: 1.4rem auto 2rem;
        padding: 0 1rem 2rem;
    }

    h1 {
        font-size: 1.35rem;
    }

    h2 {
        font-size: 1rem;
        margin: 1.2rem 0 0.35rem;
    }

    section,
    #existing-users-section {
        padding: 0.85rem;
    }

    .top-row {
        flex-direction: column;
        align-items: stretch;
    }

    .top-row button {
        width: 100%;
    }

    input[type="text"] {
        width: 100%;
        max-width: none;
    }

    input[type="number"] {
        width: 100%;
        max-width: 120px;
    }

    .wallet-actions,
    .wallet-export {
        padding: 0.85rem;
    }

    .action-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.55rem;
    }

    #btn-pay {
        grid-column: 1 / -1;
    }

    .action-buttons button {
        width: 100%;
    }

    #btn-drink,
    #btn-undo,
    #btn-pay,
    #btn-pay-today,
    #btn-credit,
    #btn-pay-cancel {
        min-height: 48px;
        padding: 0.75rem 1rem;
        font-size: 1.05rem;
    }

    #pay-options {
        flex-direction: column;
        align-items: stretch;
    }

    #pay-options button {
        width: 100%;
    }

    .action-code-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .action-code-buttons button {
        width: 100%;
        min-height: 44px;
    }

    .theme-buttons {
        gap: 0.35rem;
    }
}

.import-choice-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.import-choice-modal {
    width: min(520px, 100%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.import-choice-title {
    font-size: 1.1rem;
    letter-spacing: 0.02em;
    margin-bottom: 0.2rem;
}

.import-choice-subtitle {
    color: var(--muted);
    margin-bottom: 0.9rem;
}

.import-choice-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.import-choice-btn,
.import-choice-cancel {
    width: 100%;
}

.import-choice-btn {
    padding: 0.9rem 1rem;
    min-height: 66px;
    border-radius: 14px;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.import-choice-btn-title {
    font-weight: 700;
    color: var(--text);
}

.import-choice-btn-sub {
    color: var(--muted);
    font-size: 0.92rem;
}

.import-choice-cancel {
    padding: 0.65rem 1rem;
    border-radius: 14px;
}

body[data-no-wallet="1"] > :not(#global-action-message) {
    display: none;
}

.global-action-panel {
    max-width: 640px;
    margin: 1rem auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    color: var(--text);
}

.global-action-header {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.global-action-headline {
    font-size: 1.22rem;
    font-weight: 600;
}

.global-action-subtitle {
    color: var(--muted);
    font-size: 0.92rem;
}

.global-action-label {
    color: var(--muted);
    font-size: 0.9rem;
    font-style: normal;
}

.global-action-prompt {
    font-size: 0.9rem;
    color: var(--muted);
}

.global-action-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.global-action-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg);
    min-height: 70px;
    transition:
        transform 120ms ease,
        box-shadow 120ms ease;
}

.global-action-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.global-action-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.global-action-card-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-action-card-sub {
    font-size: 0.9rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-action-card-meta {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-action-actions {
    display: flex;
    justify-content: flex-end;
}

.global-action-cancel {
    background: transparent;
    border: 1px solid var(--border);
    font-size: 0.9rem;
}
