/* ═══════════════════════════════════════════════
       DESIGN TOKENS
    ═══════════════════════════════════════════════ */
    :root {
      --bg:          #080B10;
      --surface:     #0E1117;
      --surface2:    #141820;
      --border:      rgba(255,255,255,0.07);
      --border-hi:   rgba(255,255,255,0.14);
      --text:        #E8ECF0;
      --muted:       rgba(232,236,240,0.45);
      --accent:      #3FFFB0;
      --accent-dim:  rgba(63,255,176,0.12);
      --accent-glow: rgba(63,255,176,0.25);
      --red:         #FF4D6A;
      --blue:        #4D9FFF;
      --yellow:      #FFD166;
      --font-display:'Syne', sans-serif;
      --font-body:   'DM Sans', sans-serif;
      --font-mono:   'DM Mono', monospace;
      --radius:      20px;
      --radius-sm:   12px;
      --nav-h:       62px;
      --bn-h:        68px;
    }

    /* Light theme */
    body.light {
      --bg:         #F2F4F8;
      --surface:    #FFFFFF;
      --surface2:   #EBEDF2;
      --border:     rgba(0,0,0,0.07);
      --border-hi:  rgba(0,0,0,0.14);
      --text:       #12151A;
      --muted:      rgba(18,21,26,0.45);
      --accent:     #00C070;
      --accent-dim: rgba(0,192,112,0.10);
      --accent-glow:rgba(0,192,112,0.22);
    }

    /* ═══════════════════════════════════════════════
       RESET & BASE
    ═══════════════════════════════════════════════ */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { scroll-behavior: smooth; }
    body {
      font-family: var(--font-body);
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      overflow-x: hidden;
      -webkit-font-smoothing: antialiased;
      transition: background .25s, color .25s;
    }

    /* Grain overlay */
    body::before {
      content: '';
      position: fixed; inset: 0; z-index: 0; pointer-events: none;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
      opacity: .025;
    }

    /* ═══════════════════════════════════════════════
       ONBOARDING
    ═══════════════════════════════════════════════ */
    #onboarding {
      position: fixed; inset: 0; z-index: 9999;
      display: flex; align-items: center; justify-content: center;
      background: #040608;
      overflow: hidden;
    }
    .ob-grid {
      position: absolute; inset: 0; pointer-events: none;
      background-image:
        linear-gradient(rgba(63,255,176,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(63,255,176,.04) 1px, transparent 1px);
      background-size: 48px 48px;
      mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black, transparent);
    }
    .ob-orb1 {
      position: absolute; width: 500px; height: 500px; border-radius: 50%;
      background: radial-gradient(circle, rgba(63,255,176,.18) 0%, transparent 70%);
      top: -150px; left: -100px;
      animation: orbFloat 10s ease-in-out infinite;
    }
    .ob-orb2 {
      position: absolute; width: 360px; height: 360px; border-radius: 50%;
      background: radial-gradient(circle, rgba(77,159,255,.15) 0%, transparent 70%);
      bottom: -80px; right: -80px;
      animation: orbFloat 13s ease-in-out infinite reverse;
    }
    @keyframes orbFloat {
      0%,100% { transform: translate(0,0) scale(1); }
      50%      { transform: translate(20px,-30px) scale(1.05); }
    }

    .ob-wrap {
      position: relative; z-index: 2;
      width: 92%; max-width: 400px; text-align: center;
    }

    .ob-slide { display: none; }
    .ob-slide.active {
      display: block;
      animation: obIn .45s cubic-bezier(.34,1.56,.64,1) both;
    }
    @keyframes obIn {
      from { opacity:0; transform: translateY(28px) scale(.96); }
      to   { opacity:1; transform: translateY(0) scale(1); }
    }

    .ob-icon {
      width: 96px; height: 96px; margin: 0 auto 28px;
      border-radius: 28px;
      border: 1px solid rgba(63,255,176,.25);
      background: rgba(63,255,176,.06);
      backdrop-filter: blur(12px);
      display: flex; align-items: center; justify-content: center;
      font-size: 2.6rem;
      box-shadow: 0 0 40px rgba(63,255,176,.12), inset 0 1px 0 rgba(255,255,255,.06);
    }

    .ob-chip {
      display: inline-block; margin-bottom: 18px;
      padding: 4px 14px; border-radius: 40px;
      background: rgba(63,255,176,.1); border: 1px solid rgba(63,255,176,.3);
      color: var(--accent); font-size: .7rem; font-weight: 600;
      letter-spacing: 2px; text-transform: uppercase; font-family: var(--font-mono);
    }

    .ob-title {
      font-family: var(--font-display); font-size: 2.2rem; font-weight: 800;
      color: #fff; line-height: 1.15; margin-bottom: 14px;
    }
    .ob-title em { font-style: normal; color: var(--accent); }

    .ob-desc { color: rgba(255,255,255,.5); font-size: .96rem; line-height: 1.75; margin-bottom: 32px; }

    .ob-pills {
      display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 36px;
    }
    .ob-pill {
      padding: 7px 15px; border-radius: 30px; font-size: .78rem; font-weight: 600;
      background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
      color: rgba(255,255,255,.75);
      animation: pillPop .4s cubic-bezier(.34,1.56,.64,1) both;
    }
    .ob-pill:nth-child(1){animation-delay:.08s}
    .ob-pill:nth-child(2){animation-delay:.16s}
    .ob-pill:nth-child(3){animation-delay:.24s}
    .ob-pill:nth-child(4){animation-delay:.32s}
    @keyframes pillPop { from{opacity:0;transform:scale(.7)} to{opacity:1;transform:scale(1)} }

    .ob-cta {
      width: 100%; padding: 16px;
      background: var(--accent); color: #040608;
      border: none; border-radius: var(--radius-sm);
      font-family: var(--font-display); font-size: 1rem; font-weight: 800;
      cursor: pointer; letter-spacing: .5px;
      box-shadow: 0 8px 32px rgba(63,255,176,.3);
      transition: transform .15s, box-shadow .15s;
    }
    .ob-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(63,255,176,.4); }
    .ob-cta:active { transform: scale(.97); }
    .ob-cta.green { background: #22D96A; box-shadow: 0 8px 32px rgba(34,217,106,.3); }

    .ob-skip {
      background: none; border: none; color: rgba(255,255,255,.28);
      font-size: .83rem; cursor: pointer; margin-top: 14px;
      font-family: var(--font-body); transition: color .2s;
    }
    .ob-skip:hover { color: rgba(255,255,255,.6); }

    .ob-dots {
      display: flex; justify-content: center; gap: 7px; margin-bottom: 32px;
    }
    .ob-dot {
      height: 5px; border-radius: 3px; background: rgba(255,255,255,.15);
      transition: all .35s cubic-bezier(.34,1.56,.64,1); cursor: pointer;
    }
    .ob-dot.active { background: var(--accent); width: 24px !important; box-shadow: 0 0 8px var(--accent); }
    .ob-dot:not(.active) { width: 5px; }

    #onboarding.exit {
      animation: obExit .5s ease forwards;
    }
    @keyframes obExit {
      to { opacity: 0; transform: scale(.94); pointer-events: none; }
    }

    /* ═══════════════════════════════════════════════
       TOPNAV
    ═══════════════════════════════════════════════ */
    .topnav {
      position: sticky; top: 0; z-index: 1000;
      height: var(--nav-h);
      background: rgba(8,11,16,.85);
      backdrop-filter: blur(20px) saturate(150%);
      border-bottom: 1px solid var(--border);
      display: flex; align-items: center;
    }
    body.light .topnav { background: rgba(242,244,248,.88); }

    .topnav-inner {
      width: 100%; max-width: 900px; margin: 0 auto;
      padding: 0 20px;
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
    }

    .topnav-left { display: flex; align-items: center; gap: 10px; }

    .burger-btn {
      width: 40px; height: 40px; border-radius: 10px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--text); cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      flex-direction: column; gap: 5px; transition: background .2s;
    }
    .burger-btn span {
      display: block; width: 18px; height: 1.5px;
      background: currentColor; border-radius: 2px;
      transition: transform .25s, opacity .25s;
    }
    .burger-btn:hover { background: var(--border-hi); }

    .logo {
      font-family: var(--font-display); font-size: 1.25rem; font-weight: 800;
      color: var(--text); letter-spacing: -.5px;
    }
    .logo-dot { color: var(--accent); }

    .topnav-right { display: flex; align-items: center; gap: 8px; }

    .nav-icon-btn {
      width: 38px; height: 38px; border-radius: 10px;
      background: transparent; border: 1px solid var(--border);
      color: var(--muted); cursor: pointer; font-size: 1rem;
      display: flex; align-items: center; justify-content: center;
      transition: background .2s, color .2s, border-color .2s;
    }
    .nav-icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hi); }

    #authNavArea { display: flex; }

    .auth-nav-btn {
      padding: 8px 16px; border-radius: 10px;
      background: var(--accent-dim); border: 1px solid rgba(63,255,176,.25);
      color: var(--accent); font-family: var(--font-body); font-weight: 600;
      font-size: .83rem; cursor: pointer; transition: background .2s;
    }
    .auth-nav-btn:hover { background: rgba(63,255,176,.2); }

    /* PWA Install Button */
    .pwa-install-btn {
      display: none; align-items: center; gap: 6px;
      padding: 7px 13px; border-radius: 10px;
      background: linear-gradient(135deg, rgba(63,255,176,.15), rgba(77,159,255,.1));
      border: 1px solid rgba(63,255,176,.3);
      color: var(--accent); font-family: var(--font-body); font-weight: 600;
      font-size: .78rem; cursor: pointer;
      transition: background .2s, transform .15s, box-shadow .2s;
      animation: pwaBtn .5s cubic-bezier(.34,1.56,.64,1) both;
    }
    .pwa-install-btn:hover {
      background: rgba(63,255,176,.22);
      transform: translateY(-1px);
      box-shadow: 0 4px 16px rgba(63,255,176,.2);
    }
    @keyframes pwaBtn {
      from { opacity:0; transform: scale(.8); }
      to   { opacity:1; transform: scale(1); }
    }
    .pwa-install-btn svg { width:14px; height:14px; fill:currentColor; flex-shrink:0; }

    /* ═══════════════════════════════════════════════
       SIDEBAR
    ═══════════════════════════════════════════════ */
    .overlay {
      position: fixed; inset: 0; z-index: 1999;
      background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
      opacity: 0; visibility: hidden; transition: opacity .28s, visibility .28s;
    }
    .overlay.open { opacity: 1; visibility: visible; }

    .sidebar {
      position: fixed; top: 0; left: 0; height: 100%; z-index: 2000;
      width: 280px;
      background: var(--surface);
      border-right: 1px solid var(--border);
      transform: translateX(-100%);
      transition: transform .3s cubic-bezier(.4,0,.2,1);
      display: flex; flex-direction: column; overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-head {
      padding: 24px 22px 16px;
      border-bottom: 1px solid var(--border);
    }
    .sidebar-brand {
      font-family: var(--font-display); font-size: 1.1rem; font-weight: 800;
      color: var(--accent);
    }
    .sidebar-sub { font-size: .75rem; color: var(--muted); margin-top: 3px; }

    .sidebar-section { padding: 10px 0; }
    .sidebar-label {
      padding: 6px 20px; font-size: .65rem; font-weight: 600;
      letter-spacing: 1.5px; text-transform: uppercase;
      color: var(--muted); font-family: var(--font-mono);
    }

    .sidebar-item {
      width: 100%; padding: 13px 20px;
      background: none; border: none; color: var(--text);
      text-align: left; cursor: pointer; font-family: var(--font-body);
      font-size: .92rem; font-weight: 500;
      display: flex; align-items: center; gap: 12px;
      transition: background .18s, color .18s; border-radius: 0;
    }
    .sidebar-item .si-icon {
      width: 32px; height: 32px; border-radius: 9px;
      display: flex; align-items: center; justify-content: center;
      font-size: .95rem;
      background: var(--surface2); flex-shrink: 0;
    }
    .sidebar-item:hover { background: var(--surface2); }
    .sidebar-item.active { color: var(--accent); }
    .sidebar-item.active .si-icon { background: var(--accent-dim); }

    .sidebar-footer {
      margin-top: auto; padding: 16px 20px;
      border-top: 1px solid var(--border);
      font-size: .75rem; color: var(--muted);
    }
    .sidebar-footer a { color: var(--muted); text-decoration: none; margin-right: 12px; }
    .sidebar-footer a:hover { color: var(--text); }

    /* ═══════════════════════════════════════════════
       QUICK-ACCESS BAR (FAV)
    ═══════════════════════════════════════════════ */
    .quickbar {
      width: 100%; overflow-x: auto; scrollbar-width: none;
      padding: 10px 16px;
      display: flex; gap: 8px; align-items: center;
    }
    .quickbar::-webkit-scrollbar { display: none; }
    .qb-item {
      flex-shrink: 0; padding: 7px 14px; border-radius: 30px;
      background: var(--surface); border: 1px solid var(--border);
      color: var(--muted); font-size: .78rem; font-weight: 600;
      cursor: pointer; transition: all .18s; white-space: nowrap;
    }
    .qb-item:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

    /* ═══════════════════════════════════════════════
       TABS / MAIN LAYOUT
    ═══════════════════════════════════════════════ */
    main { padding: 0 0 16px; }

    .tab { display: none; flex-direction: column; align-items: center; padding: 20px 16px; }
    .tab.active { display: flex; animation: tabIn .35s ease both; }
    @keyframes tabIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

    /* ═══════════════════════════════════════════════
       CARD SYSTEM
    ═══════════════════════════════════════════════ */
    .card {
      width: 100%; max-width: 520px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
      margin-bottom: 16px;
      position: relative;
      overflow: hidden;
    }
    .card::before {
      content: '';
      position: absolute; top: 0; left: 0; right: 0; height: 1px;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
    }

    .card-title {
      font-family: var(--font-display); font-size: 1.15rem; font-weight: 800;
      color: var(--text); margin-bottom: 4px;
      display: flex; align-items: center; gap: 10px;
    }
    .card-title .badge-live {
      font-family: var(--font-mono); font-size: .6rem; font-weight: 500;
      padding: 3px 8px; border-radius: 20px;
      background: rgba(34,217,106,.15); color: #22D96A; border: 1px solid rgba(34,217,106,.3);
      letter-spacing: 1px; display: none;
    }

    .card-sub {
      font-size: .78rem; color: var(--muted); margin-bottom: 20px;
      font-family: var(--font-mono);
    }

    .section-title {
      font-family: var(--font-mono); font-size: .68rem; font-weight: 500;
      letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
      margin: 20px 0 10px; border-top: 1px solid var(--border); padding-top: 20px;
    }

    /* ═══════════════════════════════════════════════
       FORM ELEMENTS
    ═══════════════════════════════════════════════ */
    label {
      display: block; font-size: .75rem; font-weight: 600; color: var(--muted);
      margin-bottom: 6px; font-family: var(--font-mono);
      letter-spacing: .5px; text-transform: uppercase;
    }

    input, select, textarea {
      width: 100%;
      padding: 13px 16px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      color: var(--text); font-family: var(--font-body); font-size: .95rem;
      outline: none; margin-bottom: 10px; transition: border-color .18s, box-shadow .18s;
      -webkit-appearance: none; appearance: none;
    }
    input:focus, select:focus, textarea:focus {
      border-color: rgba(63,255,176,.4);
      box-shadow: 0 0 0 3px rgba(63,255,176,.08);
    }
    textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
    select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }
    input[type="date"] { cursor: pointer; }
    input[type="number"] { -moz-appearance: textfield; }
    input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

    /* ═══════════════════════════════════════════════
       BUTTONS
    ═══════════════════════════════════════════════ */
    .btn-primary {
      width: 100%; padding: 14px;
      background: var(--accent); color: #040608;
      border: none; border-radius: var(--radius-sm);
      font-family: var(--font-display); font-weight: 800; font-size: .92rem;
      cursor: pointer; transition: transform .15s, box-shadow .15s, opacity .15s;
      letter-spacing: .3px; margin-bottom: 10px;
    }
    .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }
    .btn-primary:active { transform: scale(.97); }

    .btn-secondary {
      padding: 10px 18px; border-radius: var(--radius-sm);
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--text); font-family: var(--font-body); font-weight: 600;
      font-size: .85rem; cursor: pointer; transition: background .18s, border-color .18s;
    }
    .btn-secondary:hover { background: var(--border-hi); }

    .btn-group { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
    .btn-pill {
      flex: 1; min-width: 80px;
      padding: 9px 12px; border-radius: 30px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--muted); font-family: var(--font-body); font-weight: 600;
      font-size: .8rem; cursor: pointer; text-align: center;
      transition: all .18s;
    }
    .btn-pill:hover { border-color: var(--accent); color: var(--accent); }
    .btn-pill.active { background: var(--accent-dim); border-color: rgba(63,255,176,.4); color: var(--accent); }

    /* ═══════════════════════════════════════════════
       RESULT DISPLAY
    ═══════════════════════════════════════════════ */
    .result-box {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 18px 20px;
      margin: 12px 0;
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      min-height: 60px;
    }
    .result-main {
      font-family: var(--font-display); font-size: 1.5rem; font-weight: 800;
      color: var(--accent); word-break: break-all; line-height: 1.2;
    }
    .result-main.pop { animation: resultPop .3s cubic-bezier(.34,1.56,.64,1); }
    @keyframes resultPop { 0%{transform:scale(.92)} 100%{transform:scale(1)} }

    .result-label {
      font-family: var(--font-mono); font-size: .65rem; letter-spacing: 1px;
      text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
    }
    .result-sub {
      font-size: .78rem; color: var(--muted); margin-top: 6px; line-height: 1.6;
    }

    .copy-btn {
      background: none; border: none; cursor: pointer;
      width: 34px; height: 34px; border-radius: 8px;
      color: var(--muted); font-size: .95rem;
      display: flex; align-items: center; justify-content: center;
      transition: background .18s, color .18s; flex-shrink: 0;
    }
    .copy-btn:hover { background: var(--border); color: var(--text); }

    /* ═══════════════════════════════════════════════
       CATEGORY TABS (converter)
    ═══════════════════════════════════════════════ */
    .cat-scroll {
      display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
      margin-bottom: 16px; padding-bottom: 2px;
    }
    .cat-scroll::-webkit-scrollbar { display: none; }
    .cat-btn {
      flex-shrink: 0; padding: 7px 14px; border-radius: 20px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--muted); font-size: .78rem; font-weight: 600;
      cursor: pointer; transition: all .18s; white-space: nowrap;
      font-family: var(--font-body);
    }
    .cat-btn.active { background: var(--accent-dim); border-color: rgba(63,255,176,.4); color: var(--accent); }

    .swap-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
    .swap-row input, .swap-row select { margin-bottom: 0; }
    .swap-btn {
      width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--accent); cursor: pointer; font-size: 1rem;
      display: flex; align-items: center; justify-content: center;
      transition: background .18s; transform: rotate(90deg);
    }
    .swap-btn:hover { background: var(--border-hi); }

    /* ═══════════════════════════════════════════════
       CHART & HISTORY
    ═══════════════════════════════════════════════ */
    #chartSection { margin-top: 16px; }
    .chart-wrap { height: 140px; margin-bottom: 12px; }
    .history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
    .history-item {
      padding: 10px 14px; background: var(--surface2); border-radius: var(--radius-sm);
      font-size: .82rem; color: var(--muted); font-family: var(--font-mono);
      border: 1px solid var(--border);
    }
    .clear-link {
      font-size: .72rem; color: var(--muted); cursor: pointer; background: none; border: none;
      font-family: var(--font-mono); padding: 4px 0;
      transition: color .18s;
    }
    .clear-link:hover { color: var(--red); }

    /* ═══════════════════════════════════════════════
       SIZE TABLE
    ═══════════════════════════════════════════════ */
    .data-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
    .data-table th {
      padding: 10px 12px; text-align: center;
      font-family: var(--font-mono); font-size: .7rem; letter-spacing: 1px; text-transform: uppercase;
      color: var(--muted); background: var(--surface2); border-bottom: 1px solid var(--border);
    }
    .data-table td {
      padding: 10px 12px; text-align: center; font-size: .85rem;
      border-bottom: 1px solid var(--border); color: var(--text);
    }
    .data-table tr:last-child td { border-bottom: none; }
    .data-table tr:hover td { background: var(--surface2); }
    .table-scroll { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

    /* ═══════════════════════════════════════════════
       COLOR PREVIEW
    ═══════════════════════════════════════════════ */
    #colorPreview {
      width: 100%; height: 72px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); margin-bottom: 12px; transition: background .3s;
    }

    /* ═══════════════════════════════════════════════
       BMI SCALE
    ═══════════════════════════════════════════════ */
    .bmi-scale {
      margin: 10px 0;
      height: 6px; border-radius: 6px;
      background: linear-gradient(90deg, #4D9FFF, #3FFFB0, #FFD166, #FF4D6A);
    }
    .bmi-labels {
      display: flex; justify-content: space-between;
      font-size: .62rem; color: var(--muted); margin-top: 5px;
      font-family: var(--font-mono);
    }

    /* ═══════════════════════════════════════════════
       BOTTOM NAV
    ═══════════════════════════════════════════════ */
    .bottom-nav {
      position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
      height: var(--bn-h);
      background: rgba(8,11,16,.9);
      backdrop-filter: blur(20px) saturate(160%);
      border-top: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-around;
      padding: 0 8px env(safe-area-inset-bottom);
    }
    body.light .bottom-nav { background: rgba(242,244,248,.92); }

    .bn-item {
      flex: 1; background: none; border: none; cursor: pointer;
      display: flex; flex-direction: column; align-items: center; gap: 4px;
      padding: 8px 6px; border-radius: var(--radius-sm);
      transition: background .18s;
      position: relative; color: var(--muted);
    }
    .bn-item:hover { background: var(--surface2); }
    .bn-icon { font-size: 1.25rem; line-height: 1; }
    .bn-label { font-size: .62rem; font-weight: 600; font-family: var(--font-mono); color: inherit; }
    .bn-item.active { color: var(--accent); }
    .bn-item.active::after {
      content: '';
      position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
      width: 20px; height: 2px; border-radius: 1px;
      background: var(--accent); box-shadow: 0 0 8px var(--accent);
    }

    /* ═══════════════════════════════════════════════
       AUTH MODAL
    ═══════════════════════════════════════════════ */
    .modal-overlay {
      position: fixed; inset: 0; z-index: 9000;
      background: rgba(0,0,0,.75); backdrop-filter: blur(12px);
      display: flex; align-items: center; justify-content: center;
      opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
    }
    .modal-overlay.open { opacity: 1; visibility: visible; }

    .modal {
      background: var(--surface); border: 1px solid var(--border-hi);
      border-radius: 28px; padding: 32px 28px 28px;
      width: 92%; max-width: 380px; position: relative;
      transform: translateY(20px) scale(.97);
      transition: transform .3s cubic-bezier(.34,1.56,.64,1);
      box-shadow: 0 32px 80px rgba(0,0,0,.5);
    }
    .modal-overlay.open .modal { transform: translateY(0) scale(1); }

    .modal-close {
      position: absolute; top: 16px; right: 16px;
      width: 32px; height: 32px; border-radius: 8px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--muted); cursor: pointer; font-size: 1rem;
      display: flex; align-items: center; justify-content: center;
      transition: background .18s, color .18s;
    }
    .modal-close:hover { background: var(--border); color: var(--text); }

    .auth-tabs-row {
      display: flex; gap: 4px; background: var(--surface2); border-radius: 12px;
      padding: 4px; margin-bottom: 24px;
    }
    .auth-tab {
      flex: 1; padding: 9px; border: none; border-radius: 8px;
      background: transparent; color: var(--muted);
      font-family: var(--font-body); font-weight: 700; font-size: .85rem;
      cursor: pointer; transition: all .2s;
    }
    .auth-tab.active { background: var(--accent); color: #040608; }

    .auth-form { display: none; }
    .auth-form.active { display: block; }

    .modal-title {
      font-family: var(--font-display); font-size: 1.4rem; font-weight: 800;
      color: var(--text); margin-bottom: 4px;
    }
    .modal-sub { font-size: .8rem; color: var(--muted); margin-bottom: 22px; font-family: var(--font-mono); }

    .auth-input-wrap { position: relative; margin-bottom: 12px; }
    .auth-input-wrap input {
      padding-left: 42px; margin-bottom: 0;
      background: var(--surface2); border: 1px solid var(--border);
    }
    .auth-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
    .field-err { font-size: .72rem; color: var(--red); margin: 3px 0 8px 4px; display: none; }
    .field-err.show { display: block; }
    input.err { border-color: var(--red) !important; }

    .auth-check-wrap {
      display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; cursor: pointer;
    }
    .auth-check-wrap input[type=checkbox] {
      width: 16px; height: 16px; margin: 0; flex-shrink: 0; accent-color: var(--accent);
    }
    .auth-check-wrap span { font-size: .78rem; color: var(--muted); line-height: 1.5; }
    .auth-check-wrap a { color: var(--accent); text-decoration: none; }

    .btn-auth {
      width: 100%; padding: 14px; border: none; border-radius: 12px;
      background: var(--accent); color: #040608;
      font-family: var(--font-display); font-weight: 800; font-size: .95rem;
      cursor: pointer; transition: transform .15s, box-shadow .15s;
      position: relative; overflow: hidden;
    }
    .btn-auth:hover { transform: translateY(-1px); box-shadow: 0 8px 28px var(--accent-glow); }
    .btn-auth:disabled { opacity: .55; cursor: not-allowed; transform: none; }
    .btn-loader {
      display: none; width: 18px; height: 18px; margin: 0 auto;
      border: 2px solid rgba(4,6,8,.3); border-top-color: #040608;
      border-radius: 50%; animation: spin .6s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .auth-divider {
      display: flex; align-items: center; gap: 10px; margin: 18px 0;
      font-size: .72rem; color: var(--muted); font-family: var(--font-mono);
    }
    .auth-divider::before, .auth-divider::after {
      content: ''; flex: 1; height: 1px; background: var(--border);
    }

    .btn-google {
      width: 100%; padding: 12px; border-radius: 12px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--text); font-family: var(--font-body); font-weight: 600;
      font-size: .9rem; cursor: pointer;
      display: flex; align-items: center; justify-content: center; gap: 10px;
      transition: border-color .2s, background .2s;
    }
    .btn-google:hover { border-color: rgba(66,133,244,.4); background: rgba(66,133,244,.05); }

    .email-sent-panel {
      display: none; text-align: center; padding: 12px 0;
    }
    .email-sent-panel.show { display: block; }
    .email-sent-icon { font-size: 3rem; margin-bottom: 10px; }
    .email-sent-title {
      font-family: var(--font-display); font-size: 1.1rem; font-weight: 800;
      color: var(--accent); margin-bottom: 8px;
    }
    .email-sent-text { font-size: .82rem; color: var(--muted); line-height: 1.6; }

    .auth-profile-wrap { position: relative; }
    .auth-profile-btn {
      padding: 7px 13px; border-radius: 10px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--text); cursor: pointer; font-family: var(--font-body);
      font-weight: 600; font-size: .82rem;
      display: flex; align-items: center; gap: 8px;
      transition: background .18s;
    }
    .auth-profile-btn:hover { background: var(--border); }
    .auth-avatar {
      width: 26px; height: 26px; border-radius: 50%;
      background: linear-gradient(135deg, var(--accent), var(--blue));
      display: flex; align-items: center; justify-content: center;
      font-size: .7rem; font-weight: 800; color: #040608;
    }
    .auth-dropdown {
      position: absolute; top: calc(100% + 8px); right: 0;
      background: var(--surface); border: 1px solid var(--border-hi); border-radius: 14px;
      min-width: 190px; overflow: hidden; z-index: 3000;
      box-shadow: 0 16px 48px rgba(0,0,0,.3);
      transform: translateY(-8px); opacity: 0; visibility: hidden;
      transition: all .22s cubic-bezier(.34,1.56,.64,1);
    }
    .auth-dropdown.open { transform: translateY(0); opacity: 1; visibility: visible; }
    .dropdown-head { padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .dropdown-name { font-weight: 800; font-size: .9rem; color: var(--accent); }
    .dropdown-email { font-size: .72rem; color: var(--muted); margin-top: 2px; font-family: var(--font-mono); }
    .dropdown-item {
      width: 100%; padding: 12px 16px; border: none; background: transparent;
      color: var(--text); text-align: left; cursor: pointer;
      font-family: var(--font-body); font-size: .85rem;
      display: flex; align-items: center; gap: 9px;
      transition: background .15s;
    }
    .dropdown-item:hover { background: var(--surface2); }
    .dropdown-item.danger { color: var(--red); }

    /* ═══════════════════════════════════════════════
       TOAST
    ═══════════════════════════════════════════════ */
    .toast {
      position: fixed; bottom: calc(var(--bn-h) + 16px); left: 50%;
      transform: translateX(-50%) translateY(10px);
      padding: 11px 20px; border-radius: 30px;
      background: var(--surface); border: 1px solid var(--border);
      color: var(--text); font-size: .84rem; font-weight: 600;
      z-index: 9999; opacity: 0; pointer-events: none;
      transition: all .3s cubic-bezier(.34,1.56,.64,1);
      white-space: nowrap; font-family: var(--font-mono);
      box-shadow: 0 8px 32px rgba(0,0,0,.3);
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
    .toast.success { background: rgba(34,217,106,.15); border-color: rgba(34,217,106,.3); color: #22D96A; }
    .toast.error   { background: rgba(255,77,106,.12); border-color: rgba(255,77,106,.3); color: var(--red); }

    /* ═══════════════════════════════════════════════
       ADMIN PANEL
    ═══════════════════════════════════════════════ */
    #adminPanel {
      position: fixed; bottom: calc(var(--bn-h) + 12px); right: 12px; z-index: 8888;
      background: var(--surface); border: 1px solid var(--border-hi); border-radius: 16px;
      padding: 16px 18px; min-width: 190px; display: none;
      box-shadow: 0 8px 32px rgba(0,0,0,.4);
    }
    .admin-title { font-family: var(--font-mono); font-size: .65rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
    .admin-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
    .admin-num { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--blue); }
    .admin-lbl { font-size: .72rem; color: var(--muted); }
    .admin-close { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: .9rem; }

    /* ═══════════════════════════════════════════════
       UTILITY
    ═══════════════════════════════════════════════ */
    /* ═══════════════════════════════════════════════
       HISTORY PANEL (full-featured)
    ═══════════════════════════════════════════════ */
    .history-panel {
      margin-top: 16px;
    }
    .history-panel-header {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 12px;
    }
    .history-panel-title {
      font-family: var(--font-mono); font-size: .65rem; font-weight: 700;
      letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
    }
    .history-filter-row {
      display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
    }
    .history-filter-btn {
      padding: 5px 12px; border-radius: 20px; font-size: .72rem; font-weight: 600;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--muted); cursor: pointer; transition: all .18s;
      font-family: var(--font-mono);
    }
    .history-filter-btn.active {
      background: var(--accent-dim); border-color: rgba(63,255,176,.4); color: var(--accent);
    }
    .history-entry {
      display: flex; align-items: center; justify-content: space-between; gap: 10px;
      padding: 12px 14px; background: var(--surface2); border-radius: var(--radius-sm);
      border: 1px solid var(--border); margin-bottom: 7px;
      animation: histIn .3s cubic-bezier(.34,1.4,.64,1) both;
    }
    @keyframes histIn { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
    .history-entry-left { flex: 1; min-width: 0; }
    .history-entry-type {
      font-size: .62rem; font-family: var(--font-mono); font-weight: 700;
      letter-spacing: 1px; text-transform: uppercase;
      color: var(--accent); margin-bottom: 3px;
    }
    .history-entry-value {
      font-family: var(--font-mono); font-size: .88rem; color: var(--text);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .history-entry-time {
      font-size: .64rem; color: var(--muted); margin-top: 2px;
    }
    .history-entry-actions { display: flex; gap: 5px; flex-shrink: 0; }
    .history-action-btn {
      width: 28px; height: 28px; border-radius: 7px;
      background: none; border: 1px solid var(--border);
      color: var(--muted); cursor: pointer; font-size: .75rem;
      display: flex; align-items: center; justify-content: center;
      transition: background .15s, color .15s;
    }
    .history-action-btn:hover { background: var(--surface); color: var(--text); }
    .history-action-btn.del:hover { background: rgba(255,77,106,.1); color: var(--red); border-color: rgba(255,77,106,.3); }
    .history-empty {
      text-align: center; padding: 28px 16px;
      color: var(--muted); font-size: .84rem; font-family: var(--font-mono);
    }
    .history-empty-icon { font-size: 2rem; margin-bottom: 8px; }

    /* ─── History Tab (sidebar tab) ─── */
    #tab-history .card { max-width: 520px; }
    .hist-stats-row {
      display: flex; gap: 10px; margin-bottom: 16px;
    }
    .hist-stat-box {
      flex: 1; background: var(--surface2); border: 1px solid var(--border);
      border-radius: var(--radius-sm); padding: 12px 14px; text-align: center;
    }
    .hist-stat-num {
      font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--accent);
    }
    .hist-stat-lbl { font-size: .65rem; color: var(--muted); font-family: var(--font-mono); margin-top: 2px; }

    /* Keyboard trap for modal */
    .modal-overlay:focus { outline: none; }

    hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
    .mono { font-family: var(--font-mono); }
    .text-accent { color: var(--accent); }
    .mt-0 { margin-top: 0 !important; }

    /* share btn */
    .share-btn {
      padding: 9px 16px; border-radius: 30px;
      background: var(--surface2); border: 1px solid var(--border);
      color: var(--muted); font-size: .78rem; font-weight: 600; cursor: pointer;
      transition: all .18s; font-family: var(--font-mono);
    }
    .share-btn:hover { border-color: var(--accent); color: var(--accent); }

    /* ═══ MULTI-CONV & CRYPTO STYLES ═══ */
    .multi-conv-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 9px 14px; background: var(--surface2); border-radius: var(--radius-sm);
      border: 1px solid var(--border);
    }
    .multi-conv-flag { font-size: 1rem; margin-right: 6px; }
    .multi-conv-code { font-family: var(--font-mono); font-size: .75rem; font-weight: 700; color: var(--muted); min-width: 36px; }
    .multi-conv-name { font-size: .78rem; color: var(--muted); flex: 1; }
    .multi-conv-val { font-family: var(--font-mono); font-size: .9rem; font-weight: 700; color: var(--accent); }

    .crypto-ticker-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 10px 14px; background: var(--surface2); border-radius: var(--radius-sm);
      border: 1px solid var(--border);
    }
    .crypto-ticker-left { display: flex; align-items: center; gap: 10px; }
    .crypto-ticker-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-dim); display: flex; align-items: center; justify-content: center; font-size: .85rem; }
    .crypto-ticker-name { font-weight: 700; font-size: .85rem; }
    .crypto-ticker-sym { font-family: var(--font-mono); font-size: .68rem; color: var(--muted); margin-top: 2px; }
    .crypto-ticker-right { text-align: right; }
    .crypto-ticker-price { font-family: var(--font-mono); font-size: .88rem; font-weight: 700; color: var(--text); }
    .crypto-ticker-change { font-family: var(--font-mono); font-size: .72rem; font-weight: 700; margin-top: 2px; }
    .crypto-ticker-change.up { color: #22D96A; }
    .crypto-ticker-change.down { color: var(--red); }

    /* ═══════════════════════════════════════════════
       HOME PAGE
    ═══════════════════════════════════════════════ */
    .home-hero {
      width: 100%; max-width: 520px;
      text-align: center; padding: 28px 0 16px;
    }
    .home-badge {
      display: inline-block; margin-bottom: 16px;
      padding: 5px 16px; border-radius: 40px;
      background: var(--accent-dim); border: 1px solid rgba(63,255,176,.3);
      color: var(--accent); font-size: .7rem; font-weight: 700;
      letter-spacing: 2px; text-transform: uppercase; font-family: var(--font-mono);
    }
    .home-title {
      font-family: var(--font-display); font-size: 2.4rem; font-weight: 800;
      color: var(--text); line-height: 1.12; margin-bottom: 14px;
    }
    .home-title em { font-style: normal; color: var(--accent); }
    .home-desc {
      font-size: .96rem; color: var(--muted); line-height: 1.75; margin-bottom: 28px;
    }
    .home-stats {
      display: flex; justify-content: center; gap: 28px; margin-bottom: 32px;
      flex-wrap: wrap;
    }
    .home-stat { text-align: center; }
    .home-stat-num {
      font-family: var(--font-display); font-size: 1.8rem; font-weight: 800;
      color: var(--accent); line-height: 1;
    }
    .home-stat-lbl {
      font-size: .7rem; color: var(--muted); font-family: var(--font-mono);
      letter-spacing: .5px; margin-top: 4px;
    }

    .home-section-label {
      width: 100%; max-width: 520px;
      font-family: var(--font-mono); font-size: .65rem; font-weight: 700;
      letter-spacing: 2px; text-transform: uppercase; color: var(--muted);
      margin: 8px 0 12px; display: flex; align-items: center; gap: 10px;
    }
    .home-section-label::after {
      content: ''; flex: 1; height: 1px; background: var(--border);
    }

    .tools-grid {
      width: 100%; max-width: 520px;
      display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
      margin-bottom: 8px;
    }
    .tool-card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 18px 16px;
      cursor: pointer; transition: all .22s cubic-bezier(.34,1.2,.64,1);
      text-align: left; position: relative; overflow: hidden;
    }
    .tool-card::before {
      content: ''; position: absolute; inset: 0; opacity: 0;
      background: radial-gradient(circle at 30% 30%, var(--accent-glow), transparent 70%);
      transition: opacity .25s;
    }
    .tool-card:hover { border-color: rgba(63,255,176,.3); transform: translateY(-3px); box-shadow: 0 12px 36px rgba(0,0,0,.25); }
    .tool-card:hover::before { opacity: 1; }
    .tool-card:active { transform: scale(.97); }

    .tool-card-icon {
      width: 44px; height: 44px; border-radius: 12px;
      background: var(--surface2); border: 1px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      font-size: 1.4rem; margin-bottom: 12px;
    }
    .tool-card-name {
      font-family: var(--font-display); font-size: .95rem; font-weight: 800;
      color: var(--text); margin-bottom: 5px;
    }
    .tool-card-desc {
      font-size: .74rem; color: var(--muted); line-height: 1.5;
    }
    .tool-card-arrow {
      position: absolute; top: 16px; right: 16px;
      font-size: .75rem; color: var(--muted); opacity: 0;
      transition: opacity .2s, transform .2s;
    }
    .tool-card:hover .tool-card-arrow { opacity: 1; transform: translate(2px,-2px); }

    .home-features {
      width: 100%; max-width: 520px;
      display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px;
    }
    .feature-row {
      display: flex; align-items: center; gap: 14px;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-sm); padding: 14px 16px;
    }
    .feature-icon {
      width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
      background: var(--accent-dim); border: 1px solid rgba(63,255,176,.2);
      display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
    }
    .feature-text-title { font-weight: 700; font-size: .88rem; color: var(--text); margin-bottom: 2px; }
    .feature-text-sub { font-size: .75rem; color: var(--muted); line-height: 1.4; }

    .home-cta-row {
      width: 100%; max-width: 520px;
      display: flex; gap: 10px; margin: 8px 0 20px;
    }
    .home-cta-btn {
      flex: 1; padding: 14px 12px;
      background: var(--accent); color: #040608;
      border: none; border-radius: var(--radius-sm);
      font-family: var(--font-display); font-weight: 800; font-size: .92rem;
      cursor: pointer; transition: transform .15s, box-shadow .15s;
    }
    .home-cta-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px var(--accent-glow); }
    .home-cta-btn.outline {
      background: transparent; color: var(--text);
      border: 1px solid var(--border);
    }
    .home-cta-btn.outline:hover { background: var(--surface2); box-shadow: none; }