:root {
  --bg: #f9fafb;
  --bg-soft: #f3f4f6;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --brand: #7c3aed;
  --brand-deep: #5500a9;
  --brand-soft: #f0f4ff;
  --brand-ring: #c4b5fd;
  --pink: #ec4899;
  --header-h: 58px;
  --sticky-h: 96px;
  --header-offset: var(--header-h);
  --shadow: 0 10px 15px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-pill: 999px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --ease: 160ms ease;
}

html[data-theme="dark"] {
  --bg: #0f0c18;
  --bg-soft: #161122;
  --surface: #1a1528;
  --ink: #f3efff;
  --muted: #b0a8c4;
  --faint: #857c9e;
  --line: #2d2640;
  --line-strong: #42385c;
  --brand: #a78bfa;
  --brand-deep: #c4b5fd;
  --brand-soft: #2a2044;
  --brand-ring: #6d28d9;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(780px 360px at 10% -5%, rgba(124, 58, 237, 0.1), transparent 55%),
    radial-gradient(640px 320px at 95% 0%, rgba(236, 72, 153, 0.08), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--brand-deep);
}

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

/* ——— Header ——— */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: transform 0.28s ease, opacity 0.28s ease;
  will-change: transform;
}

body.header-away .site-header {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

body.header-away {
  --header-offset: 0px;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.28);
}

.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform var(--ease), background var(--ease);
}

.theme-btn:hover {
  transform: translateY(-1px);
}

.theme-btn .moon {
  font-size: 1rem;
}

/* ——— Sticky composer ——— */
.sticky-panel {
  position: fixed;
  top: var(--header-offset);
  left: 0;
  right: 0;
  z-index: 45;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px 14px;
  transition: top 0.28s ease;
}

.sticky-inner {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.composer {
  position: relative;
  display: block;
  min-height: 72px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.composer:focus-within {
  border-color: var(--brand-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent),
    0 8px 24px rgba(15, 23, 42, 0.06);
}

.composer-input {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 72px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.12rem;
  font-weight: 600;
  padding: 18px 56px 22px 18px;
  text-align: center;
  letter-spacing: -0.01em;
}

.composer.has-value .composer-input {
  text-align: center;
}

.composer-placeholder {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  color: var(--faint);
  user-select: none;
  transition: opacity 0.15s ease;
}

.composer.has-value .composer-placeholder,
.composer.is-focused .composer-placeholder {
  opacity: 0;
}

.ph-pencil {
  font-size: 1.05rem;
  opacity: 0.85;
}

.ph-plain {
  font-size: 1.05rem;
  font-weight: 500;
  color: #9aa3af;
}

.ph-script {
  font-family: "Great Vibes", "Segoe Script", cursive;
  font-size: 1.7rem;
  font-weight: 400;
  color: #6b7280;
  line-height: 1;
  margin-top: 4px;
  white-space: nowrap;
}

html[data-theme="dark"] .ph-plain,
html[data-theme="dark"] .ph-script {
  color: var(--muted);
}

.char-badge {
  position: absolute;
  left: 14px;
  bottom: 8px;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.02em;
  pointer-events: none;
}

.clear-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  transition: background var(--ease), color var(--ease);
}

.clear-btn:hover {
  background: var(--bg-soft);
  color: var(--ink);
}




/* ——— Layout ——— */
.page {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--header-h) + var(--sticky-h) + 18px) 18px 48px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.page > * {
  min-width: 0;
  max-width: 100%;
}

.sidebar-wrap {
  position: sticky;
  top: calc(var(--header-offset) + var(--sticky-h) + 8px);
  transition: top 0.28s ease;
}

.sidebar-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  max-height: calc(100vh - var(--header-offset) - var(--sticky-h) - 70px);
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.side-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: auto;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.78rem;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: border-color var(--ease), background var(--ease), color var(--ease), transform var(--ease);
}

.side-btn:hover {
  transform: translateY(-1px);
  border-color: var(--brand-ring);
}

.side-btn.is-on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-deep);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}

.side-icon {
  flex-shrink: 0;
  font-size: 0.78rem;
  line-height: 1;
  max-width: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.side-label {
  flex: 0 1 auto;
  font-size: 0.78rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-col {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

img {
  max-width: 100%;
  height: auto;
}

.page-heading {
  margin: 0 0 14px;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

a.side-btn {
  text-decoration: none;
  color: inherit;
}

.font-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 16px;
  width: 100%;
  max-width: 100%;
}

.font-card {
  --accent: linear-gradient(180deg, #8b5cf6 0%, #ec4899 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  padding: 12px 12px 6px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.font-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.font-card.accent-a { --accent: linear-gradient(180deg, #4f7cff, #8b5cf6); }
.font-card.accent-b { --accent: linear-gradient(180deg, #8b5cf6, #ec4899); }
.font-card.accent-c { --accent: linear-gradient(180deg, #f59e0b, #ec4899); }
.font-card.accent-d { --accent: linear-gradient(180deg, #06b6d4, #4f7cff); }
.font-card.accent-e { --accent: linear-gradient(180deg, #10b981, #06b6d4); }
.font-card.accent-f { --accent: linear-gradient(180deg, #ec4899, #f59e0b); }
.font-card.accent-g { --accent: linear-gradient(180deg, #5500a9, #8b5cf6); }
.font-card.accent-h { --accent: linear-gradient(180deg, #ff6b6b, #8b5cf6); }

html[data-theme="dark"] .font-card {
  background: var(--surface);
  border-color: var(--line);
}

.font-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

.font-card.is-copied {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14);
}

.font-value {
  flex: 0 1 auto;
  display: block;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  /* System stack so Mathematical Alphanumeric / symbols don't tofu under DM Sans */
  font-family:
    "Segoe UI Symbol",
    "Segoe UI",
    "Apple Symbols",
    "Hiragino Sans",
    "Noto Sans Symbols 2",
    "Noto Sans",
    "DejaVu Sans",
    system-ui,
    sans-serif;
  font-size: 1.2rem;
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.font-foot {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 24px;
}

.font-chars {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-style: normal;
}

.copy-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-right: -4px;
  border-radius: 8px;
  color: var(--faint);
  transition: background 80ms ease, color 80ms ease;
}

.copy-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

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

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.skel-card {
  min-height: 88px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(
    90deg,
    var(--bg-soft) 0%,
    color-mix(in srgb, var(--surface) 70%, var(--bg-soft)) 50%,
    var(--bg-soft) 100%
  );
  background-size: 200% 100%;
  animation: skel-shine 1.1s ease-in-out infinite;
}

@keyframes skel-shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.font-grid.is-ready {
  animation: sf-grid-in 0.16s ease;
}

@keyframes sf-grid-in {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}

.load-more-wrap[hidden] {
  display: none !important;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), background var(--ease), box-shadow var(--ease);
}

.load-more-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

/* ——— Toast ——— */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 80;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ——— SEO / footer ——— */
.seo-block {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 18px 40px;
  color: var(--muted);
  font-size: 0.95rem;
  overflow-x: clip;
}

.seo-block h2 {
  color: var(--ink);
  font-size: 1.2rem;
  margin: 1.4em 0 0.5em;
}

.seo-block p {
  margin: 0.5em 0;
  max-width: 72ch;
}

.seo-block h2:first-child { margin-top: 0.4em; }
.seo-block a { color: var(--accent, #7c3aed); font-weight: 600; text-decoration: none; }
.seo-block a:hover { text-decoration: underline; }
.seo-block ol, .seo-block ul { margin: 0.6em 0 1em; padding-left: 1.25em; max-width: 72ch; }
.seo-block li { margin: 0.35em 0; }
.seo-block strong { color: var(--ink); }
.content-figure { margin: 1.2em 0; max-width: 720px; }
.content-figure-img { width: 100%; height: auto; border-radius: 14px; display: block; }
.content-figure-cap { margin-top: 0.45em; font-size: 0.85rem; color: var(--faint); }
.faq-list { max-width: 72ch; margin: 0.8em 0 1.2em; }
.faq-item { border: 1px solid var(--line); border-radius: 12px; padding: 0.55em 0.85em; margin: 0.45em 0; background: var(--card, #fff); }
.faq-item summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.faq-item p { margin: 0.45em 0 0.15em; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 18px 32px;
  text-align: center;
  color: var(--faint);
  font-size: 0.85rem;
  font-weight: 600;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin: 0 0 12px;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
}

.footer-nav a:hover {
  color: var(--brand-deep);
  text-decoration: underline;
}

.footer-copy {
  margin: 0;
}

/* ——— Legal / prose pages ——— */
body.legal-page {
  padding-top: var(--header-h);
}

.prose-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.prose-page h1 {
  margin: 0 0 0.7em;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  color: var(--ink);
}

.prose-page p {
  margin: 0.75em 0;
  color: var(--muted);
  max-width: 68ch;
  line-height: 1.65;
}

.prose-page a {
  color: var(--brand-deep);
  font-weight: 700;
  text-decoration: none;
}

.prose-page a:hover {
  text-decoration: underline;
}

.keyword-home-links {
  margin-top: 1.4em;
  max-width: 72ch;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ——— Responsive ——— */
@media (max-width: 980px) {
  .page {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .sidebar-wrap {
    position: static;
    order: -1;
    width: 100%;
    max-width: 100%;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 10px;
    margin: 0 -4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .side-btn {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    padding: 8px 12px;
    font-size: 0.74rem;
  }

  .side-icon {
    max-width: none;
  }

  .font-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .page-heading {
    font-size: 1.08rem;
  }
}

@media (max-width: 720px) {
  :root {
    --header-h: 54px;
    --sticky-h: 88px;
  }

  .header-inner {
    padding: 0 12px;
    gap: 10px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .brand-name {
    font-size: 0.98rem;
  }

  .theme-btn {
    padding: 7px 11px;
    font-size: 0.82rem;
  }

  .sticky-panel {
    padding: 8px 12px 10px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .composer {
    min-height: 64px;
    border-radius: 14px;
  }

  .composer-input {
    min-height: 64px;
    /* 16px prevents iOS input zoom */
    font-size: 16px;
    padding: 14px 44px 22px 12px;
  }

  .composer-placeholder {
    gap: 5px;
    padding: 0 40px 8px 12px;
    flex-wrap: wrap;
  }

  .ph-pencil {
    font-size: 0.95rem;
  }

  .ph-plain {
    font-size: 0.88rem;
  }

  .ph-script {
    font-size: 1.28rem;
    margin-top: 2px;
    white-space: normal;
  }

  .char-badge {
    left: 10px;
    bottom: 6px;
    font-size: 0.66rem;
  }

  .clear-btn {
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
  }

  .page {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: calc(var(--header-h) + var(--sticky-h) + 10px) 12px 36px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .sidebar-wrap {
    position: static;
    order: -1;
  }

  .sidebar-title {
    margin-bottom: 8px;
    font-size: 0.88rem;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .side-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 0.72rem;
    min-height: 36px;
  }

  .page-heading {
    font-size: clamp(1rem, 4.2vw, 1.15rem);
    margin-bottom: 10px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .font-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
  }

  .font-card {
    padding: 10px 12px 4px 14px;
    min-width: 0;
    min-height: 0;
    border-radius: 10px;
  }

  .font-card:hover {
    transform: none;
  }

  .font-value {
    font-size: 1.02rem;
    line-height: 1.4;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
  }

  .seo-block {
    padding: 8px 12px 32px;
    font-size: 0.9rem;
  }

  .seo-block h2 {
    font-size: 1.05rem;
  }

  .content-figure {
    max-width: 100%;
  }

  .prose-page {
    padding: 20px 14px 40px;
  }

  .prose-page h1 {
    font-size: clamp(1.35rem, 6vw, 1.8rem);
  }

  .site-footer {
    padding: 18px 12px calc(24px + env(safe-area-inset-bottom));
  }

  .footer-nav {
    gap: 8px 12px;
  }

  .footer-nav a {
    font-size: 0.78rem;
  }

  .toast {
    left: 12px;
    right: 12px;
    width: auto;
    transform: translateY(20px);
    text-align: center;
  }

  .toast.is-on {
    transform: translateY(0);
  }
}

@media (max-width: 420px) {
  :root {
    --sticky-h: 84px;
  }

  .brand-name {
    font-size: 0.92rem;
  }

  .theme-btn span:not(.moon) {
    display: none;
  }

  .theme-btn {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
  }

  .composer-placeholder {
    padding-right: 36px;
  }

  .ph-plain {
    font-size: 0.8rem;
  }

  .ph-script {
    font-size: 1.12rem;
  }
}
