/* ============================================================================
   QRMaker — Infinitely Weird design system
   ----------------------------------------------------------------------------
   Single source of truth for all app styling. Light + dark themes are driven
   by CSS custom properties toggled via [data-theme="light|dark"] on <html>.
   The brand gradient (yellow→orange→pink→magenta→purple→blue) is used for
   primary actions and accents. System font stack keeps the WASM app lean and
   offline-capable (no external font requests).
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Design tokens
   --------------------------------------------------------------------------- */
:root {
    /* Brand */
    --iw-yellow: #FFD23F;
    --iw-orange: #FF8A3D;
    --iw-pink: #FF3D77;
    --iw-magenta: #D633C4;
    --iw-purple: #8B3DFF;
    --iw-blue: #4E6BFF;
    --iw-gradient: linear-gradient(135deg, #FFD23F 0%, #FF8A3D 20%, #FF3D77 40%, #D633C4 60%, #8B3DFF 80%, #4E6BFF 100%);
    --iw-gradient-soft: linear-gradient(135deg, rgba(255,210,63,.16), rgba(139,61,255,.16));

    /* Typography — 1.25 modular scale (from brand design system) */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
    --fs-xs: 0.7rem;        /* 11.2 */
    --fs-sm: 0.8rem;        /* 12.8 */
    --fs-base: 1rem;        /* 16   */
    --fs-lg: 1.25rem;       /* 20   */
    --fs-xl: 1.563rem;      /* 25   */
    --fs-2xl: 1.953rem;     /* 31.25 */
    --fs-3xl: 2.441rem;     /* 39   */
    --fs-4xl: 3.052rem;     /* 48.8 */
    --lh-tight: 1.15;
    --lh-normal: 1.55;

    /* Spacing scale */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4rem;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-pill: 999px;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(17, 17, 24, 0.06), 0 1px 3px rgba(17, 17, 24, 0.10);
    --shadow-md: 0 4px 12px rgba(17, 17, 24, 0.08), 0 2px 4px rgba(17, 17, 24, 0.06);
    --shadow-lg: 0 12px 32px rgba(17, 17, 24, 0.14), 0 4px 8px rgba(17, 17, 24, 0.08);
    --shadow-glow: 0 8px 28px rgba(139, 61, 255, 0.35);

    /* Motion */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --dur: 180ms;

    /* Layout */
    --sidebar-w: 264px;
    --topbar-h: 68px;
    --max-content: 1200px;

    /* Semantic */
    --success: #22c35d;
    --warning: #f59f0a;
    --error: #ef4343;
    --info: #368fe7;
}

/* Light theme (default) */
:root, [data-theme="light"] {
    color-scheme: light;
    --bg: #f6f6f9;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f2f5;
    --surface-3: #ececf1;
    --border: #e4e4ea;
    --border-strong: #d2d2db;
    --text: #19181b;
    --text-muted: #65616b;
    --text-faint: #98949e;
    --primary: #8B3DFF;
    --primary-hover: #7a2fe6;
    --primary-contrast: #ffffff;
    --on-gradient: #ffffff;
    --ring: rgba(139, 61, 255, 0.45);
    --sidebar-bg: #ffffff;
    --sidebar-text: #4a4750;
    --sidebar-active-bg: var(--iw-gradient-soft);
    --nav-icon: #8a8792;
    --preview-checker: rgba(0,0,0,0.04);
    --scrim: rgba(17, 17, 24, 0.45);
}

/* Dark theme */
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d0c0f;
    --bg-elev: #141318;
    --surface: #19181d;
    --surface-2: #211f27;
    --surface-3: #2a2833;
    --border: #2c2a34;
    --border-strong: #3a3745;
    --text: #f2f2f6;
    --text-muted: #a4a1ad;
    --text-faint: #7c7985;
    --primary: #a870ff;
    --primary-hover: #b98aff;
    --primary-contrast: #1a0f2e;
    --on-gradient: #ffffff;
    --ring: rgba(168, 112, 255, 0.55);
    --sidebar-bg: #100f14;
    --sidebar-text: #b7b4c0;
    --sidebar-active-bg: rgba(139, 61, 255, 0.18);
    --nav-icon: #8a8792;
    --preview-checker: rgba(255,255,255,0.05);
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
    --shadow-md: 0 4px 14px rgba(0,0,0,.5);
    --shadow-lg: 0 14px 36px rgba(0,0,0,.6);
}

/* ---------------------------------------------------------------------------
   2. Reset / base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow: hidden; /* app shell manages its own scroll */
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: -0.01em;
    color: var(--text);
}
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }

::selection { background: rgba(139, 61, 255, 0.28); }

/* Accessible focus ring everywhere */
:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Scrollbars (WebKit) */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ---------------------------------------------------------------------------
   3. App shell
   --------------------------------------------------------------------------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
    transition: background var(--dur) var(--ease);
}

.main-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-6);
    background: var(--bg);
}

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: var(--sp-5) var(--sp-4);
    gap: var(--sp-5);
    overflow-y: auto;
    transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
    z-index: 40;
}

.sidebar-brand { padding: var(--sp-1) var(--sp-2); }
.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--surface-2);
    padding: 5px;
    box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name {
    font-size: var(--fs-lg);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--iw-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.brand-sub { font-size: var(--fs-xs); color: var(--text-faint); font-weight: 600; letter-spacing: 0.02em; }

/* Navigation ------------------------------------------------------------- */
.nav { display: flex; flex-direction: column; gap: var(--sp-4); flex: 1; }
.nav__section { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 700;
    color: var(--text-faint);
    padding: 0 var(--sp-2) var(--sp-2);
}
.nav__item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: var(--fs-sm);
    border: 1px solid transparent;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
    position: relative;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav__item.active {
    background: var(--sidebar-active-bg);
    color: var(--text);
    border-color: var(--border);
}
.nav__item.active::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 3px;
    background: var(--iw-gradient);
}
.nav__icon { font-size: 1rem; width: 20px; text-align: center; color: var(--nav-icon); }
.nav__item.active .nav__icon { color: var(--iw-purple); }
.nav__text { min-width: 0; }

/* Sidebar footer --------------------------------------------------------- */
.sidebar-foot { display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.plan-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    width: fit-content;
}
.plan-chip .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-faint);
}
.plan-chip.plan-free { color: var(--text-muted); }
.plan-chip.plan-free .dot { background: var(--text-faint); }
.plan-chip.plan-pro {
    background: var(--iw-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-glow);
}
.plan-chip.plan-pro .dot { background: #fff; }

.account-line { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.account-email { font-size: var(--fs-xs); color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }

/* Topbar ----------------------------------------------------------------- */
.topbar {
    height: var(--topbar-h);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    transition: background var(--dur) var(--ease);
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.topbar-kicker { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700; color: var(--text-faint); }
.topbar-title h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.menu-toggle { display: none; }

/* Theme segmented control ------------------------------------------------ */
.theme-switch {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    gap: 2px;
}
.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 600;
    border-radius: var(--r-pill);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-btn:hover { color: var(--text); }
.theme-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .theme-btn.active { background: var(--surface-3); }

/* ---------------------------------------------------------------------------
   4. Buttons
   --------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 0.7rem 1.15rem;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-weight: 700;
    font-size: var(--fs-sm);
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
    text-decoration: none;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--iw-gradient);
    color: var(--on-gradient);
    box-shadow: var(--shadow-md);
}
.btn-primary:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }

.btn-soft {
    background: var(--iw-gradient-soft);
    color: var(--text);
    border-color: var(--border);
}
.btn-soft:hover { background: var(--iw-gradient-soft); }

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.5rem 0.85rem; font-size: 0.78rem; }
.btn-lg { padding: 0.95rem 1.5rem; font-size: var(--fs-base); border-radius: var(--r-lg); }

.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    font-weight: 600;
}
.btn-google:hover {
    background: var(--surface-2);
    border-color: var(--text-faint);
    transform: translateY(-1px);
}
.btn-google svg { flex: 0 0 auto; }

/* ---------------------------------------------------------------------------
   5. Badges, chips, alerts
   --------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
}
.badge-pro {
    background: var(--iw-gradient);
    color: #fff;
    border-color: transparent;
}
.badge-free { background: var(--surface-2); color: var(--text-muted); }
.badge-success { background: rgba(34,195,93,.14); color: var(--success); border-color: transparent; }
.badge-warn { background: rgba(245,159,10,.14); color: var(--warning); border-color: transparent; }

.plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: var(--r-pill);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}
.plan-badge.plan-free { background: var(--surface-3); color: var(--text-muted); }
.plan-badge.plan-pro { background: var(--iw-gradient); color: #fff; box-shadow: var(--shadow-glow); }

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}
.alert .alert-ico { flex: 0 0 auto; font-weight: 800; }
.alert-info { border-color: rgba(54,143,231,.4); background: rgba(54,143,231,.08); color: var(--text); }
.alert-info .alert-ico { color: var(--info); }
.alert-success { border-color: rgba(34,195,93,.4); background: rgba(34,195,93,.08); }
.alert-success .alert-ico { color: var(--success); }
.alert-error { border-color: rgba(239,67,67,.4); background: rgba(239,67,67,.08); }
.alert-error .alert-ico { color: var(--error); }

/* ---------------------------------------------------------------------------
   6. Panels, cards, grids
   --------------------------------------------------------------------------- */
.page { max-width: var(--max-content); margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-6); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.section-head { display: flex; flex-direction: column; gap: 4px; }
.section-head h2 { font-size: var(--fs-2xl); }
.section-head p { color: var(--text-muted); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--sp-5);
}
.card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    color: var(--text);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
    position: relative;
    overflow: hidden;
}
.card::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--iw-gradient);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
}
.card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card:hover::after { opacity: 1; }
.card h3 { font-size: var(--fs-lg); }
.card p { color: var(--text-muted); font-size: var(--fs-sm); }
.card-ico {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-md);
    background: var(--iw-gradient-soft);
    color: var(--iw-purple);
}
.card-cta { margin-top: auto; font-size: var(--fs-sm); font-weight: 700; color: var(--primary); }

.status-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-5);
}
.status-panel { display: flex; flex-direction: column; gap: var(--sp-3); }
.status-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.status-head h2 { font-size: var(--fs-lg); }
.status-panel p { color: var(--text-muted); font-size: var(--fs-sm); }
.status-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); }

.feature-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.feature-list li { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.tick {
    flex: 0 0 auto;
    width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(34,195,93,.14);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 800;
    margin-top: 1px;
}

/* ---------------------------------------------------------------------------
   7. Hero (dashboard)
   --------------------------------------------------------------------------- */
.hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: var(--sp-6);
    align-items: center;
    background:
        radial-gradient(120% 140% at 0% 0%, var(--iw-gradient-soft), transparent 55%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-7);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.hero-copy { display: flex; flex-direction: column; gap: var(--sp-4); }
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--iw-purple);
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--iw-gradient); border-radius: 2px; }
.hero-copy h1 { font-size: var(--fs-3xl); letter-spacing: -0.03em; }
.hero-copy p { color: var(--text-muted); font-size: var(--fs-lg); max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); }

.hero-visual { display: flex; align-items: center; justify-content: center; }
.hero-qr {
    position: relative;
    width: 100%;
    max-width: 240px;
    aspect-ratio: 1;
    border-radius: var(--r-lg);
    background:
        linear-gradient(var(--surface-2) 1px, transparent 1px) 0 0 / 12px 12px,
        linear-gradient(90deg, var(--surface-2) 1px, transparent 1px) 0 0 / 12px 12px,
        var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 18px;
}
.hq-grid {
    position: absolute;
    inset: 18px;
    border-radius: var(--r-md);
    background:
        linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 14px 14px,
        linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 14px 14px;
    opacity: .5;
}
.hq-corner {
    position: absolute;
    width: 34px; height: 34px;
    border: 4px solid var(--iw-purple);
    border-radius: 6px;
}
.hq-corner.tl { top: 22px; left: 22px; border-right: 0; border-bottom: 0; }
.hq-corner.tr { top: 22px; right: 22px; border-left: 0; border-bottom: 0; }
.hq-corner.bl { bottom: 22px; left: 22px; border-right: 0; border-top: 0; }

/* ---------------------------------------------------------------------------
   8. Forms
   --------------------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: var(--sp-5); }
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.label { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.label .req { color: var(--iw-pink); }
.field-hint { font-size: var(--fs-xs); color: var(--text-faint); }

.input, .select, .textarea {
    width: 100%;
    padding: 0.72rem 0.9rem;
    font-size: var(--fs-sm);
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--error); }
.input.invalid:focus { box-shadow: 0 0 0 3px rgba(239,67,67,.3); }
.textarea { resize: vertical; min-height: 96px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.8rem center; padding-right: 2.2rem; }
.error-text { font-size: var(--fs-xs); color: var(--error); font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

/* Toggle switch ---------------------------------------------------------- */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    user-select: none;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    flex: 0 0 auto;
    width: 42px; height: 24px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    position: relative;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--iw-gradient); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Range slider ----------------------------------------------------------- */
.range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    outline: none;
}
.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--iw-purple);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform var(--dur) var(--ease);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.12); }
.range::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--iw-purple);
    cursor: pointer;
}
.range:focus-visible { outline: 2px solid var(--ring); outline-offset: 4px; }

/* Color field ------------------------------------------------------------ */
.color-row { display: flex; align-items: center; gap: var(--sp-3); }
.color-input {
    -webkit-appearance: none;
    appearance: none;
    width: 44px; height: 40px;
    padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-input::-moz-color-swatch { border: none; border-radius: 6px; }
.color-hex { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-muted); text-transform: uppercase; }

/* Segmented control ------------------------------------------------------ */
.seg {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    gap: 2px;
}
.seg-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 600;
    border-radius: 8px;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg-btn.active { background: var(--surface-3); }

/* Pro lock --------------------------------------------------------------- */
.pro-lock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: var(--r-pill);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    background: var(--iw-gradient);
    color: #fff;
}
.field.locked { opacity: 0.6; }
.field.locked .input, .field.locked .select, .field.locked .range, .field.locked .color-input { pointer-events: none; }

/* ---------------------------------------------------------------------------
   9. Generator layout + preview
   --------------------------------------------------------------------------- */
.gen-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr);
    gap: var(--sp-6);
    align-items: start;
}
.gen-form { display: flex; flex-direction: column; gap: var(--sp-5); }
.gen-group { display: flex; flex-direction: column; gap: var(--sp-4); }
.gen-group-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 800;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.gen-group-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.preview-panel {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-md);
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.preview-head h3 { font-size: var(--fs-lg); }
.preview-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    border-radius: var(--r-md);
    border: 1px dashed var(--border-strong);
    background:
        linear-gradient(45deg, var(--preview-checker) 25%, transparent 25%, transparent 75%, var(--preview-checker) 75%) 0 0 / 20px 20px,
        linear-gradient(45deg, var(--preview-checker) 25%, transparent 25%, transparent 75%, var(--preview-checker) 75%) 10px 10px / 20px 20px,
        var(--surface-2);
    padding: var(--sp-5);
    overflow: hidden;
}
.qr-preview { width: 100%; max-width: 320px; height: auto; border-radius: var(--r-sm); }
.qr-preview svg { width: 100%; height: auto; display: block; }
.preview-empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); color: var(--text-faint); text-align: center; padding: var(--sp-6); }
.preview-empty .pe-ico { font-size: 2.4rem; }
.preview-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.preview-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------------------------------------------------------------------------
   10. Subscriptions / plans
   --------------------------------------------------------------------------- */
.plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-5);
    align-items: stretch;
}
.plan-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-6);
    position: relative;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.plan-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.plan-card.featured {
    border-color: transparent;
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        var(--iw-gradient) border-box;
    border: 2px solid transparent;
    box-shadow: var(--shadow-glow);
}
.plan-flag {
    position: absolute;
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 14px;
    border-radius: var(--r-pill);
    background: var(--iw-gradient);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    white-space: nowrap;
    box-shadow: var(--shadow-glow);
}
.plan-name { font-size: var(--fs-lg); font-weight: 800; }
.plan-price { display: flex; align-items: baseline; gap: 6px; }
.plan-price .amount { font-size: var(--fs-4xl); font-weight: 800; letter-spacing: -0.03em; }
.plan-price .period { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }
.plan-desc { color: var(--text-muted); font-size: var(--fs-sm); }
.plan-features { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-2) 0; }
.plan-features li { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.plan-features li.off { color: var(--text-faint); }
.plan-features .x { color: var(--text-faint); font-weight: 800; flex: 0 0 auto; }
.plan-cta { margin-top: auto; }
.plan-note { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }

/* ---------------------------------------------------------------------------
   11. Boot screen
   --------------------------------------------------------------------------- */
.boot {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-5);
    background: var(--bg);
    z-index: 100;
}
.boot-logo {
    width: 72px; height: 72px;
    border-radius: 18px;
    background: var(--surface);
    padding: 10px;
    box-shadow: var(--shadow-md);
    animation: bootPulse 1.6s var(--ease) infinite;
}
.boot-bar {
    width: 180px; height: 5px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}
.boot-bar span {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: 999px;
    background: var(--iw-gradient);
    animation: bootSlide 1.2s var(--ease) infinite;
}
.boot-text { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }

@keyframes bootPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes bootSlide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* ---------------------------------------------------------------------------
   12. Blazor error UI
   --------------------------------------------------------------------------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    padding: var(--sp-4) var(--sp-5);
    background: #fff;
    color: #19181b;
    border-top: 3px solid var(--error);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    align-items: center;
    gap: var(--sp-3);
}
#blazor-error-ui.show { display: flex; }
#blazor-error-ui .reload { color: var(--primary); font-weight: 700; margin-left: auto; }
#blazor-error-ui .dismiss { margin-left: var(--sp-2); font-weight: 800; cursor: pointer; }

/* ---------------------------------------------------------------------------
   13. Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .gen-grid { grid-template-columns: 1fr; }
    .preview-panel { position: static; }
    .hero { grid-template-columns: 1fr; }
    .hero-visual { order: -1; }
    .hero-qr { max-width: 180px; }
}

@media (max-width: 860px) {
    :root { --sidebar-w: 0px; }
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .app.sidebar-open .sidebar { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 0 var(--sp-4); }
    .topbar-actions .upgrade-cta { display: none; }
    .content { padding: var(--sp-4); }
    .theme-btn { padding: 6px 8px; }
    .theme-btn .t-label { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .hero { padding: var(--sp-5); }
    .hero-copy h1 { font-size: var(--fs-2xl); }
}

/* ---------------------------------------------------------------------------
   14. Reduced motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
