/* =====================================================================
   Notepadle — shared styles (app + static pages)
   ===================================================================== */
:root {
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --secondary: #8B5CF6;
  --primary-soft: rgba(99, 102, 241, .08);
  --active-bg: #F3E8FF;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --muted-bg: #F4F4F5;
  --text: #0F172A;
  --text-2: #64748B;
  --border: #E2E8F0;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .05), 0 4px 6px -2px rgba(0, 0, 0, .025);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .2);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --topbar-h: 70px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0F172A;
  --card: #1E293B;
  --muted-bg: rgba(255, 255, 255, .06);
  --text: #F8FAFC;
  --text-2: #94A3B8;
  --border: #334155;
  --active-bg: rgba(139, 92, 246, .16);
  --primary-soft: rgba(99, 102, 241, .14);
  --shadow: 0 4px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.i { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 1000; }
.skip-link:focus { left: 8px; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background-color .2s, border-color .2s, color .2s, transform .2s var(--ease), box-shadow .2s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 2px 4px rgba(99, 102, 241, .2); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 14px rgba(99, 102, 241, .3); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; }
.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: var(--error); color: var(--error); background: rgba(239, 68, 68, .06); }
.btn-block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); padding: 0;
  transition: color .2s, border-color .2s, background-color .2s, transform .2s var(--ease);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.is-on { color: var(--warning); border-color: var(--warning); }

/* Theme toggle icon swap */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.theme-toggle .i { transition: transform .4s var(--ease); }
.theme-toggle:hover .i { transform: rotate(-20deg); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: grid; grid-template-columns: 260px 1fr auto; align-items: center; gap: 20px;
  padding: 0 28px; background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-center { display: flex; align-items: center; justify-content: center; gap: 14px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 21px; letter-spacing: -.03em; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 28px; height: 28px; color: var(--secondary); transition: transform .3s var(--ease); }
.logo:hover .logo-mark { transform: rotate(-8deg) scale(1.05); }
.menu-btn { display: none; }
.top-link { color: var(--text-2); font-weight: 600; font-size: 14px; padding: 8px 10px; border-radius: 8px; transition: color .2s, background-color .2s; }
.top-link:hover, .top-link[aria-current="page"] { color: var(--text); background: var(--primary-soft); text-decoration: none; }

.search {
  width: 100%; max-width: 560px; height: 40px; display: flex; align-items: center; gap: 10px;
  padding: 0 14px 0 18px; border-radius: 100px; background: var(--muted-bg); border: 1px solid transparent; color: var(--text-2);
  transition: background-color .2s, border-color .2s, box-shadow .2s;
}
.search:focus-within { background: var(--card); border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14.5px; font-weight: 500; }
.search input::-webkit-search-cancel-button { display: none; }
.kbd { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--card); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }

/* ---------- App layout ---------- */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: 260px; flex: none; background: var(--card); border-right: 1px solid var(--border);
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 24px 16px; display: flex; flex-direction: column;
}
.nav { list-style: none; margin: 0; padding: 0; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; margin-bottom: 4px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text-2); font-size: 14.5px; font-weight: 600;
  transition: background-color .2s, color .2s, transform .2s var(--ease);
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item:active { transform: scale(.98); }
.nav-item[aria-current="true"] { background: var(--active-bg); color: var(--secondary); }
.nav-item::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--secondary); transform: scaleY(0); transition: transform .25s var(--ease);
}
.nav-item[aria-current="true"]::before { transform: scaleY(1); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  font-size: 12px; font-weight: 700; padding: 1px 10px; border-radius: 20px; min-width: 30px; text-align: center;
  background: var(--card); border: 1px solid var(--border); color: var(--text-2); transition: all .2s;
}
.nav-item[aria-current="true"] .count { border-color: transparent; background: var(--card); color: var(--secondary); }
.nav-label {
  display: flex; align-items: center; justify-content: space-between; margin: 28px 12px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2);
}
.nav-label .icon-btn { width: 28px; height: 28px; border: 0; background: transparent; }
.nav-label .icon-btn .i { width: 15px; height: 15px; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }

.tip-card {
  margin-top: auto; padding: 20px; border-radius: 16px; border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 6%, var(--card)), var(--card));
}
.tip-icon {
  width: 56px; height: 56px; border-radius: 50%; margin-bottom: 12px; display: grid; place-items: center; color: var(--primary);
  background: radial-gradient(circle, rgba(99, 102, 241, .16), rgba(139, 92, 246, .05));
}
.tip-icon .i { width: 26px; height: 26px; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-3px) rotate(-4deg); } }
.tip-card h2 { font-size: 15px; font-weight: 800; margin-bottom: 6px; }
.tip-card p { font-size: 13px; color: var(--text-2); margin: 0 0 14px; line-height: 1.5; }
.tip-card .btn { width: 100%; border: 0; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.tip-card .btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

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

/* Guest banner */
.banner {
  margin: 24px 32px 0; padding: 16px 22px; border-radius: 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: rgba(99, 102, 241, .06); border: 1px solid rgba(99, 102, 241, .16); font-size: 14px;
  animation: fadeUp .5s var(--ease) both;
}
.banner-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); color: var(--primary); box-shadow: var(--shadow); }
.banner strong { display: block; color: var(--primary); font-size: 15px; }
.banner span { color: var(--text-2); }
.banner .btn { margin-left: auto; }
.banner-close { margin-left: 0 !important; }

/* Toolbar */
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 28px 32px 20px; }
.toolbar h2 { font-size: 26px; font-weight: 800; margin: 0 0 4px; }
.toolbar-sub { font-size: 14px; color: var(--text-2); font-weight: 500; }
.toolbar-controls { display: flex; align-items: center; gap: 12px; }
.select {
  height: 40px; padding: 0 34px 0 12px; border: 1px solid var(--border); border-radius: 10px; background-color: var(--card);
  font-size: 14px; font-weight: 500; outline: 0; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.select:hover, .select:focus { border-color: var(--primary); }
.select:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }

/* Segmented control with sliding thumb (grid / list) */
.seg { position: relative; display: inline-flex; height: 40px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.seg::before {
  content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 7px;
  background: var(--active-bg); transition: transform .3s var(--ease);
}
.seg[data-active="list"]::before { transform: translateX(100%); }
.seg button { position: relative; z-index: 1; width: 40px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; transition: color .2s; }
.seg button[aria-pressed="true"] { color: var(--secondary); }

/* ---------- Notes ---------- */
.notes { padding: 4px 32px 40px; min-height: 320px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 22px; }
.list { display: grid; gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; padding: 22px; border-radius: 16px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); outline: 0;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
  animation: cardIn .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms);
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent, var(--primary)) 40%, var(--border)); box-shadow: 0 14px 28px -6px rgba(15, 23, 42, .1), 0 4px 10px -2px rgba(15, 23, 42, .05); }
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent, var(--primary)) 12%, transparent), transparent 55%);
}
/* skip entry animation on quiet re-renders (autosave, pin, etc.) */
.no-anim .card { animation: none; }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
.card-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--card); color: var(--accent, var(--primary)); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); position: relative; z-index: 1;
  transition: transform .3s var(--ease);
}
.card:hover .card-icon { transform: scale(1.06) rotate(-4deg); }
.card-icon .i { width: 22px; height: 22px; }
.card-title { position: relative; z-index: 1; font-size: 16px; font-weight: 700; margin: 0 40px 8px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-preview { position: relative; z-index: 1; flex: 1; margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.6; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; min-height: 22px; }
.card-meta { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.card-flags { display: inline-flex; gap: 6px; align-items: center; color: var(--warning); }
.card-flags .i { width: 14px; height: 14px; }
.card-flags .lock { color: var(--text-2); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-menu {
  position: absolute; top: 16px; right: 16px; z-index: 2; width: 34px; height: 34px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2); display: grid; place-items: center;
  opacity: 0; transform: scale(.9); transition: opacity .2s, transform .2s var(--ease), background-color .2s, color .2s;
}
.card:hover .card-menu, .card:focus-within .card-menu, .card-menu[aria-expanded="true"] { opacity: 1; transform: none; }
.card-menu:hover, .card-menu[aria-expanded="true"] { background: var(--bg); color: var(--text); }
@media (hover: none) { .card-menu { opacity: 1; transform: none; } }
.card-bin { position: relative; z-index: 1; display: flex; gap: 8px; margin-top: 14px; }
.card-bin .btn { flex: 1; height: 36px; font-size: 13px; }

/* List view */
.list .card { flex-direction: row; align-items: center; gap: 16px; padding: 14px 18px; }
.list .card-icon { margin: 0; width: 40px; height: 40px; }
.list .card-body { flex: 1; min-width: 0; }
.list .card-title { margin: 0 0 2px; }
.list .card-preview { -webkit-line-clamp: 1; }
.list .card-meta { margin: 0; flex-direction: column; align-items: flex-end; gap: 4px; padding-right: 36px; }
.list .card-menu { top: 50%; margin-top: -17px; }
.list .card-bin { margin: 0; }
.list .card-bin .btn { flex: none; }
.grid .card-body { display: contents; }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 70px 20px; color: var(--text-2); animation: fadeUp .4s var(--ease) both; }
.empty-icon { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 22px; background: rgba(99, 102, 241, .1); color: var(--primary); }
.empty-icon .i { width: 44px; height: 44px; }
.empty h3 { color: var(--text); font-size: 21px; font-weight: 800; }
.empty p { max-width: 380px; margin: 0 0 22px; }

/* ---------- Dropdown menu ---------- */
.menu {
  position: fixed; z-index: 300; width: 230px; padding: 6px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--border); box-shadow: 0 16px 40px rgba(15, 23, 42, .18);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.97); transform-origin: top right;
  transition: opacity .16s ease, transform .2s var(--ease), visibility 0s linear .2s;
}
.menu.up { transform-origin: bottom right; transform: translateY(6px) scale(.97); }
.menu.open { opacity: 1; visibility: visible; transform: none; transition: opacity .16s ease, transform .2s var(--ease), visibility 0s; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px;
  background: transparent; text-align: left; font-size: 14px; font-weight: 500; color: var(--text);
  transition: background-color .15s, color .15s, padding-left .2s var(--ease);
}
.menu button .i { width: 16px; height: 16px; color: var(--text-2); transition: color .15s; }
.menu button:hover, .menu button:focus-visible { background: var(--bg); color: var(--primary); padding-left: 15px; outline: 0; }
.menu button:hover .i { color: var(--primary); }
.menu .danger, .menu .danger .i { color: var(--error); }
.menu .danger:hover { background: rgba(239, 68, 68, .08); color: var(--error); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }

/* ---------- Overlays / modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s;
}
.overlay.open { opacity: 1; visibility: visible; transition: opacity .25s ease, visibility 0s; }
.modal {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; padding: 28px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(.96); transition: transform .3s var(--ease);
}
.overlay.open .modal, .overlay.open .editor { transform: none; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.modal-head h3 { flex: 1; margin: 0; font-size: 20px; font-weight: 800; }
.modal-x { width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-2); border-radius: 8px; display: grid; place-items: center; transition: background-color .2s, color .2s, transform .2s; }
.modal-x:hover { background: var(--bg); color: var(--text); transform: rotate(90deg); }
.modal p { color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; margin: 14px 0; font-size: 13.5px; font-weight: 600; }
.input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
  font-size: 14.5px; outline: 0; transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); background: var(--card); }
.error-text { color: var(--error); font-size: 13px; margin: 4px 0 0; min-height: 1em; }
.strength { height: 6px; border-radius: 6px; background: var(--border); overflow: hidden; margin-top: 8px; }
.strength span { display: block; height: 100%; width: 0; background: var(--error); transition: width .35s var(--ease), background-color .35s; }
.choice-list { display: grid; gap: 8px; margin-top: 12px; }
.choice-list .btn { justify-content: flex-start; height: 44px; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .2s var(--ease), border-color .2s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot[aria-pressed="true"] { border-color: var(--text); transform: scale(1.1); }
.color-dot.none { background: var(--bg); box-shadow: inset 0 0 0 1px var(--border); position: relative; }
.color-dot.none::after { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 1.5px; background: var(--text-2); transform: rotate(-45deg); }
.cat-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 10px; transition: background-color .2s; }
.cat-row:hover { background: var(--bg); }
.cat-row span { flex: 1; font-weight: 600; }
.cat-row .icon-btn { width: 32px; height: 32px; border: 0; background: transparent; }

/* Tabs (settings) */
.tabs { position: relative; display: flex; gap: 4px; padding: 4px; margin: 16px 0 6px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.tab { position: relative; z-index: 1; flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 600; color: var(--text-2); transition: color .2s; }
.tab[aria-selected="true"] { color: var(--text); }
.tab-thumb { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; border-radius: 9px; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); transition: transform .3s var(--ease), width .3s var(--ease); }
.tab-panel { animation: fadeUp .3s var(--ease) both; }

/* ---------- Editor ---------- */
.editor {
  width: 100%; max-width: 860px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  transform: translateY(18px) scale(.97); transition: transform .32s var(--ease);
}
.editor-top { display: flex; align-items: center; gap: 10px; padding: 14px 20px 14px 26px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.editor-top h3 { margin: 0; font-size: 17px; font-weight: 800; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.save-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); transition: background-color .2s; }
.save-state.saving::before { background: var(--warning); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-weight: 500; cursor: pointer; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 20px; background: var(--border); position: relative; margin: 0; cursor: pointer; transition: background-color .25s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .25s var(--ease); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(14px); }
.spacer { flex: 1; }
.editor-top .icon-btn { width: 36px; height: 36px; }
.editor-title { width: 100%; border: 0; outline: 0; background: transparent; padding: 20px 26px 4px; font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.editor-title::placeholder { color: var(--text-2); opacity: .6; }
.editor-fields { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 26px 14px; border-bottom: 1px solid var(--border); }
.editor-fields .select { height: 34px; font-size: 13px; }
.tag-field { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tag-input { width: 120px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); outline: 0; font-size: 13px; transition: border-color .2s, width .3s var(--ease); }
.tag-input:focus { border-color: var(--primary); width: 160px; }
.tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; background: var(--primary-soft); color: var(--primary); animation: fadeUp .25s var(--ease) both; }
.tag button { border: 0; background: transparent; color: inherit; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; padding: 0; font-size: 14px; line-height: 1; }
.tag button:hover { background: rgba(99, 102, 241, .15); }
.editor-fields .color-row { margin-left: auto; }
.rt { display: flex; gap: 2px; padding: 8px 20px; border-bottom: 1px solid var(--border); background: var(--bg); overflow-x: auto; }
.rt button { flex: none; width: 34px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); display: grid; place-items: center; font-size: 14px; font-weight: 700; transition: background-color .15s, color .15s, box-shadow .15s; }
.rt button:hover { background: var(--card); color: var(--primary); box-shadow: 0 2px 6px rgba(0, 0, 0, .06); }
.rt button.active { color: var(--primary); background: var(--card); }
.rt .sep { flex: none; width: 1px; margin: 4px 6px; background: var(--border); }
.editor-body { flex: 1; overflow-y: auto; padding: 18px 26px 24px; min-height: 260px; }
.editor-content { min-height: 240px; outline: 0; font-size: 15.5px; line-height: 1.75; word-wrap: break-word; }
.editor-content:empty::before { content: attr(data-placeholder); color: var(--text-2); opacity: .7; pointer-events: none; }
.editor-content h2 { font-size: 22px; margin: .6em 0 .3em; }
.editor-content ul, .editor-content ol { padding-left: 24px; }
.editor-content blockquote { margin: .6em 0; padding-left: 16px; border-left: 4px solid var(--primary); color: var(--text-2); font-style: italic; }
.editor-content pre { background: var(--bg); border: 1px solid var(--border); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font: 13.5px/1.6 var(--mono); }
.editor-content a { text-decoration: underline; }
.editor-content.locked { filter: blur(6px); user-select: none; pointer-events: none; }
.editor-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 26px; border-top: 1px solid var(--border); background: var(--bg); font-size: 13px; color: var(--text-2); }
.editor-foot .counts { margin-left: auto; font-weight: 600; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 500; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--card); font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); pointer-events: none;
  opacity: 0; transform: translate(-50%, 16px) scale(.96); transition: opacity .25s, transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .btn { pointer-events: auto; height: 28px; padding: 0 10px; font-size: 13px; background: transparent; color: var(--primary); border: 0; }
:root[data-theme="dark"] .toast .btn { color: var(--primary-hover); }

.scrim { position: fixed; inset: 0; z-index: 140; background: rgba(15, 23, 42, .45); opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s linear .25s; }
.scrim.open { opacity: 1; visibility: visible; transition: opacity .25s, visibility 0s; }

/* ---------- SEO content sections ---------- */
.section { padding: 56px 32px 8px; max-width: 1100px; width: 100%; margin: 0 auto; }
.section-head { text-align: center; max-width: 660px; margin: 0 auto 30px; }
.eyebrow { display: inline-block; padding: 4px 12px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 12px; }
.section h1, .section h2.title { font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; }
.section-head p { color: var(--text-2); font-size: 16px; margin: 0; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature {
  padding: 24px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.feature:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: 0 14px 28px -8px rgba(15, 23, 42, .12); }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); box-shadow: 0 6px 14px rgba(99, 102, 241, .3); }
.feature h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--text-2); font-size: 14.5px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; counter-reset: s; }
.steps li { counter-increment: s; padding: 24px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); position: relative; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; margin-bottom: 12px; background: var(--primary); color: #fff; font-weight: 800; }
.steps h3 { font-size: 17px; margin-bottom: 4px; }
.steps p { margin: 0; color: var(--text-2); font-size: 14.5px; }
kbd { font: 600 12px var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); }
.faq { max-width: 780px; margin: 0 auto; display: grid; gap: 10px; }
.faq details { border-radius: 14px; background: var(--card); border: 1px solid var(--border); transition: border-color .2s, box-shadow .2s; }
.faq details[open] { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow); }
.faq summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; font-weight: 700; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .i { color: var(--text-2); transition: transform .3s var(--ease); }
.faq details[open] summary .i { transform: rotate(180deg); color: var(--primary); }
.faq details p { margin: 0; padding: 0 20px 18px; color: var(--text-2); animation: fadeUp .3s var(--ease) both; }

/* ---------- Footer ---------- */
.footer { margin-top: auto; padding: 44px 0 20px; border-top: 1px solid var(--border); background: var(--bg); }
.main .footer { margin-top: 56px; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.footer-top { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; padding-bottom: 30px; }
.footer-top p { color: var(--text-2); font-size: 14px; margin: 14px 0 0; max-width: 320px; }
.footer h2 { font-size: 14px; font-weight: 700; margin: 0 0 14px; letter-spacing: 0; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.footer-link { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; transition: color .2s, transform .2s var(--ease); }
.footer-link:hover { color: var(--primary); text-decoration: none; transform: translateX(3px); }
.footer-link .i { width: 16px; height: 16px; }
.footer-bottom { padding-top: 20px; border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--text-2); }

/* ---------- Static pages ---------- */
.static-body { display: flex; flex-direction: column; min-height: 100vh; }
.topbar.simple { display: flex; justify-content: space-between; }
.topbar.simple .btn span { display: inline; }
.prose-card .post-card { box-shadow: none; }
.page { flex: 1; padding: 44px 0 56px; animation: fadeUp .45s var(--ease) both; }
.prose { max-width: 780px; margin: 0 auto; }
.prose h1 { font-size: clamp(28px, 4vw, 38px); font-weight: 800; }
.prose h2 { font-size: 21px; margin-top: 1.8em; }
.prose p, .prose li { color: var(--text); }
.prose .updated { color: var(--text-2); font-size: 14px; }
.prose-card { padding: 32px; border-radius: 20px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); }
.breadcrumb { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; opacity: .6; }
.post-list { display: grid; gap: 16px; }
.post-card { padding: 24px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.post-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px -8px rgba(15, 23, 42, .12); }
.post-card time { font-size: 13px; color: var(--text-2); }
.post-card h2 { font-size: 20px; margin: 4px 0 6px; }
.post-card p { margin: 0; color: var(--text-2); }
.form { display: grid; gap: 4px; }
.form textarea.input { height: auto; padding: 12px 14px; resize: vertical; }
.form select.input { appearance: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 20px; }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100%; z-index: 150; width: 280px;
    transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: none;
  }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .25); }
  .nav-item::before { left: -16px; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 112px; }
  .topbar { grid-template-columns: 1fr auto; height: auto; min-height: var(--topbar-h); padding: 10px 14px; gap: 10px; }
  .topbar-center { grid-column: 1 / -1; order: 3; }
  .search { max-width: none; }
  .search .kbd, .top-link.hide-sm { display: none; }
  .topbar-center .btn span { display: none; }
  .topbar-center .btn { width: 40px; padding: 0; flex: none; }
  .banner { margin: 16px 14px 0; }
  .banner .btn { margin-left: 0; }
  .toolbar { padding: 22px 14px 14px; }
  .toolbar h2 { font-size: 22px; }
  .toolbar-controls { width: 100%; }
  .toolbar-controls .select { flex: 1; }
  .notes { padding: 4px 14px 32px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 18px; }
  .list .card-meta { display: none; }
  .list .card-menu { right: 8px; }
  .section { padding: 44px 14px 8px; }
  .footer-inner { padding: 0 16px; }
  .footer-top { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer-top > div:first-child { grid-column: 1 / -1; }
  .overlay { padding: 12px; }
  .modal { padding: 22px 18px; }
  #editor-overlay { padding: 0; }
  .editor { max-height: 100%; height: 100%; max-width: none; border-radius: 0; border: 0; }
  .editor-top { padding: 10px 12px 10px 18px; }
  .editor-top h3, .switch span { display: none; }
  .editor-title { padding: 16px 18px 4px; font-size: 22px; }
  .editor-fields { padding: 8px 18px 12px; }
  .editor-fields .color-row { margin-left: 0; }
  .rt { padding: 6px 10px; }
  .editor-body { padding: 14px 18px; }
  .editor-foot { padding: 10px 18px; }
  .editor-foot .hint { display: none; }
  .editor-foot .counts { margin-left: 0; margin-right: auto; }
  .prose-card { padding: 22px 18px; }
}
@media (max-width: 340px) {
  .logo span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 720px) {
  .topbar.simple { min-height: 64px; }
  .topbar.simple .topbar-right { gap: 6px; }
  .topbar.simple .btn span { display: none; }
  .topbar.simple .btn { width: 40px; padding: 0; }
  .editor-foot .btn { flex: 1; }
  .editor-foot .counts { flex-basis: 100%; }
}
