@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/space-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/space-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); }

    :root {
      --bg: #0c1016;
      --card: #131921;
      --raise: #171e28;
      --field: #0e1319;
      --line: #232b37;
      --line-strong: #344052;
      --text: #e8ecf2;
      --label: #c4ccd8;
      --text-soft: #8b97a8;
      --text-faint: #5b6778;
      --focus: #9aa7bb;
      --focus-ring: rgba(154, 167, 187, 0.2);
      --btn: #dde3ec;
      --btn-hover: #f1f4f8;
      --btn-ink: #0c1016;
      --danger: #e5776f;
      --ok: #5eb88a;
      --radius: 7px;
      --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
      --sbw: 252px;
      --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
      --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    }

    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    html, body { height: 100%; }

    body {
      margin: 0;
      font-family: var(--font);
      color: var(--text);
      background: var(--bg);
      -webkit-font-smoothing: antialiased;
      overflow-x: hidden;
    }

    button { font: inherit; color: inherit; }
    .ico { width: 18px; height: 18px; flex: none; }

    /* Faint grid behind everything, fading toward the edges */
    body { --gm: radial-gradient(ellipse 70% 65% at 50% 45%, #000 0%, transparent 100%); }
    body.in-app { --gm: radial-gradient(ellipse 120% 105% at 58% 40%, #000 25%, transparent 100%); }

    body::before {
      content: "";
      position: fixed;
      inset: 0;
      background-image:
        linear-gradient(rgba(190, 205, 230, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(190, 205, 230, 0.05) 1px, transparent 1px);
      background-size: 56px 56px;
      background-position: center top;
      mask-image: var(--gm);
      -webkit-mask-image: var(--gm);
      pointer-events: none;
    }

    /* Light that runs along the grid lines (drawn on a canvas, see startTrails) */
    #bg {
      position: fixed; inset: 0; width: 100%; height: 100%;
      pointer-events: none;
      mask-image: var(--gm);
      -webkit-mask-image: var(--gm);
    }

    /* Scrollbars (the page scrolls, cards do not) */
    .scroll { scrollbar-width: thin; scrollbar-color: #3a475b transparent; }
    @supports selector(::-webkit-scrollbar) {
      .scroll { scrollbar-width: auto; scrollbar-color: auto; }
      .scroll::-webkit-scrollbar { width: 14px; height: 14px; }
      .scroll::-webkit-scrollbar-track { background: transparent; }
      .scroll::-webkit-scrollbar-thumb {
        background: #2d3848;
        border: 4px solid transparent;
        border-radius: 10px;
        background-clip: padding-box;
      }
      .scroll::-webkit-scrollbar-thumb:hover { background: #46556c; background-clip: padding-box; border: 4px solid transparent; }
    }

    /* ---------- Shared controls ---------- */
    .input {
      width: 100%;
      height: 44px;
      padding: 0 14px;
      font: inherit;
      font-size: 14px;
      color: var(--text);
      background: var(--field);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      transition: border-color 0.15s, box-shadow 0.15s;
    }
    .input::placeholder { color: var(--text-faint); }
    .input:hover { border-color: var(--line-strong); }
    .input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-ring); }
    .input[aria-invalid="true"] { border-color: var(--danger); }
    .input:-webkit-autofill,
    .input:-webkit-autofill:hover,
    .input:-webkit-autofill:focus {
      -webkit-text-fill-color: var(--text);
      -webkit-box-shadow: 0 0 0 1000px var(--field) inset;
      caret-color: var(--text);
      transition: background-color 9999s ease-out 0s;
    }

    .control { position: relative; }
    .control > .ico.lead {
      position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
      color: var(--text-faint); pointer-events: none; transition: color 0.15s;
    }
    .control:focus-within > .ico.lead { color: var(--label); }
    .control .input.has-lead { padding-left: 42px; }

    .btn {
      display: inline-flex; align-items: center; justify-content: center; gap: 8px;
      height: 40px; padding: 0 16px;
      font-size: 14px; font-weight: 600;
      border: 1px solid var(--line-strong); border-radius: var(--radius);
      background: transparent; cursor: pointer;
      transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
    }
    .btn:hover { background: rgba(190, 205, 230, 0.07); }
    .btn:active { transform: translateY(1px); }
    .btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .chip:focus-visible,
    .tag-opt:focus-visible, .sw:focus-visible, .ic-opt:focus-visible, .act:focus-visible {
      outline: 2px solid var(--focus); outline-offset: 2px;
    }
    .btn-primary { color: var(--btn-ink); background: var(--btn); border-color: transparent; }
    .btn-primary:hover { background: var(--btn-hover); }
    .btn-danger { color: var(--danger); border-color: rgba(229, 119, 111, 0.4); }
    .btn-danger:hover { background: rgba(229, 119, 111, 0.1); }
    .btn[disabled] { opacity: 0.6; cursor: progress; }

    .icon-btn {
      width: 36px; height: 36px; display: grid; place-items: center;
      border: 0; border-radius: 8px; background: transparent;
      color: var(--text-soft); cursor: pointer;
      transition: color 0.15s, background 0.15s;
    }
    .icon-btn:hover { color: var(--text); background: rgba(190, 205, 230, 0.08); }

    /* Tags */
    .tag {
      --c: #9aa7bb;
      display: inline-flex; align-items: center; gap: 6px;
      height: 24px; padding: 0 9px 0 7px;
      font-size: 12px; font-weight: 500; white-space: nowrap;
      color: color-mix(in srgb, var(--c) 72%, #fff);
      background: color-mix(in srgb, var(--c) 14%, transparent);
      border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);
      border-radius: 999px;
    }
    .tag .ico, .tag img { width: 13px; height: 13px; }
    .tag .ico { color: var(--c); }
    .tag img { object-fit: contain; border-radius: 3px; }

    /* =========================================================
       AUTH
       ========================================================= */
    .auth {
      min-height: 100%;
      display: grid; place-items: center;
      padding: 32px 20px;
    }
    .wrap { position: relative; isolation: isolate; width: 100%; max-width: 400px;
      transition: opacity 0.32s ease, transform 0.4s var(--ease); }
    .auth.leaving .wrap { opacity: 0; transform: scale(0.97) translateY(-10px); }

    .logo { display: block; width: 240px; height: auto; margin: 0 auto 40px; }

    .auth-card {
      position: relative;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 32px 32px 30px;
    }

    /* Reverse shadow: light spilling evenly out from behind the card */
    @property --sweep { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

    .auth-card::before, .auth-card::after {
      content: ""; position: absolute; z-index: -1; pointer-events: none; border-radius: 18px;
    }
    .auth-card::before {
      inset: -5px;
      background: conic-gradient(from var(--sweep),
        rgba(255,255,255,0.50), rgba(255,255,255,0.20) 22%,
        rgba(255,255,255,0.46) 50%, rgba(255,255,255,0.20) 72%, rgba(255,255,255,0.50));
      filter: blur(11px);
      animation: sweep 7s linear infinite, flicker 3.2s ease-in-out infinite alternate;
    }
    .auth-card::after {
      inset: -22px; border-radius: 30px;
      background: rgba(214, 226, 248, 0.20);
      filter: blur(30px);
      animation: breathe 4.5s ease-in-out infinite alternate;
    }
    @keyframes sweep { to { --sweep: 360deg; } }
    @keyframes flicker { from { opacity: 0.75; } to { opacity: 1; } }
    @keyframes breathe { from { opacity: 0.45; transform: scale(0.985); } to { opacity: 1; transform: scale(1.015); } }

    /* The body is clipped so content can slide while the height morphs.
       Padding and negative margin keep focus rings from being cut off. */
    .auth-body { overflow: hidden; margin: -8px; padding: 8px; }
    .auth-body.morphing { transition: height 0.3s var(--ease); }

    .auth-inner {
      transition: opacity 0.17s ease, transform 0.24s var(--ease);
    }
    .auth-inner.out { opacity: 0; transform: translateX(calc(var(--dir, 1) * -24px)); }
    .auth-inner.pre { opacity: 0; transform: translateX(calc(var(--dir, 1) * 24px)); transition: none; }

    .auth h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
    .lede { margin: 0 0 26px; color: var(--text-soft); font-size: 14px; line-height: 1.5; }

    .field { margin-bottom: 16px; }
    .field > label, .label {
      display: block; margin-bottom: 7px;
      font-size: 13px; font-weight: 500; letter-spacing: 0.005em; color: var(--label);
    }
    .field-hint { margin: 6px 0 0; font-size: 12px; color: var(--text-faint); }

    .form-error {
      margin: 0 0 14px; padding: 9px 12px;
      font-size: 13px; line-height: 1.4; color: #f0b0aa;
      background: rgba(229, 119, 111, 0.1);
      border: 1px solid rgba(229, 119, 111, 0.3);
      border-radius: var(--radius);
    }

    #password, #f-password { padding-right: 48px; }
    .toggle {
      position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
      width: 36px; height: 36px; display: grid; place-items: center;
      border: 0; border-radius: 8px; background: transparent;
      color: var(--text-soft); cursor: pointer;
      transition: color 0.15s, background 0.15s;
    }
    .toggle:hover { color: var(--text); background: rgba(190, 205, 230, 0.08); }
    .toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
    .toggle .eye-off { display: none; }
    .toggle[aria-pressed="true"] .eye { display: none; }
    .toggle[aria-pressed="true"] .eye-off { display: block; }

    .submit {
      width: 100%; height: 44px; margin-top: 8px;
      font-size: 14px; font-weight: 600;
      color: var(--btn-ink); background: var(--btn);
      border: 0; border-radius: var(--radius); cursor: pointer;
      transition: background 0.15s, box-shadow 0.15s, transform 0.05s, opacity 0.15s;
    }
    .submit:hover { background: var(--btn-hover); }
    .submit:active { transform: translateY(1px); }
    .submit:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus-ring), 0 0 0 1px var(--focus); }
    .submit[disabled] { opacity: 0.65; cursor: progress; }

    .switch { margin: 20px 0 0; text-align: center; font-size: 13px; color: var(--text-soft); }
    .switch button {
      padding: 2px 3px; margin-left: 2px; font-weight: 600; color: var(--text);
      background: none; border: 0; border-radius: 4px; cursor: pointer;
    }
    .switch button:hover { text-decoration: underline; text-underline-offset: 3px; }
    .switch button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

    .assurance {
      display: flex; align-items: center; justify-content: center; gap: 8px;
      margin: 22px 0 0; font-size: 13px; color: var(--text-soft);
    }
    .assurance .ico { width: 14px; height: 14px; }

    /* =========================================================
       APP SHELL
       ========================================================= */
    .app { position: fixed; inset: 0; overflow: hidden; background: transparent; }

    .sidebar {
      position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
      width: var(--sbw);
      display: flex; flex-direction: column;
      padding: 20px 14px 14px;
      background: var(--card);
      border-right: 1px solid var(--line);
      transition: transform 0.34s var(--ease);
    }
    .app.closed .sidebar { transform: translateX(-100%); }

    .side-logo { display: block; width: 112px; height: auto; margin: 6px auto 26px; }

    .nav { display: flex; flex-direction: column; gap: 4px; }
    .nav-item {
      position: relative;
      display: flex; align-items: center; gap: 12px;
      width: 100%; height: 40px; padding: 0 12px;
      font-size: 14px; font-weight: 500; text-align: left;
      color: var(--text-soft);
      background: transparent; border: 0; border-radius: 8px; cursor: pointer;
      transition: color 0.15s, background 0.15s;
    }
    .nav-item:hover { color: var(--text); background: rgba(190, 205, 230, 0.06); }
    .nav-item[aria-current="page"] { color: var(--text); background: rgba(190, 205, 230, 0.1); }
    .nav-item[aria-current="page"]::before {
      content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
      border-radius: 0 3px 3px 0; background: var(--btn);
    }
    .nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

    .side-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
    .user { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; min-width: 0; }
    .avatar {
      width: 32px; height: 32px; flex: none; display: grid; place-items: center;
      font-size: 14px; font-weight: 600; text-transform: uppercase;
      color: var(--text); background: #1f2835; border: 1px solid var(--line-strong); border-radius: 50%;
    }
    .uname { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .main {
      position: absolute; inset: 0 0 0 var(--sbw);
      display: flex; flex-direction: column; min-width: 0;
      transition: left 0.34s var(--ease), inset 0.34s var(--ease);
    }
    .app.closed .main { inset: 0; }

    .scrim {
      position: fixed; inset: 0; z-index: 25;
      background: rgba(5, 8, 12, 0.6);
      opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
    }

    .topbar {
      flex: none; height: 64px; display: flex; align-items: center; gap: 12px;
      padding: 0 24px 0 14px; border-bottom: 1px solid var(--line);
    }
    .topbar h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
    .topbar .spacer { flex: 1; }

    .content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
    .page { animation: page-in 0.28s var(--ease); }
    @keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

    /* Passwords page */
    .toolbar {
      position: sticky; top: 0; z-index: 6;
      padding: 18px 28px 14px;
      background: rgba(12, 16, 22, 0.82);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
      transition: box-shadow 0.2s;
    }
    .toolbar.stuck { box-shadow: 0 1px 0 var(--line); }
    .toolbar-row { display: flex; gap: 12px; max-width: 1240px; margin: 0 auto; }
    .toolbar .control { flex: 1; }
    .sort { position: relative; width: 190px; flex: none; }
    .sort select {
      appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px;
    }
    .sort .ico { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-soft); pointer-events: none; width: 16px; height: 16px; }
    .sort select option { background: var(--card); color: var(--text); }

    .chips { display: flex; gap: 8px; flex-wrap: wrap; max-width: 1240px; margin: 14px auto 0; }
    .chip {
      --c: #9aa7bb;
      display: inline-flex; align-items: center; gap: 7px;
      height: 32px; padding: 0 12px 0 10px;
      font-size: 13px; font-weight: 500; color: var(--text-soft);
      background: transparent;
      border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .chip .ico, .chip img { width: 15px; height: 15px; }
    .chip .ico { color: var(--c); }
    .chip img { object-fit: contain; border-radius: 3px; }
    .chip .n { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
    .chip:hover { color: var(--text); border-color: var(--line-strong); }
    .chip[aria-pressed="true"] {
      color: var(--text);
      background: color-mix(in srgb, var(--c) 18%, transparent);
      border-color: color-mix(in srgb, var(--c) 55%, transparent);
    }

    .list { padding: 6px 28px 48px; max-width: 1296px; margin: 0 auto; }
    .group-title {
      display: flex; align-items: center; gap: 10px;
      margin: 26px 0 12px; font-size: 13px; font-weight: 600; color: var(--label);
    }
    .group-title:first-child { margin-top: 10px; }
    .group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
    .group-title .n { font-weight: 400; color: var(--text-faint); }
    .grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

    .pw {
      min-width: 0;
      padding: 18px;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 12px;
      transition: border-color 0.18s, background 0.18s;
    }
    .pw:hover, .pw:focus-within { border-color: var(--line-strong); background: #151c25; }
    .pw.in { animation: card-in 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
    @keyframes card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

    .pw-head { display: flex; align-items: center; gap: 12px; }
    .tile {
      width: 40px; height: 40px; flex: none; display: grid; place-items: center;
      font-size: 17px; font-weight: 600; text-transform: uppercase;
      color: var(--label);
      background: linear-gradient(160deg, #222c3a, #181f2a);
      border: 1px solid var(--line-strong); border-radius: 10px;
    }
    .pw-title { min-width: 0; flex: 1; }
    .pw-title h3 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pw-title a { display: block; font-size: 12px; color: var(--text-soft); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pw-title a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
    .pw-actions { display: flex; gap: 2px; margin-right: -6px; opacity: 0; transition: opacity 0.15s; }
    .pw:hover .pw-actions, .pw:focus-within .pw-actions { opacity: 1; }
    @media (hover: none) { .pw-actions { opacity: 1; } }

    .act {
      width: 32px; height: 32px; display: grid; place-items: center;
      border: 0; border-radius: 7px; background: transparent; color: var(--text-soft); cursor: pointer;
      transition: color 0.15s, background 0.15s;
    }
    .act:hover { color: var(--text); background: rgba(190, 205, 230, 0.09); }
    .act.danger:hover { color: var(--danger); background: rgba(229, 119, 111, 0.12); }
    .act .ico { width: 16px; height: 16px; }

    .rows { margin-top: 16px; display: grid; gap: 8px; }
    .row {
      display: flex; align-items: center; gap: 4px;
      padding: 6px 6px 6px 12px;
      background: var(--field); border: 1px solid var(--line); border-radius: 8px;
    }
    .row .k { width: 74px; flex: none; font-size: 12px; color: var(--text-faint); }
    .row .v { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .row .v.secret { font-family: var(--mono); font-size: 13px; letter-spacing: 0.02em; }
    .row .v.muted { color: var(--text-faint); }

    .pw-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

    .empty {
      display: grid; justify-items: center; gap: 10px;
      padding: 72px 20px; text-align: center; color: var(--text-soft);
    }
    .empty .big {
      width: 56px; height: 56px; display: grid; place-items: center;
      color: var(--text-soft); background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 6px;
    }
    .empty .big .ico { width: 24px; height: 24px; }
    .empty h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
    .empty p { margin: 0 0 8px; font-size: 14px; }

    /* Settings page */
    .settings { max-width: 640px; margin: 0 auto; padding: 28px 28px 56px; display: grid; gap: 16px; }
    .panel { padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
    .panel h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
    .panel p { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--text-soft); }
    .panel p:last-child { margin-bottom: 0; }
    .kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; font-size: 14px; border-top: 1px solid var(--line); }
    .kv:first-of-type { border-top: 0; }
    .kv span:first-child { color: var(--text-soft); }

    /* Entrance after signing in */
    .app.entering .sidebar { animation: side-in 0.55s var(--ease) both; }
    .app.entering .topbar { animation: fade-up 0.5s var(--ease) 0.12s both; }
    .app.entering .toolbar { animation: fade-up 0.5s var(--ease) 0.18s both; }
    @keyframes side-in { from { transform: translateX(-100%); } to { transform: none; } }
    @keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

    /* =========================================================
       DRAWER (add / edit)
       ========================================================= */
    dialog.drawer {
      position: fixed; inset: 0 0 0 auto; margin: 0;
      width: min(500px, 100vw); max-width: 100vw; height: 100%; max-height: 100%;
      padding: 0; color: var(--text);
      background: var(--card);
      border: 0; border-left: 1px solid var(--line-strong);
      box-shadow: -30px 0 60px -20px rgba(0, 0, 0, 0.6);
    }
    dialog.drawer[open] { display: flex; flex-direction: column; animation: drawer-in 0.34s var(--ease); }
    dialog.drawer.closing { animation: drawer-out 0.2s ease forwards; }
    dialog.drawer::backdrop { background: rgba(5, 8, 12, 0.62); animation: fade-in 0.25s ease; }
    dialog.drawer.closing::backdrop { animation: fade-out 0.2s ease forwards; }
    @keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
    @keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }
    @keyframes fade-in { from { opacity: 0; } }
    @keyframes fade-out { to { opacity: 0; } }

    .drawer-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 18px 24px; border-bottom: 1px solid var(--line); }
    .drawer-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
    .drawer form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
    .drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px 28px; }
    .drawer-foot { flex: none; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--card); }

    .ac { position: relative; }
    .suggest {
      position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
      margin: 0; padding: 6px; list-style: none;
      background: var(--raise); border: 1px solid var(--line-strong); border-radius: 10px;
      box-shadow: 0 22px 44px -14px rgba(0, 0, 0, 0.75);
      transform-origin: top center;
      animation: drop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
    }
    @keyframes drop { from { opacity: 0; transform: translateY(-10px) scaleY(0.9); } to { opacity: 1; transform: none; } }
    .suggest li {
      display: flex; align-items: center; gap: 12px; padding: 8px 10px;
      border-radius: 7px; cursor: pointer;
    }
    .suggest li[aria-selected="true"] { background: rgba(190, 205, 230, 0.1); }
    .suggest .tile { width: 32px; height: 32px; font-size: 14px; border-radius: 8px; }
    .suggest .s-name { font-size: 14px; font-weight: 500; }
    .suggest .s-dom { display: block; font-size: 12px; color: var(--text-soft); }
    .suggest .s-txt { flex: 1; min-width: 0; }
    .suggest .best { font-size: 11px; font-weight: 600; color: var(--btn-ink); background: var(--btn); padding: 2px 7px; border-radius: 999px; }

    .pw-tools { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; gap: 0; }
    .pw-tools .toggle, .pw-tools .gen { position: static; transform: none; }
    .gen { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); cursor: pointer; }
    .gen:hover { color: var(--text); background: rgba(190, 205, 230, 0.08); }
    #f-password { padding-right: 84px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.02em; }
    #f-password[type="password"] { letter-spacing: 0.06em; }

    .strength { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
    .strength .bars { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .strength .bars i { height: 4px; border-radius: 4px; background: var(--line); transition: background 0.25s; }
    .strength .lab { width: 54px; text-align: right; font-size: 12px; color: var(--text-soft); }

    .section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 10px; }
    .section-title .label { margin: 0; }

    .tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }
    .tag-wrap { position: relative; display: inline-flex; }
    .tag-opt {
      --c: #9aa7bb;
      display: inline-flex; align-items: center; gap: 7px;
      height: 32px; padding: 0 12px 0 10px; font-size: 13px; font-weight: 500;
      color: var(--text-soft); background: transparent;
      border: 1px dashed var(--line-strong); border-radius: 999px; cursor: pointer;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .tag-opt .ico, .tag-opt img { width: 15px; height: 15px; }
    .tag-opt .ico { color: var(--c); }
    .tag-opt img { object-fit: contain; border-radius: 3px; }
    .tag-opt:hover { color: var(--text); }
    .tag-opt[aria-pressed="true"] {
      color: var(--text); border-style: solid;
      background: color-mix(in srgb, var(--c) 20%, transparent);
      border-color: color-mix(in srgb, var(--c) 60%, transparent);
    }
    .tag-edit {
      width: 22px; height: 22px; margin-left: 2px; display: grid; place-items: center;
      border: 0; border-radius: 50%; background: transparent; color: var(--text-faint); cursor: pointer;
    }
    .tag-edit:hover { color: var(--text); background: rgba(190, 205, 230, 0.1); }
    .tag-edit .ico { width: 13px; height: 13px; }
    .tag-edit:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
    .tag-new { color: var(--text-soft); border-style: dashed; }

    .editor { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s var(--ease); }
    .editor.open { grid-template-rows: 1fr; }
    .editor > div { overflow: hidden; min-height: 0; }
    .editor-card {
      margin-top: 14px; padding: 18px;
      background: var(--field); border: 1px solid var(--line); border-radius: 12px;
    }
    .editor-card .field { margin-bottom: 16px; }
    .swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
    .sw {
      width: 26px; height: 26px; padding: 0; border-radius: 50%;
      background: var(--c); border: 2px solid transparent; cursor: pointer;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
      transition: transform 0.12s;
    }
    .sw:hover { transform: scale(1.1); }
    .sw[aria-pressed="true"] { border-color: var(--bg); box-shadow: 0 0 0 2px var(--text); }
    .sw-custom { position: relative; width: 26px; height: 26px; border-radius: 50%; overflow: hidden; border: 1px solid var(--line-strong);
      background: conic-gradient(#e5776f, #e0a458, #5eb88a, #5fc3d6, #8f8cf0, #e87aa0, #e5776f); }
    .sw-custom input { position: absolute; inset: -6px; width: 40px; height: 40px; opacity: 0; cursor: pointer; }
    .sw-custom:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

    .icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
    .ic-opt {
      height: 38px; display: grid; place-items: center; padding: 0;
      color: var(--text-soft); background: transparent;
      border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
      transition: background 0.12s, color 0.12s, border-color 0.12s;
    }
    .ic-opt:hover { color: var(--text); border-color: var(--line-strong); }
    .ic-opt[aria-pressed="true"] { color: var(--c, var(--text)); background: color-mix(in srgb, var(--c, #9aa7bb) 18%, transparent); border-color: color-mix(in srgb, var(--c, #9aa7bb) 60%, transparent); }
    .ic-opt .ico { width: 18px; height: 18px; }
    .ic-opt img { width: 20px; height: 20px; object-fit: contain; border-radius: 3px; }
    .upload-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
    .upload-row small { color: var(--text-faint); font-size: 12px; }
    .editor-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
    .editor-foot .grow { flex: 1; }
    .editor-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
    .btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }

    /* Toasts */
    .toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
    .toast {
      pointer-events: auto; display: flex; align-items: center; gap: 14px;
      padding: 11px 16px; font-size: 14px;
      background: #1b2330; border: 1px solid var(--line-strong); border-radius: 10px;
      box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.7);
      animation: toast-in 0.3s var(--ease);
    }
    .toast.out { animation: toast-out 0.22s ease forwards; }
    .toast button { padding: 2px 4px; font-weight: 600; color: var(--btn); background: none; border: 0; border-radius: 4px; cursor: pointer; }
    .toast button:hover { text-decoration: underline; text-underline-offset: 3px; }
    @keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
    @keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
    .toast.bump { animation: toast-bump 0.18s ease; }
    @keyframes toast-bump { 40% { transform: scale(1.05); } }

    /* Password generator page */
    .genpage { max-width: 640px; margin: 0 auto; padding: 28px 28px 56px; display: grid; gap: 16px; }
    .gen-display {
      min-height: 88px; padding: 20px 22px; display: flex; align-items: center;
      font-family: var(--mono); font-size: 20px; line-height: 1.45; letter-spacing: 0.04em; word-break: break-all;
      background: var(--field); border: 1px solid var(--line); border-radius: 10px;
    }
    .genpage .strength { margin-top: 14px; }
    .gen-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
    .len { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; font-size: 14px; }
    .len output { font-family: var(--mono); }
    .range {
      -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; margin: 16px 0 10px;
      border-radius: 6px; outline: none; cursor: pointer;
      background: linear-gradient(to right, var(--btn) var(--pct, 30%), #232d3b var(--pct, 30%));
    }
    .range::-webkit-slider-thumb {
      -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
      background: #fff; border: 0; box-shadow: 0 0 0 1px var(--line-strong), 0 2px 8px rgba(0, 0, 0, 0.5);
    }
    .range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px var(--line-strong), 0 2px 8px rgba(0, 0, 0, 0.5); }
    .range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--focus-ring), 0 0 0 1px var(--focus); }
    .range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--focus-ring), 0 0 0 1px var(--focus); }
    .opts { margin-top: 8px; }
    .opt {
      display: flex; align-items: center; justify-content: space-between; gap: 16px;
      padding: 13px 0; font-size: 14px; border-top: 1px solid var(--line); cursor: pointer;
    }
    .opt small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-faint); }
    .opt input {
      -webkit-appearance: none; appearance: none; position: relative; flex: none;
      width: 40px; height: 24px; margin: 0; border-radius: 999px; cursor: pointer;
      background: #232d3b; border: 1px solid var(--line-strong);
      transition: background 0.2s, border-color 0.2s;
    }
    .opt input::after {
      content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
      background: var(--text-soft); transition: transform 0.22s var(--ease), background 0.2s;
    }
    .opt input:checked { background: #3a4a62; border-color: #56688a; }
    .opt input:checked::after { transform: translateX(16px); background: #fff; }
    .opt input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

    /* ---------- Responsive ---------- */
    @media (max-width: 860px) {
      .main, .app.closed .main { inset: 0; }
      .sidebar { box-shadow: 30px 0 60px -20px rgba(0, 0, 0, 0.6); }
      .app:not(.closed) .scrim { opacity: 1; pointer-events: auto; }
      .topbar { padding-right: 16px; }
      .toolbar { padding: 14px 16px 12px; }
      .list { padding: 4px 16px 40px; }
      .settings { padding: 20px 16px 40px; }
      .toolbar-row { flex-wrap: wrap; }
      .sort { width: 100%; }
      .grid { grid-template-columns: 1fr; }
      #add-btn .txt { display: none; }
      #add-btn { padding: 0 12px; }
    }
    @media (max-width: 440px) {
      .auth-card { padding: 26px 22px 24px; }
      .logo { width: 200px; margin-bottom: 32px; }
    }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
      .auth-card::before, .auth-card::after { animation: none !important; }
      .auth-card::after { opacity: 0.8; }
    }

/* ---------- Server-connected additions ---------- */
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; }
.pw-hint { margin: -4px 0 14px; line-height: 1.45; }
.forgot { margin: -6px 0 14px; text-align: right; }
.forgot button {
  padding: 2px 3px; font-size: 13px; color: var(--text-soft);
  background: none; border: 0; border-radius: 4px; cursor: pointer;
}
.forgot button:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.forgot button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.sync { display: flex; align-items: center; gap: 8px; padding: 0 6px 12px; font-size: 12px; color: var(--text-soft); }
.sync .dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--ok); transition: background 0.3s; }
.sync[data-state="saving"] .dot { background: #e0a458; animation: dot-pulse 1s ease-in-out infinite alternate; }
.sync[data-state="offline"] .dot { background: var(--danger); }
@keyframes dot-pulse { from { opacity: 0.4; } to { opacity: 1; } }

dialog.modal {
  width: min(500px, calc(100vw - 32px)); padding: 28px;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line-strong); border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
dialog.modal[open] { animation: modal-in 0.3s var(--ease); }
dialog.modal::backdrop { background: rgba(5, 8, 12, 0.7); backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
dialog.modal h2 { margin: 0 0 10px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
dialog.modal p { margin: 0 0 18px; font-size: 14px; line-height: 1.55; color: var(--text-soft); }
.rk-key {
  padding: 16px; font-family: var(--mono); font-size: 15px; line-height: 1.7; letter-spacing: 0.06em; word-break: break-all; text-align: center;
  color: var(--text); background: var(--field); border: 1px solid var(--line-strong); border-radius: 10px; user-select: all;
}
.rk-actions { display: flex; gap: 8px; margin: 12px 0 20px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: #c9d3e3; cursor: pointer; }
dialog.modal .btn-primary { width: 100%; height: 44px; }
dialog.modal .btn-primary[disabled] { cursor: not-allowed; }
