/* ============================================================
   VAULT — Design System
   ============================================================ */

:root {
    --primary: #4A6FA5;
    --primary-hover: #3D5F91;
    --primary-light: #E8EFF8;
    --primary-dark: #345183;

    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --surface-hover: #F0F2F5;
    --border: #E2E6EA;
    --border-focus: #4A6FA5;

    --text: #1A1D21;
    --text-secondary: #6C757D;
    --text-muted: #ADB5BD;
    --text-inverse: #FFFFFF;

    --success: #28A745;
    --success-bg: #D4EDDA;
    --warning: #F0AD4E;
    --warning-bg: #FFF3CD;
    --danger: #DC3545;
    --danger-bg: #F8D7DA;
    --info: #17A2B8;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
    --shadow-xl: 0 20px 40px rgba(0,0,0,.12);

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --sidebar-width: 260px;
    --topbar-height: 56px;
}

html.dark {
    --primary: #58A6FF;
    --primary-hover: #79C0FF;
    --primary-light: #1C2D41;
    --primary-dark: #79C0FF;

    --bg: #0D1117;
    --surface: #161B22;
    --surface-hover: #1C2128;
    --border: #30363D;
    --border-focus: #58A6FF;

    --text: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #484F58;
    --text-inverse: #0D1117;

    --success: #3FB950;
    --success-bg: #1B3726;
    --warning: #D29922;
    --warning-bg: #3B2E00;
    --danger: #F85149;
    --danger-bg: #3D1419;

    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
    --shadow-xl: 0 20px 40px rgba(0,0,0,.5);
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Layout
   ============================================================ */

#app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card .logo svg {
    width: 48px;
    height: 48px;
    color: var(--primary);
}

.auth-card .logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 12px;
    color: var(--text);
}

.auth-card .logo p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Main app layout */
.app-layout {
    display: flex;
    min-height: 100dvh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-nav .nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav .nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar .nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-nav .nav-item .badge {
    margin-left: auto;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-folders { padding: 12px; }

.sidebar-folders .folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

.topbar .search-box {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.topbar .search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.topbar .search-box input {
    width: 100%;
    padding: 8px 12px 8px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

.topbar .search-box input:focus {
    border-color: var(--border-focus);
}

.topbar .search-box input::placeholder {
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Content area */
.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); text-decoration: none; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { opacity: .9; text-decoration: none; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn:disabled, .btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================================================
   Forms
   ============================================================ */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group .help-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.form-input-password {
    position: relative;
}

.form-input-password input {
    padding-right: 44px;
}

.form-input-password .toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
}

.form-input-password .toggle-password:hover {
    color: var(--text-secondary);
}

.form-input-password .toggle-password svg {
    width: 18px;
    height: 18px;
}

/* Password strength meter */
.strength-meter {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin-top: 8px;
    overflow: hidden;
}

.strength-meter .bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

.strength-meter .bar.s0 { width: 0%; }
.strength-meter .bar.s1 { width: 25%; background: var(--danger); }
.strength-meter .bar.s2 { width: 50%; background: var(--warning); }
.strength-meter .bar.s3 { width: 75%; background: var(--info); }
.strength-meter .bar.s4 { width: 100%; background: var(--success); }

.strength-label {
    font-size: 0.75rem;
    margin-top: 4px;
    color: var(--text-muted);
}

/* ============================================================
   Entry Cards
   ============================================================ */

.entries-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.entry-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.entry-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.entry-card .entry-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.entry-card .entry-info {
    flex: 1;
    min-width: 0;
}

.entry-card .entry-name {
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-card .entry-user {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-card .entry-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.entry-card:hover .entry-actions { opacity: 1; }

.entry-card .entry-fav {
    color: var(--text-muted);
}

.entry-card .entry-fav.active {
    color: var(--warning);
}

/* ============================================================
   Detail Panel
   ============================================================ */

.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.detail-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    z-index: 201;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.detail-panel.open {
    transform: translateX(0);
}

.detail-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.detail-panel .panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.detail-panel .panel-body {
    padding: 20px;
    flex: 1;
}

.detail-panel .panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Field row in detail */
.field-row {
    margin-bottom: 16px;
}

.field-row .field-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.field-row .field-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9375rem;
    word-break: break-all;
}

.field-row .field-value.mono {
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.field-row .field-value .masked {
    letter-spacing: 2px;
}

/* ============================================================
   Password Generator
   ============================================================ */

.generator {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.generator .gen-output {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    text-align: center;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    word-break: break-all;
    user-select: all;
}

.generator .gen-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.generator .gen-slider {
    display: flex;
    align-items: center;
    gap: 12px;
}

.generator .gen-slider input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

.generator .gen-slider span {
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.generator .gen-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.generator .gen-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.generator .gen-options input[type="checkbox"] {
    accent-color: var(--primary);
}

/* ============================================================
   2FA Code Input
   ============================================================ */

.code-input {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 24px 0;
}

.code-input input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.code-input input:focus {
    border-color: var(--primary);
}

/* ============================================================
   Toast
   ============================================================ */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    min-width: 280px;
    max-width: 420px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); }

.toast .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

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

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ============================================================
   Settings
   ============================================================ */

.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section h3 svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

/* ============================================================
   Empty state
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 360px;
    margin: 0 auto 20px;
}

/* ============================================================
   Backup codes
   ============================================================ */

.backup-codes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}

.backup-codes code {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    text-align: center;
    letter-spacing: 1px;
}

/* ============================================================
   QR Code
   ============================================================ */

.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-container canvas {
    border-radius: var(--radius);
    margin: 0 auto;
}

.qr-box {
    display: inline-block;
    background: #fff;
    padding: 12px;
    border-radius: var(--radius);
    line-height: 0;
}

.qr-box img,
.qr-box canvas { display: block; margin: 0 auto; }

.qr-secret-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 16px;
    margin-bottom: 4px;
}

.qr-secret {
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: 1px;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    word-break: break-all;
    user-select: all;
    cursor: pointer;
}

/* ============================================================
   Lock screen
   ============================================================ */

.lock-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
    text-align: center;
}

.lock-screen svg {
    width: 64px;
    height: 64px;
    color: var(--primary);
    margin-bottom: 20px;
}

.lock-screen h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.lock-screen p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

/* ============================================================
   Theme toggle
   ============================================================ */

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.theme-toggle svg { width: 18px; height: 18px; }

/* ============================================================
   Utilities
   ============================================================ */

.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }

/* ============================================================
   Animations
   ============================================================ */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================================
   Responsive
   ============================================================ */

/* ============================================================
   Toggle Switch
   ============================================================ */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-switch .slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .slider {
    background: var(--primary);
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(20px);
}

/* ============================================================
   Password Generator — Standalone (desktop + mobile)
   ============================================================ */

.generator-standalone {
    max-width: 520px;
}

.gen-display {
    margin-bottom: 20px;
}

.gen-output-standalone {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    text-align: center;
    padding: 22px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    word-break: break-all;
    user-select: all;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
}

.gen-display-actions {
    display: flex;
    gap: 8px;
}

.gen-display-actions .btn { flex: 1; }

.gen-controls-standalone {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.gen-controls-standalone .gen-slider {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
}

.gen-controls-standalone .gen-slider input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

.gen-controls-standalone .gen-slider span:last-child {
    font-weight: 600;
    min-width: 28px;
    text-align: right;
}

.gen-controls-standalone .gen-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.gen-option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.gen-option-label input { accent-color: var(--primary); }

/* ============================================================
   Bottom Navigation / FAB / Bottom Sheet / Mobile chrome
   (base = hidden; activated in mobile media query)
   ============================================================ */

.bottom-nav,
.mobile-fab,
.mobile-topbar,
.mobile-avatar-dropdown,
.mobile-search-overlay,
.mobile-filter-chips,
.bottom-sheet-container { display: none; }

.filter-chip {
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-chip.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* ============================================================
   Responsive — Mobile (< 768px)
   ============================================================ */

@media (max-width: 768px) {
    /* Hide desktop chrome on mobile */
    .sidebar { display: none !important; }
    .detail-panel,
    .detail-overlay { display: none !important; }
    .main-content { margin-left: 0; }
    .auth-card { padding: 28px 20px; }

    /* Mobile layout shell */
    .mobile-layout {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    /* Mobile topbar */
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 56px;
        padding: 0 16px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .mobile-topbar-title {
        font-size: 1.125rem;
        font-weight: 700;
    }

    .mobile-topbar-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-topbar-actions .btn-ghost svg { width: 22px; height: 22px; }

    /* Avatar button */
    .mobile-avatar-btn {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: var(--primary);
        color: #fff;
        border: none;
        font-size: 0.875rem;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Avatar dropdown */
    .mobile-avatar-dropdown {
        display: block;
        position: fixed;
        top: 56px;
        right: 12px;
        width: 220px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        z-index: 120;
        overflow: hidden;
        padding: 6px;
    }

    .mobile-avatar-dropdown.hidden { display: none; }

    .mobile-avatar-dropdown-email {
        padding: 10px 12px;
        font-size: 0.8125rem;
        color: var(--text-secondary);
        border-bottom: 1px solid var(--border);
        margin-bottom: 6px;
        word-break: break-all;
    }

    .mobile-avatar-dropdown-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 10px 12px;
        background: none;
        border: none;
        border-radius: var(--radius-sm);
        color: var(--text);
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        text-align: left;
    }

    .mobile-avatar-dropdown-item:hover { background: var(--surface-hover); }
    .mobile-avatar-dropdown-item svg { width: 18px; height: 18px; }
    .mobile-avatar-dropdown-logout { color: var(--danger); }

    /* Search overlay */
    .mobile-search-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        z-index: 150;
        box-shadow: var(--shadow);
        transform: translateY(-100%);
        transition: transform 0.2s ease;
        padding: env(safe-area-inset-top, 0) 0 0;
    }

    .mobile-search-overlay.open { transform: translateY(0); }

    .mobile-search-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        height: 56px;
        padding: 0 12px;
    }

    .mobile-search-input-wrap {
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
    }

    .mobile-search-input-wrap svg {
        position: absolute;
        left: 12px;
        width: 18px;
        height: 18px;
        color: var(--text-muted);
        pointer-events: none;
    }

    .mobile-search-input-wrap input {
        width: 100%;
        padding: 10px 12px 10px 40px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--bg);
        color: var(--text);
        font-size: 1rem;
        outline: none;
    }

    .mobile-search-input-wrap input:focus { border-color: var(--border-focus); }

    /* Filter chips */
    .mobile-filter-chips {
        display: flex;
        gap: 8px;
        padding: 12px 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .mobile-filter-chips::-webkit-scrollbar { display: none; }

    /* Content area */
    .mobile-content-area {
        flex: 1;
        padding: 4px 0 16px;
        overflow-y: auto;
    }

    .entries-grid { padding: 0 12px; gap: 8px; }

    /* Entry cards touch-friendly */
    .entry-card { padding: 14px 16px; min-height: 62px; }
    .entry-card .entry-actions { opacity: 1; }
    .entry-card .entry-actions .btn-ghost svg { width: 20px; height: 20px; }

    /* Bottom nav */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .bottom-nav .nav-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 0.6875rem;
        font-weight: 500;
        color: var(--text-muted);
        background: none;
        border: none;
        cursor: pointer;
        transition: color 0.15s;
    }

    .bottom-nav .nav-tab.active { color: var(--primary); }
    .bottom-nav .nav-tab svg { width: 22px; height: 22px; }

    /* FAB */
    .mobile-fab {
        display: flex;
        position: fixed;
        right: 18px;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary);
        color: #fff;
        border: none;
        box-shadow: var(--shadow-lg);
        z-index: 99;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: transform 0.15s, background 0.15s;
    }

    .mobile-fab:active { transform: scale(0.92); }
    .mobile-fab svg { width: 26px; height: 26px; }

    /* Bottom sheet */
    .bottom-sheet-container { display: block; }

    .bottom-sheet-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 200;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }

    .bottom-sheet-backdrop.open { opacity: 1; pointer-events: auto; }

    .bottom-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 88vh;
        background: var(--surface);
        border-radius: 18px 18px 0 0;
        box-shadow: var(--shadow-xl);
        z-index: 201;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .bottom-sheet.open { transform: translateY(0); }

    .bottom-sheet-drag-handle {
        padding: 12px 0 4px;
        display: flex;
        justify-content: center;
        flex-shrink: 0;
        cursor: grab;
        touch-action: none;
    }

    .bottom-sheet-drag-handle span {
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        display: block;
    }

    .bottom-sheet .panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 20px 12px;
        flex-shrink: 0;
    }

    .bottom-sheet .panel-body {
        overflow-y: auto;
        padding: 0 20px 16px;
        flex: 1;
    }

    .bottom-sheet .panel-footer {
        padding: 12px 20px;
        border-top: 1px solid var(--border);
        display: flex;
        gap: 8px;
        justify-content: flex-end;
        flex-shrink: 0;
    }

    /* Full-screen modal editor */
    .modal-overlay { padding: 0; }
    .modal-overlay .modal {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    .modal-overlay .modal-header { flex-shrink: 0; }
    .modal-overlay .modal-body { flex: 1; overflow-y: auto; }
    .modal-overlay .modal-footer { flex-shrink: 0; }

    /* Toast above bottom nav */
    #toast-container {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .toast { min-width: auto; max-width: none; }

    /* Settings + generator padding */
    .content-area { padding: 16px 12px; }
    .settings-section { margin-left: 0; margin-right: 0; }
    .generator-standalone { padding: 16px; max-width: 100%; }

    /* Code input on mobile */
    .code-input { gap: 6px; }
    .code-input input { width: 44px; height: 52px; font-size: 1.375rem; }
}

/* ============================================================
   Responsive — Tablet / Desktop
   ============================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .entries-grid { grid-template-columns: 1fr; }
}

@media (min-width: 1025px) {
    .entries-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
