/* POC Library: light + dark, mobile first */
:root {
  --bg: #f5f6fb;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #ffffff;
  --surface-2: #eef0f7;
  --text: #121521;
  --muted: #5d6479;
  --border: rgba(18, 21, 33, .09);
  --accent: #6d5dfc;
  --accent-2: #22d3ee;
  --accent-text: #ffffff;
  --accent-soft: rgba(109, 93, 252, .12);
  --danger-bg: rgba(220, 38, 38, .1);
  --danger: #b42318;
  --mark: rgba(250, 204, 21, .45);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -8px rgba(16, 24, 40, .12);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .06), 0 18px 40px -12px rgba(109, 93, 252, .35);
  --orb-opacity: .35;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14;
    --surface: rgba(22, 25, 36, .72);
    --surface-solid: #161924;
    --surface-2: #1d2130;
    --text: #eceef5;
    --muted: #9aa1b5;
    --border: rgba(255, 255, 255, .08);
    --accent: #8b7dff;
    --accent-text: #0b0d14;
    --accent-soft: rgba(139, 125, 255, .16);
    --danger-bg: rgba(248, 113, 113, .12);
    --danger: #fca5a5;
    --mark: rgba(250, 204, 21, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 18px 40px -12px rgba(139, 125, 255, .35);
    --orb-opacity: .22;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d14;
  --surface: rgba(22, 25, 36, .72);
  --surface-solid: #161924;
  --surface-2: #1d2130;
  --text: #eceef5;
  --muted: #9aa1b5;
  --border: rgba(255, 255, 255, .08);
  --accent: #8b7dff;
  --accent-text: #0b0d14;
  --accent-soft: rgba(139, 125, 255, .16);
  --danger-bg: rgba(248, 113, 113, .12);
  --danger: #fca5a5;
  --mark: rgba(250, 204, 21, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-hover: 0 18px 40px -12px rgba(139, 125, 255, .35);
  --orb-opacity: .22;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
svg { fill: currentColor; flex-shrink: 0; }
button { font: inherit; color: inherit; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Soft animated background */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orbs span {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: var(--orb-opacity);
  animation: drift 22s ease-in-out infinite alternate;
}
.bg-orbs span:nth-child(1) { width: 420px; height: 420px; background: var(--accent); top: -140px; left: -120px; }
.bg-orbs span:nth-child(2) { width: 360px; height: 360px; background: var(--accent-2); top: 30%; right: -140px; animation-delay: -7s; }
.bg-orbs span:nth-child(3) { width: 300px; height: 300px; background: #f472b6; bottom: -120px; left: 25%; animation-delay: -14s; opacity: calc(var(--orb-opacity) * .6); }
@keyframes drift { to { transform: translate(40px, 30px) scale(1.1); } }

/* Buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 10px 24px -10px var(--accent);
}
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0) scale(.99); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .spinner {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.sm { width: 40px; height: 40px; border-radius: 10px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ============ Login ============ */
.login-body {
  display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.login-card {
  width: 100%; max-width: 400px; padding: 36px 28px 30px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: var(--shadow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
.login-card.shake { animation: shake .45s; }
.login-card h1 { margin: 18px 0 4px; font-size: 24px; letter-spacing: -.02em; }
.lock {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 14px 30px -12px var(--accent);
}
.muted { color: var(--muted); margin: 0 0 22px; }
.form { display: grid; gap: 14px; text-align: left; }
.pw-wrap { position: relative; }
.pw-wrap input {
  width: 100%; height: 54px; padding: 0 56px 0 18px;
  font: inherit; font-size: 17px; letter-spacing: .02em; color: var(--text);
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 14px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.pw-wrap input:focus { outline: none; border-color: var(--accent); background: var(--surface-solid); box-shadow: 0 0 0 4px var(--accent-soft); }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: none; color: var(--muted); border-radius: 10px; cursor: pointer;
  display: grid; place-items: center;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle .eye-off, .pw-toggle.on .eye-open { display: none; }
.pw-toggle.on .eye-off { display: block; }
.caps { margin: -4px 0 0; font-size: 13px; color: #d97706; }
.alert {
  background: var(--danger-bg); color: var(--danger); border-radius: 12px;
  padding: 11px 14px; font-size: 14px; margin: 0 0 16px; text-align: left;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ============ App ============ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: inherit; text-decoration: none; }
.brand img { border-radius: 8px; }
.top-actions { display: flex; gap: 8px; }
.top-actions form { margin: 0; }
#themeBtn .i-moon { display: none; }
:root[data-theme="dark"] #themeBtn .i-sun { display: none; }
:root[data-theme="dark"] #themeBtn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeBtn .i-sun { display: none; }
  :root:not([data-theme="light"]) #themeBtn .i-moon { display: block; }
}

.container {
  max-width: 1120px; margin: 0 auto;
  padding: 24px 16px calc(48px + env(safe-area-inset-bottom));
}

.hero { margin: 8px 0 20px; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.hero h1 {
  margin: 0; font-size: clamp(28px, 6vw, 42px); line-height: 1.1; letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stats { display: flex; gap: 10px; margin-top: 18px; }
.stat {
  display: flex; flex-direction: column; min-width: 110px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.stat strong { font-size: 20px; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }

/* Toolbar */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.search { position: relative; display: flex; align-items: center; }
.search > svg { position: absolute; left: 16px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 52px; padding: 0 48px 0 46px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming in */
  color: var(--text); background: var(--surface-solid);
  border: 1.5px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.kbd {
  position: absolute; right: 14px; font: 12px/1 ui-monospace, monospace; color: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 4px 7px; pointer-events: none;
}
.search input:focus ~ .kbd, .search input:not(:placeholder-shown) ~ .kbd { display: none; }
.clear-btn {
  position: absolute; right: 6px; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
[hidden] { display: none !important; }
.clear-btn:hover { color: var(--text); background: var(--surface-2); }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chips {
  min-width: 0; display: flex; gap: 4px; padding: 4px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex-shrink: 0; min-height: 36px; padding: 0 14px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.chips button:hover { color: var(--text); }
.chips button[aria-pressed="true"]::after { content: "↓"; margin-left: 5px; font-size: 13px; color: var(--accent); }
.chips button[aria-pressed="true"][data-dir="rev"]::after { content: "↑"; }
.chips button[aria-pressed="true"] { background: var(--surface-solid); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.view-toggle { display: flex; gap: 6px; flex-shrink: 0; }

.meta-row { display: flex; justify-content: space-between; gap: 12px; }
.sort-label { margin-left: auto; white-space: nowrap; }
.meta { color: var(--muted); font-size: 14px; margin: 8px 0 14px; min-height: 21px; }

/* Cards */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.grid > li { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px; height: 100%;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s, border-color .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.card:active { transform: translateY(-1px) scale(.995); }
.card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #fff; text-transform: uppercase;
  background: linear-gradient(135deg, hsl(var(--h) 80% 62%), hsl(calc(var(--h) + 40) 80% 52%));
  box-shadow: 0 8px 18px -10px hsl(var(--h) 80% 50%);
}
.card-title { min-width: 0; flex: 1; }
.card h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card h2 a { color: inherit; text-decoration: none; }
/* Whole card is clickable */
.card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card h2 a:focus-visible { outline: none; }
.card:has(h2 a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .path { font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.card .desc {
  margin: 0; color: var(--muted); font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .desc.none { font-style: italic; opacity: .7; }
.card-foot { margin-top: auto; display: flex; flex-wrap: wrap; row-gap: 6px; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.pill { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); }
.card-actions { margin-left: auto; display: flex; gap: 4px; position: relative; z-index: 1; }
.card-actions button, .card-actions a {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
  color: var(--muted); background: none; border: 0; cursor: pointer;
}
.card-actions button:hover, .card-actions a:hover { color: var(--accent); background: var(--accent-soft); }
.arrow { transition: transform .2s; }
.card:hover .arrow { transform: translateX(3px); color: var(--accent); }

/* List view */
.grid.list { grid-template-columns: 1fr; gap: 8px; }
.grid.list .card { flex-direction: row; align-items: center; padding: 12px 14px; gap: 14px; }
.grid.list .card-head { flex: 0 1 260px; }
.grid.list .desc { flex: 1; -webkit-line-clamp: 1; }
.grid.list .card-foot { margin-top: 0; flex-shrink: 0; }

/* Skeletons + empty state */
.skeleton .card { pointer-events: none; }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 50%, var(--surface-solid)) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  padding: 48px 16px; border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.empty svg { color: var(--accent); opacity: .7; margin-bottom: 8px; }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  background: var(--text); color: var(--bg); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (hover: none) { .kbd { display: none; } }

/* Phones */
@media (max-width: 640px) {
  .container { padding-top: 16px; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 16px; }
  .card:hover { transform: none; }
  .grid.list .card { flex-wrap: wrap; }
  .grid.list .card-head { flex: 1 1 auto; }
  .grid.list .desc { display: none; }
  .stat { flex: 1; min-width: 0; padding: 10px 12px; }
  .stat strong { font-size: 17px; }
  .stat strong, .stat span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chips { flex: 1; }
  .chips button { flex: 1; padding: 0 8px; }
  .login-card { padding: 30px 20px 24px; border-radius: 22px; }
}


/* ============ Categories & tags ============ */
.filters { display: grid; gap: 10px; margin-top: 12px; }
.cat-row {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin: 0 -16px; padding: 2px 16px;
}
.cat-row::-webkit-scrollbar { display: none; }
.cat-chip {
  --h: 250;
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font-size: 14px; font-weight: 500; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background .15s, border-color .15s, color .15s;
}
.cat-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) 75% 58%); }
.cat-chip:first-child::before { display: none; }
.cat-chip .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-chip:hover { border-color: hsl(var(--h) 75% 58%); }
.cat-chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.cat-chip[aria-pressed="true"] .count { color: inherit; opacity: .7; }

.active-tag { display: flex; align-items: center; gap: 8px; }
.muted-sm { font-size: 13px; color: var(--muted); }

.card-sub { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 2px; }
.card-sub .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  --h: 250;
  position: relative; z-index: 1; flex-shrink: 0;
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; border: 0; cursor: pointer;
  font-size: 12px; font-weight: 600;
  color: hsl(var(--h) 70% 38%); background: hsl(var(--h) 85% 60% / .14);
}
:root[data-theme="dark"] .badge { color: hsl(var(--h) 85% 76%); background: hsl(var(--h) 80% 60% / .18); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge { color: hsl(var(--h) 85% 76%); background: hsl(var(--h) 80% 60% / .18); } }

.tags { display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 1; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tag:hover { color: var(--accent); border-color: var(--accent); }
.tag.on { color: var(--accent); background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.tag .x { border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; padding: 0 0 0 4px; cursor: pointer; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ghost:hover { filter: brightness(.97); }
.btn.sm { min-height: 38px; font-size: 14px; margin-top: 14px; }
.empty .btn { display: inline-flex; }
.empty span { display: block; }

.db-note {
  margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: rgba(217, 119, 6, .12); color: #b45309; border: 1px solid rgba(217, 119, 6, .25);
}
:root[data-theme="dark"] .db-note { color: #fbbf24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .db-note { color: #fbbf24; } }

/* ============ Edit sheet ============ */
.sheet {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: 22px;
  background: var(--surface-solid); color: var(--text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
  overflow: auto;
}
.sheet[open] { animation: rise .25s cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: rgba(8, 10, 18, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet form { display: grid; gap: 14px; padding: 18px 20px 20px; }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; word-break: break-word; }
.sheet-sub { margin: 2px 0 0; font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.fld { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fld em { font-style: normal; font-weight: 400; opacity: .8; }
.fld input, .fld textarea, .tag-input {
  width: 100%; font: inherit; font-size: 16px; font-weight: 400; color: var(--text);
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px; padding: 11px 14px;
}
.fld textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.fld input:focus, .fld textarea:focus, .tag-input:focus-within {
  outline: none; border-color: var(--accent); background: var(--surface-solid); box-shadow: 0 0 0 4px var(--accent-soft);
}
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; min-height: 50px; cursor: text; }
.tag-input input { flex: 1; min-width: 120px; border: 0; background: none; padding: 4px; font-size: 16px; color: var(--text); box-shadow: none; }
.tag-input input:focus { outline: none; box-shadow: none; background: none; }
.tag-suggest, .cat-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-picks { margin-top: -6px; }
.cat-picks .cat-chip { min-height: 32px; font-size: 13px; padding: 0 12px; }
.cat-picks .cat-chip:first-child::before { display: block; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.sheet-actions .btn { min-width: 110px; }

.pw-meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: -4px; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: 3px; background: #dc2626; transition: width .2s, background .2s; }
.pw-meter span[data-level="2"] { background: #d97706; }
.pw-meter span[data-level="3"] { background: #65a30d; }
.pw-meter span[data-level="4"] { background: #16a34a; }
.manual-line { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 12px; white-space: pre-wrap; word-break: break-all; user-select: all; }

@media (max-width: 640px) {
  /* Bottom sheet on phones */
  .sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet[open] { animation: slideup .28s cubic-bezier(.2, .8, .2, 1); }
  .sheet-grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: -6px auto 0; }
  .sheet-actions .btn { flex: 1; }
}
@keyframes slideup { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
