:root {
  --bg: #e9edf4;
  --bg-soft: #f4f6fa;
  --ink: #0b1220;
  --muted: #5a6578;
  --line: #d5dce8;
  --line-strong: #b8c2d4;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: #ffffff;
  --accent: #e11d2e;
  --accent-ink: #ffffff;
  --accent-soft: #ff3b4a;
  --ok: #1f7a4d;
  --err: #c5303e;
  --shadow-xl: 0 22px 50px rgba(11, 18, 32, 0.1);
  --shadow-sm: 0 1px 0 rgba(11, 18, 32, 0.04), 0 10px 28px rgba(11, 18, 32, 0.06);
  --shadow-preview: 0 28px 60px rgba(11, 18, 32, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Syne", sans-serif;
  --font-body: "Outfit", sans-serif;
  --cat-finance: #1f7a4d;
  --cat-finance-bg: rgba(31, 122, 77, 0.08);
  --cat-finance-border: rgba(31, 122, 77, 0.2);
  --cat-tech: #b45309;
  --cat-tech-bg: rgba(180, 83, 9, 0.08);
  --cat-tech-border: rgba(180, 83, 9, 0.2);
  --cat-general: #2563a8;
  --cat-general-bg: rgba(37, 99, 168, 0.08);
  --cat-general-border: rgba(37, 99, 168, 0.2);
  --surface-text: #2a3a4e;
  --surface-muted: #faf8f5;
  --hit-bg: #ffe08a;
  --body-grad: linear-gradient(165deg, #f7f8fc 0%, #e8edf5 48%, #e4e9f2 100%);
  --brand-locker-color: #0b1220;
  --panel-border: rgba(255, 255, 255, 0.7);
  --panel-inset: rgba(255, 255, 255, 0.65);
}

[data-theme="dark"] {
  --bg: #0b1018;
  --bg-soft: #101826;
  --ink: #edf2fa;
  --muted: #9eacc2;
  --line: #273246;
  --line-strong: #3a4b66;
  --panel: rgba(18, 26, 40, 0.9);
  --panel-strong: #162033;
  --accent: #ff4d5c;
  --accent-ink: #ffffff;
  --accent-soft: #ff6b78;
  --ok: #4ade97;
  --err: #fb7185;
  --shadow-xl: 0 18px 40px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.035), 0 10px 24px rgba(0, 0, 0, 0.28);
  --shadow-preview: 0 24px 56px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --cat-finance: #5eead4;
  --cat-finance-bg: rgba(94, 234, 212, 0.12);
  --cat-finance-border: rgba(94, 234, 212, 0.28);
  --cat-tech: #fdba74;
  --cat-tech-bg: rgba(253, 186, 116, 0.12);
  --cat-tech-border: rgba(253, 186, 116, 0.28);
  --cat-general: #7dd3fc;
  --cat-general-bg: rgba(125, 211, 252, 0.12);
  --cat-general-border: rgba(125, 211, 252, 0.28);
  --surface-text: #e4ebf7;
  --surface-muted: #101826;
  --hit-bg: rgba(250, 204, 21, 0.28);
  --body-grad: radial-gradient(ellipse 60% 40% at 90% 0%, rgba(56, 120, 200, 0.06), transparent 48%),
    linear-gradient(180deg, #121a28 0%, #0b1018 100%);
  --brand-locker-color: #f3f6fb;
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-inset: rgba(255, 255, 255, 0.035);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: only light;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--body-grad);
  overflow-x: hidden;
  transition: background 0.28s ease, color 0.28s ease;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(11, 18, 32, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 18, 32, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 75% 55% at 50% 0%, #000 15%, transparent 72%);
  animation: gridDrift 36s linear infinite;
}

.bg-orb {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: orbFloat 14s ease-in-out infinite;
}

.bg-orb-a {
  width: min(52vw, 420px);
  height: min(52vw, 420px);
  top: -8%;
  left: -6%;
  background: radial-gradient(circle, rgba(225, 29, 46, 0.22), transparent 68%);
}

.bg-orb-b {
  width: min(48vw, 380px);
  height: min(48vw, 380px);
  top: 8%;
  right: -8%;
  background: radial-gradient(circle, rgba(37, 99, 168, 0.18), transparent 68%);
  animation-delay: -5s;
}

@keyframes gridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 56px 56px, 56px 56px; }
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18px, 22px) scale(1.08); }
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1140px, 94vw);
  margin: 28px auto 56px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--panel-inset);
  backdrop-filter: blur(18px) saturate(1.2);
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.brand-lockup-lg {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.brand-lockup-sm {
  gap: 10px;
}

.brand-mark {
  flex: 0 0 auto;
  display: block;
  border-radius: 14px;
  box-shadow:
    0 10px 24px rgba(11, 18, 32, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  animation:
    markPop 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    brandMarkFloat 5.5s ease-in-out 0.7s infinite;
  transform-origin: center center;
}

.brand-lockup-sm .brand-mark {
  border-radius: 11px;
}

@keyframes markPop {
  from {
    opacity: 0;
    transform: scale(0.86) rotate(-4deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes brandMarkFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    filter: drop-shadow(0 6px 10px rgba(225, 29, 46, 0.12));
  }
  50% {
    transform: translateY(-2px) rotate(-1.5deg);
    filter: drop-shadow(0 10px 14px rgba(225, 29, 46, 0.2));
  }
}

.brand-text {
  min-width: 0;
}

.brand-word {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--ink);
  animation: brandWordIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand-lockup-lg .brand-word {
  font-size: clamp(1.85rem, 5vw, 2.45rem);
}

.brand-lockup-sm .brand-word {
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
}

.brand-yandex {
  background: linear-gradient(
    110deg,
    #e11d2e 0%,
    #ff4d5c 28%,
    #ff9a8b 48%,
    #ff4d5c 68%,
    #e11d2e 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brandYandexShine 6.5s ease-in-out infinite;
}

.brand-dot {
  color: var(--accent);
  margin: 0 1px;
  display: inline-block;
  animation: brandDotPulse 2.8s ease-in-out infinite;
}

.brand-locker {
  color: var(--brand-locker-color);
  position: relative;
  animation: brandLockerSoft 7s ease-in-out infinite;
}

@keyframes brandWordIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes brandYandexShine {
  0%, 100% {
    background-position: 100% 50%;
  }
  50% {
    background-position: 0% 50%;
  }
}

@keyframes brandDotPulse {
  0%, 100% {
    opacity: 0.7;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.25);
  }
}

@keyframes brandLockerSoft {
  0%, 100% {
    opacity: 0.92;
    letter-spacing: -0.045em;
  }
  50% {
    opacity: 1;
    letter-spacing: -0.03em;
  }
}

.brand-tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  max-width: 28ch;
}

.hello-line {
  margin: 10px 0 0;
  position: relative;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35em;
  width: 100%;
  max-width: 36rem;
  line-height: 1.45;
}

.hello-line .hello-name {
  position: relative;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(
    105deg,
    var(--ink) 0%,
    var(--ink) 38%,
    color-mix(in srgb, var(--accent) 70%, var(--ink) 30%) 50%,
    var(--ink) 62%,
    var(--ink) 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: helloShimmer 7.5s ease-in-out infinite;
}

.hello-line .hello-rest {
  color: var(--muted);
  animation: helloSoftPulse 5.5s ease-in-out infinite;
}

.hello-line .hello-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 2px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  opacity: 0.55;
  animation: helloDot 2.8s ease-in-out infinite;
}

@keyframes helloShimmer {
  0%, 100% {
    background-position: 100% 50%;
  }
  50% {
    background-position: 0% 50%;
  }
}

@keyframes helloSoftPulse {
  0%, 100% {
    opacity: 0.78;
  }
  50% {
    opacity: 1;
  }
}

@keyframes helloDot {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  50% {
    opacity: 0.85;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hello-line .hello-name,
  .hello-line .hello-rest,
  .hello-line .hello-dot,
  .brand-mark,
  .brand-word,
  .brand-yandex,
  .brand-dot,
  .brand-locker {
    animation: none !important;
  }

  .hello-line .hello-name {
    color: var(--ink);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
  }

  .hello-line .hello-rest {
    color: var(--muted);
  }

  .brand-yandex {
    background: linear-gradient(120deg, #e11d2e 0%, #ff4d5c 55%, #ff7a66 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

[data-theme="dark"] .hello-line .hello-name {
  background: linear-gradient(
    105deg,
    #edf2fa 0%,
    #edf2fa 38%,
    #ff8a95 50%,
    #edf2fa 62%,
    #edf2fa 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.page-title {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
}

.auth-panel {
  position: relative;
  max-width: 460px;
  margin: 64px auto;
  padding: 30px 28px 28px;
  overflow: hidden;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #ff7a66 45%, transparent 85%);
}

.auth-panel h1,
.topbar h2,
.editor h3,
.admin-head h3,
.recent-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 26px 0 16px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(11, 18, 32, 0.04);
  border: 1px solid rgba(11, 18, 32, 0.05);
}

.tab,
.view-tab {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.view-tab {
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.tab:hover,
.view-tab:hover {
  transform: translateY(-1px);
  color: var(--ink);
}

.view-tab:hover {
  border-color: var(--line-strong);
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(11, 18, 32, 0.08);
}

.view-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.auth-form,
.macro-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 3px rgba(225, 29, 46, 0.12);
}

textarea {
  resize: vertical;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  position: relative;
  overflow: hidden;
  color: var(--accent-ink);
  border-color: transparent;
  background: linear-gradient(135deg, #e11d2e 0%, #ff3b4a 55%, #ff6a55 100%);
  box-shadow: 0 10px 22px rgba(225, 29, 46, 0.28);
}

.btn.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.28) 48%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
}

.btn.primary:hover {
  background: linear-gradient(135deg, #ff2a3c 0%, #ff4d5c 55%, #ff7a66 100%);
  border-color: transparent;
}

.btn.primary:hover::after {
  transform: translateX(120%);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.7);
}

#yandexAuthBtn {
  border-color: #f2c2c6;
  background: linear-gradient(180deg, #fff 0%, #fff5f5 100%);
}

#yandexAuthBtn:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

#hintsBtn {
  color: #fff;
  border-color: #1f4f7a;
  background: #2563a8;
  box-shadow: 0 8px 18px rgba(37, 99, 168, 0.2);
}

#hintsBtn:hover {
  background: #2f74c0;
}

.hidden {
  display: none !important;
}

.site-gate-locked {
  overflow: hidden;
}

.site-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(ellipse 60% 40% at 50% 20%, rgba(225, 29, 46, 0.12), transparent 55%),
    rgba(11, 18, 32, 0.52);
  backdrop-filter: blur(14px) saturate(1.1);
  animation: fadeIn 0.32s ease;
}

.site-gate-overlay.is-leaving {
  animation: fadeOut 0.22s ease forwards;
}

.site-gate-overlay.is-leaving:has(.site-gate-modal.is-success) {
  animation: gateSuccessOut 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.site-gate-modal.is-success {
  animation: gateSuccessPulse 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.site-gate-logo.is-unlocked {
  animation: lockMarkPop 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.site-gate-modal {
  position: relative;
  width: min(420px, 96vw);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 22px;
  padding: 26px 24px 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-preview), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  animation: gateIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.site-gate-modal::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #ff7a66 50%, transparent 90%);
}

.site-gate-glow {
  position: absolute;
  top: -40%;
  right: -20%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 29, 46, 0.16), transparent 68%);
  pointer-events: none;
  animation: orbFloat 10s ease-in-out infinite;
}

.site-gate-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.site-gate-logo {
  display: block;
  border-radius: 13px;
  box-shadow: 0 10px 22px rgba(11, 18, 32, 0.16);
}

.site-gate-word {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.04em;
  line-height: 1;
}

.site-gate-kicker {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.site-gate-modal h3 {
  position: relative;
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.45rem;
}

.site-gate-lead {
  position: relative;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.site-gate-form {
  position: relative;
  display: grid;
  gap: 12px;
}

.site-gate-field {
  display: grid;
  gap: 7px;
}

.site-gate-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.site-gate-input-shell {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(11, 18, 32, 0.03);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.site-gate-input-shell:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 4px rgba(225, 29, 46, 0.12);
  transform: translateY(-1px);
}

.site-gate-input-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  color: #8a94a5;
  pointer-events: none;
  transition: color 0.18s ease;
}

.site-gate-input-icon svg {
  overflow: visible;
}

.site-gate-input-icon.is-unlocked {
  color: #1f7a4d;
}

.site-gate-input-icon.is-unlocked svg path:first-of-type {
  transform-origin: 12px 8px;
  animation: lockShackleOpen 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.site-gate-input-shell:focus-within .site-gate-input-icon {
  color: var(--accent);
}

.site-gate-input-shell input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 50px;
  border: 0;
  border-radius: 0;
  padding: 0 8px 0 0;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.site-gate-input-shell input:focus {
  outline: none;
  box-shadow: none;
}

.site-gate-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 50px;
  border: 0;
  background: transparent;
  color: #8a94a5;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
}

.site-gate-toggle:hover {
  color: var(--ink);
  transform: scale(1.05);
}

.site-gate-toggle .icon-eye-off {
  display: none;
}

.site-gate-toggle.is-visible .icon-eye {
  display: none;
}

.site-gate-toggle.is-visible .icon-eye-off {
  display: block;
}

.site-gate-submit {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  font-size: 14px;
}

.site-gate-error {
  position: relative;
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--err);
  font-weight: 700;
  font-size: 13px;
}

.site-gate-modal.is-error {
  animation: gateShake 0.42s ease;
}

.site-gate-modal.is-error .site-gate-input-shell {
  border-color: color-mix(in srgb, var(--err) 55%, var(--line));
  box-shadow: 0 0 0 4px rgba(197, 48, 62, 0.12);
}

@keyframes gateIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeOut {
  to { opacity: 0; }
}

@keyframes gateShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@keyframes gateSuccessPulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

@keyframes gateSuccessOut {
  to {
    opacity: 0;
    transform: scale(1.03);
    filter: blur(4px);
  }
}

@keyframes lockMarkPop {
  0% { transform: scale(1) rotate(0deg); }
  35% { transform: scale(1.1) rotate(-8deg); }
  70% { transform: scale(0.98) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes lockShackleOpen {
  to {
    transform: translateY(-4px) rotate(-22deg);
  }
}

.message {
  min-height: 0;
  margin: 0;
  font-weight: 650;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1400;
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.92);
  color: #f4f7fb;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.app-toast.is-ok {
  border-color: rgba(74, 222, 151, 0.35);
}

.app-toast.is-error {
  border-color: rgba(251, 113, 133, 0.45);
  background: rgba(60, 20, 28, 0.94);
}

[data-theme="light"] .app-toast,
:root:not([data-theme="dark"]) .app-toast {
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xl);
}

[data-theme="light"] .app-toast.is-ok,
:root:not([data-theme="dark"]) .app-toast.is-ok {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}

[data-theme="light"] .app-toast.is-error,
:root:not([data-theme="dark"]) .app-toast.is-error {
  border-color: color-mix(in srgb, var(--err) 40%, var(--line));
  color: var(--err);
}

.notes-list-item mark.search-hit {
  background: var(--hit-bg);
  border-radius: 3px;
  padding: 0 1px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 12px;
  align-items: center;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.hero::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -12%;
  width: 320px;
  height: 320px;
  border-radius: 42%;
  background: radial-gradient(circle, rgba(225, 29, 46, 0.12), transparent 68%);
  pointer-events: none;
  animation: floatBlob 10s ease-in-out infinite;
}

.hero::after {
  content: "";
  position: absolute;
  left: -8%;
  bottom: -60%;
  width: 240px;
  height: 240px;
  border-radius: 45%;
  background: radial-gradient(circle, rgba(37, 99, 168, 0.1), transparent 70%);
  pointer-events: none;
  animation: floatBlob 12s ease-in-out infinite reverse;
}

@keyframes floatBlob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-16px, 14px) scale(1.07); }
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
}

.hero-copy .brand-lockup {
  flex: 0 0 auto;
}

.hero-copy h2 {
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  line-height: 1.05;
  color: var(--ink);
}

.brand-link {
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.brand-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.brand-link:hover .brand-mark {
  box-shadow:
    0 14px 28px rgba(11, 18, 32, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.btn-compact {
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.nm-badge {
  display: inline-block;
  margin: 0 0 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hotkey-hint,
.hero-note {
  font-size: 12px;
}

.hero-note {
  max-width: 340px;
  margin: 0;
  text-align: right;
}

.hero-side {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  justify-items: end;
  align-self: center;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions .btn-compact {
  padding: 8px 12px;
  min-height: 36px;
}

.filters {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}

.filters-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-toolbar .view-tabs {
  flex: 1 1 auto;
  min-width: 0;
}

.clear-filters-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 4px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.16s ease, text-decoration-color 0.16s ease;
}

.clear-filters-btn:hover {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.filters.proposals-mode .search-wrap,
.filters.proposals-mode .category-pills,
.filters.proposals-mode .clear-filters-btn,
.filters.notes-mode .clear-filters-btn {
  display: none;
}

.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  padding-left: 14px;
  min-height: 46px;
  font-size: 15px;
}

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel-strong);
  box-shadow: var(--shadow-xl);
  animation: rise 0.2s ease;
}

.suggestions button {
  width: 100%;
  border: 0;
  padding: 11px 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 0.14s ease;
}

.suggestions button:hover,
.suggestions button.active {
  background: var(--cat-general-bg);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
}

#filterCategoryPills {
  padding: 8px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  background: var(--panel-strong);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.pill:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  color: var(--ink);
}

.pill.active {
  color: var(--ink);
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}

.editor,
.admin-panel {
  padding: 16px;
  margin-bottom: 12px;
  animation: rise 0.35s ease;
}

.editor-lead {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 168, 0.05);
  color: #35506a;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.editor.proposal-mode {
  border-color: #b9cfe6;
  background:
    radial-gradient(circle at 90% -10%, rgba(37, 99, 168, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.9);
}

.editor.proposal-mode .macro-form {
  border: 1px solid #d5e3f2;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.editor.proposal-mode .btn.primary {
  border-color: #1f4f7a;
  background: #2563a8;
  box-shadow: 0 8px 18px rgba(37, 99, 168, 0.2);
}

.editor-actions,
.proposal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-head p {
  margin: 4px 0 14px;
}

.admin-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-section {
  animation: rise 0.28s ease;
}

.admin-categories-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.admin-category-row:hover {
  transform: translateX(2px);
  border-color: var(--line-strong);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 10px;
  align-items: start;
}

.admin-stack {
  display: grid;
  gap: 10px;
}

.admin-form,
.proposal-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.admin-form h4,
.proposal-head h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: -0.02em;
}

#adminsSummary {
  margin: 8px 0 0;
  font-size: 12px;
}

.proposal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-search-row {
  margin-bottom: 10px;
}

.proposal-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.proposal-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: #fff;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.proposal-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.proposal-item h5 {
  margin: 0 0 4px;
  font-size: 15px;
  font-family: var(--font-display);
}

.proposal-item p {
  margin: 0 0 6px;
  font-size: 12px;
}

.admin-user-last-seen {
  color: var(--ink);
  font-size: 12.5px !important;
}

.admin-user-last-seen strong {
  font-weight: 700;
}

.admin-user-last-seen.is-never {
  color: var(--muted);
}

.admin-user-last-seen.is-never strong {
  font-weight: 650;
}

.status-badge {
  display: inline-block;
  border-radius: 8px;
  padding: 3px 8px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pending {
  color: #6a561d;
  background: #fff8e5;
  border-color: #f1dfaa;
}

.status-approved {
  color: #17563f;
  background: #e9f8f1;
  border-color: #b9e8d1;
}

.status-editor {
  color: #1f4d72;
  background: #e8f2fb;
  border-color: #b9d3ea;
}

.status-rejected {
  color: #8f2f3d;
  background: #feecf0;
  border-color: #f2bfca;
}

.proposal-item pre {
  margin: 0 0 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f5f1;
  font-size: 12px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}

.admin-macro-card {
  padding: 12px;
  background: #fff;
}

.admin-macro-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-macro-top .macro-category {
  flex-shrink: 0;
}

.admin-macro-body {
  margin: 0 0 8px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--surface-text);
  font-size: 12px;
  line-height: 1.55;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

.admin-macro-actions {
  justify-content: flex-end;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.macro-card {
  position: relative;
  padding: 14px 14px 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 72px;
  max-height: 72px;
  overflow: hidden;
  border-color: var(--line);
  background: var(--panel-strong);
  border-left: 3px solid color-mix(in srgb, var(--cat-general) 55%, var(--line) 45%);
  cursor: pointer;
  animation: cardIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) var(--card-delay, 0ms) both;
  transition: transform 0.22s ease, box-shadow 0.22s ease, max-height 0.28s ease, border-color 0.22s ease, opacity 0.18s ease, filter 0.18s ease;
}

@keyframes cardIn {
  from {
    opacity: 0;
    filter: blur(7px);
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

.macro-card.is-search-pop {
  animation:
    cardIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) var(--card-delay, 0ms) both,
    searchHitPop 0.42s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--card-delay, 0ms) + 80ms) both;
}

.macro-card.is-search-miss {
  opacity: 0;
  filter: blur(4px);
  transform: scale(0.96);
  pointer-events: none;
}

@keyframes searchHitPop {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-2px) scale(1.03); }
  100% { transform: translateY(0) scale(1); }
}

.macro-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 54px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, transparent 0%, var(--panel-strong) 88%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.macro-card:hover,
.macro-card:focus-within,
.macro-card.expanded {
  transform: translateY(-3px);
  max-height: 128px;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xl);
}

.macro-card:hover::after,
.macro-card:focus-within::after,
.macro-card.expanded::after {
  opacity: 1;
}

.macro-card.copied {
  box-shadow: 0 0 0 2px rgba(31, 122, 77, 0.22), var(--shadow-sm);
}

.macro-card.copy-flash,
.recent-macro-chip.copy-flash {
  animation: copyFlash 0.42s ease;
}

@keyframes copyFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 122, 77, 0.35), var(--shadow-sm);
    filter: brightness(1);
  }
  35% {
    box-shadow: 0 0 0 6px rgba(31, 122, 77, 0.12), var(--shadow-md);
    filter: brightness(1.08);
  }
  100% {
    box-shadow: 0 0 0 2px rgba(31, 122, 77, 0.18), var(--shadow-sm);
    filter: brightness(1);
  }
}

.copy-sparks {
  position: fixed;
  z-index: 13000;
  width: 0;
  height: 0;
  pointer-events: none;
}

.copy-sparks span {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  animation: copySpark 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes copySpark {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.55);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(0.15);
  }
}

.macro-card.is-collapsing {
  transform: translateY(0) !important;
  max-height: 72px !important;
}

.macro-card.is-collapsing::after {
  opacity: 0 !important;
}

.macro-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.macro-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.macro-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.macro-meta,
.macro-category,
.macro-hover-hint,
.macro-tags {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.macro-category {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--cat-general-border);
  background: var(--cat-general-bg);
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 650;
  font-size: 10px;
  text-transform: uppercase;
}

.macro-meta,
.macro-category,
.macro-hover-hint,
.macro-body,
.macro-tags,
.macro-actions,
.favorite-btn {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.macro-card:hover .macro-meta,
.macro-card:hover .macro-category,
.macro-card:hover .macro-hover-hint,
.macro-card:hover .macro-tags,
.macro-card:hover .macro-actions,
.macro-card:hover .favorite-btn,
.macro-card:focus-within .macro-meta,
.macro-card:focus-within .macro-category,
.macro-card:focus-within .macro-hover-hint,
.macro-card:focus-within .macro-tags,
.macro-card:focus-within .macro-actions,
.macro-card:focus-within .favorite-btn,
.macro-card.expanded .macro-meta,
.macro-card.expanded .macro-category,
.macro-card.expanded .macro-hover-hint,
.macro-card.expanded .macro-tags,
.macro-card.expanded .macro-actions,
.macro-card.expanded .favorite-btn {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.macro-card.is-collapsing .macro-meta,
.macro-card.is-collapsing .macro-category,
.macro-card.is-collapsing .macro-hover-hint,
.macro-card.is-collapsing .macro-body,
.macro-card.is-collapsing .macro-tags,
.macro-card.is-collapsing .macro-actions,
.macro-card.is-collapsing .favorite-btn {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.macro-body {
  display: none;
  margin: 0;
  padding: 10px 10px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--surface-text);
  white-space: pre-wrap;
  max-height: 184px;
  overflow: hidden;
}

.macro-card:hover .macro-body,
.macro-card:focus-within .macro-body,
.macro-card.expanded .macro-body {
  display: none;
  max-height: 0;
  overflow: hidden;
}

.macro-preview-popover {
  position: fixed;
  z-index: 1100;
  width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow-preview);
  padding: 14px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.macro-preview-popover.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.macro-preview-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.macro-preview-category {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--cat-general-border);
  background: var(--cat-general-bg);
  color: var(--muted);
  font-weight: 650;
}

.macro-preview-body {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: min(54vh, 420px);
  overflow: auto;
}

mark.search-hit {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--hit-bg);
  color: inherit;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.icon-btn:hover {
  transform: scale(1.06);
  border-color: var(--line-strong);
  color: var(--ink);
}

.icon-btn.active {
  color: #b45309;
  border-color: #f0c9a0;
  background: #fff7ed;
}

.macro-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cat-tone-finance {
  --cat-accent: var(--cat-finance);
  --cat-accent-bg: var(--cat-finance-bg);
  --cat-accent-border: var(--cat-finance-border);
}

.cat-tone-tech {
  --cat-accent: var(--cat-tech);
  --cat-accent-bg: var(--cat-tech-bg);
  --cat-accent-border: var(--cat-tech-border);
}

.cat-tone-general {
  --cat-accent: var(--cat-general);
  --cat-accent-bg: var(--cat-general-bg);
  --cat-accent-border: var(--cat-general-border);
}

.macro-card.cat-tone-finance { border-left-color: color-mix(in srgb, var(--cat-finance) 60%, var(--line) 40%); }
.macro-card.cat-tone-tech { border-left-color: color-mix(in srgb, var(--cat-tech) 60%, var(--line) 40%); }
.macro-card.cat-tone-general { border-left-color: color-mix(in srgb, var(--cat-general) 60%, var(--line) 40%); }

.macro-card.cat-tone-finance .macro-category,
.macro-preview-popover.cat-tone-finance .macro-preview-category {
  color: var(--muted);
  border-color: var(--cat-finance-border);
  background: var(--cat-finance-bg);
}

.macro-card.cat-tone-tech .macro-category,
.macro-preview-popover.cat-tone-tech .macro-preview-category {
  color: var(--muted);
  border-color: var(--cat-tech-border);
  background: var(--cat-tech-bg);
}

.macro-card.cat-tone-general .macro-category,
.macro-preview-popover.cat-tone-general .macro-preview-category {
  color: var(--muted);
  border-color: var(--cat-general-border);
  background: var(--cat-general-bg);
}

#filterCategoryPills .pill.cat-tone-finance.active {
  background: var(--cat-finance-bg);
  border-color: var(--cat-finance-border);
  color: color-mix(in srgb, var(--cat-finance) 70%, var(--ink) 30%);
}

#filterCategoryPills .pill.cat-tone-tech.active {
  background: var(--cat-tech-bg);
  border-color: var(--cat-tech-border);
  color: color-mix(in srgb, var(--cat-tech) 70%, var(--ink) 30%);
}

#filterCategoryPills .pill.cat-tone-general.active {
  background: var(--cat-general-bg);
  border-color: var(--cat-general-border);
  color: color-mix(in srgb, var(--cat-general) 70%, var(--ink) 30%);
}

.macro-card.cat-tone-finance.copied,
.macro-card.cat-tone-tech.copied,
.macro-card.cat-tone-general.copied {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cat-accent, var(--cat-general)) 25%, transparent), var(--shadow-sm);
}

.recent-section {
  margin: 0 0 12px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: none;
  backdrop-filter: blur(10px);
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}

.recent-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.recent-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}

.recent-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.recent-macros-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.recent-macros-row::-webkit-scrollbar {
  display: none;
}

.recent-macro-chip {
  flex: 0 0 auto;
  max-width: 200px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 2px solid color-mix(in srgb, var(--cat-general) 55%, var(--line) 45%);
  border-radius: 10px;
  padding: 7px 10px;
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.recent-macro-chip:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.recent-macro-chip.copied {
  border-color: color-mix(in srgb, var(--cat-accent, var(--cat-general)) 45%, var(--line));
  background: color-mix(in srgb, var(--cat-accent, var(--cat-general)) 8%, var(--panel-strong));
}

.recent-macro-chip.cat-tone-finance { border-left-color: color-mix(in srgb, var(--cat-finance) 60%, var(--line) 40%); }
.recent-macro-chip.cat-tone-tech { border-left-color: color-mix(in srgb, var(--cat-tech) 60%, var(--line) 40%); }
.recent-macro-chip.cat-tone-general { border-left-color: color-mix(in srgb, var(--cat-general) 60%, var(--line) 40%); }

.recent-macro-chip-title {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.recent-macro-chip-meta {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0.85;
}

@media (max-width: 880px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-side {
    justify-items: start;
  }

  .hero-note {
    text-align: left;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .layout {
    width: min(96vw, 1120px);
    margin-top: 14px;
  }

  .macro-preview-popover {
    display: none !important;
  }

  .macro-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .editor-actions,
  .macro-actions,
  .proposal-actions {
    width: 100%;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
  }
}

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

  .bg-layer,
  .bg-orb {
    animation: none;
  }
}

/* ── Theme toggle ── */
.theme-toggle-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1200;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xl);
}

.theme-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.theme-toggle-sun { display: none; }
.theme-toggle-moon { display: block; }

[data-theme="dark"] .theme-toggle-sun { display: block; }
[data-theme="dark"] .theme-toggle-moon { display: none; }

/* ── Dark theme contrast overrides ── */
[data-theme="dark"] .bg-layer {
  opacity: 0.22;
}

[data-theme="dark"] .bg-orb-a {
  display: none;
}

[data-theme="dark"] .bg-orb-b {
  background: radial-gradient(circle, rgba(125, 211, 252, 0.12), transparent 68%);
}

[data-theme="dark"] .btn {
  background: var(--panel-strong);
  color: var(--ink);
}

[data-theme="dark"] .btn.ghost {
  background: rgba(26, 35, 51, 0.9);
}

[data-theme="dark"] .btn.primary {
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 18px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .btn.primary:hover {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 22px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn.primary::after {
  opacity: 0.35;
}

[data-theme="dark"] .hero::before {
  background: radial-gradient(circle, rgba(125, 160, 210, 0.1), transparent 68%);
}

[data-theme="dark"] .hero::after {
  background: radial-gradient(circle, rgba(80, 110, 160, 0.08), transparent 70%);
}

[data-theme="dark"] .tab.active {
  background: #243044;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .view-tab {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

[data-theme="dark"] .view-tab.active {
  background: rgba(255, 77, 92, 0.16);
  border-color: rgba(255, 77, 92, 0.38);
  color: #ffe4e7;
}

[data-theme="dark"] .macro-card,
[data-theme="dark"] .recent-section {
  background: rgba(18, 26, 40, 0.72);
  border-color: var(--line);
}

[data-theme="dark"] .recent-count {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .recent-macro-chip,
[data-theme="dark"] .proposal-item,
[data-theme="dark"] .admin-form,
[data-theme="dark"] .proposal-box,
[data-theme="dark"] .admin-category-row,
[data-theme="dark"] .admin-macro-card,
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .site-gate-modal,
[data-theme="dark"] .site-gate-input-shell,
[data-theme="dark"] .macro-preview-popover {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] .macro-card:hover,
[data-theme="dark"] .macro-card:focus-within,
[data-theme="dark"] .macro-card.expanded,
[data-theme="dark"] .recent-macro-chip:hover {
  border-color: var(--line-strong);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .macro-title,
[data-theme="dark"] .macro-preview-title,
[data-theme="dark"] .recent-macro-chip-title,
[data-theme="dark"] .proposal-item h5 {
  color: #f5f8fd;
}

[data-theme="dark"] .macro-meta,
[data-theme="dark"] .macro-hover-hint,
[data-theme="dark"] .recent-macro-chip-meta {
  color: var(--muted);
}

[data-theme="dark"] .macro-body,
[data-theme="dark"] .macro-preview-body,
[data-theme="dark"] .admin-macro-body,
[data-theme="dark"] .proposal-item pre {
  background: #0e1522;
  color: #e8eef8;
  border-color: #2a3750;
}

[data-theme="dark"] .macro-preview-popover {
  background: #182338;
  border-color: #334560;
  box-shadow: var(--shadow-preview);
}

[data-theme="dark"] .macro-preview-category {
  color: #c9d7ea;
}

[data-theme="dark"] .suggestions {
  background: #1a2333;
  border-color: var(--line-strong);
}

[data-theme="dark"] .suggestions button {
  color: var(--ink);
}

[data-theme="dark"] .suggestions button:hover,
[data-theme="dark"] .suggestions button.active {
  background: rgba(125, 211, 252, 0.12);
}

[data-theme="dark"] .pill {
  background: #162033;
  color: var(--muted);
}

[data-theme="dark"] .pill.active {
  color: var(--ink);
  background: rgba(255, 77, 92, 0.14);
}

[data-theme="dark"] .category-pills,
[data-theme="dark"] #filterCategoryPills {
  background: rgba(12, 17, 26, 0.55);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: #121925;
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #8492a8;
}

[data-theme="dark"] #yandexAuthBtn {
  border-color: #4a3040;
  background: linear-gradient(180deg, #241820 0%, #1c1418 100%);
  color: var(--ink);
}

[data-theme="dark"] .status-pending {
  color: #fde68a;
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(250, 204, 21, 0.28);
}

[data-theme="dark"] .status-approved {
  color: #86efac;
  background: rgba(74, 222, 151, 0.12);
  border-color: rgba(74, 222, 151, 0.28);
}

[data-theme="dark"] .status-editor {
  color: #7dd3fc;
  background: rgba(125, 211, 252, 0.12);
  border-color: rgba(125, 211, 252, 0.28);
}

[data-theme="dark"] .status-rejected {
  color: #fda4af;
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.28);
}

[data-theme="dark"] .editor-lead {
  background: rgba(125, 211, 252, 0.08);
  color: #c7daf0;
  border-color: var(--line-strong);
}

[data-theme="dark"] .editor.proposal-mode .macro-form {
  background: #152033;
  border-color: var(--line);
}

[data-theme="dark"] .icon-btn.active {
  color: #fdba74;
  border-color: rgba(253, 186, 116, 0.35);
  background: rgba(253, 186, 116, 0.12);
}

[data-theme="dark"] .site-gate-overlay {
  background: rgba(5, 8, 14, 0.78);
}

[data-theme="dark"] .site-gate-modal {
  border-color: var(--line);
  background: rgba(22, 30, 44, 0.96);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .site-gate-modal::before,
[data-theme="dark"] .site-gate-glow {
  display: none;
}

[data-theme="dark"] .auth-panel::before {
  display: none;
}

[data-theme="dark"] .articles-list-wrap,
[data-theme="dark"] .article-view-wrap,
[data-theme="dark"] .article-list-item,
[data-theme="dark"] .article-color-picker-wrap {
  background: var(--panel-strong);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] .article-list-item.active {
  background: rgba(255, 77, 92, 0.12);
  border-color: rgba(255, 77, 92, 0.35);
}

[data-theme="dark"] .article-body {
  color: var(--surface-text);
}

[data-theme="dark"] .article-body blockquote {
  background: rgba(255, 77, 92, 0.1);
  color: #f8d7db;
  border-left-color: var(--accent);
}

[data-theme="dark"] .article-body a {
  color: #ff8a95;
}

[data-theme="dark"] .brand-yandex {
  background: linear-gradient(
    110deg,
    #ff3b4a 0%,
    #ff6b78 28%,
    #ffb0a8 48%,
    #ff6b78 68%,
    #ff3b4a 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="dark"] .brand-mark {
  filter: drop-shadow(0 8px 14px rgba(255, 77, 92, 0.18));
}

/* ── Personal notes (SimpleNote-like) ── */
.notes-panel {
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
  animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.notes-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  min-height: min(70vh, 720px);
}

.notes-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 70%, transparent);
}

.notes-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.notes-sidebar-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 2px;
}

.notes-list-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.notes-list-item:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.notes-list-item.active {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel-strong));
  box-shadow: var(--shadow-sm);
}

.notes-list-item-title {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-list-item-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.notes-list-item-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.notes-pin-mark {
  color: var(--accent);
  font-weight: 700;
}

.notes-editor-wrap {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-strong);
}

.notes-empty {
  margin: auto;
  padding: 28px 24px;
  text-align: center;
  max-width: 360px;
}

.notes-empty h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.notes-empty .btn {
  margin-top: 14px;
}

.notes-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: min(70vh, 720px);
}

.notes-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.notes-editor-toolbar input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.notes-editor-toolbar input:focus {
  outline: none;
  box-shadow: none;
}

.notes-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.notes-save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.notes-save-status.is-saved {
  color: #1f7a4d;
}

.notes-save-check {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
}

.notes-save-check-path {
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
}

.notes-save-status.is-check-anim .notes-save-check-path {
  animation: notesCheckDraw 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes notesCheckDraw {
  to { stroke-dashoffset: 0; }
}

.notes-editor textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 360px;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 18px 16px 24px;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  line-height: 1.65;
}

.notes-editor textarea:focus {
  outline: none;
  box-shadow: none;
}

.filters.notes-mode .search-wrap,
.filters.notes-mode .category-pills {
  display: none;
}

[data-theme="dark"] .notes-sidebar {
  background: rgba(12, 17, 26, 0.55);
}

[data-theme="dark"] .notes-list-item {
  background: #162033;
}

[data-theme="dark"] .notes-list-item.active {
  background: rgba(255, 77, 92, 0.12);
  border-color: rgba(255, 77, 92, 0.35);
}

[data-theme="dark"] .notes-editor-wrap {
  background: #162033;
}

[data-theme="dark"] .notes-editor-toolbar input,
[data-theme="dark"] .notes-editor textarea {
  color: var(--ink);
}

@media (max-width: 880px) {
  .notes-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .notes-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 280px;
  }

  .notes-editor {
    min-height: 52vh;
  }
}

/* Theme circular reveal */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 9999;
  animation: themeReveal 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes themeReveal {
  from {
    clip-path: circle(0px at var(--theme-x, 50%) var(--theme-y, 0%));
  }
  to {
    clip-path: circle(var(--theme-r, 100vmax) at var(--theme-x, 50%) var(--theme-y, 0%));
  }
}

@media (prefers-reduced-motion: reduce) {
  .macro-card.is-search-pop,
  .macro-card.is-search-miss,
  .copy-sparks,
  .macro-card.copy-flash,
  .recent-macro-chip.copy-flash,
  .notes-save-status.is-check-anim .notes-save-check-path,
  .site-gate-logo.is-unlocked,
  .site-gate-input-icon.is-unlocked svg path:first-of-type {
    animation: none !important;
  }

  .macro-card.is-search-miss {
    opacity: 0;
    filter: none;
    transform: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}
