    :root {
      color-scheme: dark;
      --bg: #0c101c;
      --surface: #151b2c;
      --surface-hover: #1a2136;
      --border: #232c45;
      --ink: #e8edf8;
      --muted: #8d97b2;
      --accent: #35c3f0;
      --accent-ink: #06121a;
      --connect: #2ecb7d;
      --connect-hover: #5fe9a5;
      --connect-ink: #05170e;
      --danger: #ff5d6c;
      --radius: 10px;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
      background: var(--bg);
      color: var(--ink);
      min-height: 100vh;
      padding: 28px 20px 60px;
      font-size: 15px;
      line-height: 1.45;
    }
    .shell { max-width: 980px; margin: 0 auto; }

    button { font: inherit; cursor: pointer; border: none; border-radius: var(--radius); }
    button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    input, select { font: inherit; }

    /* ── Pasek górny ── */
    header {
      display: flex;
      align-items: center;
      gap: 14px;
      margin-bottom: 22px;
      flex-wrap: wrap;
    }
    h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: .2px; margin-right: 6px; }
    h1 .count { color: var(--muted); font-weight: 400; font-size: 1rem; }
    .search {
      flex: 1;
      min-width: 220px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--ink);
      padding: 9px 14px;
      font-size: 14px;
    }
    .search::placeholder { color: var(--muted); }
    .search:focus { outline: none; border-color: var(--accent); }

    .btn-add {
      background: var(--accent);
      color: var(--accent-ink);
      font-weight: 650;
      padding: 9px 16px;
      white-space: nowrap;
    }
    .btn-add:hover { filter: brightness(1.1); }

    /* menu „więcej" */
    .menu-wrap { position: relative; }
    .btn-menu {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--ink);
      padding: 9px 12px;
      display: flex; align-items: center; gap: 8px;
    }
    .btn-menu:hover { background: var(--surface-hover); }
    .menu {
      display: none;
      position: absolute; right: 0; top: calc(100% + 6px);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      min-width: 200px;
      padding: 6px;
      z-index: 50;
      box-shadow: 0 12px 32px rgba(0,0,0,.45);
    }
    .menu.open { display: block; }
    .menu .who {
      padding: 8px 10px 10px;
      font-size: 12.5px;
      color: var(--muted);
      border-bottom: 1px solid var(--border);
      margin-bottom: 6px;
    }
    .menu .who .menu-role {
      display: inline-block;
      margin-left: 6px;
      padding: 2px 7px;
      border-radius: 999px;
      background: var(--surface-hover);
      color: var(--muted);
      font-size: 11px;
      font-weight: 600;
      letter-spacing: .02em;
    }
    .menu button {
      display: block; width: 100%;
      text-align: left;
      background: none; color: var(--ink);
      padding: 8px 10px; border-radius: 6px;
      font-size: 14px;
    }
    .menu button:hover { background: var(--surface-hover); }
    .menu button.logout { color: var(--danger); }
    .menu hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

    /* ── Filtry i sortowanie ── */
    .filters {
      display: flex; align-items: center; gap: 8px;
      flex-wrap: wrap; margin-bottom: 16px;
    }
    .chip {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--muted);
      padding: 5px 13px;
      border-radius: 999px;
      font-size: 13px;
    }
    .chip:hover { color: var(--ink); border-color: var(--accent); }
    .chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
    .btn-clear-filters {
      border: none;
      background: none;
      color: var(--muted);
      font-size: 13px;
      text-decoration: underline;
      cursor: pointer;
      padding: 4px 6px;
    }
    .btn-clear-filters:hover { color: var(--ink); }
    .sort {
      margin-left: auto;
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--muted);
      border-radius: var(--radius);
      padding: 6px 10px;
      font-size: 13px;
    }

    /* ── Lista kontaktów ── */
    .list { display: flex; flex-direction: column; gap: 10px; }
    .empty { color: var(--muted); text-align: center; padding: 40px 0; }
    .card {
      display: flex;
      align-items: center;
      gap: 16px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 14px 16px;
      transition: border-color .15s, background .15s;
    }
    .card:hover { background: var(--surface-hover); border-color: #2e3a5c; }

    .info { min-width: 0; flex: 1; }
    .host-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
    .host { font-weight: 650; font-size: 15.5px; overflow-wrap: anywhere; }
    /* tagi na karcie = semantyczne przyciski (filtrują listę po tagu) */
    .tag {
      color: var(--accent);
      font-size: 12.5px;
      background: rgba(53,195,240,.09);
      border: none;
      border-radius: 999px;
      padding: 1px 9px;
      cursor: pointer;
      transition: background .12s, color .12s;
    }
    .tag:hover { background: rgba(53,195,240,.2); }
    .tag:active { background: rgba(53,195,240,.3); }
    .meta {
      display: flex; align-items: center; gap: 14px;
      margin-top: 3px;
      color: var(--muted); font-size: 13px;
      font-variant-numeric: tabular-nums;
      flex-wrap: wrap;
    }
    .meta .id { font-family: "Cascadia Code", Consolas, monospace; letter-spacing: .4px; }
    .meta .uses { font-size: 12.5px; }
    /* przycisk „Kopiuj ID” obok ID w meta — kompaktowy, jak .tag */
    .btn-copy-id {
      display: inline-flex; align-items: center; gap: 5px;
      background: none; border: 1px solid var(--border);
      color: var(--muted);
      font-size: 12.5px;
      padding: 1px 8px;
      border-radius: 999px;
      cursor: pointer;
      white-space: nowrap;
      transition: border-color .12s, color .12s, background .12s;
    }
    .btn-copy-id svg { width: 12px; height: 12px; }
    .btn-copy-id:hover { border-color: var(--accent); color: var(--accent); background: rgba(53,195,240,.09); }
    .pwd-reveal {
      font-family: "Cascadia Code", Consolas, monospace;
      color: var(--ink);
      background: rgba(53,195,240,.09);
      border-radius: 6px;
      padding: 1px 8px;
      overflow-wrap: anywhere;
    }

    /* akcje główne */
    .primary-actions { display: flex; gap: 8px; flex-shrink: 0; }
    .btn-copy {
      background: transparent;
      border: 1px solid var(--accent);
      color: var(--accent);
      font-weight: 600;
      padding: 9px 16px;
      display: flex; align-items: center; gap: 7px;
      white-space: nowrap;
    }
    .btn-copy:hover { background: rgba(53,195,240,.12); }
    .btn-connect {
      background: var(--connect);
      color: var(--connect-ink);
      font-weight: 650;
      padding: 9px 18px;
      display: flex; align-items: center; gap: 7px;
      white-space: nowrap;
      transition: background .12s, transform .12s, box-shadow .12s;
    }
    .btn-connect:hover {
      background: var(--connect-hover);
      transform: scale(1.08);
      box-shadow:
        0 0 0 2px var(--bg),
        0 0 0 4px var(--connect-hover),
        0 4px 20px rgba(46, 203, 125, .5);
    }
    .btn-connect:active { transform: scale(1.03); }

    /* akcje drugorzędne – małe ikony */
    .secondary-actions {
      display: flex; gap: 2px; flex-shrink: 0;
      padding-left: 12px;
      border-left: 1px solid var(--border);
    }
    .btn-icon {
      background: none;
      color: var(--muted);
      width: 32px; height: 32px;
      border-radius: 7px;
      display: flex; align-items: center; justify-content: center;
    }
    .btn-icon:hover { background: var(--surface-hover); color: var(--ink); }
    .btn-icon.del:hover { color: var(--danger); background: rgba(255,93,108,.1); }
    .btn-icon svg { width: 16px; height: 16px; }

    /* ── Modale ── */
    .modal-overlay {
      display: none;
      position: fixed; inset: 0;
      background: rgba(0, 0, 0, 0.65);
      z-index: 1000;
      justify-content: center; align-items: center;
      padding: 20px;
    }
    .modal-overlay.active { display: flex; }
    .modal {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 26px;
      width: 100%;
      max-width: 460px;
      box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    }
    .modal h2 { font-size: 1.15rem; font-weight: 650; margin-bottom: 18px; }
    .form-row { margin-bottom: 14px; }
    .form-row label {
      display: block;
      font-size: 13px;
      color: var(--muted);
      margin-bottom: 5px;
    }
    .form-row input {
      width: 100%;
      background: var(--bg);
      border: 1px solid var(--border);
      color: var(--ink);
      padding: 9px 12px;
      border-radius: 8px;
      font-size: 14px;
    }
    .form-row input:focus { outline: none; border-color: var(--accent); }
    .form-hint { color: var(--muted); font-size: 12px; margin-top: 4px; display: block; }
    .field-error {
      display: block;
      min-height: 0;
      color: var(--danger);
      font-size: 12.5px;
      margin-top: 4px;
    }
    .form-row input[aria-invalid="true"] { border-color: var(--danger); }
    .form-row input[aria-invalid="true"]:focus { border-color: var(--danger); }
    .pwd-row { display: flex; gap: 8px; }
    .pwd-row input { flex: 1; }
    .btn-gen {
      background: var(--surface-hover);
      border: 1px solid var(--border);
      color: var(--muted);
      padding: 0 12px;
      font-size: 13px;
      white-space: nowrap;
    }
    .btn-gen:hover { color: var(--ink); border-color: var(--accent); }
    .modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
    .btn-primary {
      background: var(--accent);
      color: var(--accent-ink);
      font-weight: 650;
      padding: 9px 18px;
    }
    .btn-primary:hover { filter: brightness(1.1); }
    .btn-ghost {
      background: none;
      border: 1px solid var(--border);
      color: var(--muted);
      padding: 9px 16px;
    }
    .btn-ghost:hover { color: var(--ink); background: var(--surface-hover); }

    /* ── Ekran logowania ── */
    #login-screen {
      display: none;
      justify-content: center; align-items: center;
      min-height: calc(100vh - 90px);
    }
    .login-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 32px 28px;
      width: 100%; max-width: 360px;
    }
    .login-card h1 { text-align: center; margin: 0 0 22px; }
    .login-error { color: var(--danger); font-size: 13.5px; margin-top: 12px; display: none; }

    /* ── Powiadomienia ── */
    .toast {
      position: fixed; bottom: 24px; left: 50%;
      transform: translate(-50%, 16px);
      background: var(--surface);
      border: 1px solid var(--connect);
      color: var(--ink);
      padding: 10px 18px;
      border-radius: var(--radius);
      font-size: 14px;
      z-index: 2000;
      opacity: 0; pointer-events: none;
      transition: opacity .2s, transform .2s;
      max-width: min(90vw, 480px);
    }
    .toast.show { opacity: 1; transform: translate(-50%, 0); }
    .toast.error { border-color: var(--danger); }

    @media (prefers-reduced-motion: reduce) {
      .toast, .card, .btn-connect { transition: none; }
      .btn-connect:hover { transform: none; }
    }

    /* ── mobile ── */
    @media (max-width: 700px) {
      body { padding: 16px 12px 50px; }
      .card { flex-wrap: wrap; }
      .info { flex-basis: 100%; }
      /* tagi: dłuższe listy zawijają się (flex-wrap na .host-line),
         przy wąskiej kolumnie większy docisk dla touch */
      .tag { min-height: 28px; padding: 3px 11px; }
      .meta { gap: 10px; }
      .btn-copy-id { min-height: 28px; padding: 3px 10px; }
      .primary-actions { flex: 1; }
      .primary-actions button { flex: 1; justify-content: center; }
      .secondary-actions { border-left: none; padding-left: 0; }
      .sort { margin-left: 0; }
    }

    /* ── Stany UI zmieniane klasami przez app.js (zamiast inline stylów) ── */
    .is-hidden { display: none !important; }
    #app-screen { display: none; }
    #login-screen.is-active { display: flex !important; }
    #app-screen.is-active { display: block !important; }
    .login-error.shown { display: block !important; }
    .btn-login { width: 100%; margin-top: 6px; }
    #tag-filters { display: flex; gap: 8px; flex-wrap: wrap; }
    .copy-helper { position: fixed; opacity: 0; }
    .pwd-reveal { display: none; }
    .pwd-reveal.is-revealed { display: inline !important; }

    /* ── Stany listy: ładowanie / błąd / pusta ── */
    #list-state { margin: 12px 0; }
    #list-state.is-hidden { display: none !important; }
    #list-state .list-state-part { display: none; }
    #list-state.list-state--loading #list-state-loading { display: block; }
    #list-state.list-state--error #list-state-error { display: block; }
    #list-state.list-state--empty #list-state-empty { display: block; }
    #list-state-error { color: var(--danger); }
    #btn-retry-list { margin-top: 8px; }
