/* ============================================================================
   Sésamo — flat, clean UI system
   ----------------------------------------------------------------------------
   One coherent stylesheet: design tokens (light + dark), base, components.
   Principles: flat surfaces, 1px hairlines, a single emerald accent,
   4px spacing grid, 120–150ms color/bg transitions, shadows only on overlays.
   ============================================================================ */

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

/* ----------------------------------------------------------------------------
   1. Design tokens
   ---------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Canvas & surfaces */
  --bg: #fafbfc;                 /* app canvas / sidebar */
  --surface: #ffffff;            /* panels, cards, modals, inputs */
  --surface-2: #f2f4f7;          /* wells: avatars, chips, code blocks */
  --hover: #eef1f4;              /* row & button hover */

  /* Hairlines */
  --border: #e6eaef;             /* structural hairline */
  --border-strong: #d6dce4;      /* inputs, outlined buttons */

  /* Ink */
  --text: #171c23;               /* primary */
  --text2: #4d5866;              /* secondary (AA) */
  --text3: #677384;              /* muted labels (AA) */
  --text4: #98a2b1;              /* decorative / placeholders */

  /* Accent (emerald) */
  --accent: #0d9373;             /* fills */
  --accent-hover: #0b7f64;       /* fill hover */
  --accent-ink: #0b7f64;         /* accent-colored text (AA on white) */
  --accent-tint: rgba(13, 147, 115, 0.09);
  --accent-tint-strong: rgba(13, 147, 115, 0.16);
  --on-accent: #ffffff;
  --ring: 0 0 0 2px rgba(13, 147, 115, 0.25);

  /* Semantic */
  --danger: #d92d20;
  --danger-ink: #c8281c;
  --danger-tint: rgba(217, 45, 32, 0.08);
  --warn: #d97706;
  --warn-ink: #a95a05;
  --warn-tint: rgba(217, 119, 6, 0.1);
  --ok: #0d9373;
  --star: #e8930c;

  /* Strength ramp (decorative bars) */
  --s-vw: #dc2626;
  --s-w: #f59e0b;
  --s-f: #eab308;
  --s-s: #84cc16;
  --s-vs: #0d9373;

  /* Overlay-only depth */
  --overlay: rgba(15, 20, 28, 0.42);
  --shadow-modal: 0 20px 50px -12px rgba(16, 24, 36, 0.25);
  --shadow-pop: 0 10px 32px -8px rgba(16, 24, 36, 0.16);
  --toast-bg: #1c222c;
  --toast-text: #f2f5f9;

  /* Geometry */
  --r-lg: 14px;                  /* modals / palette */
  --r-md: 10px;                  /* cards, inputs, avatars */
  --r-sm: 8px;                   /* buttons, nav rows */
  --r-xs: 6px;                   /* chips, badges */
  --sidebar-w: 240px;
  --itemlist-w: 320px;

  /* Type & motion */
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto,
          'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --t-fast: 130ms ease;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0e14;
  --surface: #131720;
  --surface-2: #1a202b;
  --hover: #1c2431;

  --border: #222a37;
  --border-strong: #303b4c;

  --text: #e8ecf1;
  --text2: #aab4c2;
  --text3: #8a95a6;
  --text4: #5d6979;

  --accent: #16b590;
  --accent-hover: #2ecfa9;
  --accent-ink: #35c9a4;
  --accent-tint: rgba(22, 181, 144, 0.12);
  --accent-tint-strong: rgba(22, 181, 144, 0.22);
  --on-accent: #06251c;
  --ring: 0 0 0 2px rgba(22, 181, 144, 0.32);

  --danger: #f0655c;
  --danger-ink: #f47b73;
  --danger-tint: rgba(240, 101, 92, 0.12);
  --warn: #eda23c;
  --warn-ink: #efb160;
  --warn-tint: rgba(237, 162, 60, 0.12);
  --ok: #16b590;
  --star: #f2b13d;

  --s-vw: #f26d64;
  --s-w: #f5a623;
  --s-f: #e7c62b;
  --s-s: #96d13c;
  --s-vs: #16b590;

  --overlay: rgba(2, 5, 10, 0.6);
  --shadow-modal: 0 24px 56px -12px rgba(0, 0, 0, 0.65);
  --shadow-pop: 0 12px 36px -8px rgba(0, 0, 0, 0.55);
  --toast-bg: #242c39;
  --toast-text: #eef2f7;
}

/* ----------------------------------------------------------------------------
   2. Base
   ---------------------------------------------------------------------------- */
html { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 13px;
  line-height: 1.5;
}

h1, h2, h3, h4 { letter-spacing: -0.01em; }

::selection { background: var(--accent-tint-strong); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }

/* Inline SVG icons (icons.js) inherit currentColor */
svg.icon { vertical-align: -0.155em; flex-shrink: 0; }
.btn-icon svg.icon, .sidebar-item-icon svg.icon { vertical-align: middle; }
.icon-up { transform: rotate(180deg); }

/* ----------------------------------------------------------------------------
   3. Screens & auth
   ---------------------------------------------------------------------------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

.auth-screen {
  max-width: 380px;
  margin: 0 auto;
  padding: 24px 16px;
  width: 100%;
  justify-content: center;
}

.auth-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
}

.auth-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 4px;
  border-radius: var(--r-lg);
  background: var(--accent-tint);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container h2 {
  font-size: 20px;
  font-weight: 650;
  text-align: center;
  color: var(--text);
}

.auth-container p {
  color: var(--text2);
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.auth-email-hint {
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.recovery-code {
  display: block;
  word-break: break-all;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  user-select: all;
  color: var(--text);
}

.version-footer {
  display: block;
  font-size: 11px;
  color: var(--text4);
  text-align: center;
}

/* ----------------------------------------------------------------------------
   4. App layout (3 panes)
   ---------------------------------------------------------------------------- */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--itemlist-w) 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ----------------------------------------------------------------------------
   5. Sidebar
   ---------------------------------------------------------------------------- */
.sidebar {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-content { flex: 1; overflow-y: auto; padding: 4px 0 8px; }

.sidebar-section { padding: 4px 0; }
.sidebar-section + .sidebar-section { margin-top: 8px; }

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text4);
  padding: 8px 20px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  margin: 1px 10px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  border: none;
  background: none;
  color: var(--text2);
  width: calc(100% - 20px);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-sm);
}

.sidebar-item:hover { background: var(--hover); color: var(--text); }

.sidebar-item.active {
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.sidebar-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  flex-shrink: 0;
  color: var(--text3);
  transition: color var(--t-fast);
}
.sidebar-item:hover .sidebar-item-icon { color: var(--text2); }
.sidebar-item.active .sidebar-item-icon { color: var(--accent-ink); }

.sidebar-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item .badge-shared {
  display: inline-flex;
  align-items: center;
  color: var(--text4);
  flex-shrink: 0;
}
.badge-shared { display: inline-flex; align-items: center; color: var(--text4); }

.sidebar-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 20px);
  margin: 1px 10px;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text4);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
}
.sidebar-add-btn:hover { background: var(--hover); color: var(--text2); }

.kbd-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--text4);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-footer { padding: 8px 10px 10px; border-top: 1px solid var(--border); }

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
}
.sidebar-logout-btn:hover { background: var(--hover); color: var(--text); }
.sidebar-logout-btn svg.icon { color: var(--text4); }
.sidebar-logout-btn:hover svg.icon { color: var(--text2); }

.sidebar-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 0;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}
.sidebar-footer-meta .version-footer { text-align: right; }

.locale-select {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.locale-select:hover { color: var(--text); border-color: var(--text4); }

/* --- Sidebar global search --- */
.sidebar-global-search { position: relative; padding: 0 14px 8px; }

.global-search-results {
  position: absolute;
  top: 100%;
  left: 10px;
  right: 10px;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.gs-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.gs-row:hover { background: var(--hover); }
.gs-icon {
  width: 22px;
  height: 22px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gs-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.gs-title {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-sub {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------------------------
   6. Item list panel
   ---------------------------------------------------------------------------- */
.item-list-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.item-list-header { padding: 12px 12px 8px; }

.search-input {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
  font-family: inherit;
}
.search-input:hover { background: var(--hover); }
.search-input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.search-input::placeholder { color: var(--text4); }

/* --- Shared-with chips under the search --- */
.vault-shares {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 14px 8px;
}
.vault-shares-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text4);
}
.team-chip {
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Tag / favorites filter bar --- */
.tag-bar {
  display: flex;
  gap: 6px;
  padding: 4px 12px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tag-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.filter-chip:hover { background: var(--hover); color: var(--text); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* --- Item rows --- */
.item-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.item-card {
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  padding: 8px 10px;
  cursor: pointer;
  transition: background var(--t-fast);
  display: flex;
  align-items: center;
  gap: 10px;
}
.item-card:hover { background: var(--hover); }
.item-card.active { background: var(--accent-tint); }

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
  transition: background var(--t-fast), color var(--t-fast);
}
.item-card.active .card-icon {
  background: var(--accent-tint-strong);
  color: var(--accent-ink);
}

.card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.card-info h3 {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.card-info p {
  font-size: 12px;
  color: var(--text3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card .totp-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.fav-indicator {
  display: inline-flex;
  align-items: center;
  color: var(--star);
  flex-shrink: 0;
}

.weak-indicator {
  display: inline-flex;
  align-items: center;
  color: var(--warn);
  flex-shrink: 0;
}

/* Tag chips on rows */
.row-tags { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.row-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text3);
  white-space: nowrap;
}
.row-tag::before { content: "#"; opacity: 0.55; }
.row-tag.more::before { content: ""; }

/* --- Bottom action bar --- */
.item-list-actions {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.item-list-actions .item-list-add-btn { margin: 0; flex: 1; }

.item-list-add-btn {
  margin: 4px 8px 8px;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text3);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: center;
}
.item-list-add-btn:hover { background: var(--hover); color: var(--text); }
#btn-add-item { color: var(--accent-ink); }
#btn-add-item:hover { background: var(--accent-tint); color: var(--accent-ink); }

/* --- Team detail (inside list panel) --- */
#team-detail-panel { flex: 1; overflow-y: auto; padding: 8px 14px 16px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.section-header h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}

.member-list { display: flex; flex-direction: column; gap: 2px; }

.member-card {
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background var(--t-fast);
}
.member-card:hover { background: var(--hover); }
.member-card .card-info h3 {
  font-size: 13px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.member-name { font-weight: 600; }
.member-email { font-size: 12px; color: var(--text3); margin-top: 1px; }
.member-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* Role badges */
.badge-role {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-admin { background: var(--accent-tint); color: var(--accent-ink); }
.badge-member { background: var(--surface-2); color: var(--text3); }
.badge-pending { background: var(--warn-tint); color: var(--warn-ink); }
.badge-owner { background: var(--accent-tint-strong); color: var(--accent-ink); }

.vault-list { display: flex; flex-direction: column; gap: 2px; }

.vault-card {
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: background var(--t-fast);
  display: flex;
  align-items: center;
  gap: 10px;
}
.vault-card:hover { background: var(--hover); }

/* ----------------------------------------------------------------------------
   7. Detail panel
   ---------------------------------------------------------------------------- */
.detail-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 28px 36px;
}

#detail-content { width: 100%; max-width: 700px; margin: 0 auto; }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.detail-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text2);
  flex-shrink: 0;
  overflow: hidden;
}
.detail-item-icon:empty { display: none; }
.detail-item-icon .item-emoji { font-size: 19px; }

.detail-header h2 {
  font-size: 20px;
  font-weight: 650;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-actions { display: flex; gap: 2px; flex-shrink: 0; }

.fav-star.active { color: var(--star); }
.fav-star.active:hover { color: var(--star); }

/* Meta row: type badge + tags + last edited */
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  align-items: center;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-xs);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 650;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.tag-chip:hover { background: var(--accent-tint); color: var(--accent-ink); }
.tag-chip::before { content: "#"; opacity: 0.5; margin-right: 1px; }

.detail-edited {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text4);
  margin-left: auto;
}

/* --- Field rows --- */
.field-group { background: transparent; }

.field {
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field + .field { border-top: 1px solid var(--border); }

.field-main { min-width: 0; flex: 1; }

.field-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-value {
  font-size: 14px;
  word-break: break-all;
  color: var(--text);
}
.field-value.mono { font-family: var(--mono); font-size: 13.5px; }
.field-value.masked { color: var(--text4); letter-spacing: 2px; font-family: var(--mono); }
.field-value.link { color: var(--accent-ink); text-decoration: none; }
.field-value.link:hover { text-decoration: underline; }

.field-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* Reveal ghost actions on row hover (pointer devices only) */
@media (hover: hover) and (pointer: fine) {
  .field .field-actions { opacity: 0; transition: opacity var(--t-fast); }
  .field:hover .field-actions,
  .field:focus-within .field-actions { opacity: 1; }
}

/* --- TOTP --- */
.totp-display { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

.totp-code {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 2px;
  color: var(--accent-ink);
}

.totp-countdown { width: 30px; height: 30px; flex-shrink: 0; transform: rotate(-90deg); }
.totp-countdown-bg { stroke: var(--border); }
.totp-countdown-fg { stroke: var(--accent); transition: stroke-dashoffset 1s linear; }
.totp-countdown-text {
  fill: var(--text2);
  font-size: 11px;
  font-weight: 600;
  transform: rotate(90deg);
  transform-origin: 18px 18px;
}

/* --- Detail extras (health / breach) --- */
.detail-extras { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.extras-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3);
  margin-bottom: 10px;
}

.extras-breach-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.breach-ok {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 550;
}
.breach-bad {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--danger-ink);
  font-size: 13px;
  font-weight: 600;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3);
  margin-top: 20px;
  margin-bottom: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* --- Attachments --- */
.attachments-list { display: flex; flex-direction: column; gap: 4px; }
.attachment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  margin-bottom: 4px;
}
.attachment-icon { display: flex; color: var(--text3); flex-shrink: 0; }
.attachment-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-size { font-size: 11px; color: var(--text4); flex-shrink: 0; }
.attachment-row a.btn-icon { color: var(--text3); text-decoration: none; }
.attachment-row a.btn-icon:hover { color: var(--text); }

/* Item icon variants (custom emoji / favicon fallback) */
.item-emoji { font-size: 15px; line-height: 1; }
.item-type-fallback { align-items: center; justify-content: center; }
.favicon-img { border-radius: 4px; display: block; }

/* --- Strength meter --- */
.strength { margin-top: 8px; }
.strength-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease, background 0.25s ease;
}
.strength-vw { background: var(--s-vw); }
.strength-w  { background: var(--s-w); }
.strength-f  { background: var(--s-f); }
.strength-s  { background: var(--s-s); }
.strength-vs { background: var(--s-vs); }
.strength-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}
.strength-detail { color: var(--text4); font-weight: 400; }

/* ----------------------------------------------------------------------------
   8. Forms
   ---------------------------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}

input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
  font-family: inherit;
}
input:focus { border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder { color: var(--text4); }

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: auto; }
input[type="range"] { accent-color: var(--accent); padding: 0; border: none; box-shadow: none; }

.select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.select:focus { border-color: var(--accent); box-shadow: var(--ring); }

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { white-space: nowrap; }

.label-hint { color: var(--text4); font-weight: 400; font-size: 11px; }
.icon-hint { margin: -8px 0 12px; display: block; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
}
.checkbox-row input { width: auto; }

/* --- Item type selector --- */
.type-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}
.type-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 3px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.type-tab > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.type-tab:hover { background: var(--hover); color: var(--text); }
.type-tab.active {
  border-color: transparent;
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}

/* --- Custom fields --- */
.custom-fields-list { display: flex; flex-direction: column; gap: 6px; }
.cf-row { display: flex; gap: 6px; align-items: center; }
.cf-row .cf-label { flex: 2; min-width: 0; }
.cf-row .cf-value { flex: 3; min-width: 0; }
.cf-hidden-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 7px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-strong);
  color: var(--text3);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.cf-hidden-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  margin: 0;
  cursor: pointer;
}
.cf-hidden-toggle:has(input:checked) {
  color: var(--accent-ink);
  background: var(--accent-tint);
  border-color: transparent;
}

/* --- Add attachment / add field ghost buttons --- */
.attach-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 7px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  background: none;
  color: var(--text3);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  width: fit-content;
}
.attach-add-btn:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.import-file-input-hidden { display: none; }

/* ----------------------------------------------------------------------------
   9. Buttons
   ---------------------------------------------------------------------------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  width: 100%;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--hover); }

.btn-danger {
  background: transparent;
  color: var(--danger-ink);
  border-color: var(--border-strong);
}
.btn-danger:hover { background: var(--danger-tint); border-color: var(--danger); }

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
  width: auto;
  white-space: nowrap;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 6px;
  border-radius: 7px;
  transition: background var(--t-fast), color var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon-danger:hover { background: var(--danger-tint); color: var(--danger-ink); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

/* SSO login: one button per identity provider + "or" separator above the
   SRP email/password form. */
.sso-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-separator::before,
.auth-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------------------
   10. Empty states
   ---------------------------------------------------------------------------- */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text4);
  padding: 24px;
}
.empty-state > .icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state p { font-size: 13px; text-align: center; }

.empty-text { color: var(--text4); font-size: 13px; padding: 12px 0; }

/* ----------------------------------------------------------------------------
   11. Modals
   ---------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.active { display: flex; animation: fade-in 0.12s ease; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  width: 90%;
  max-width: 440px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.modal-overlay.active .modal { animation: pop-in 0.15s ease; }

.modal h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 18px;
}
.modal h3 svg.icon { color: var(--accent-ink); }

.modal .form-group { margin-bottom: 14px; }

.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

.modal-lg { max-width: 640px; width: 92%; }
.modal-lg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-lg-header h3 { margin-bottom: 0; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.98) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ----------------------------------------------------------------------------
   12. Command palette
   ---------------------------------------------------------------------------- */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 300;
  padding-top: 13vh;
}
.cmd-overlay.active { display: flex; animation: fade-in 0.12s ease; }

.cmd-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 90%;
  max-width: 580px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}
.cmd-overlay.active .cmd-box { animation: pop-in 0.15s ease; }

.cmd-input {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 16px 18px;
  font-size: 16px;
  background: transparent;
}
.cmd-input:focus { box-shadow: none; border-color: var(--border); }

.cmd-results { overflow-y: auto; padding: 6px; }

.cmd-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.cmd-row.active { background: var(--accent-tint); }
.cmd-row.active .cmd-icon { color: var(--accent-ink); }
.cmd-row.active .cmd-title { color: var(--accent-ink); }

.cmd-icon {
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 14px;
  flex-shrink: 0;
}
.cmd-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cmd-title {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-sub {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}
.cmd-loading, .cmd-empty {
  padding: 24px;
  text-align: center;
  color: var(--text4);
  font-size: 13px;
}
.cmd-footer {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text4);
}

/* ----------------------------------------------------------------------------
   13. Watchtower (security dashboard)
   ---------------------------------------------------------------------------- */
.watchtower-body { max-height: 68vh; overflow-y: auto; }
.wt-summary { font-size: 13px; color: var(--text2); margin-bottom: 14px; }

.wt-allclear {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 550;
  margin-bottom: 12px;
}

.wt-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.wt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.wt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.wt-bad .wt-badge { background: var(--danger-tint); color: var(--danger-ink); }
.wt-warn .wt-badge { background: var(--warn-tint); color: var(--warn-ink); }
.wt-note { font-size: 12px; font-weight: 400; color: var(--text4); margin-left: auto; }

.wt-list { display: flex; flex-direction: column; gap: 2px; }
.wt-group {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  padding: 4px;
  margin-bottom: 6px;
}
.wt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--t-fast);
}
.wt-item:hover { background: var(--hover); }

/* ----------------------------------------------------------------------------
   14. Password generator
   ---------------------------------------------------------------------------- */
.gen-output-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
}
.gen-output {
  flex: 1;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}

.gen-mode-row { display: flex; gap: 8px; margin: 16px 0 14px; }
.radio-pill { flex: 1; position: relative; cursor: pointer; }
.radio-pill input { position: absolute; opacity: 0; }
.radio-pill span {
  display: block;
  text-align: center;
  padding: 7px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.radio-pill input:checked + span {
  border-color: transparent;
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}
.radio-pill input:focus-visible + span { box-shadow: var(--ring); }

.gen-slider-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gen-slider-row label { font-size: 13px; font-weight: 500; min-width: 52px; }
.gen-slider-row input[type="range"] { flex: 1; width: auto; }
.gen-slider-val {
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--accent-ink);
}
.gen-checks { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.gen-checks .checkbox-row { margin-top: 0; font-size: 12px; }

/* ----------------------------------------------------------------------------
   15. History modal
   ---------------------------------------------------------------------------- */
.history-body { max-height: 55vh; overflow-y: auto; }
.history-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: none; }
.history-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.history-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text3);
}
.history-actions { display: flex; gap: 2px; flex-shrink: 0; }
.history-mini {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

/* Mini read-only fields (history / shared item) */
.mini-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.mini-field:last-child { border-bottom: none; }
.mini-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 90px;
  flex-shrink: 0;
}
.mini-value {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-family: var(--mono);
  word-break: break-all;
  color: var(--text);
}
.mini-value.masked { color: var(--text4); letter-spacing: 2px; }
.mini-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ----------------------------------------------------------------------------
   16. Share links
   ---------------------------------------------------------------------------- */
.share-result { margin-top: 14px; }
.share-url-row { display: flex; gap: 6px; align-items: center; }
.share-url-row input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text2);
  background: var(--surface-2);
  border-color: transparent;
}
.share-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--warn-ink);
  background: var(--warn-tint);
}
.share-links-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.share-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.share-link-icon { display: flex; color: var(--text3); flex-shrink: 0; }
.share-link-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.share-link-date { color: var(--text2); }
.share-state { font-size: 11px; color: var(--text4); }
.share-state.share-active { color: var(--ok); }
.share-state.share-used { color: var(--text4); }
.share-state.share-expired { color: var(--warn-ink); }

/* Recipient screen */
.share-open-container { text-align: center; }
.share-item-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  background: var(--surface);
  text-align: left;
}
.share-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.share-item-title h3 { font-size: 16px; font-weight: 650; flex: 1; min-width: 0; }
.share-item-fields { margin-top: 4px; }
.share-gone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text2);
  padding: 20px 0;
  font-size: 14px;
}
.share-open-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
}

/* ----------------------------------------------------------------------------
   17. Import
   ---------------------------------------------------------------------------- */
.import-description { color: var(--text2); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }

.import-file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
}
.import-file-label:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--text);
}
.import-file-label.has-file {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-tint);
  color: var(--text);
}

.import-preview {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text2);
}
.import-errors-preview {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--danger-tint);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--danger-ink);
  max-height: 100px;
  overflow-y: auto;
}

.import-progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0 12px;
}
.import-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0%;
  transition: width 0.2s ease;
}
.import-progress-text { color: var(--text2); font-size: 13px; text-align: center; }

.import-results-summary {
  margin: 12px 0;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-line;
}
.import-error-item {
  padding: 6px 0;
  font-size: 12px;
  color: var(--danger-ink);
  border-bottom: 1px solid var(--border);
}
.import-error-item:last-child { border-bottom: none; }

/* ----------------------------------------------------------------------------
   18. Toast
   ---------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(72px);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 400;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
  max-width: min(90vw, 480px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); color: #ffffff; }

/* ----------------------------------------------------------------------------
   19. Bottom nav (mobile, currently disabled by JS)
   ---------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  z-index: 50;
}
.nav-item {
  flex: 1;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  transition: color var(--t-fast);
  font-size: 11px;
  font-weight: 500;
}
.nav-item.active { color: var(--accent-ink); }
.nav-item:hover { color: var(--text); }
.nav-icon { display: inline-flex; line-height: 1; }
.nav-label { font-size: 10px; }

/* ----------------------------------------------------------------------------
   20. Mobile
   ---------------------------------------------------------------------------- */
.mobile-back-row {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.mobile-back-row h2 { font-size: 15px; font-weight: 550; flex: 1; }

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 280px;
    border-right: 1px solid var(--border);
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-pop);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 39;
    display: none;
  }
  .sidebar-overlay.active { display: block; }

  .item-list-panel { border-right: none; }

  .detail-panel {
    position: fixed;
    inset: 0;
    z-index: 30;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    background: var(--surface);
    padding: 0 16px 16px;
  }
  .detail-panel.mobile-open { transform: translateX(0); }

  .mobile-back-row { display: flex; margin: 0 -16px 12px; }

  .item-list-header { display: flex; gap: 8px; align-items: center; }

  .mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    transition: background var(--t-fast);
  }
  .mobile-menu-btn:hover { background: var(--hover); }

  .bottom-nav { display: none !important; }

  .toast { bottom: 16px; }

  .auth-container { border: none; background: transparent; padding: 24px 4px; }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ----------------------------------------------------------------------------
   21. Motion preferences
   ---------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------------------------
   22. Orange skin — Orange Design System (Boosted) look
   ----------------------------------------------------------------------------
   Second SKIN dimension on <html>: [data-skin="orange"] (absent = Light).
   Combines freely with the MODE dimension [data-theme="dark"].
   Principles (ODS): black & white carry the UI, orange is used sparingly as
   the accent; SQUARE design language (no rounded corners except semantic
   circles: dots, spinner, TOTP ring); bold emphasis; hard 2px borders and
   crisp focus outlines instead of soft glows.
   Purely additive: only variable + component overrides, no base rule edits.
   ---------------------------------------------------------------------------- */

[data-skin="orange"] {
  color-scheme: light;

  /* Canvas & surfaces (ODS light: white canvas, functional greys) */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eeeeee;
  --hover: #f6f6f6;

  /* Hairlines */
  --border: #dddddd;
  --border-strong: #cccccc;

  /* Ink (black carries the UI) */
  --text: #000000;
  --text2: #333333;
  --text3: #595959;
  --text4: #999999;

  /* Accent — ODS accessible orange; accent-colored TEXT stays black (ODS) */
  --accent: #f16e00;
  --accent-hover: #d55e00;
  --accent-ink: #000000;
  --accent-tint: rgba(241, 110, 0, 0.10);
  --accent-tint-strong: rgba(241, 110, 0, 0.20);
  --on-accent: #000000;            /* black on orange: AA; never white on #f16e00 */
  --ring: 0 0 0 2px #f16e00;       /* hard ring, no soft glow */

  /* Functional (ODS light; info #4170d8 unused by this token system) */
  --danger: #cd3c14;
  --danger-ink: #cd3c14;
  --danger-tint: rgba(205, 60, 20, 0.08);
  --warn: #ffcc00;
  --warn-ink: #7d5b00;             /* AA amber ink; #fc0 itself is never used as text on white */
  --warn-tint: rgba(255, 204, 0, 0.16);
  --ok: #228722;
  --star: #f16e00;

  /* Strength ramp mapped to danger / warning / neutral / success */
  --s-vw: #cd3c14;
  --s-w: #ffcc00;
  --s-f: #999999;
  --s-s: #228722;
  --s-vs: #228722;

  /* Overlays & toasts (ODS toast: black bg, white text) */
  --overlay: rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 20px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 10px 32px -8px rgba(0, 0, 0, 0.16);
  --toast-bg: #000000;
  --toast-text: #ffffff;

  /* SQUARE design language: kill every radius the system exposes */
  --r-lg: 0;
  --r-md: 0;
  --r-sm: 0;
  --r-xs: 0;

  /* ODS type stack */
  --font: 'Helvetica Neue', Helvetica, 'Noto Sans', Arial, sans-serif;

  /* Consciously inherited from :root: --sidebar-w, --itemlist-w, --mono, --t-fast */
}

[data-skin="orange"][data-theme="dark"] {
  color-scheme: dark;

  /* ODS dark: #141414 canvas, #333-based surfaces */
  --bg: #141414;
  --surface: #141414;
  --surface-2: #333333;
  --hover: #333333;

  --border: #333333;
  --border-strong: #666666;

  --text: #ffffff;
  --text2: #cccccc;
  --text3: #999999;
  --text4: #666666;

  --accent: #ff7900;
  --accent-hover: #f16e00;
  --accent-ink: #ffffff;
  --accent-tint: rgba(255, 121, 0, 0.14);
  --accent-tint-strong: rgba(255, 121, 0, 0.26);
  --on-accent: #000000;            /* black on orange in dark mode too */
  --ring: 0 0 0 2px #ff7900;

  /* Functional (ODS dark: #6c6 / #69f / #fc0 / #f66) */
  --danger: #ff6666;
  --danger-ink: #ff6666;
  --danger-tint: rgba(255, 102, 102, 0.14);
  --warn: #ffcc00;
  --warn-ink: #ffcc00;
  --warn-tint: rgba(255, 204, 0, 0.14);
  --ok: #66cc66;
  --star: #ff7900;

  --s-vw: #ff6666;
  --s-w: #ffcc00;
  --s-f: #999999;
  --s-s: #66cc66;
  --s-vs: #66cc66;

  --overlay: rgba(0, 0, 0, 0.7);
  --shadow-modal: 0 24px 56px -12px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 12px 36px -8px rgba(0, 0, 0, 0.6);
  --toast-bg: #333333;
  --toast-text: #ffffff;

  /* Radii and --font inherited from [data-skin="orange"] (same in both modes) */
}

/* --- Orange skin: square the hardcoded radii (pills, chips, bars, toast) --- */
[data-skin="orange"]::-webkit-scrollbar-thumb,
[data-skin="orange"] ::-webkit-scrollbar-thumb,
[data-skin="orange"] .kbd-hint,
[data-skin="orange"] .row-tag,
[data-skin="orange"] .favicon-img,
[data-skin="orange"] .strength-bar,
[data-skin="orange"] .strength-fill,
[data-skin="orange"] .btn-small,
[data-skin="orange"] .btn-icon,
[data-skin="orange"] .cmd-tag,
[data-skin="orange"] .import-progress-bar-container,
[data-skin="orange"] .import-progress-bar,
[data-skin="orange"] .toast {
  border-radius: 0;
}
/* Semantic circles KEPT round on purpose: .spinner, .item-card .totp-indicator,
   and the SVG TOTP countdown ring. */

/* --- Orange skin: focus — crisp orange outline, offset, no glow --- */
[data-skin="orange"] :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 0;
}

/* --- Orange skin: buttons (bold; primary orange/black, secondary inverts) --- */
[data-skin="orange"] .btn { font-weight: 700; }

[data-skin="orange"] .btn-secondary {
  background: transparent;
  border: 2px solid var(--text);
  color: var(--text);
  padding: 8px 15px; /* compensate 1px→2px border, keep height */
}
[data-skin="orange"] .btn-secondary:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
[data-skin="orange"] .btn-small.btn-secondary { padding: 4px 9px; }

[data-skin="orange"] .btn-danger {
  background: #cd3c14;
  border-color: #cd3c14;
  color: #ffffff;
}
[data-skin="orange"] .btn-danger:hover {
  background: #a8300f;
  border-color: #a8300f;
  color: #ffffff;
}
[data-skin="orange"][data-theme="dark"] .btn-danger {
  background: #ff6666;
  border-color: #ff6666;
  color: #000000;
}
[data-skin="orange"][data-theme="dark"] .btn-danger:hover {
  background: #ff8585;
  border-color: #ff8585;
  color: #000000;
}

/* --- Orange skin: inputs — hard 2px borders, black/white focus, no glow --- */
[data-skin="orange"] input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"])),
[data-skin="orange"] .select,
[data-skin="orange"] .search-input {
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 0;
  color: var(--text);
}
[data-skin="orange"] input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"])):focus,
[data-skin="orange"] .select:focus,
[data-skin="orange"] .search-input:focus {
  border-color: var(--text);
  box-shadow: none;
  background: var(--surface);
}
/* Command palette input keeps its bottom-hairline-only look */
[data-skin="orange"] .cmd-input,
[data-skin="orange"] .cmd-input:focus {
  border: none;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  box-shadow: none;
}

/* --- Orange skin: sidebar/nav — active row: bold + 4px orange left border --- */
[data-skin="orange"] .sidebar-item {
  border-left: 4px solid transparent;
  padding-left: 6px; /* compensate the indicator border */
  border-radius: 0;
}
[data-skin="orange"] .sidebar-item.active {
  background: var(--hover); /* #f6f6f6 light / #333 dark */
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}
[data-skin="orange"] .sidebar-item.active .sidebar-item-icon { color: var(--text); }
[data-skin="orange"] .nav-item.active { font-weight: 700; }

/* --- Orange skin: brand marks — the Sésamo door, white on brand orange
   (#ff7900, logo treatment: matches the app icon, exempt from text AA) --- */
[data-skin="orange"] .auth-mark,
[data-skin="orange"] .brand-mark {
  background: #ff7900;
  color: #ffffff;
}

/* --- Orange skin: links — underlined ink, orange on hover (ODS) --- */
[data-skin="orange"] .link-btn,
[data-skin="orange"] .field-value.link {
  color: var(--text);
  text-decoration: underline;
}
[data-skin="orange"] .link-btn:hover,
[data-skin="orange"] .field-value.link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* --- Orange skin: dark-mode error toast — black text on light red (AA) --- */
[data-skin="orange"][data-theme="dark"] .toast.error {
  color: #000000;
}

/* ----------------------------------------------------------------------------
   23. Onboarding — first-steps checklist (sidebar) + welcome dialog
   ----------------------------------------------------------------------------
   Theme/skin-agnostic: only system variables, so the orange skin squares and
   recolors it for free. Rendered/updated by onboarding.js.
   ---------------------------------------------------------------------------- */
.onboarding-card {
  margin: 12px 10px 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.onboarding-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.onboarding-title { font-size: 12px; font-weight: 700; color: var(--text2); }
.onboarding-count { font-size: 11px; color: var(--text4); }
.onboarding-close {
  margin-left: auto;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  border-radius: var(--r-xs);
  padding: 2px;
  color: var(--text4);
  cursor: pointer;
}
.onboarding-close:hover { color: var(--text2); background: var(--hover); }

.onboarding-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  overflow: hidden;
  margin-bottom: 8px;
}
.onboarding-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--t-fast);
}

.onboarding-step {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 4px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text3);
  font-size: 12.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.onboarding-step:hover { background: var(--hover); color: var(--text); }
.onboarding-step-icon { display: flex; color: var(--accent-ink); }
.onboarding-step-label { flex: 1; }
.onboarding-check {
  width: 16px;
  height: 16px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  color: var(--on-accent);
}
.onboarding-step.done .onboarding-check {
  background: var(--accent);
  border-color: var(--accent);
}
.onboarding-step.done .onboarding-step-label { text-decoration: line-through; color: var(--text4); }
.onboarding-step.done .onboarding-step-icon { color: var(--text4); }

.onboarding-complete { font-size: 12.5px; color: var(--text3); margin: 2px 0 0; }

/* Welcome dialog */
.modal-welcome .welcome-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  border-radius: var(--r-md);
  background: var(--accent-tint);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-welcome .welcome-intro { color: var(--text3); font-size: 13.5px; margin-bottom: 14px; }
.welcome-point {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.welcome-point-icon {
  display: flex;
  flex: none;
  margin-top: 1px;
  color: var(--accent-ink);
}
.welcome-point p { font-size: 13.5px; color: var(--text2); margin: 0; }

/* ----------------------------------------------------------------------------
   24. Linked devices (QR pairing modal)
   Token-driven throughout, so the Orange skin and dark mode apply untouched.
   The QR tile itself is intentionally white-with-black-modules in every
   theme: scanners need that contrast.
   ---------------------------------------------------------------------------- */
.device-qr-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.device-qr-result:not(:empty) { margin: 4px 0 16px; }
.device-qr {
  background: #ffffff;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  line-height: 0;
}
.device-qr svg { display: block; }
.device-scan-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}
.device-qr-result .share-url-row { width: 100%; }
.device-qr-result .share-warning { width: 100%; margin-top: 0; }

.device-list-title { margin-top: 16px; }
.device-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.device-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.device-row-icon { display: flex; color: var(--text3); flex-shrink: 0; }
.device-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.device-row-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-row-meta { font-size: 11px; color: var(--text4); }
.device-row-revoked .device-row-name,
.device-row-revoked .device-row-icon { color: var(--text4); }
.device-badge-revoked {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--danger-ink);
  background: var(--danger-tint);
}

/* ----------------------------------------------------------------------------
   23. Server-driven login options
   ----------------------------------------------------------------------------
   The head script sets html[data-auth] from the cached /auth/mode answer:
   'password' (email form), 'sso' (providers only) or 'unknown' (first visit,
   nothing cached). The form is held back until the answer is known so the
   login screen never paints one option and swaps to another; 'unknown' shows
   a spinner that renderSSOLogin resolves.
   ---------------------------------------------------------------------------- */
html[data-auth="unknown"] #srp-login,
html[data-auth="sso"] #srp-login { display: none; }

.auth-loading {
  display: none;
  justify-content: center;
  padding: 26px 0;
  color: var(--text3);
}
html[data-auth="unknown"] .auth-loading { display: flex; }
.auth-loading .spinner {
  width: 22px;
  height: 22px;
  border-color: var(--border-strong);
  border-top-color: var(--accent);
}

/* Passkey login/unlock buttons (login + lock screens) */
.btn-passkey {
  width: 100%;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
