:root {
    --bg: #0d0d0d;
    --surface: #161616;
    --surface-2: #1e1e1e;
    --border: #262626;
    --text: #efefef;
    --text-muted: #888;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-dim: rgba(99, 102, 241, 0.12);
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.12);
    --error: #ef4444;
    --error-dim: rgba(239, 68, 68, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: opacity 0.15s; }
a:hover { opacity: 0.8; }

/* ── Layout ── */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s, border-color 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-white { background: #fff; color: #0d0d0d; }
.btn-white:hover { background: #e8e8e8; opacity: 1; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: #444; opacity: 1; }

.btn-danger { color: var(--error); border-color: rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: var(--error-dim); border-color: var(--error); opacity: 1; }

.btn-lg { padding: 14px 32px; font-size: 15px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ── Nav ── */

.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: rgba(13, 13, 13, 0.8);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.nav-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    letter-spacing: -0.3px;
    text-decoration: none;
}
.logo:hover { opacity: 1; }

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

.nav-email {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 4px;
}

/* ── Hero ── */

.hero {
    padding: 96px 0 72px;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 4px 14px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.hero h1 {
    font-size: clamp(36px, 6vw, 62px);
    font-weight: 700;
    letter-spacing: -1.5px;
    line-height: 1.08;
    margin-bottom: 20px;
    color: #fff;
}

.hero-sub {
    font-size: 17px;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto 36px;
    line-height: 1.7;
}

/* ── Features ── */

.features {
    padding: 56px 0 72px;
    border-top: 1px solid var(--border);
}

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

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
}

.feature-icon {
    width: 38px;
    height: 38px;
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--accent);
}

.feature-icon svg { width: 18px; height: 18px; }

.feature-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }

.feature-card p { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── Generator ── */

.generator-section {
    padding: 72px 0 96px;
    border-top: 1px solid var(--border);
}

.generator-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
}

.generator-card h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    color: #fff;
}

.generator-sub { color: var(--text-muted); font-size: 15px; margin-bottom: 28px; }

.input-row {
    display: flex;
    gap: 8px;
    max-width: 580px;
    margin: 0 auto 20px;
}

.field {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--text-muted); }

/* ── QR Result ── */

.qr-result { animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.qr-preview {
    display: inline-block;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    line-height: 0;
}

/* qr-code-styling renders a canvas — display at 220px regardless of internal resolution */
#qrContainer canvas {
    display: block;
    width: 220px !important;
    height: 220px !important;
}

.qr-actions { margin-bottom: 32px; }

/* ── Save Prompt ── */

.save-prompt {
    border-top: 1px solid var(--border);
    padding-top: 32px;
}

.save-prompt h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.save-prompt > p { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }

.save-row {
    display: flex;
    gap: 8px;
    max-width: 440px;
    margin: 0 auto 12px;
}

.msg {
    font-size: 13px;
    min-height: 18px;
    transition: color 0.15s;
}
.msg.success { color: var(--success); }
.msg.error { color: var(--error); }

/* ── Saved indicator ── */

.saved-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--success-dim);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--success);
    margin-top: 24px;
}

.saved-badge a { color: var(--success); text-decoration: underline; text-underline-offset: 3px; }

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ── Auth / Login / Verify shared ── */

.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 65px);
    padding: 40px 24px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
    width: 100%;
    max-width: 420px;
}

.auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; color: #fff; }
.auth-card p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }

.auth-card .field { width: 100%; margin-bottom: 10px; }
.auth-card .btn { width: 100%; }

.auth-card .msg { margin-top: 10px; display: block; }

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

.status-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.status-icon.success { background: var(--success-dim); color: var(--success); }
.status-icon.error { background: var(--error-dim); color: var(--error); }
.status-icon svg { width: 22px; height: 22px; }

/* ── Dashboard ── */

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 36px;
    padding-top: 56px;
    padding-bottom: 0;
}

.dash-header h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; color: #fff; }

.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    padding-bottom: 80px;
}

.qr-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s;
}

.qr-card:hover { border-color: #3a3a3a; }

.qr-card-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

.qr-card-date { font-size: 12px; color: var(--text-muted); }

.qr-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}

/* ── Empty / loading states ── */

.state-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 80px 0;
}

.state-center h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.state-center p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* ── Footer ── */

.footer {
    border-top: 1px solid var(--border);
    padding: 36px 0;
    text-align: center;
}

.footer .logo { display: block; margin-bottom: 8px; }
.footer p { font-size: 13px; color: var(--text-muted); }

/* ── Style panel ── */

.style-panel {
    max-width: 580px;
    margin: 0 auto 28px;
    padding: 18px 20px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
}

.style-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.slabel {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    width: 52px;
    flex-shrink: 0;
}

/* Dot-style buttons */
.dsb-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.dsb {
    padding: 5px 11px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
    white-space: nowrap;
}

.dsb:hover { border-color: #444; color: var(--text); }

.dsb.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* Color controls */
.color-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.color-field {
    display: flex;
    align-items: center;
    gap: 7px;
}

.clabel {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

input[type="color"] {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: none;
    cursor: pointer;
    padding: 2px;
    -webkit-appearance: none;
    appearance: none;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 4px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

/* Preset swatches */
.preset-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex-shrink: 0;
}

.preset-swatches {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pswatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    flex-shrink: 0;
}

.pswatch:hover  { transform: scale(1.15); border-color: var(--text-muted); }
.pswatch.active { border-color: var(--accent); }

/* ── API Keys Section ── */

.api-section {
    margin-top: 56px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.api-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.api-section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.api-section-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* Usage bar */
.usage-bar-wrap {
    margin-bottom: 28px;
}

.usage-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.usage-bar-track {
    height: 6px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.4s ease;
}

.usage-bar-fill.warning { background: #f59e0b; }
.usage-bar-fill.danger  { background: var(--error); }

/* Key cards */
.key-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.key-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.key-card-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.key-card-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.key-card-prefix {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    background: var(--surface-2);
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.key-card-usage {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* One-time key reveal */
.key-reveal-box {
    background: var(--success-dim);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.key-reveal-label {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
    margin-bottom: 8px;
}

.key-reveal-value {
    display: flex;
    align-items: center;
    gap: 10px;
}

.key-reveal-code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    flex: 1;
    color: var(--text);
}

.btn-copy {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-copy.copied {
    background: var(--success-dim);
    color: var(--success);
    border-color: var(--success);
}

/* ── Responsive ── */

@media (max-width: 640px) {
    .features-grid { grid-template-columns: 1fr; }
    .generator-card { padding: 28px 20px; }
    .auth-card { padding: 32px 24px; }
    .input-row { flex-direction: column; }
    .save-row { flex-direction: column; }
    .style-row { flex-wrap: wrap; }
    .hero { padding: 60px 0 48px; }
    .dash-header { flex-direction: column; align-items: flex-start; gap: 16px; }
}
