/* ════════════════════════════════════════════
   TypoMatch — style.css
   ════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #eeeeee;
  color: #0a0a0a;
}

button { font-family: inherit; cursor: pointer; }
input  { font-family: inherit; }

/* ── App shell ──────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════ */
.sidebar {
  width: 288px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #ebebeb;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}

/* Brand */
.sidebar-top {
  padding: 18px 18px 16px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-name { font-size: 32px; font-weight: 700; color: #0a0a0a; letter-spacing: -1px; line-height: 1; font-family: 'Space Mono', monospace; }
.brand-tagline { font-size: 10px; color: #b8b8b8; }

/* Scrollable body */
.sidebar-body {
  flex: 1; overflow-y: auto;
  padding: 6px 18px 14px;
}

.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: #e8e8e8; border-radius: 2px; }

/* Loading */
.fonts-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 52px 0; color: #b0b0b0; font-size: 12px;
}

.loading-spinner {
  width: 20px; height: 20px;
  border: 2px solid #e8e8e8;
  border-top-color: #0a0a0a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Section labels */
.section-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; color: #0a0a0a;
  letter-spacing: 0.01em;
  padding: 12px 0 6px;
}

.section-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}

.dot-heading { background: #6366f1; }
.dot-body    { background: #10b981; }
.dot-display { background: #f59e0b; }

/* Control groups */
.control-group { padding: 7px 0; }

.control-label {
  display: block;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: #b0b0b0; margin-bottom: 7px;
}

.label-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 7px;
}

.label-row .control-label { margin-bottom: 0; }

.slider-readout {
  font-size: 11px; font-weight: 700; color: #0a0a0a;
  min-width: 40px; text-align: right;
}

.sidebar-divider { height: 1px; background: #f0f0f0; margin: 5px 0; }

/* ── Font Selector ─────────────────────── */
.font-selector { position: relative; }

.font-trigger {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  background: #f7f7f7; border: 1px solid #e8e8e8; border-radius: 7px;
  cursor: pointer; font-size: 12px; font-weight: 500; color: #0a0a0a;
  transition: border-color 0.13s, background 0.13s;
  user-select: none;
}

.font-trigger:hover { border-color: #d0d0d0; background: #f2f2f2; }
.font-trigger.open  { border-color: #0a0a0a; background: #fff; }

.chevron {
  color: #b8b8b8; transition: transform 0.17s ease; flex-shrink: 0;
}
.font-trigger.open .chevron { transform: rotate(180deg); }

.font-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid #e8e8e8; border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.05);
  z-index: 200; overflow: hidden; display: none;
  animation: dropIn 0.13s ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.font-dropdown.open { display: block; }

.dropdown-search {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; border-bottom: 1px solid #f0f0f0; color: #c0c0c0;
}

.dropdown-search input {
  flex: 1; border: none; outline: none;
  font-size: 12px; color: #0a0a0a; background: transparent;
}

.dropdown-search input::placeholder { color: #d0d0d0; }

.dropdown-cats {
  display: flex; gap: 4px;
  padding: 6px 10px; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap;
}

.cat-pill {
  padding: 2px 8px; border-radius: 100px;
  border: 1px solid #e8e8e8; background: #f7f7f7;
  font-size: 10px; font-weight: 500; color: #7a7a7a;
  cursor: pointer; transition: all 0.11s;
}

.cat-pill:hover { border-color: #c8c8c8; color: #0a0a0a; }
.cat-pill.active { background: #0a0a0a; border-color: #0a0a0a; color: #fff; }

.font-list {
  list-style: none; max-height: 195px; overflow-y: auto; padding: 4px 0;
}

.font-list::-webkit-scrollbar { width: 3px; }
.font-list::-webkit-scrollbar-thumb { background: #e8e8e8; border-radius: 2px; }

.font-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; cursor: pointer; transition: background 0.09s;
}

.font-list-item:hover  { background: #f7f7f7; }
.font-list-item.active { background: #f3f3f3; }

.font-item-left { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }

.font-item-name {
  font-size: 12px; color: #0a0a0a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.font-item-cat { font-size: 10px; color: #c0c0c0; text-transform: capitalize; }

.font-item-check { color: #0a0a0a; display: none; flex-shrink: 0; }
.font-list-item.active .font-item-check { display: block; }

.font-list-empty { padding: 16px 10px; text-align: center; font-size: 12px; color: #b8b8b8; }

/* ── Sliders ──────────────────────────── */
.slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 3px; background: #e5e5e5; border-radius: 2px; outline: none; cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #0a0a0a; cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  box-shadow: 0 0 0 5px rgba(0,0,0,0.08);
}

.slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #0a0a0a; border: none; cursor: pointer;
}

/* ── Weight Grid ──────────────────────── */
.weight-grid { display: flex; flex-wrap: wrap; gap: 4px; }

.weight-btn {
  padding: 3px 8px; border-radius: 5px;
  border: 1px solid #e8e8e8; background: #f7f7f7;
  font-size: 11px; color: #7a7a7a; cursor: pointer;
  transition: all 0.11s; line-height: 1.5;
}

.weight-btn:hover:not(:disabled) { border-color: #c8c8c8; color: #0a0a0a; }
.weight-btn.active { background: #0a0a0a; border-color: #0a0a0a; color: #fff; }
.weight-btn:disabled { opacity: 0.22; cursor: not-allowed; }

/* ── Color Picker ─────────────────────── */
.color-row { display: flex; align-items: center; gap: 10px; }

.color-swatch-label {
  position: relative; width: 34px; height: 34px;
  cursor: pointer; flex-shrink: 0;
}

.color-swatch-label input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: none; padding: 0;
}

.color-swatch-preview {
  width: 34px; height: 34px; border-radius: 8px;
  border: 2px solid rgba(0,0,0,0.1);
  pointer-events: none; transition: border-color 0.13s;
}

.color-swatch-label:hover .color-swatch-preview { border-color: rgba(0,0,0,0.25); }

.color-hex-badge {
  font-size: 11px; font-weight: 500; color: #7a7a7a;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  letter-spacing: 0.02em;
}

/* ── Theme / Unit switches ────────────── */
.theme-switch, .unit-switch {
  display: flex; background: #f3f3f3; border-radius: 7px; padding: 3px; gap: 2px;
}

.theme-opt, .unit-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 8px; border-radius: 5px; border: none; background: transparent;
  font-size: 11px; font-weight: 500; color: #7a7a7a; cursor: pointer; transition: all 0.17s;
}

.unit-btn { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-weight: 600; }

.theme-opt.active, .unit-btn.active {
  background: #fff; color: #0a0a0a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Sidebar Footer ───────────────────── */
.sidebar-footer {
  padding: 12px 18px 16px; border-top: 1px solid #f0f0f0; flex-shrink: 0;
}

.css-block {
  background: #111; border-radius: 7px; padding: 10px 12px;
  margin-bottom: 8px; max-height: 130px; overflow-y: auto; overflow-x: auto;
}

.css-block::-webkit-scrollbar { width: 3px; height: 3px; }
.css-block::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.css-block pre {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 10px; line-height: 1.75; color: #d4d4d4; white-space: pre;
}

.cs-prop    { color: #9cdcfe; }
.cs-value   { color: #ce9178; }
.cs-comment { color: #6a9955; }

.copy-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 12px; background: #0a0a0a; color: #fff; border: none; border-radius: 7px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.13s, transform 0.1s; letter-spacing: 0.01em;
}

.copy-btn:hover  { background: #2a2a2a; }
.copy-btn:active { transform: scale(0.98); }

/* ════════════════════════════════════════════
   MAIN AREA
   ════════════════════════════════════════════ */
.main {
  flex: 1; overflow-y: auto;
  background: #eeeeee; padding: 56px 64px;
  transition: background 0.3s;
}

.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }

.main-inner {
  max-width: 864px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
}

/* Topbar */
.preview-topbar {
  display: flex; align-items: center; justify-content: space-between;
}

.preview-breadcrumb { font-size: 12px; color: #777; font-weight: 400; }

/* Topbar Randomize button */
.topbar-randomize-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: transparent;
  color: #555;
  border: 1px solid #d0d0d0;
  border-radius: 7px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  letter-spacing: 0.01em;
}

.topbar-randomize-btn:hover {
  background: #0a0a0a; color: #fff; border-color: #0a0a0a;
}

.topbar-randomize-btn:active { transform: scale(0.97); }

.topbar-randomize-btn svg { transition: transform 0.4s ease; }
.topbar-randomize-btn.spinning svg { animation: spinOnce 0.45s ease; }

@keyframes spinOnce {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════
   PREVIEW CARD
   ════════════════════════════════════════════ */
.preview-card {
  background: #fff; border-radius: 8px;
  border: 1px solid rgba(196,196,196,0.15);
  box-shadow: 0 12px 32px rgba(26,28,28,0.06);
  overflow: hidden;
}

/* ── Hero ────────────────────────────────── */
.card-hero {
  position: relative; height: 360px;
  background: #c8c8c8; overflow: hidden;
}

.hero-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  transition: opacity 0.4s ease;
}

/* Gradient from bottom for text readability */
.hero-readability {
  position: absolute; bottom: 0; left: 0; right: 0; height: 80%;
  background: linear-gradient(to top,
    rgba(255,255,255,0.94) 0%,
    rgba(255,255,255,0.6)  38%,
    rgba(255,255,255,0)    100%);
  z-index: 2;
}

/* Title on hero */
.hero-text {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 0 60px 44px; z-index: 3;
}

.article-title {
  font-size: var(--phs, 64px);
  line-height: var(--phlh, 1.2);
  letter-spacing: var(--phls, 0em);
  font-weight: var(--phw, 400);
  color: var(--phc, #0a0a0a);
  font-family: var(--phf, 'Inter'), sans-serif;
  max-width: 720px;
  transition: font-family 0.2s, font-size 0.15s, color 0.2s;
}

/* ── Card body ────────────────────────── */
.card-content { padding: 52px 60px 68px; }

.article-grid {
  display: flex; gap: 48px; align-items: flex-start;
}

/* Left */
.article-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 22px;
}

.article-text {
  font-size: var(--pbs, 16px);
  line-height: var(--pblh, 1.6);
  letter-spacing: var(--pbls, 0em);
  font-weight: var(--pbw, 400);
  color: var(--pbc, #404040);
  font-family: var(--pbf, 'Inter'), sans-serif;
  transition: font-family 0.2s, font-size 0.15s, color 0.2s;
}

.article-actions {
  display: flex; gap: 12px; align-items: center;
  padding-top: 22px;
  border-top: 1px solid rgba(196,196,196,0.22);
  flex-wrap: wrap;
}

.btn-primary {
  padding: 10px 26px;
  background: #0a0a0a; color: #fff;
  border: none; border-radius: 2px;
  font-size: var(--pbs, 16px); font-weight: 500;
  font-family: var(--pbf, 'Inter'), sans-serif;
  cursor: pointer; letter-spacing: var(--pbls, 0em);
  transition: background 0.13s;
}

.btn-primary:hover { background: #2a2a2a; }

.btn-ghost {
  padding: 9px 20px;
  background: transparent; color: #171717;
  border: 1px solid rgba(0,0,0,0.12); border-radius: 2px;
  font-size: var(--pbs, 16px);
  font-family: var(--pbf, 'Inter'), sans-serif;
  cursor: pointer; letter-spacing: var(--pbls, 0em);
  transition: border-color 0.13s;
}

.btn-ghost:hover { border-color: rgba(0,0,0,0.3); }

/* Right */
.article-aside {
  width: 202px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 24px;
}

/* Font Specs */
.font-specs-widget {
  background: #f3f3f3; border-radius: 4px;
  padding: 18px; display: flex; flex-direction: column; gap: 8px;
}

.widget-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: #737373;
  font-family: var(--pbf, 'Inter'), sans-serif;
}

.specs-sublabel {
  font-size: 10px; font-weight: 600; color: #a3a3a3;
  font-family: var(--pbf, 'Inter'), sans-serif; letter-spacing: 0.02em;
}

.spec-divider { height: 1px; background: #e5e5e5; margin: 2px 0; }

.spec-list { display: flex; flex-direction: column; gap: 5px; }

.spec-item {
  display: flex; justify-content: space-between; align-items: center; gap: 5px;
}

.spec-key {
  font-size: 10px; color: #a3a3a3;
  font-family: var(--pbf, 'Inter'), sans-serif; white-space: nowrap; flex-shrink: 0;
}

.spec-val {
  font-size: 10px; font-weight: 600; color: #1a1c1c;
  font-family: var(--pbf, 'Inter'), sans-serif;
  text-align: right; word-break: break-all;
}

.spec-color-row { display: flex; align-items: center; gap: 4px; }

.spec-color-dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1); flex-shrink: 0;
}

/* Thumbnail */
.thumbnail-widget { display: flex; flex-direction: column; gap: 6px; }

.thumbnail-img {
  width: 100%; height: 110px; border-radius: 2px;
  background:
    repeating-linear-gradient(-32deg,
      transparent 0px, transparent 18px,
      rgba(255,255,255,0.1) 18px, rgba(255,255,255,0.1) 19px),
    linear-gradient(140deg, #d2d2d2 0%, #bdbdbd 100%);
}

.thumbnail-caption {
  font-size: 10px; color: #a3a3a3; line-height: 1.55;
  font-family: var(--pbf, 'Inter'), sans-serif;
  letter-spacing: var(--pbls, 0em);
}

/* ════════════════════════════════════════════
   DARK THEME
   ════════════════════════════════════════════ */
.main.dark-bg { background: #1a1a1a; }
.main.dark-bg .preview-breadcrumb { color: #555; }
.main.dark-bg .topbar-randomize-btn {
  color: #888; border-color: #3a3a3a; background: transparent;
}
.main.dark-bg .topbar-randomize-btn:hover {
  background: #f0f0f0; color: #0a0a0a; border-color: #f0f0f0;
}

.preview-card.dark {
  background: #1c1c1c;
  border-color: rgba(80,80,80,0.2);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}

.preview-card.dark .card-hero { background: #2c2c2c; }

/* Darken the hero image slightly in dark mode */
.preview-card.dark .hero-img { filter: brightness(0.65) saturate(0.7); }

.preview-card.dark .hero-readability {
  background: linear-gradient(to top,
    rgba(28,28,28,0.97) 0%,
    rgba(28,28,28,0.6) 42%,
    transparent 100%);
}

/* Force readable title in dark mode regardless of user color */
.preview-card.dark .hero-text .article-title { color: #f0f0f0 !important; }

.preview-card.dark .article-text { color: var(--pbc, #b4b4b4); }

.preview-card.dark .article-actions { border-top-color: rgba(255,255,255,0.08); }

.preview-card.dark .btn-primary { background: #ebebeb; color: #0a0a0a; }
.preview-card.dark .btn-primary:hover { background: #d5d5d5; }
.preview-card.dark .btn-ghost { color: #c8c8c8; border-color: rgba(255,255,255,0.14); }

.preview-card.dark .font-specs-widget { background: #2a2a2a; }
.preview-card.dark .widget-label   { color: #555; }
.preview-card.dark .specs-sublabel { color: #484848; }
.preview-card.dark .spec-key       { color: #484848; }
.preview-card.dark .spec-val       { color: #d8d8d8; }
.preview-card.dark .spec-divider   { background: #383838; }
.preview-card.dark .spec-color-dot { border-color: rgba(255,255,255,0.15); }
.preview-card.dark .thumbnail-img {
  background:
    repeating-linear-gradient(-32deg,
      transparent 0px, transparent 18px,
      rgba(255,255,255,0.04) 18px, rgba(255,255,255,0.04) 19px),
    linear-gradient(140deg, #3a3a3a 0%, #252525 100%);
}
.preview-card.dark .thumbnail-caption { color: #484848; }

/* ── Flash card ───────────────────────── */
.preview-card.changing { opacity: 0.72; transition: opacity 0.12s; }

/* ════════════════════════════════════════════
   HERO TINT OVERLAY
   ════════════════════════════════════════════ */
.hero-tint {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.22);
  z-index: 1;
  transition: background 0.3s;
}

.preview-card.dark .hero-tint {
  background: rgba(0, 0, 0, 0.45);
}

/* ════════════════════════════════════════════
   HERO IMAGE CONTROLS  (sidebar)
   ════════════════════════════════════════════ */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  background: #f7f7f7;
  border: 1px dashed #d0d0d0;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 500;
  color: #5a5a5a;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  margin-bottom: 8px;
}

.upload-btn:hover {
  background: #f0f0f0;
  border-color: #b0b0b0;
  color: #0a0a0a;
}

.upload-btn input[type="file"] {
  display: none;
}

/* Preset image thumbnails */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.preset-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.13s, opacity 0.13s, transform 0.12s;
  padding: 0;
  overflow: hidden;
}

.preset-thumb:hover {
  opacity: 0.85;
  transform: scale(1.04);
}

.preset-thumb.active {
  border-color: #0a0a0a;
}

/* ── Toast ────────────────────────────── */
.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #0a0a0a; color: #fff;
  padding: 9px 18px; border-radius: 100px;
  font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 7px;
  box-shadow: 0 4px 22px rgba(0,0,0,0.22);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 9999; pointer-events: none; white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ════════════════════════════════════════════
   RIGHT SIDEBAR  (preview text editor)
   ════════════════════════════════════════════ */
.right-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #ebebeb;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}

.right-sidebar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  color: #b0b0b0;
}

.rsb-title {
  font-size: 13px;
  font-weight: 700;
  color: #0a0a0a;
  letter-spacing: -0.2px;
  flex: 1;
}

.right-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px 20px;
}

.right-sidebar-body::-webkit-scrollbar { width: 3px; }
.right-sidebar-body::-webkit-scrollbar-thumb { background: #e8e8e8; border-radius: 2px; }

/* Text editor textarea */
.text-editor {
  width: 100%;
  border: 1px solid #e8e8e8;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.6;
  color: #0a0a0a;
  background: #f7f7f7;
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.13s, background 0.13s;
  min-height: 64px;
}

.text-editor:focus {
  border-color: #0a0a0a;
  background: #fff;
}

.text-editor::placeholder { color: #d0d0d0; }

/* ── Mobile text editor button ─────────── */
.mobile-text-btn {
  display: none;
  align-items: center; gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid #d0d0d0;
  border-radius: 7px;
  font-size: 12px; font-weight: 600; color: #555;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  flex-shrink: 0;
}

.mobile-text-btn:hover { background: #0a0a0a; color: #fff; border-color: #0a0a0a; }

.main.dark-bg .mobile-text-btn {
  color: #888; border-color: #3a3a3a;
}
.main.dark-bg .mobile-text-btn:hover {
  background: #f0f0f0; color: #0a0a0a; border-color: #f0f0f0;
}

/* ════════════════════════════════════════════
   MOBILE SIDEBAR CONTROLS
   ════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

.sidebar-close-btn {
  display: none;
  background: none; border: none;
  color: #b0b0b0; cursor: pointer; padding: 2px;
  margin-left: auto; flex-shrink: 0;
  transition: color 0.13s;
}

.sidebar-close-btn:hover { color: #0a0a0a; }

.mobile-menu-btn {
  display: none;
  align-items: center; gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid #d0d0d0;
  border-radius: 7px;
  font-size: 12px; font-weight: 600; color: #555;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  flex-shrink: 0;
}

.mobile-menu-btn:hover { background: #0a0a0a; color: #fff; border-color: #0a0a0a; }

/* Dark mode mobile button */
.main.dark-bg .mobile-menu-btn {
  color: #888; border-color: #3a3a3a;
}
.main.dark-bg .mobile-menu-btn:hover {
  background: #f0f0f0; color: #0a0a0a; border-color: #f0f0f0;
}

/* ════════════════════════════════════════════
   RESPONSIVE — TABLET  (≤ 1024px)
   ════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .main { padding: 40px 32px; }
  .card-content { padding: 44px 36px 56px; }
  .hero-text { padding: 0 36px 36px; }
  .article-title { font-size: min(var(--phs, 64px), 48px); }
  /* Right sidebar hides at tablet — accessed via "Edit Text" button */
  .right-sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s;
    z-index: 100;
  }
  .right-sidebar.open {
    transform: translateX(0);
    box-shadow: -6px 0 40px rgba(0,0,0,0.15);
  }
  .right-sidebar .sidebar-close-btn { display: flex; align-items: center; }
  .mobile-text-btn { display: flex; }
}

/* ════════════════════════════════════════════
   RESPONSIVE — MOBILE  (≤ 768px)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* App shell — let main scroll naturally */
  .app { height: auto; min-height: 100vh; overflow: visible; }

  /* Sidebar becomes a fixed slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 300px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s;
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 40px rgba(0,0,0,0.2);
  }

  .sidebar-close-btn { display: flex; align-items: center; }
  .mobile-menu-btn   { display: flex; }
  .mobile-text-btn   { display: flex; }

  /* Right sidebar — already fixed from tablet rule, just ensure it's there */
  .right-sidebar { width: 90vw; max-width: 320px; }

  /* Topbar */
  .preview-topbar { gap: 8px; }
  .preview-breadcrumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Main area */
  .main { width: 100%; padding: 20px 16px 48px; }
  .main-inner { max-width: 100%; }

  /* Hero */
  .card-hero { height: 220px; }
  .hero-text { padding: 0 20px 24px; }
  .article-title { font-size: min(var(--phs, 64px), 36px); }

  /* Card body */
  .card-content { padding: 28px 20px 40px; }

  /* Stack article grid */
  .article-grid { flex-direction: column; gap: 28px; }
  .article-aside { width: 100%; }

  /* Spec widget: two columns side-by-side */
  .font-specs-widget {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    align-items: start;
  }
  .font-specs-widget .widget-label { grid-column: 1 / -1; margin-bottom: 0; }
  .font-specs-widget .specs-sublabel { margin-top: 0 !important; }

  /* Preset thumbnails: 4 per row on mobile */
  .preset-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE  (≤ 480px)
   ════════════════════════════════════════════ */
@media (max-width: 480px) {
  .main { padding: 14px 12px 40px; }

  /* Topbar: hide breadcrumb to save space */
  .preview-breadcrumb { display: none; }

  /* Hero */
  .card-hero { height: 170px; }
  .hero-text { padding: 0 14px 20px; }
  .article-title { font-size: min(var(--phs, 64px), 26px); }

  /* Card body */
  .card-content { padding: 22px 14px 32px; }

  /* Spec widget: single column */
  .font-specs-widget { grid-template-columns: 1fr; }

  /* Thumbnail hidden on small screens */
  .thumbnail-widget { display: none; }

  /* Sidebar full width on very small screens */
  .sidebar { width: 100%; }
}
