:root {
    --bg: #0a0b0f;
    --surface: #12141a;
    --elevated: #1a1d26;
    --border: rgba(255,255,255,0.08);
    --text: #f0f2f5;
    --muted: #8b929e;
    --dim: #5c6370;
    --accent: #6366f1;
    --accent-soft: rgba(99,102,241,0.2);
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 16px;
    --font: 'DM Sans', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --nav-h: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 45% at 50% -10%, rgba(99,102,241,0.18), transparent),
        radial-gradient(ellipse 50% 30% at 100% 100%, rgba(99,102,241,0.08), transparent);
    pointer-events: none;
}

.app {
    min-height: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem 0.75rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.logo svg {
    width: 22px;
    height: 22px;
}

.header h1 {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header p {
    font-size: 0.8125rem;
    color: var(--muted);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.icon-btn svg { width: 20px; height: 20px; }

main {
    flex: 1;
    padding: 0.75rem 1.25rem calc(var(--nav-h) + var(--safe-bottom) + 1rem);
}

.hidden { display: none !important; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-icon svg {
    width: 56px;
    height: 56px;
    color: var(--dim);
    margin-bottom: 1rem;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.account-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.25s ease;
}

.account-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 3px 0 0 3px;
}

.account-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.875rem;
}

.account-info h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.account-info span {
    font-size: 0.8125rem;
    color: var(--muted);
}

.btn-delete {
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.125rem;
    line-height: 1;
}

.btn-delete:hover { color: var(--danger); }

.code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.totp-code {
    font-family: var(--mono);
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    color: var(--text);
    user-select: all;
}

.btn-copy {
    background: var(--elevated);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-copy.copied {
    color: var(--success);
    border-color: rgba(34,197,94,0.3);
}

.timer-row {
    margin-top: 0.75rem;
}

.timer-bar {
    height: 3px;
    background: var(--elevated);
    border-radius: 999px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 1s linear;
}

.timer-label {
    font-size: 0.75rem;
    color: var(--dim);
    margin-top: 0.375rem;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(18,20,26,0.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 50;
}

.nav-item {
    background: none;
    border: none;
    color: var(--dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 1rem;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }

.nav-scan {
    margin-top: -24px;
}

.scan-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: grid;
    place-items: center;
    color: white;
    box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}

.scan-ring svg { width: 26px; height: 26px; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.modal-sheet {
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem 0.75rem;
}

.modal-header h3 {
    font-size: 1.0625rem;
    font-weight: 600;
}

.scanner-wrap {
    padding: 0 1.25rem 1.5rem;
}

#qr-reader {
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

#qr-reader video {
    border-radius: var(--radius);
}

.scanner-hint {
    text-align: center;
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: 1rem;
}

.add-form {
    padding: 0 1.25rem 1rem;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.field input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--dim);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.25rem;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

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

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    margin: 0 1.25rem 1.5rem;
}

.btn-block { width: 100%; }

.toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    background: var(--elevated);
    border: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 200;
    transition: transform 0.3s ease;
    max-width: calc(100% - 2rem);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: rgba(34,197,94,0.3); color: var(--success); }
.toast.error { border-color: rgba(239,68,68,0.3); color: var(--danger); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
