/* ==========================================================================
   Markdown Files Viewer - Public Editorial Stylesheet
   Content-first editorial layout, rich typography, MathML & GFM callouts,
   responsive mobile navigation drawer, Studio view modes, and clean A4 print.
   ========================================================================== */

:root {
  --font-editorial: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13.5px;
  --text-lg: 14.5px;

  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 10px;
  --space-6: 12px;
  --space-7: 14px;
  --space-8: 16px;

  --color-canvas-default: #FFFFFF;
  --color-canvas-subtle: #F6F8FA;
  --color-canvas-inset: #F1F5F9;
  --color-border-default: #D0D7DE;
  --color-border-subtle: #E2E8F0;
  --color-border-muted: #CBD5E1;

  --color-fg-default: #1F2328;
  --color-fg-muted: #59636E;
  --color-fg-subtle: #6E7781;

  --color-accent-emphasis: #0969DA;
  --color-accent-fg: #2F81F7;
  --color-accent-subtle: rgba(9, 105, 218, 0.08);
  --color-danger-fg: #D1242F;

  --color-prettylights-syntax-markup-inserted-text: #116329;
  --color-prettylights-syntax-markup-inserted-bg: #DAFBE1;
  --color-prettylights-syntax-markup-deleted-bg: #FFEBE9;

  --shadow-sm: 0px 2px 8px 0px rgba(0, 0, 0, 0.03);
  --shadow-md: 0px 6px 18px 0px rgba(9, 105, 218, 0.11);
  --shadow-xl: 0px 10px 32px 0px rgba(15, 23, 42, 0.07), 0px 2px 8px 0px rgba(15, 23, 42, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --header-height: 56px;
}

[data-theme="dark"] {
  --color-canvas-default: #0D1117;
  --color-canvas-subtle: #161B22;
  --color-canvas-inset: #010409;
  --color-border-default: #30363D;
  --color-border-subtle: #21262D;
  --color-border-muted: #484F58;

  --color-fg-default: #E6EDF3;
  --color-fg-muted: #8B949E;
  --color-fg-subtle: #7D8590;

  --color-accent-emphasis: #2F81F7;
  --color-accent-subtle: rgba(56, 139, 253, 0.15);
  --color-prettylights-syntax-markup-inserted-bg: rgba(46, 160, 67, 0.16);
  --color-prettylights-syntax-markup-inserted-text: #3FB950;
  --color-prettylights-syntax-markup-deleted-bg: rgba(248, 81, 73, 0.16);
  --color-danger-fg: #F85149;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--color-fg-default);
  background-color: var(--color-canvas-default);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-accent-emphasis);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Sticky Editorial Header
   ========================================================================== */
.editorial-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--color-canvas-default);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  z-index: 1000;
  user-select: none;
}

.editorial-brand-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.editorial-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none !important;
  color: var(--color-fg-default);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.editorial-logo-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.editorial-logo-icon img.uploaded-brand-logo {
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
}

.header-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-fg-muted);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  text-decoration: none !important;
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: var(--font-ui);
}
.header-nav-link:hover, .header-nav-link.active {
  background: var(--color-canvas-subtle);
  color: var(--color-fg-default);
}
.header-nav-link.active {
  color: var(--color-accent-emphasis);
  font-weight: 600;
}

.header-nav-dropdown-wrap {
  position: relative;
}

.dropdown-caret {
  font-size: 10px;
  color: var(--color-fg-muted);
  margin-left: 2px;
}

.header-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 275px;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 6px;
  margin-top: 2px;
  z-index: 1050;
}

.header-nav-dropdown-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 8px;
}

.header-nav-dropdown-wrap:hover .header-dropdown-menu,
.header-nav-dropdown-wrap:focus-within .header-dropdown-menu {
  display: block;
}

.header-dropdown-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  transition: background 0.14s ease;
}
.header-dropdown-item:hover {
  background: var(--color-canvas-subtle);
}
.hdi-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-fg-default);
}
.hdi-desc {
  font-size: 11px;
  color: var(--color-fg-muted);
  margin-top: 2px;
}

.editorial-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-divider-v {
  width: 1px;
  height: 20px;
  background: var(--color-border-subtle);
}

/* Editorial Buttons */
.editorial-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: var(--font-ui);
  border: 1px solid var(--color-border-default);
  background: var(--color-canvas-default);
  color: var(--color-fg-default);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  text-decoration: none !important;
}
.editorial-btn:hover {
  background: var(--color-canvas-subtle);
  border-color: var(--color-border-muted);
}
.editorial-btn-sm {
  padding: 5px 10px;
  font-size: var(--text-sm);
}
.editorial-btn-xs {
  padding: 4px 9px;
  font-size: var(--text-sm);
}
.editorial-btn-primary {
  background: var(--color-accent-emphasis);
  color: #FFFFFF !important;
  border-color: var(--color-accent-emphasis);
}
.editorial-btn-primary:hover {
  filter: brightness(0.93);
  background: var(--color-accent-emphasis);
}
.header-btn-icon-only {
  width: 34px;
  height: 34px;
  padding: 0;
}

/* Mobile Hamburger Toggle & Slide-Out Drawer (Collapsed & Expanded States) */
.mobile-hamburger-btn {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.mobile-hamburger-btn[aria-expanded="true"] {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent-emphasis);
}

.hamburger-bars {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  width: 17px;
  height: 13px;
}

.hamburger-bars span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--color-fg-default);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease, background 0.15s ease;
}

.mobile-hamburger-btn[aria-expanded="true"] .hamburger-bars span {
  background: var(--color-accent-emphasis);
}
.mobile-hamburger-btn[aria-expanded="true"] .hamburger-bars span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}
.mobile-hamburger-btn[aria-expanded="true"] .hamburger-bars span:nth-child(2) {
  opacity: 0;
}
.mobile-hamburger-btn[aria-expanded="true"] .hamburger-bars span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
  z-index: 1490;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.mobile-nav-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 90vw);
  height: 100dvh;
  max-height: 100vh;
  background: var(--color-canvas-default);
  border-left: 1px solid var(--color-border-default);
  box-shadow: var(--shadow-xl);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
}
.mobile-nav-drawer.open {
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

@media (min-width: 961px) {
  .mobile-nav-drawer,
  .mobile-nav-backdrop {
    display: none !important;
  }
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-canvas-subtle);
  flex-shrink: 0;
}
.mobile-drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.mobile-drawer-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.mobile-drawer-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-fg-default);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-drawer-subtitle {
  font-size: 11px;
  color: var(--color-fg-muted);
  margin-top: 1px;
}
.mobile-drawer-close-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 14px;
  flex-shrink: 0;
}

.mobile-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-nav-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mobile-nav-top-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-fg-default);
  background: var(--color-canvas-subtle);
  border: 1px solid var(--color-border-subtle);
  text-decoration: none !important;
  transition: all 0.15s ease;
}
.mobile-nav-top-link:hover,
.mobile-nav-top-link.active {
  border-color: var(--color-accent-emphasis);
  color: var(--color-accent-emphasis);
  background: var(--color-accent-subtle);
}

.mobile-nav-accordion {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-canvas-default);
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.mobile-nav-accordion[open],
.mobile-nav-accordion.has-active-route {
  border-color: var(--color-border-default);
}
.mobile-nav-accordion[open] {
  box-shadow: var(--shadow-sm);
}

.mobile-nav-accordion summary {
  min-height: 46px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-fg-default);
  background: var(--color-canvas-subtle);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.mobile-nav-accordion summary::-webkit-details-marker {
  display: none;
}
.mobile-nav-accordion[open] summary {
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-accent-emphasis);
}

.mna-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mna-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--color-accent-subtle);
  color: var(--color-accent-emphasis);
  flex-shrink: 0;
}
.mna-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mna-summary-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.mna-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-fg-muted);
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-subtle);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}
.mna-chevron {
  font-size: 11px;
  color: var(--color-fg-muted);
  transition: transform 0.18s ease;
}
.mobile-nav-accordion[open] .mna-chevron {
  transform: rotate(180deg);
  color: var(--color-accent-emphasis);
}

.mobile-nav-accordion:not([open]) .mobile-nav-sublist {
  display: none;
}

.mobile-nav-sublist {
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 2px;
  background: var(--color-canvas-default);
}
.mobile-nav-sublist a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-fg-muted);
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  transition: background 0.14s ease, color 0.14s ease;
}
.mobile-nav-sublist a::after {
  content: "›";
  font-size: 14px;
  opacity: 0.45;
}
.mobile-nav-sublist a:hover {
  background: var(--color-canvas-subtle);
  color: var(--color-fg-default);
}
.mobile-nav-sublist a.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent-emphasis);
  font-weight: 600;
}
.mobile-nav-sublist a.active::after {
  opacity: 1;
}

.mobile-drawer-footer {
  flex-shrink: 0;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-canvas-subtle);
}

.mobile-nav-trust-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-nav-trust-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-fg-muted);
  text-decoration: none !important;
}
.mobile-nav-trust-links a:hover,
.mobile-nav-trust-links a.active {
  border-color: var(--color-accent-emphasis);
  color: var(--color-accent-emphasis);
  background: var(--color-accent-subtle);
}

.page-body-container {
  flex: 1;
  width: 100%;
}

/* ==========================================================================
   Homepage Hero & Studio
   ========================================================================== */
.homepage-view {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.homepage-hero {
  padding: 52px 24px 38px;
  text-align: center;
  background: linear-gradient(180deg, var(--color-canvas-subtle) 0%, var(--color-canvas-default) 100%);
  border-bottom: 1px solid var(--color-border-subtle);
}

.hero-inner-container {
  max-width: 840px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent-emphasis);
  background: var(--color-accent-subtle);
  border: 1px solid rgba(9, 105, 218, 0.2);
  margin-bottom: 18px;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16A34A;
}

.hero-title {
  font-family: var(--font-editorial);
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--color-fg-default);
  line-height: 1.15;
  margin-bottom: 14px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--color-fg-muted);
  line-height: 1.6;
  max-width: 660px;
  margin-bottom: 14px;
}

.editorial-byline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--color-fg-muted);
}
.editorial-byline a {
  font-weight: 600;
  color: var(--color-fg-default);
}
.editorial-byline a:hover {
  color: var(--color-accent-emphasis);
}
.tool-view-title-group .editorial-byline {
  justify-content: flex-start;
  margin-top: 10px;
}

.hero-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.hero-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-fg-muted);
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-default);
  text-decoration: none !important;
  transition: all 0.15s ease;
}
.hero-chip:hover, .hero-chip-highlight {
  color: var(--color-accent-emphasis);
  border-color: var(--color-accent-emphasis);
  background: var(--color-accent-subtle);
}

/* Studio Card & Zen Fullscreen */
.homepage-studio-section {
  padding: 32px 24px 48px;
  max-width: 1380px;
  margin: 0 auto;
  width: 100%;
}

.studio-container-card {
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-canvas-default);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.studio-container-card.zen-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  border-radius: 0;
  border: none;
  height: 100vh;
}
.studio-container-card.zen-fullscreen .studio-split-frame {
  flex: 1;
  height: auto;
}

.studio-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--color-canvas-default);
  border-bottom: 1px solid var(--color-border-subtle);
  gap: 12px;
  flex-wrap: wrap;
}

.studio-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.editorial-doc-title {
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-fg-default);
  border-radius: var(--radius-sm);
  outline: none;
  min-width: 200px;
  max-width: 340px;
  transition: all 0.15s ease;
}
.editorial-doc-title:hover {
  border-color: var(--color-border-subtle);
  background: var(--color-canvas-subtle);
}
.editorial-doc-title:focus {
  border-color: var(--color-accent-emphasis);
  background: var(--color-canvas-default);
}

.save-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-fg-muted);
}
.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16A34A;
}
.save-dot.unsaved {
  background: #D97706;
}

/* Segmented View Mode Switcher */
.studio-view-modes {
  display: inline-flex;
  align-items: center;
  background: var(--color-canvas-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-fg-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: all 0.14s ease;
}
.view-mode-btn:hover {
  color: var(--color-fg-default);
}
.view-mode-btn.active {
  background: var(--color-canvas-default);
  color: var(--color-accent-emphasis);
  box-shadow: var(--shadow-sm);
}

.studio-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dropdown Menus */
.dropdown-wrapper {
  position: relative;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 230px;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 5px;
  z-index: 1100;
}
.dropdown-menu.show {
  display: block;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 11px;
  font-size: 12.5px;
  font-family: var(--font-ui);
  color: var(--color-fg-default);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  text-decoration: none !important;
}
.dropdown-item:hover, .dropdown-item.active {
  background: var(--color-canvas-subtle);
}
.dropdown-item.active {
  color: var(--color-accent-emphasis);
  font-weight: 600;
}
.dropdown-divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: 4px 0;
}

.doc-quick-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.doc-quick-delete-btn {
  background: none;
  border: none;
  color: var(--color-fg-subtle);
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.doc-quick-delete-btn:hover {
  color: var(--color-danger-fg);
  background: var(--color-prettylights-syntax-markup-deleted-bg);
}

/* Formatting Toolbar */
.format-toolbar {
  height: 38px;
  background: var(--color-canvas-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 3px;
  overflow-x: auto;
  user-select: none;
}
.format-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 5px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--color-fg-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
}
.format-btn:hover {
  background: var(--color-canvas-default);
  color: var(--color-fg-default);
  box-shadow: var(--shadow-sm);
}
.format-toolbar-separator {
  width: 1px;
  height: 16px;
  background: var(--color-border-subtle);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Split Monaco & Preview */
.studio-split-frame {
  height: 560px;
  width: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}

.column {
  height: 100%;
  overflow: hidden;
  position: relative;
}

.editor-pane {
  width: 50%;
  background: var(--color-canvas-default);
}

#editor-wrapper, #editor {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.editor-drop-overlay {
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--color-accent-emphasis);
  border-radius: var(--radius-md);
  background: rgba(9, 105, 218, 0.1);
  color: var(--color-accent-emphasis);
  font-weight: 700;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
}
.editor-drop-overlay.visible {
  display: flex;
}

.split-divider {
  width: 6px;
  background: var(--color-border-subtle);
  cursor: col-resize;
  position: relative;
  z-index: 20;
  transition: background 0.15s ease;
}
.split-divider:hover, .split-divider.active {
  background: var(--color-accent-emphasis);
}

.preview-pane {
  width: 50%;
  background: var(--color-canvas-subtle);
  overflow-y: auto;
}

#preview-wrapper {
  padding: 26px 32px;
  max-width: 860px;
  margin: 0 auto;
}

.markdown-body {
  background: transparent !important;
  color: var(--color-fg-default) !important;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.markdown-body img,
.markdown-body svg {
  max-width: 100%;
  height: auto;
}
.markdown-body pre,
.markdown-body table {
  max-width: 100%;
  overflow-x: auto;
}

/* Demoted Preview H1 (Preserves GFM H1 visual hierarchy while keeping strictly 1 host <h1>) */
.markdown-body .md-preview-h1 {
  font-size: 2em;
  font-weight: 600;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--color-border-default);
  margin-top: 24px;
  margin-bottom: 16px;
  line-height: 1.25;
}
.markdown-body .md-preview-h1:first-child {
  margin-top: 0;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--color-border-default);
  background: var(--color-canvas-default);
  color: var(--color-fg-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

/* Native MathML, Callout Alerts, Frontmatter & Highlights */
.mv-math-block {
  display: block;
  text-align: center;
  margin: 18px 0;
  padding: 10px 14px;
  overflow-x: auto;
  font-size: 1.18em;
}
.mv-math-inline {
  display: inline-block;
  padding: 0 2px;
}

.mv-callout {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--color-accent-emphasis);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--color-accent-subtle);
}
.mv-callout-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  margin-bottom: 4px;
  color: var(--color-fg-default);
}
.mv-callout-body p:last-child {
  margin-bottom: 0;
}
.mv-callout-tip { border-left-color: #16A34A; background: rgba(22, 163, 74, 0.09); }
.mv-callout-important { border-left-color: #8250DF; background: rgba(130, 80, 223, 0.09); }
.mv-callout-warning { border-left-color: #D97706; background: rgba(217, 119, 6, 0.1); }
.mv-callout-caution { border-left-color: #D1242F; background: rgba(209, 36, 47, 0.1); }

.mv-frontmatter-card {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
  background: var(--color-canvas-inset);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.mv-fm-pill {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-subtle);
}
.mv-tag-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-accent-subtle);
  color: var(--color-accent-emphasis);
}
.markdown-body mark {
  background: rgba(250, 204, 21, 0.4);
  color: inherit;
  padding: 1px 4px;
  border-radius: 3px;
}

.mermaid-error {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--color-prettylights-syntax-markup-deleted-bg);
  color: var(--color-danger-fg);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Status Bar */
.studio-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--color-canvas-default);
  border-top: 1px solid var(--color-border-subtle);
  font-size: 12px;
  color: var(--color-fg-muted);
  user-select: none;
  flex-wrap: wrap;
  gap: 8px;
}
.statusbar-left, .statusbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-sep {
  color: var(--color-border-muted);
}
.sync-scroll-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* ==========================================================================
   Homepage Tool Grids, Pillars & Visible FAQ
   ========================================================================== */
.homepage-category-section {
  padding: 48px 24px;
  max-width: 1380px;
  margin: 0 auto;
  width: 100%;
  border-top: 1px solid var(--color-border-subtle);
}

.category-header {
  margin-bottom: 28px;
}

.category-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent-emphasis);
  background: var(--color-accent-subtle);
  padding: 3px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

.category-title {
  font-family: var(--font-editorial);
  font-size: 30px;
  font-weight: 700;
  color: var(--color-fg-default);
  letter-spacing: -0.015em;
}

.category-description {
  font-size: 15px;
  color: var(--color-fg-muted);
  margin-top: 6px;
  max-width: 720px;
}

.tools-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 18px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  text-decoration: none !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.tool-card:hover {
  border-color: var(--color-accent-emphasis);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-icon {
  font-size: 24px;
  margin-bottom: 12px;
}

.tool-card-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--color-fg-default);
  margin-bottom: 8px;
}

.tool-card-desc {
  font-size: 13px;
  color: var(--color-fg-muted);
  line-height: 1.55;
  flex: 1;
  margin-bottom: 16px;
}

.tool-card-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent-emphasis);
}

.homepage-pillars-section {
  background: var(--color-canvas-subtle);
  border-top: 1px solid var(--color-border-subtle);
  padding: 56px 24px;
}

.pillars-container, .faq-inner-container {
  max-width: 1240px;
  margin: 0 auto;
}

.pillars-header {
  text-align: center;
  margin-bottom: 40px;
}
.pillars-header h2 {
  font-family: var(--font-editorial);
  font-size: 32px;
  font-weight: 700;
  color: var(--color-fg-default);
}
.pillars-header p {
  font-size: 15px;
  color: var(--color-fg-muted);
  margin-top: 8px;
}

.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 24px;
}

.pillar-card {
  padding: 28px;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}
.pillar-icon {
  font-size: 28px;
  margin-bottom: 14px;
}
.pillar-card h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-fg-default);
  margin-bottom: 8px;
}
.pillar-card p {
  font-size: 13.5px;
  color: var(--color-fg-muted);
  line-height: 1.6;
}

.homepage-faq-section {
  padding: 56px 24px;
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-canvas-default);
}

/* ==========================================================================
   Global Footer (Clean Editorial 4-Column Layout)
   ========================================================================== */
.site-footer {
  background: var(--color-canvas-subtle);
  border-top: 1px solid var(--color-border-subtle);
  padding: 48px 24px 32px;
}

.footer-container {
  max-width: 1380px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 36px;
}

.footer-freshness {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--color-fg-subtle);
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.footer-brand-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-fg-default);
}
.footer-bio {
  font-size: 13px;
  color: var(--color-fg-muted);
  line-height: 1.65;
  max-width: 360px;
}

.footer-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-fg-muted);
  margin-bottom: 14px;
}

.footer-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-nav-list a {
  font-size: 13px;
  color: var(--color-fg-muted);
  text-decoration: none;
}
.footer-nav-list a:hover {
  color: var(--color-accent-emphasis);
}

.footer-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 22px;
  border-top: 1px solid var(--color-border-subtle);
  font-size: 12.5px;
  color: var(--color-fg-muted);
  flex-wrap: wrap;
  gap: 16px;
}
.footer-bottom-links {
  display: flex;
  align-items: center;
  gap: 12px;
}
.footer-bottom-links a {
  color: var(--color-fg-muted);
}
.footer-bottom-links a:hover {
  color: var(--color-accent-emphasis);
}

/* ==========================================================================
   Dedicated Tool Views
   ========================================================================== */
.tool-page-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tool-view-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  width: 100%;
}

.tool-page-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  gap: 12px;
}

.tool-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--color-fg-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.tool-breadcrumbs a,
.bc-cat,
.bc-sep {
  color: var(--color-fg-muted);
  flex-shrink: 0;
}
.bc-sep {
  color: var(--color-border-muted);
}
.bc-current {
  font-weight: 600;
  color: var(--color-fg-default);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-back-studio-btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.back-label-mobile {
  display: none;
}

.tool-view-header {
  margin-bottom: 24px;
}
.tool-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-accent-emphasis);
  background: var(--color-accent-subtle);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: 8px;
}
.tool-view-title-group h1 {
  font-family: var(--font-editorial);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-fg-default);
}
.tool-view-title-group p {
  font-size: 15px;
  color: var(--color-fg-muted);
  margin-top: 6px;
  max-width: 740px;
}

.tool-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  min-height: 480px;
  margin-bottom: 32px;
}

.tool-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-canvas-default);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.tool-panel-bar {
  padding: 9px 14px;
  background: var(--color-canvas-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--color-fg-muted);
  font-weight: 600;
  flex-wrap: wrap;
}

.tool-textarea {
  flex: 1;
  width: 100%;
  padding: 16px;
  border: none;
  background: var(--color-canvas-default);
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--color-fg-default);
  outline: none;
  resize: vertical;
  line-height: 1.6;
  min-height: 390px;
}
.tool-textarea.code-font {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.tool-textarea.content-editable {
  overflow-y: auto;
}

.pdf-preview-canvas, .word-preview-box {
  flex: 1;
  padding: 26px;
  background: var(--color-canvas-default);
  overflow-y: auto;
  line-height: 1.65;
}

.social-card-stage {
  padding: 24px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-canvas-inset);
  overflow: auto;
}

.social-card-render {
  width: 100%;
  max-width: 620px;
  padding: 32px 36px;
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  line-height: 1.65;
}

.mindmap-stage {
  padding: 20px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: var(--color-canvas-subtle);
}
.mindmap-stage svg,
.mermaid-canvas svg {
  max-width: 100%;
  height: auto;
}

.tool-controls-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.social-card-render h1, .social-card-render h2 {
  margin-bottom: 12px;
}
.social-card-render p, .social-card-render ul {
  margin-bottom: 12px;
}

.slide-card {
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 18px;
  background: var(--color-canvas-default);
  box-shadow: var(--shadow-sm);
}
.slide-card-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--color-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.diff-split-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.diff-split-inputs .tool-textarea {
  min-height: 210px;
}
.diff-output-panel {
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-canvas-default);
}
.diff-result-view {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 14px;
  max-height: 400px;
  overflow-y: auto;
}
.diff-line {
  padding: 2px 8px;
  line-height: 1.45;
  white-space: pre-wrap;
  border-radius: 3px;
}
.diff-added {
  background: var(--color-prettylights-syntax-markup-inserted-bg);
  color: var(--color-prettylights-syntax-markup-inserted-text);
}
.diff-removed {
  background: var(--color-prettylights-syntax-markup-deleted-bg);
  color: var(--color-danger-fg);
}
.diff-same {
  color: var(--color-fg-muted);
}

.interactive-grid-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 12px;
  background: var(--color-canvas-default);
}
.interactive-grid-table th, .interactive-grid-table td {
  border: 1px solid var(--color-border-default);
  padding: 9px 12px;
  outline: none;
  min-width: 110px;
}
.interactive-grid-table tbody tr:first-child th {
  background: var(--color-canvas-subtle);
  font-weight: 700;
}
.table-editor-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.reader-view-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: 14px;
  margin-bottom: 32px;
  gap: 12px;
  flex-wrap: wrap;
}
.reader-editorial-article {
  font-family: var(--font-editorial);
  font-size: 18px;
  line-height: 1.82;
}

.mermaid-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}
.mermaid-template-selector {
  display: flex;
  gap: 8px;
}

.tool-faq-section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border-subtle);
}
.tool-faq-section h2 {
  font-family: var(--font-editorial);
  font-size: 26px;
  margin-bottom: 20px;
  color: var(--color-fg-default);
}
.tool-faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 18px;
}
.tool-faq-card {
  padding: 22px;
  background: var(--color-canvas-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}
.tool-faq-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-fg-default);
}
.tool-faq-card p {
  font-size: 13.5px;
  color: var(--color-fg-muted);
  line-height: 1.62;
}

/* Trust, Author, Legal & Support Page Styles */
.trust-doc-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.trust-doc-card {
  padding: 26px 28px;
  background: var(--color-canvas-default);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.trust-doc-card h2 {
  font-family: var(--font-editorial);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--color-fg-default);
}
.trust-doc-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-fg-default);
}
.trust-doc-card p {
  font-size: 14px;
  line-height: 1.68;
  color: var(--color-fg-muted);
}
.trust-doc-card p + p {
  margin-top: 10px;
}
.trust-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.trust-bullet-list {
  margin: 12px 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-fg-muted);
}
.author-profile-box {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 12px;
}
.author-avatar-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-accent-emphasis);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.author-role {
  font-size: 12.5px !important;
  font-weight: 600;
  color: var(--color-accent-emphasis) !important;
  margin-bottom: 8px;
}

/* Toast Notification */
.app-toast, .admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-fg-default);
  color: var(--color-canvas-default);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
}
.app-toast.show, .admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Responsive Breakpoints (Tablet <= 960px, Mobile <= 640px, Compact <= 420px)
   ========================================================================== */
@media (max-width: 1080px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 960px) {
  .header-nav-links {
    display: none;
  }
  .mobile-hamburger-btn {
    display: inline-flex;
  }
  .editorial-header {
    padding: 0 14px;
    gap: 10px;
  }
  .editorial-logo {
    white-space: nowrap;
  }
  .editorial-actions-right {
    gap: 6px;
    flex-shrink: 0;
  }
  .tool-split-grid,
  .diff-split-inputs {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .studio-split-frame {
    flex-direction: column;
    height: 620px;
  }
  .studio-split-frame[data-active-mode="editor"],
  .studio-split-frame[data-active-mode="preview"] {
    height: 480px;
  }
  .editor-pane,
  .preview-pane {
    width: 100% !important;
    height: 50%;
  }
  .studio-split-frame[data-active-mode="split"] .editor-pane {
    border-bottom: 1px solid var(--color-border-default);
  }
  .studio-split-frame[data-active-mode="editor"] .editor-pane,
  .studio-split-frame[data-active-mode="preview"] .preview-pane {
    height: 100%;
  }
  .split-divider {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .header-divider-v {
    display: none;
  }
  #lang-dropdown-trigger {
    padding: 5px 8px;
    font-size: 12px;
  }

  /* Hero & Bylines */
  .homepage-hero {
    padding: 30px 16px 24px;
  }
  .hero-badge-pill {
    font-size: 11px;
    padding: 5px 12px;
    text-align: center;
    line-height: 1.4;
  }
  .badge-dot {
    flex-shrink: 0;
  }
  .hero-title {
    font-size: 30px;
  }
  .hero-subtitle {
    font-size: 14.5px;
  }
  .editorial-byline {
    flex-direction: column;
    gap: 3px;
    text-align: center;
  }
  .tool-view-title-group .editorial-byline {
    align-items: flex-start;
    text-align: left;
  }
  .editorial-byline .byline-sep {
    display: none;
  }
  .hero-chips-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
  }
  .hero-chip {
    text-align: center;
    padding: 8px 10px;
  }

  /* Containers & Grids (Zero 320px Overflow) */
  .homepage-studio-section,
  .homepage-category-section,
  .homepage-pillars-section,
  .homepage-faq-section,
  .tool-view-container,
  .reader-view-container {
    padding: 24px 14px 36px;
  }
  .site-footer {
    padding: 36px 16px 26px;
  }
  .tools-card-grid,
  .pillars-grid,
  .tool-faq-grid,
  .trust-meta-grid,
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .category-title,
  .pillars-header h2,
  .tool-faq-section h2 {
    font-size: 23px;
  }

  /* Studio Topbar, View Switcher & Viewport-Safe Mobile Dropdowns */
  .studio-topbar {
    position: relative;
    padding: 10px 12px;
    gap: 10px;
  }
  .studio-topbar-left {
    width: 100%;
    min-width: 0;
  }
  .editorial-doc-title {
    min-width: 0;
    flex: 1;
    max-width: none;
    font-size: 16px;
  }
  .studio-view-modes {
    width: 100%;
    display: flex;
  }
  .studio-view-modes .view-mode-btn[data-view-mode] {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
  }
  .studio-topbar-right {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .studio-topbar-right .dropdown-wrapper {
    position: static;
  }
  .studio-topbar-right .editorial-btn {
    width: 100%;
    padding: 6px 4px;
    font-size: 11.5px;
    gap: 4px;
  }
  .studio-topbar-right .dropdown-menu {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    top: calc(100% - 4px);
  }
  .format-toolbar {
    height: 42px;
    padding: 0 10px;
    scrollbar-width: none;
  }
  .format-toolbar::-webkit-scrollbar {
    display: none;
  }
  .format-btn {
    flex-shrink: 0;
    min-width: 32px;
    height: 30px;
  }
  #preview-wrapper {
    padding: 16px;
  }
  .studio-statusbar {
    padding: 8px 12px;
    font-size: 11.5px;
  }
  .statusbar-left {
    flex-wrap: wrap;
    row-gap: 4px;
    gap: 7px;
  }

  /* Mobile Adapted Breadcrumbs */
  .tool-page-nav-bar {
    padding: 8px 11px;
    margin-bottom: 18px;
    background: var(--color-canvas-subtle);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    gap: 8px;
  }
  .tool-breadcrumbs {
    font-size: 12px;
    gap: 5px;
  }
  .bc-cat {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .back-label-desktop {
    display: none;
  }
  .back-label-mobile {
    display: inline;
  }
  .tool-back-studio-btn {
    padding: 4px 8px;
    font-size: 11.5px;
  }

  /* Tool Headers, Textareas & Cards */
  .tool-view-title-group h1 {
    font-size: 24px;
    line-height: 1.24;
  }
  .tool-view-title-group p {
    font-size: 14px;
  }
  .tool-textarea {
    min-height: 230px;
    font-size: 16px;
    padding: 14px;
  }
  .tool-textarea.code-font {
    font-size: 13px;
  }
  .pdf-preview-canvas,
  .word-preview-box {
    padding: 16px;
  }
  .social-card-stage,
  .mindmap-stage,
  .mermaid-canvas {
    padding: 14px;
  }
  .social-card-render {
    padding: 20px 16px;
    border-radius: 10px;
  }
  .tool-controls-actions {
    margin-left: 0;
    width: 100%;
  }
  .tool-controls-actions .editorial-btn {
    flex: 1;
  }
  .reader-editorial-article {
    font-size: 16.5px;
    line-height: 1.75;
  }
  .trust-doc-card {
    padding: 18px 16px;
  }
  .author-profile-box {
    flex-direction: column;
    gap: 12px;
  }
  .footer-bottom-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .footer-bottom-links {
    flex-wrap: wrap;
    gap: 8px 10px;
  }
  .app-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    text-align: center;
  }
}

@media (max-width: 400px) {
  .editorial-header {
    padding: 0 10px;
    gap: 6px;
  }
  .editorial-logo {
    font-size: 13.5px;
    gap: 6px;
  }
  .editorial-logo-icon {
    width: 24px;
    height: 24px;
  }
  .editorial-actions-right {
    gap: 4px;
  }
  #lang-dropdown-trigger {
    padding: 4px 6px;
    font-size: 11px;
  }
  .header-btn-icon-only,
  .mobile-hamburger-btn {
    width: 32px;
    height: 32px;
  }
  .bc-cat,
  .bc-sep-cat {
    display: none;
  }
}

/* ==========================================================================
   Clean A4 Print / Save-as-PDF Stylesheet (Zero Chrome Spillover)
   ========================================================================== */
@media print {
  @page {
    size: A4;
    margin: 18mm 16mm;
  }

  html, body {
    background: #FFFFFF !important;
    color: #000000 !important;
    overflow: visible !important;
  }

  .editorial-header,
  .mobile-nav-drawer,
  .mobile-nav-backdrop,
  .homepage-hero,
  .studio-topbar,
  .format-toolbar,
  .editor-pane,
  .split-divider,
  .studio-statusbar,
  .homepage-category-section,
  .homepage-pillars-section,
  .homepage-faq-section,
  .site-footer,
  .tool-page-nav-bar,
  .tool-view-header,
  .tool-input-panel,
  .tool-panel-bar,
  .tool-faq-section,
  .reader-toolbar,
  .code-copy-btn,
  .app-toast {
    display: none !important;
  }

  .homepage-studio-section,
  .studio-container-card,
  .studio-split-frame,
  .preview-pane,
  #preview-wrapper,
  .tool-view-container,
  .tool-split-grid,
  .tool-print-target-panel,
  .printable-surface {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    background: #FFFFFF !important;
  }

  pre, blockquote, table, .mv-callout {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .slide-card {
    break-after: page;
    page-break-after: always;
    border: 1px solid #CBD5E1 !important;
    padding: 24mm 16mm !important;
  }
}
