:root {
  color-scheme: light;
  --page: #fff; --paper: #f5f5f7; --surface: #fff;
  --ink: #1d1d1f; --muted: #6e6e73; --line: #d2d2d7;
  --blue: #0071e3; --accent: #0066cc;
  --soft: #ededf0; --hover: #e5e5ea; --pressed: #d8d8de;
  --selection: #e9edf2;
  --tab-active-bg: #fff;
  --tab-active-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.06);
  --tab-hover: rgba(0,0,0,.045);
  --header: rgba(255,255,255,.86); --separator: #e2e2e7;
  --field-line: #c7c7cc; --subtle-line: #ebebf0;
  --icon-line: #e6e6eb; --icon-fallback: #f2f2f5; --icon-ink: #515154;
  --danger: #c32828; --danger-surface: #fff0f0;
  --vault-open-bg: #e9f7ef; --vault-open-ink: #116f3b; --vault-open-line: #bfe6cf;
  --ai-bg: #f0f6ff; --ai-line: #cfe2ff; --ai-badge-bg: #0071e3; --ai-badge-ink: #fff;
  --warn-bg: #fff8ea; --warn-line: #f2d399; --warn-ink: #8a5600;
  --skel-base: #ededf0; --skel-shine: #f7f7f9;
  --card-shadow: 0 2px 10px #00000008, 0 0 0 1px #0000000a;
  --card-hover-shadow: 0 10px 26px #0000000f, 0 0 0 1px #00000014;
  --menu-shadow: 0 14px 36px #0000001c, 0 0 0 1px #00000010;
  --toast-bg: #1d1d1f; --toast-ink: #fff;
  --ease-out: cubic-bezier(.2,.7,.3,1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0d; --paper: #111113; --surface: #1c1c1e;
  --ink: #f5f5f7; --muted: #a1a1a6; --line: #3f3f44;
  --blue: #0a84ff; --accent: #6cb4ff;
  --soft: #2a2a2d; --hover: #343438; --pressed: #414146;
  --selection: #292d33;
  --tab-active-bg: #27272c;
  --tab-active-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 1px rgba(255,255,255,.08);
  --tab-hover: rgba(255,255,255,.05);
  --header: rgba(18,18,20,.88); --separator: #2c2c30;
  --field-line: #4e4e54; --subtle-line: #2d2d31;
  --icon-line: #343438; --icon-fallback: #28282b; --icon-ink: #c7c7cc;
  --danger: #ff8585; --danger-surface: #3c2529;
  --vault-open-bg: #153122; --vault-open-ink: #57db92; --vault-open-line: #23543a;
  --ai-bg: #142235; --ai-line: #243f66; --ai-badge-bg: #0a84ff; --ai-badge-ink: #fff;
  --warn-bg: #2e2412; --warn-line: #5c4418; --warn-ink: #f6c967;
  --skel-base: #26262a; --skel-shine: #323238;
  --card-shadow: 0 2px 10px #00000028, 0 0 0 1px #ffffff10;
  --card-hover-shadow: 0 12px 28px #00000048, 0 0 0 1px #ffffff1f;
  --menu-shadow: 0 18px 42px #00000060, 0 0 0 1px #ffffff18;
  --toast-bg: #ededf0; --toast-ink: #1d1d1f;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; transition: color .18s, background-color .18s, border-color .18s, box-shadow .2s, transform .18s var(--ease-out), opacity .18s; }
button:disabled { opacity: .45; cursor: default; }
a { color: inherit; text-decoration: none; }
a[href] { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Unified Sticky Workbench Header */
.shell { min-height: 100dvh; display: flex; flex-direction: column; background: var(--paper); }
.site-header { position: sticky; top: 0; z-index: 40; background: var(--header); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-bottom: 1px solid var(--subtle-line); }
.header-inner { max-width: 1180px; min-height: 60px; margin: auto; padding: 10px 24px; display: grid; grid-template-columns: auto minmax(220px, 1fr) auto auto; align-items: center; gap: 12px 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; min-height: 38px; padding: 4px 6px 4px 2px; border-radius: 10px; font-size: 15px; font-weight: 650; letter-spacing: -.015em; white-space: nowrap; }
.brand:hover { opacity: .82; }
.brand-mark { display: block; width: 28px; height: 28px; flex-shrink: 0; object-fit: contain; border-radius: 7.5px; }
.brand-icon { display: block; width: 58px; height: 58px; flex-shrink: 0; object-fit: contain; border-radius: 14.5px; }

/* Header Search */
.search-area { width: 100%; max-width: 480px; justify-self: center; min-width: 0; }
.search { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; height: 40px; margin: 0; padding: 0 8px 0 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; cursor: text; transition: border-color .18s, box-shadow .18s, background-color .18s; }
.search:hover { border-color: var(--muted); }
.search:focus-within { background: var(--surface); border-color: var(--blue); box-shadow: 0 0 0 3px #0071e326; }
.search-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); }
.search:focus-within .search-icon { color: var(--accent); }
.search input { flex: 1; width: 0; min-width: 0; height: 100%; margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; font-size: 13px; color: var(--ink); caret-color: var(--accent); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search input:focus { outline: none; box-shadow: none; }
.search input:focus::placeholder { color: transparent; }
.search-clear { display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 14px; line-height: 1; flex-shrink: 0; }
.search-clear:hover { background: var(--hover); color: var(--ink); }
.search kbd { color: var(--muted); border: 1px solid var(--separator); border-radius: 5px; padding: 1px 6px; font-size: 11px; line-height: 1.4; flex-shrink: 0; }
#ai-search-button { flex-shrink: 0; min-height: 28px; padding: 0 10px; border-radius: 8px; background: var(--soft); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
#ai-search-button:hover:not(:disabled) { background: var(--hover); }
#ai-search-button:disabled { opacity: .5; cursor: default; }

/* Vault Unlocked Status Pill */
.vault-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 11px; border-radius: 999px; background: var(--vault-open-bg); color: var(--vault-open-ink); border: 1px solid var(--vault-open-line); font-size: 12px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vault-pill svg { width: 14px; height: 14px; flex-shrink: 0; }
.vault-pill-action { padding-left: 6px; margin-left: 2px; border-left: 1px solid var(--vault-open-line); font-weight: 600; }
.vault-pill:hover { filter: brightness(.96); }

/* Header Right Action Controls */
.header-actions { display: inline-flex; align-items: center; gap: 8px; justify-self: end; flex-shrink: 0; }
.header-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 10px; background: var(--soft); color: var(--accent); font-size: 12px; font-weight: 550; white-space: nowrap; }
.header-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.header-chip:hover { background: var(--hover); }
.chip-label-short { display: none; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 10px; background: var(--soft); color: var(--ink); flex-shrink: 0; }
.icon-button svg { width: 17px; height: 17px; }
.icon-button:hover { background: var(--hover); }
.theme-sun { display: none; }
[data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
.primary.add-button { min-height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13px; font-weight: 550; gap: 5px; white-space: nowrap; }
.add-label-short { display: none; }

/* Core Buttons */
.primary, .secondary { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 12px; padding: 10px 20px; font-size: 14px; font-weight: 500; line-height: 1.4; }
.primary { background: var(--blue); color: #fff; }
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.primary:active:not(:disabled) { transform: scale(.98); }
.secondary { background: var(--soft); color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--hover); }
.secondary:active:not(:disabled) { background: var(--pressed); transform: scale(.98); }
.text-button { min-height: 40px; background: none; color: var(--muted); font-size: 13px; padding: 8px 12px; border-radius: 10px; }
.text-button:hover:not(:disabled) { color: var(--accent); background: var(--hover); }
.wide { width: 100%; }
.eyebrow { color: var(--muted); font-size: 12px; line-height: 1.5; font-weight: 500; }
.muted { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

/* Main Workspace */
.workspace { flex: 1; display: flex; flex-direction: column; }
.workspace-inner { width: 100%; max-width: 1180px; margin: 0 auto; padding: 14px 24px 28px; flex: 1; }

/* Clean Matte Category Bar */
.category-bar { margin-bottom: 16px; }
nav#categories { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 4px 2px; margin-inline: -2px; }
nav#categories::-webkit-scrollbar { display: none; }
nav#categories button { position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 6px 13px; border-radius: 999px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 500; white-space: nowrap; }
nav#categories button:hover:not(.active) { background: var(--tab-hover); color: var(--ink); }
nav#categories button.active {
  background: var(--tab-active-bg); color: var(--ink); font-weight: 600;
  box-shadow: var(--tab-active-shadow);
}
nav#categories button.is-inbox-tab { color: var(--warn-ink); background: var(--warn-bg); box-shadow: inset 0 0 0 1px var(--warn-line); }
nav#categories button.is-inbox-tab:hover:not(.active) { filter: brightness(.97); color: var(--warn-ink); }
nav#categories button.is-inbox-tab.active { background: var(--warn-bg); color: var(--warn-ink); box-shadow: var(--tab-active-shadow), inset 0 0 0 1px var(--warn-line); }
nav#categories button.is-inbox-tab .nav-count { opacity: .95; font-weight: 650; }
nav#categories button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.nav-symbol { display: none; }
.nav-count { font-size: 11px; opacity: .65; font-variant-numeric: tabular-nums; }

/* Search Status Strip & AI Summary */
.search-status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 14px; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--subtle-line); transition: background-color .18s, border-color .18s; }
.search-status-bar.is-ai-summary { align-items: flex-start; padding: 11px 14px; background: var(--ai-bg); border-color: var(--ai-line); }
.search-status-main { display: flex; align-items: flex-start; gap: 9px; min-width: 0; flex: 1; }
.search-ai-badge { flex-shrink: 0; margin-top: 1px; padding: 2px 7px; border-radius: 6px; background: var(--ai-badge-bg); color: var(--ai-badge-ink); font-size: 11px; font-weight: 600; line-height: 1.5; letter-spacing: .01em; white-space: nowrap; }
.search-status { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.search-status-bar.is-ai-summary .search-status { color: var(--ink); font-size: 13px; line-height: 1.6; font-weight: 450; }
.search-status[data-status="busy"] { color: var(--blue); }
.search-status[data-status="error"] { color: var(--danger); }
#search-clear-ai { min-height: 28px; padding: 4px 10px; font-size: 12px; color: var(--accent); flex-shrink: 0; }

/* Collections & 3-Column Compact Cards */
.inbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 16px; padding: 13px 16px; border-radius: 14px; background: var(--warn-bg); border: 1px solid var(--warn-line); }
.inbox-bar-copy { min-width: 0; }
.inbox-bar-copy strong { display: block; font-size: 13.5px; font-weight: 650; color: var(--warn-ink); }
.inbox-bar-copy p { margin: 3px 0 0; font-size: 12px; line-height: 1.55; color: var(--ink); opacity: .82; }
#batch-identify-button { flex-shrink: 0; min-height: 36px; padding: 7px 14px; border-radius: 10px; background: var(--surface); color: var(--accent); border: 1px solid var(--warn-line); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
#batch-identify-button:hover:not(:disabled) { background: var(--hover); }
.collection { margin-bottom: 24px; }
.collection:last-of-type { margin-bottom: 0; }
#all-sites { scroll-margin-top: 76px; }
.collection-heading { display: flex; align-items: baseline; gap: 10px; padding-bottom: 12px; }
.collection-heading h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.count { color: var(--muted); font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.card { position: relative; min-width: 0; display: flex; flex-direction: column; text-align: left; border-radius: 16px; padding: 15px 16px 12px; background: var(--surface); box-shadow: var(--card-shadow); transition: box-shadow .2s ease, transform .2s var(--ease-out); }
.card.menu-open { z-index: 30; }
.card-top { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.site-icon { position: relative; display: grid; place-items: center; flex-shrink: 0; width: 42px; height: 42px; overflow: hidden; border: 1px solid var(--icon-line); border-radius: 11px; background: #fff; color: var(--icon-ink); }
.site-icon-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 6px; object-fit: contain; border-radius: 10px; background: #fff; }
.site-icon-image.is-loading { opacity: 0; }
.site-icon-fallback { display: grid; place-items: center; width: 100%; height: 100%; background: var(--icon-fallback); color: var(--icon-ink); }
.site-icon-fallback svg { display: block; width: 22px; height: 22px; }
.card-meta { min-width: 0; flex: 1; }
.card-title-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.card-link { min-width: 0; flex: 0 1 auto; max-width: 100%; }
.card-link h3 { margin: 0; font-size: 15px; line-height: 1.35; font-weight: 600; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: 16px; cursor: pointer; }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 3px solid var(--blue); outline-offset: 2px; }
.pin-mark { flex-shrink: 0; font-size: 11px; color: var(--accent); line-height: 1; }
.card-open-hint { flex-shrink: 0; margin-left: auto; font-size: 13px; color: var(--muted); opacity: 0; transition: opacity .16s ease, transform .16s ease; }
.site-url { margin: 3px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-reason { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 10px; padding: 7px 10px; border-radius: 10px; background: var(--ai-bg); border: 1px solid var(--ai-line); color: var(--ink); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-reason-mark { color: var(--accent); flex-shrink: 0; font-size: 11px; line-height: 1.65; }
.card.is-ai-match .site-note { margin-top: 0; opacity: .82; }
.site-note { margin: 10px 0 12px; color: var(--muted); font-size: 12.5px; line-height: 1.55; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }

/* Clean Single-Row Card Footer */
.card-bottom { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--subtle-line); }
.credential-button { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; max-width: 100%; min-width: 0; padding: 4px 10px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credential-button svg { width: 13px; height: 13px; flex-shrink: 0; }
.credential-button.is-saved { color: var(--accent); }
.credential-button:hover { background: var(--hover); color: var(--accent); }
.card.is-pending-card { box-shadow: 0 2px 10px #00000008, 0 0 0 1px var(--warn-line); }
.site-note.is-pending-placeholder { font-style: italic; opacity: .78; }
.inbox-promote-button { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; max-width: 100%; min-width: 0; padding: 4px 11px; border-radius: 8px; background: var(--ai-bg); border: 1px solid var(--ai-line); color: var(--accent); font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-promote-button svg { width: 13px; height: 13px; flex-shrink: 0; }
.inbox-promote-button:hover { filter: brightness(.96); }
.card-footer-right { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.site-category-pill { font-size: 10.5px; color: var(--muted); padding: 2px 7px; border-radius: 6px; background: var(--paper); max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-more-button { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; flex-shrink: 0; }
.card-more-button:hover, .card.menu-open .card-more-button { background: var(--soft); color: var(--ink); }

/* Floating Card More Menu */
.card-menu { position: absolute; right: 12px; bottom: 46px; z-index: 35; min-width: 144px; padding: 5px; border-radius: 12px; background: var(--surface); box-shadow: var(--menu-shadow); display: flex; flex-direction: column; gap: 2px; animation: menu-in .14s var(--ease-out) both; }
.card-menu button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 8px; background: transparent; color: var(--ink); font-size: 12.5px; text-align: left; white-space: nowrap; }
.card-menu button:hover { background: var(--soft); }
.card-menu button svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.card-menu-divider { height: 1px; margin: 3px 6px; background: var(--subtle-line); }
.card-menu .danger-button { color: var(--danger); }
.card-menu .danger-button svg { color: var(--danger); }
.card-menu .danger-button:hover { background: var(--danger-surface); color: var(--danger); }
@keyframes menu-in { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: none; } }

@media (hover: hover) and (pointer: fine) {
  .card:hover { box-shadow: var(--card-hover-shadow); }
  .card:has(.card-link:hover) .card-link h3 { color: var(--accent); }
  .card:has(.card-link:hover) .card-open-hint, .card:hover .card-open-hint { opacity: .85; transform: translate(1px, -1px); }
}

.card-skeleton { pointer-events: none; user-select: none; }
.skel { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--skel-base) 25%, var(--skel-shine) 50%, var(--skel-base) 75%); background-size: 200% 100%; animation: skel-shimmer 1.3s ease-in-out infinite; }
.skel-icon { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; }
.skel-title { width: 68%; height: 16px; margin-top: 2px; }
.skel-url { width: 46%; height: 12px; margin-top: 8px; }
.skel-reason { width: 100%; height: 34px; margin: 12px 0; border-radius: 10px; }
.skel-pill { width: 78px; height: 24px; border-radius: 8px; }
.skel-dot { width: 24px; height: 24px; border-radius: 8px; }
@keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Empty State & Minimal Footer */
.empty { text-align: center; background: var(--surface); border-radius: 18px; padding: 48px 24px; box-shadow: var(--card-shadow); }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 14px; font-size: 26px; background: var(--soft); color: var(--muted); }
.empty h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; font-weight: 600; }
.empty p { color: var(--muted); line-height: 1.7; margin: 10px 0 22px; font-size: 13px; }
footer { width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 24px max(22px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--subtle-line); }
footer > span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.private-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--vault-open-ink); flex-shrink: 0; }

/* Login Screen */
.login-wrap { min-height: 100dvh; padding: 56px 24px; display: grid; place-items: center; background: var(--page); }
.login-card { width: 100%; max-width: 440px; text-align: center; }
.login-card > .brand-icon { margin: 0 auto 24px; }
.login-card h1 { margin: 14px 0; font-size: clamp(32px, 5vw, 44px); letter-spacing: -.04em; line-height: 1.2; font-weight: 650; }
.login-card > .muted { font-size: 15px; }
.login-card form { max-width: 360px; margin: 30px auto 22px; text-align: left; }
.login-card form .primary { margin-top: 6px; }
.login-card > .theme-toggle { margin-top: 22px; display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 999px; font-size: 12.5px; }
.login-card > .theme-toggle svg { width: 16px; height: 16px; }
.login-card > .helper { max-width: 380px; margin-inline: auto; }

/* Forms & Dialogs */
.helper { color: var(--muted); font-size: 12px; line-height: 1.75; margin: 14px 0 0; }
label { display: block; color: var(--ink); font-size: 13px; font-weight: 500; margin-bottom: 16px; line-height: 1.5; }
input, textarea { display: block; width: 100%; margin-top: 7px; padding: 11px 14px; border: 1px solid var(--field-line); border-radius: 11px; outline: none; background: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.5; transition: border-color .16s, box-shadow .16s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #0071e326; }
textarea { resize: vertical; }
.optional { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: 5px; }
.checkbox { display: flex; align-items: center; gap: 10px; min-height: 30px; cursor: pointer; }
.checkbox input { margin: 0; width: 18px; height: 18px; box-shadow: none; accent-color: var(--blue); cursor: pointer; }

dialog { color: var(--ink); background: var(--surface); border: 0; border-radius: 22px; padding: 28px; width: calc(100% - 32px); max-width: 500px; max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 24px 80px #0000002c; }
dialog::backdrop { background: #00000055; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
dialog[open] { animation: dialog-in .2s var(--ease-out) both; }
dialog[open]::backdrop { animation: backdrop-in .16s ease both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.dialog-heading h2 { font-size: 23px; line-height: 1.3; letter-spacing: -.025em; font-weight: 650; margin: 4px 0 0; }
.close { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; padding: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 24px; line-height: 1; }
.close:hover { background: var(--hover); color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.edit-dialog-actions { flex-wrap: wrap; }
.edit-dialog-actions [data-close] { margin-right: auto; }
.compact-helper { margin: -8px 0 16px; }
.quick-add-actions { align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
#quick-add-full { color: var(--accent); padding-inline: 8px; }
.compact { font-size: 13px; margin-bottom: 18px; }

/* Grouped Settings Dialog */
.settings-section { padding: 14px 16px; margin-bottom: 14px; border-radius: 14px; background: var(--paper); border: 1px solid var(--subtle-line); }
.settings-section-title { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 10px; letter-spacing: .02em; }
.settings-stack { display: flex; flex-direction: column; gap: 8px; }
.settings-stack .secondary, .settings-stack .primary { min-height: 40px; font-size: 13px; }
.backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.backup-grid .secondary { min-height: 40px; padding: 8px 12px; font-size: 13px; }
.settings-section .helper { margin-top: 10px; font-size: 11.5px; }
.settings-footer { margin-top: 6px; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--subtle-line); padding: 10px 0; }
.device-row:first-child { padding-top: 2px; }
.device-row:last-child { border-bottom: 0; padding-bottom: 4px; }
.device-row > div { min-width: 0; }
.device-row strong { display: block; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.device-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.device-row .current { flex-shrink: 0; color: var(--accent); font-size: 11px; font-weight: 500; }
#pair-button { margin-top: 10px; min-height: 40px; font-size: 13px; }
#pair-result { margin-top: 14px; }
#pair-code, #inbox-token-value { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
#inbox-token-result { margin-top: 12px; }
#inbox-token-revoke { color: var(--danger); }
#passkey-remove-button { color: var(--danger); }
#logout-button { color: var(--danger); }
#password-help { margin: 0 0 18px; }
#password-status:empty { display: none; }

/* Autofill & Browser Helper */
.duplicate-hint { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -8px 0 14px; padding: 9px 12px; border-radius: 11px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); font-size: 12px; line-height: 1.5; }
.duplicate-hint-text { min-width: 0; overflow-wrap: anywhere; }
.duplicate-hint-action { flex-shrink: 0; min-height: 28px; padding: 4px 10px; border-radius: 8px; background: var(--surface); color: var(--accent); font-size: 11.5px; font-weight: 600; border: 1px solid var(--warn-line); white-space: nowrap; }
.duplicate-hint-action:hover { background: var(--hover); }
.identify-row { display: flex; align-items: center; gap: 12px; margin: -6px 0 18px; }
.identify-row .helper { flex: 1; min-width: 0; margin: 0; }
.identify-row .secondary { flex-shrink: 0; min-height: 36px; padding: 6px 14px; font-size: 12.5px; }
#identify-status[data-status="busy"] { color: var(--blue); }
#identify-status[data-status="error"] { color: var(--danger); }
.browser-identify { margin: 10px 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.browser-identify p { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.browser-identify a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.browser-identify .secondary { width: 100%; min-height: 38px; font-size: 13px; }
.helper-install { max-width: 640px; margin: 64px auto; padding: 0 24px; }
.helper-install h1 { font-size: 30px; }
.helper-install p, .helper-install li { color: var(--muted); line-height: 1.85; }
.helper-install ol { padding-left: 22px; margin-block: 24px; }
.helper-install li { margin-bottom: 10px; }

/* Vault & Shared Google Accounts Dialog */
#vault-dialog { width: min(540px, calc(100vw - 32px)); }
.vault-site { margin: -8px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.vault-qr { display: block; margin: 16px auto; max-width: 100%; height: auto; padding: 8px; border-radius: 14px; background: #fff; }
#vault-secret, #vault-recovery-codes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; letter-spacing: .02em; }
#vault-recovery-codes { width: 100%; resize: none; line-height: 1.8; }
.vault-field { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.vault-field input { min-width: 0; flex: 1; margin-top: 0; }
.vault-field .secondary { flex-shrink: 0; min-height: 44px; padding: 0 13px; font-size: 12.5px; }
.vault-actions { flex-wrap: wrap; }
.vault-actions .danger-button { color: var(--danger); margin-right: auto; }
#vault-status:empty { display: none; }
#vault-credential-form > label { margin: 16px 0 0; }
.vault-methods { display: flex; gap: 4px; padding: 4px; margin: 14px 0 18px; border-radius: 12px; background: var(--soft); }
.vault-methods button { flex: 1; min-height: 40px; padding: 8px; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.vault-methods button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px #00000014; }
#vault-enroll-shortcut, #vault-shared-shortcut { margin-top: 8px; color: var(--accent); }
#vault-auth-form > .helper { margin: 0 0 14px; }
#vault-shared-panel > .helper { margin: 0 0 16px; }
#shared-account-select { display: block; width: 100%; min-width: 0; margin-top: 7px; padding: 11px 12px; border: 1px solid var(--field-line); border-radius: 11px; color: var(--ink); background: var(--surface); font-size: 15px; }
#shared-account-select:focus-visible { outline: 3px solid #0071e326; border-color: var(--blue); }
#shared-account-form > label[for="shared-password"] { margin-bottom: 0; }
.shared-sites { min-width: 0; margin: 18px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.shared-sites legend { padding: 0 6px; font-size: 12.5px; font-weight: 500; }
.shared-select-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.shared-select-tools > span { margin-right: auto; }
.shared-select-tools .text-button { min-height: 30px; padding: 4px 8px; font-size: 11.5px; }
.shared-bookmarks { max-height: 230px; overflow-y: auto; overscroll-behavior: contain; }
.shared-bookmark { display: flex; align-items: center; gap: 11px; margin: 0; padding: 10px 6px; border-top: 1px solid var(--subtle-line); cursor: pointer; font-weight: 400; }
.shared-bookmark input { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--blue); }
.shared-bookmark-text { min-width: 0; overflow-wrap: anywhere; }
.shared-bookmark-text > span { display: block; font-size: 13px; }
.shared-bookmark small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.shared-bookmark:has(input:disabled) { opacity: .5; cursor: default; }
#vault-countdown { color: var(--vault-open-ink); margin: 0 0 14px; font-weight: 500; }
#vault-linked-note:empty { display: none; }
#vault-manage-shared, #vault-use-shared { color: var(--accent); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; width: max-content; max-width: calc(100% - 32px); background: var(--toast-bg); color: var(--toast-ink); border-radius: 12px; padding: 11px 18px; box-shadow: 0 8px 28px #00000024; font-size: 13px; line-height: 1.5; animation: toast-in .18s var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }

/* Tablet Breakpoint */
@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip-label-full { display: none; }
  .chip-label-short { display: inline; }
  .add-label-full { display: none; }
  .add-label-short { display: inline; }
}

/* Mobile Breakpoint */
@media (max-width: 640px) {
  .header-inner { grid-template-columns: auto minmax(0, 1fr); padding: 8px 14px 10px; gap: 8px 10px; min-height: 0; }
  .brand { font-size: 14px; gap: 7px; padding: 2px 0; min-height: 36px; }
  .brand-mark { width: 25px; height: 25px; }
  .header-actions { gap: 6px; }
  .header-chip { min-height: 34px; padding: 0 9px; font-size: 11.5px; gap: 4px; }
  .header-chip svg { width: 13px; height: 13px; }
  .icon-button { width: 34px; height: 34px; }
  .icon-button svg { width: 16px; height: 16px; }
  .primary.add-button { min-height: 34px; padding: 0 11px; font-size: 12px; }
  .search-area { grid-column: 1 / -1; max-width: none; order: 3; }
  .search { height: 38px; padding: 0 6px 0 10px; border-radius: 11px; }
  .search input { font-size: 16px; }
  .search input::placeholder { font-size: 12.5px; }
  .search kbd { display: none; }
  #ai-search-button { min-height: 28px; padding: 0 9px; font-size: 11.5px; }
  .vault-pill { grid-column: 1 / -1; order: 4; justify-content: space-between; width: 100%; min-height: 32px; border-radius: 10px; font-size: 11.5px; }

  .workspace-inner { padding: 10px 14px 20px; }
  .category-bar { margin-bottom: 12px; }
  nav#categories button { min-height: 34px; padding: 6px 11px; font-size: 12px; gap: 5px; }
  .collection { margin-bottom: 18px; }
  .collection-heading { padding-bottom: 9px; }
  .collection-heading h2 { font-size: 12px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 11px 11px 9px; border-radius: 14px; }
  .card-link::after { border-radius: 14px; }
  .card-top { gap: 8px; }
  .site-icon { width: 34px; height: 34px; border-radius: 9px; }
  .skel-icon { width: 34px; height: 34px; border-radius: 9px; }
  .skel-reason { height: 28px; margin: 9px 0; }
  .site-icon-image { padding: 4px; border-radius: 8px; }
  .site-icon-fallback svg { width: 18px; height: 18px; }
  .card-title-row { align-items: flex-start; }
  .card-link h3 { font-size: 13px; line-height: 1.3; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .pin-mark { margin-top: 2px; }
  .card-open-hint { display: none; }
  .site-url { font-size: 10.5px; margin-top: 2px; }
  .search-status-bar { align-items: flex-start; padding: 9px 11px; gap: 8px; }
  .search-status-main { flex-direction: column; gap: 5px; }
  .search-status-bar.is-ai-summary .search-status { font-size: 12.5px; line-height: 1.55; }
  .ai-reason { margin: 7px 0 8px; padding: 6px 8px; border-radius: 8px; font-size: 11px; line-height: 1.45; gap: 4px; }
  .site-note { font-size: 11px; line-height: 1.45; margin: 7px 0 9px; -webkit-line-clamp: 2; }
  .card-bottom { padding-top: 8px; gap: 4px; }
  .credential-button { min-height: 28px; padding: 3px 7px; font-size: 10.5px; gap: 4px; }
  .credential-button svg { width: 11.5px; height: 11.5px; }
  .inbox-bar { flex-direction: column; align-items: stretch; padding: 11px 12px; gap: 10px; }
  #batch-identify-button { width: 100%; }
  .inbox-promote-button { min-height: 28px; padding: 3px 8px; font-size: 10.5px; gap: 4px; }
  .inbox-promote-button svg { width: 11.5px; height: 11.5px; }
  .edit-dialog-actions { gap: 8px; }
  .edit-dialog-actions [data-close] { margin-right: 0; }
  .edit-dialog-actions > button { flex: 1 1 auto; padding-inline: 12px; font-size: 13px; }
  .quick-add-actions { flex-direction: column-reverse; align-items: stretch; }
  .quick-add-actions > button { width: 100%; }
  .site-category-pill { display: none; }
  .card-more-button { width: 28px; height: 28px; font-size: 15px; }
  .card-menu { right: 8px; bottom: 40px; min-width: 132px; }
  .card-menu button { min-height: 36px; font-size: 12px; }

  footer { flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 14px max(18px, env(safe-area-inset-bottom)); font-size: 10.5px; }
  dialog { padding: 22px 18px; border-radius: 20px; }
  .dialog-heading h2 { font-size: 20px; }
  .backup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .brand-name { display: none; }
  .header-inner { padding-inline: 10px; }
  .workspace-inner { padding-inline: 10px; }
  .cards { gap: 8px; }
  .card { padding: 10px 9px 8px; }
}
@media (max-width: 400px) {
  .vault-actions > button { flex: 1 1 auto; }
  .vault-field { flex-wrap: wrap; }
  .vault-field input { flex-basis: 100%; }
  .identify-row { align-items: flex-start; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
