/* =====================================================================
   Attic - styles
   Search is the hero: calm, fast, minimal. Mobile first, then desktop.
   Colors live in CSS variables so the two themes stay in sync.
   ===================================================================== */

/* ------------------------------ Tokens ------------------------------ */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-code: ui-monospace, "SF Mono", Consolas, monospace;
  --transition: 180ms ease;
  --tap: 44px;
  --content-max: 880px;
  color-scheme: dark;
}

/* Dark theme (default) */
:root,
[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-2: #243449;
  --border: #334155;
  --text: #E2E8F0;
  --muted: #94A3B8;
  --primary: #14B8A6;
  --primary-hover: #2DD4BF;
  --on-primary: #04201D;
  --note: #60A5FA;
  --link: #A78BFA;
  --snippet: #FBBF24;
  --danger: #EF4444;
  --success: #22C55E;
  --shadow: 0 10px 30px rgba(2, 6, 23, .45);
  color-scheme: dark;
}

/* Light theme */
[data-theme="light"] {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #475569;
  --primary: #0D9488;
  --primary-hover: #0F766E;
  --on-primary: #FFFFFF;
  --note: #2563EB;
  --link: #7C3AED;
  --snippet: #B45309;
  --danger: #DC2626;
  --success: #16A34A;
  --shadow: 0 10px 30px rgba(15, 23, 42, .12);
  color-scheme: light;
}

/* ------------------------------ Base ------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

button, input, select, textarea { font: inherit; color: inherit; }

.icon { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo { display: block; color: var(--primary); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* The hidden attribute must always win, even over display:flex rules. */
[hidden] { display: none !important; }

/* ------------------------------ Buttons ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.btn:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--text) 12%); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-active { color: var(--primary); }

/* ------------------------------ Forms ------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .9rem; font-weight: 600; color: var(--text); }
.field-hint { font-size: .8rem; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}

.select-wrap { display: inline-block; }
.select-wrap select { min-width: 140px; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .92rem;
}
.alert-error {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--text);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .85rem;
  color: var(--muted);
}

/* ------------------------------ Auth pages ------------------------- */
.auth-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo { display: inline-flex; margin-bottom: 8px; }
.auth-logo .logo { color: var(--primary); }
.auth-title { font-size: 1.9rem; letter-spacing: -.02em; }
.auth-tagline { color: var(--primary); font-weight: 600; letter-spacing: .01em; }
.auth-intro { color: var(--muted); font-size: .92rem; margin-bottom: 16px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.auth-form .btn { margin-top: 4px; }
.auth-note {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 18px; color: var(--muted); font-size: .82rem;
}
.form-error, .alert + .auth-form { margin-top: 12px; }

/* ------------------------------ App shell -------------------------- */
.app-page { height: 100vh; height: 100dvh; overflow: hidden; }

.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-head { padding: 4px 8px 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark { display: inline-flex; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.brand-tag { color: var(--muted); font-size: .8rem; padding-left: 38px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.side-link .icon { color: inherit; }
.as-button { width: 100%; border: none; background: transparent; cursor: pointer; text-align: left; }

.side-section { margin-top: 14px; padding: 0 12px; }
.side-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}
.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-muted { color: var(--muted); font-size: .85rem; padding: 6px 0; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; color: var(--muted); font-size: .85rem;
}

.nav-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(2, 6, 23, .55);
}

.main { display: flex; flex-direction: column; min-width: 0; height: 100%; min-height: 0; }

/* ------------------------------ Top bar ---------------------------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-height: 60px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.topbar-brand {
  display: none; /* shown on mobile */
  align-items: center; gap: 8px;
  color: var(--text); font-weight: 700; letter-spacing: -.02em;
}

.search {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  max-width: 640px;
}
.search-icon {
  position: absolute; left: 12px; display: flex; color: var(--muted); pointer-events: none;
}
.search input {
  padding-left: 40px;
  background: var(--surface);
  border-radius: 999px;
}
.topbar-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.new-item-btn { margin-right: 4px; padding: 8px 14px; min-height: 40px; }
.new-item-btn .icon { color: inherit; }

.theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline-flex; }

/* ------------------------------ Content ---------------------------- */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 24px 16px 96px;
}
.content > * { max-width: var(--content-max); margin-inline: auto; }

.page-head { margin-bottom: 18px; }
.page-title { font-size: 1.6rem; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: .92rem; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  min-height: 55vh;
  padding: 24px;
}
.empty-logo { display: inline-flex; margin-bottom: 4px; }
.empty-logo .logo { width: 64px; height: 64px; opacity: .9; }
.empty-title { font-size: 1.35rem; letter-spacing: -.01em; }
.empty-text { color: var(--muted); max-width: 420px; }
.empty-state .btn { margin-top: 8px; }

/* Cards (used from Step 1 for settings) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.02rem; margin-bottom: 12px;
}
.settings-card .card-title .icon { color: var(--primary); }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.setting-row:first-of-type { border-top: none; }
.setting-info { display: flex; flex-direction: column; gap: 2px; }
.setting-name { font-weight: 600; }
.setting-help { color: var(--muted); font-size: .85rem; }
.settings-foot { text-align: center; color: var(--muted); font-size: .82rem; padding-top: 8px; }

/* ------------------------------ Mobile nav / FAB ------------------- */
.mobile-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: none;
  justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.mobile-link {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 64px; min-height: var(--tap);
  padding: 6px 8px;
  border: none; background: transparent;
  color: var(--muted); font-size: .72rem; font-weight: 600;
  border-radius: var(--radius-sm); cursor: pointer;
}
.mobile-link.is-active { color: var(--primary); }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: none;
  align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border: none; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.fab:hover { background: var(--primary-hover); }
.fab:active { transform: scale(.96); }

/* ------------------------------ Responsive ------------------------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }

  .menu-btn { display: inline-flex; }
  .topbar-brand { display: inline-flex; margin-right: auto; }
  .topbar { flex-wrap: wrap; }
  .topbar .search { order: 3; flex-basis: 100%; }

  .mobile-nav { display: flex; }
  .fab { display: inline-flex; }
  .new-item-btn { display: none; }

  .content { padding-bottom: 150px; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ------------------------------ Item list --------------------------- */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.result-count { color: var(--muted); font-size: .85rem; }
.sort-wrap select { min-height: 40px; padding: 6px 12px; }

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item-card-li { display: block; }

.item-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.item-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.item-card:active { transform: translateY(1px); }
.item-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.item-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.item-date { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.item-title { font-size: 1.02rem; font-weight: 600; margin-bottom: 4px; word-break: break-word; }
.item-preview {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.item-domain { color: var(--muted); font-size: .8rem; }

/* Type badges: always icon + text, never color alone */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-note { color: var(--note); background: color-mix(in srgb, var(--note) 13%, transparent); border-color: color-mix(in srgb, var(--note) 38%, transparent); }
.badge-link { color: var(--link); background: color-mix(in srgb, var(--link) 13%, transparent); border-color: color-mix(in srgb, var(--link) 38%, transparent); }
.badge-snippet { color: var(--snippet); background: color-mix(in srgb, var(--snippet) 13%, transparent); border-color: color-mix(in srgb, var(--snippet) 38%, transparent); }
.badge-pinned { color: var(--primary); background: color-mix(in srgb, var(--primary) 13%, transparent); border-color: color-mix(in srgb, var(--primary) 38%, transparent); }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .78rem;
}
button.tag-chip {
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
button.tag-chip:hover { color: var(--primary); border-color: var(--primary); }
.tag-chip.is-active { color: var(--primary); border-color: var(--primary); }
.tag-count { color: var(--muted); font-size: .72rem; margin-left: 4px; }
.tag-chip.is-active .tag-count { color: var(--primary); }
#tagList .tag-chip { width: 100%; justify-content: space-between; }

/* ------------------------------ Modal / dialogs --------------------- */
dialog.modal {
  border: none;
  padding: 0;
  background: transparent;
  width: 100%;
  max-width: min(640px, calc(100vw - 24px));
}
dialog.modal::backdrop { background: rgba(2, 6, 23, .55); }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.type-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.type-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
  transition: background var(--transition), color var(--transition);
}
.type-tab:hover { color: var(--text); }
.type-tab.is-active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }

.capture-fields { display: flex; flex-direction: column; gap: 14px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-optional { color: var(--muted); font-weight: 400; font-size: .8rem; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.link-btn:hover { color: var(--primary); background: var(--surface-2); }

textarea { resize: vertical; min-height: 120px; font-family: inherit; line-height: 1.5; }
div.markdown-body textarea { font-family: inherit; }

.secret-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .78rem;
}
.secret-hint .icon { color: var(--danger); }

.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-suggest .suggest-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .82rem;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.tag-suggest .suggest-chip:hover { border-color: var(--primary); color: var(--primary); }

.modal-actions { display: flex; align-items: center; gap: 10px; }
.modal-actions .spacer { flex: 1; }
.btn-danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* ------------------------------ Markdown ---------------------------- */
.markdown-body {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-wrap: anywhere;
  line-height: 1.6;
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 18px 0 10px;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.markdown-body h1 { font-size: 1.45rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.1rem; }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px; padding-left: 1.5em; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body a { color: var(--primary); text-decoration: underline; }
.markdown-body blockquote {
  border-left: 3px solid var(--primary);
  margin: 0 0 12px;
  padding: 2px 0 2px 14px;
  color: var(--muted);
}
.markdown-body code { font-family: var(--font-code); font-size: .9em; }
.markdown-body :not(pre) > code {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 2px 6px;
  border-radius: 4px;
}
.markdown-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin-bottom: 12px;
}
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }
.markdown-body table { border-collapse: collapse; margin-bottom: 12px; display: block; overflow-x: auto; max-width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.markdown-body th { background: var(--surface-2); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.markdown-body mark { background: color-mix(in srgb, var(--snippet) 40%, transparent); color: inherit; }

/* ------------------------------ Item detail ------------------------- */
.item-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-detail-actions { display: flex; align-items: center; gap: 8px; }
.item-detail-title { font-size: 1.35rem; margin: 12px 0 6px; word-break: break-word; letter-spacing: -.01em; }
.item-detail-meta { color: var(--muted); font-size: .82rem; }
.item-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.item-detail-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--link);
  font-size: .9rem;
  word-break: break-all;
  margin: 4px 0;
}
.item-detail .markdown-body { background: transparent; border: 1px solid var(--border); }

/* ------------------------------ Toast ------------------------------ */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  z-index: 80;
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .type-tab span { display: none; }
  .modal-card { padding: 14px; }
  .item-card { padding: 14px; }
}

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

/* ------------------------------ Search UI -------------------------- */
.item-card mark {
  background: color-mix(in srgb, var(--snippet) 40%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* --------------------------- Snippet blocks ------------------------ */
.snippet-block {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}
.snippet-lang {
  align-self: flex-start;
  padding: 4px 10px;
  font-family: var(--font-code);
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) 0 0;
}
.snippet-block .snippet-code {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow-x: auto;
  padding: 12px 14px;
}
.snippet-block .snippet-code code {
  background: transparent;
  padding: 0;
}

/* ------------------------------ Trash / flags ----------------------- */
.badge-trash { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); border-color: color-mix(in srgb, var(--danger) 38%, transparent); }

.item-card-trash { cursor: default; }
.item-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.item-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* ------------------------------ Related items ----------------------- */
.related { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 14px; }
.related-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.related-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.related-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}
.related-item:hover { border-color: var(--primary); }
.related-item-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* ------------------------------ Toast actions ----------------------- */
.toast.has-action { display: flex; align-items: center; gap: 12px; }
.toast-action {
  flex: none;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.toast-action:hover { background: var(--primary); color: var(--on-primary); }

/* ------------------------------ Backup / import ---------------------- */
.import-form { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.file-btn { flex: none; cursor: pointer; }
.settings-card .import-form .btn { flex: none; }
.setting-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.password-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 16px 2px 4px;
}
.password-box[hidden] { display: none; }

/* ------------------------------ Shortcuts guide ---------------------- */
.modal-sm { max-width: min(440px, calc(100vw - 24px)); }
.modal-title { font-size: 1.15rem; letter-spacing: -.01em; }
.shortcuts-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}
.shortcuts-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
}
.shortcuts-list li:last-child { border-bottom: none; }
.shortcut-name { color: var(--muted); font-size: .92rem; }
.shortcut-keys { display: inline-flex; align-items: center; gap: 6px; }
.kbd-plus { color: var(--muted); font-size: .85rem; }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-family: var(--font-code);
  font-size: .82rem;
  color: var(--text);
  line-height: 1;
}
