/* ==========================================================================
   Material Design 3 (M3 / Material You) Design System — FontMap Web UI
   Derived directly from Google's Material Design 3 Specification & Tokens
   Tonal containment over harsh borders, semantic hierarchy, accessible targets.
   ========================================================================== */

:root {
  /* Brand / Seed Accent */
  --md-ref-palette-primary: #3b82f6;

  /* M3 Dark Theme Color Roles (Default for FontMap) */
  --md-sys-color-primary: #a8c7fa;
  --md-sys-color-on-primary: #042a59;
  --md-sys-color-primary-container: #0842a0;
  --md-sys-color-on-primary-container: #d3e3fd;

  --md-sys-color-secondary: #7fcfff;
  --md-sys-color-on-secondary: #003355;
  --md-sys-color-secondary-container: #004a77;
  --md-sys-color-on-secondary-container: #c2e7ff;

  --md-sys-color-tertiary: #6dd58c;
  --md-sys-color-on-tertiary: #0a3818;
  --md-sys-color-tertiary-container: #0f5224;
  --md-sys-color-on-tertiary-container: #c4eed0;

  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;

  --md-sys-color-surface: #111318;
  --md-sys-color-on-surface: #e2e2e9;
  --md-sys-color-surface-variant: #44474f;
  --md-sys-color-on-surface-variant: #c4c7cf;

  /* Surface Container Hierarchy */
  --md-sys-color-surface-container-lowest: #0c0e13;
  --md-sys-color-surface-container-low: #191c20;
  --md-sys-color-surface-container: #1d2024;
  --md-sys-color-surface-container-high: #272a2f;
  --md-sys-color-surface-container-highest: #32353a;

  --md-sys-color-outline: #8e9199;
  --md-sys-color-outline-variant: #44474f;

  /* Shapes */
  --md-sys-shape-none: 0px;
  --md-sys-shape-extra-small: 4px;
  --md-sys-shape-small: 8px;
  --md-sys-shape-medium: 12px;
  --md-sys-shape-large: 16px;
  --md-sys-shape-extra-large: 28px;
  --md-sys-shape-full: 9999px;

  /* Elevations */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0 1px 3px 1px rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.30);
  --md-sys-elevation-2: 0 2px 6px 2px rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.30);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.15), 0 1px 3px 0 rgba(0, 0, 0, 0.30);
  --md-sys-elevation-4: 0 6px 10px 4px rgba(0, 0, 0, 0.15), 0 2px 3px 0 rgba(0, 0, 0, 0.30);
  --md-sys-elevation-5: 0 8px 12px 6px rgba(0, 0, 0, 0.15), 0 4px 4px 0 rgba(0, 0, 0, 0.30);

  /* Typography */
  --md-sys-typescale-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --md-sys-typescale-font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Legacy aliases for compatibility */
  --bg-app: var(--md-sys-color-surface);
  --bg-header: var(--md-sys-color-surface);
  --bg-sidebar: var(--md-sys-color-surface-container-low);
  --bg-card: var(--md-sys-color-surface-container);
  --bg-card-hover: var(--md-sys-color-surface-container-high);
  --bg-card-selected: var(--md-sys-color-primary-container);
  --bg-pill: var(--md-sys-color-surface-container-high);
  --bg-pill-active: var(--md-sys-color-secondary-container);

  --text-main: var(--md-sys-color-on-surface);
  --text-secondary: var(--md-sys-color-secondary);
  --text-muted: var(--md-sys-color-on-surface-variant);
  --text-dim: var(--md-sys-color-outline);
  --text-accent: var(--md-sys-color-primary);
  --accent: var(--md-sys-color-primary);

  --font-inspected: system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-font-family);
  font-size: 14px;
  line-height: 20px;
}

.font-mono {
  font-family: var(--md-sys-typescale-font-mono);
}

/* App Scaffold */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background-color: var(--md-sys-color-surface);
}

/* ==========================================================================
   5.1 Top App Bar (M3 Specification: 64px, Tonal Surface, Accessible 48px Targets)
   ========================================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 16px;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-bottom: 1px solid var(--md-sys-color-surface-container-high);
  box-shadow: var(--md-sys-elevation-1);
  flex-shrink: 0;
  gap: 16px;
  z-index: 20;
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  letter-spacing: -0.01em;
}

.brand-icon {
  font-size: 20px;
  color: var(--md-sys-color-primary);
}

.font-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--md-sys-shape-small);
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  box-shadow: var(--md-sys-elevation-0);
  font-size: 12px;
  font-weight: 500;
}

.badge-bold {
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.badge-dim {
  color: var(--md-sys-color-secondary);
}

.badge-format {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

/* M3 Search Bar (Pill Shape, 44px, Surface Container High) */
.header-center {
  flex: 1;
  max-width: 480px;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-full);
  height: 44px;
  padding: 0 16px;
  gap: 10px;
  box-shadow: var(--md-sys-elevation-1);
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

.search-box:focus-within {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-2), 0 0 0 2px var(--md-sys-color-primary);
}

.search-icon {
  color: var(--md-sys-color-outline);
  font-size: 14px;
  display: flex;
  align-items: center;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  line-height: 20px;
  user-select: text;
}

.search-box input::placeholder {
  color: var(--md-sys-color-outline);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--md-sys-color-outline);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--md-sys-shape-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: color 150ms ease, background-color 150ms ease;
}

.clear-btn:hover {
  color: var(--md-sys-color-on-surface);
  background-color: rgba(255, 255, 255, 0.08);
}

/* M3 Segmented Button (Density Group) */
.density-group {
  display: flex;
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-full);
  padding: 3px;
  gap: 2px;
}

.density-btn {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--md-sys-shape-full);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.density-btn:hover {
  color: var(--md-sys-color-on-surface);
  background-color: rgba(255, 255, 255, 0.06);
}

.density-btn.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
  box-shadow: var(--md-sys-elevation-1);
}

/* M3 Buttons (Filled Button & Split Button) */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-radius: var(--md-sys-shape-full);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--md-sys-elevation-1);
  transition: background-color 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.action-btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--md-sys-elevation-2);
}

.action-btn.secondary {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

.action-btn.secondary:hover {
  filter: brightness(1.08);
  box-shadow: var(--md-sys-elevation-2);
}

/* Split Button & Dropdown Menu */
.split-btn-group {
  display: inline-flex;
  position: relative;
  box-shadow: var(--md-sys-elevation-1);
  border-radius: var(--md-sys-shape-full);
}

.split-main-btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  padding-right: 14px;
}

.split-dropdown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 12px;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-top-right-radius: var(--md-sys-shape-full);
  border-bottom-right-radius: var(--md-sys-shape-full);
  border-left: 1px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-size: 11px;
  transition: filter 150ms ease, background-color 150ms ease;
}

.split-dropdown-btn:hover {
  filter: brightness(1.08);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-medium);
  box-shadow: var(--md-sys-elevation-3);
  padding: 8px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: var(--md-sys-shape-small);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background-color 150ms ease;
}

.dropdown-item:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

.dropdown-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.dropdown-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.dropdown-sub {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--md-sys-color-outline-variant);
  margin: 6px 0;
}

/* M3 Icon Button (40x40 Visual, Full Pill, Ripple Effect) */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 150ms ease, color 150ms ease;
}

.icon-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}

/* ==========================================================================
   5.4 Chips & Badges (Category Pill Bar: M3 Filter Chips)
   ========================================================================== */
.category-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background-color: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-0);
  border-bottom: 1px solid var(--md-sys-color-surface-container);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  z-index: 10;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-small);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.cat-pill:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
}

.cat-pill.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
  font-weight: 600;
  box-shadow: var(--md-sys-elevation-1);
}

.cat-count {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.22);
  color: inherit;
  padding: 1px 6px;
  border-radius: var(--md-sys-shape-full);
}

/* ==========================================================================
   Workspace & Grid Area (Surface Canvas: #111318)
   ========================================================================== */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  background-color: var(--md-sys-color-surface);
}

.grid-wrapper {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: var(--md-sys-color-surface);
}

.grid-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  outline: none;
  overflow-anchor: none;
  position: relative;
}

.grid-scroll-track {
  width: 100%;
  position: relative;
  overflow: hidden;
}

.grid-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: grid;
  gap: 10px;
  will-change: transform;
}

/* Grid density columns */
.grid-cols-16 { grid-template-columns: repeat(16, minmax(0, 1fr)); }
.grid-cols-14 { grid-template-columns: repeat(14, minmax(0, 1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid-cols-10 { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.grid-cols-8  { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.grid-cols-6  { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-cols-5  { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cols-4  { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ==========================================================================
   5.3 Cards & Containers: Character Grid Tiles (M3 Surface Container: #1d2024)
   ========================================================================== */
.grid-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-medium);
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.grid-tile:hover {
  background-color: var(--md-sys-color-surface-container-high);
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-2);
}

.grid-tile:active {
  transform: scale(0.97);
}

.grid-tile.selected {
  background-color: var(--md-sys-color-primary-container);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary), var(--md-sys-elevation-2);
}

.tile-glyph {
  font-family: var(--font-inspected);
  line-height: 1;
  text-align: center;
  color: var(--md-sys-color-on-surface);
  transition: color 150ms ease;
}

.grid-tile.selected .tile-glyph {
  color: var(--md-sys-color-on-primary-container);
}

.tile-hex {
  font-size: 11px;
  color: var(--md-sys-color-outline);
  margin-top: 4px;
  font-family: var(--md-sys-typescale-font-mono);
}

.grid-tile.selected .tile-hex {
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
}

/* Tile sizes depending on density */
.grid-cols-16 .grid-tile, .grid-cols-14 .grid-tile, .grid-cols-12 .grid-tile {
  height: 58px;
}
.grid-cols-16 .tile-glyph, .grid-cols-14 .tile-glyph, .grid-cols-12 .tile-glyph {
  font-size: 22px;
}
.grid-cols-16 .tile-hex, .grid-cols-14 .tile-hex, .grid-cols-12 .tile-hex {
  display: none;
}

.grid-cols-10 .grid-tile, .grid-cols-8 .grid-tile {
  height: 76px;
}
.grid-cols-10 .tile-glyph, .grid-cols-8 .tile-glyph {
  font-size: 32px;
}

.grid-cols-6 .grid-tile, .grid-cols-5 .grid-tile, .grid-cols-4 .grid-tile {
  height: 96px;
}
.grid-cols-6 .tile-glyph, .grid-cols-5 .tile-glyph, .grid-cols-4 .tile-glyph {
  font-size: 46px;
}
.grid-cols-6 .tile-hex, .grid-cols-5 .tile-hex, .grid-cols-4 .tile-hex {
  font-size: 11px;
}

/* ==========================================================================
   Empty & Welcome States (M3 Filled Card, Extra-Large Shapes)
   ========================================================================== */
.empty-state, .welcome-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.empty-icon, .welcome-icon {
  font-size: 56px;
  color: var(--md-sys-color-primary);
}

.empty-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.empty-desc {
  color: var(--md-sys-color-on-surface-variant);
  max-width: 400px;
  font-size: 14px;
  line-height: 22px;
}

.primary-btn {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  height: 44px;
  padding: 0 28px;
  border-radius: var(--md-sys-shape-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: var(--md-sys-elevation-1);
  transition: background-color 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--md-sys-elevation-2);
}

.secondary-btn {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: none;
  height: 44px;
  padding: 0 24px;
  border-radius: var(--md-sys-shape-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: var(--md-sys-elevation-1);
  transition: background-color 150ms ease, filter 150ms ease;
}

.secondary-btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--md-sys-elevation-2);
}

.welcome-card {
  background: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-extra-large);
  padding: 44px 52px;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--md-sys-elevation-2);
}

.welcome-card h2 {
  font-size: 26px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.welcome-card p {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 15px;
  line-height: 24px;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.welcome-drop-hint {
  font-size: 12px;
  color: var(--md-sys-color-outline);
  margin-top: 6px;
}

/* Drag & Drop Overlay */
.drag-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 19, 24, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

.drag-drop-card {
  border: 2px dashed var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-extra-large);
  padding: 52px 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background-color: var(--md-sys-color-surface-container);
  box-shadow: var(--md-sys-elevation-4);
}

.drag-icon {
  font-size: 60px;
  color: var(--md-sys-color-primary);
}

/* ==========================================================================
   Inspector Sidebar Panel (M3 Surface Container Low: #191c20)
   ========================================================================== */
.inspector-panel {
  width: 380px;
  height: 100%;
  background-color: var(--md-sys-color-surface-container-low);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 5;
}

.inspector-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.inspector-empty {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-outline);
  padding: 24px;
  text-align: center;
  font-size: 14px;
}

.preview-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-large);
  box-shadow: var(--md-sys-elevation-1);
}

.inspector-glyph {
  font-family: var(--font-inspected);
  font-size: 76px;
  line-height: 1.1;
  margin-bottom: 12px;
  user-select: text;
  color: var(--md-sys-color-on-surface);
}

.inspector-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  text-align: center;
  margin-bottom: 4px;
}

.inspector-subtitle {
  font-size: 12px;
  font-family: var(--md-sys-typescale-font-mono);
  color: var(--md-sys-color-primary);
  font-weight: 500;
}

.copy-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.copy-btn {
  height: 36px;
  padding: 0 8px;
  background-color: var(--md-sys-color-surface-container-high);
  border: none;
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-sys-shape-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: all 150ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.copy-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-2);
}

.copy-btn.primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.copy-btn.primary:hover {
  filter: brightness(1.08);
}

.details-card {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-medium);
  padding: 16px;
  box-shadow: var(--md-sys-elevation-1);
}

.card-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  font-size: 12px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--md-sys-color-on-surface-variant);
}

.detail-val {
  color: var(--md-sys-color-on-surface);
  user-select: text;
  text-align: right;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* Ligature list */
.ligature-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ligature-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--md-sys-color-surface-container-high);
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-small);
  font-size: 12px;
}

.ligature-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lig-idx {
  color: var(--md-sys-color-outline);
}

.lig-hex {
  font-weight: 700;
  font-family: var(--md-sys-typescale-font-mono);
  color: var(--md-sys-color-secondary);
}

.lig-name {
  color: var(--md-sys-color-on-surface-variant);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lig-char {
  font-family: var(--font-inspected);
  font-size: 18px;
  color: var(--md-sys-color-on-surface);
}

/* ==========================================================================
   Status Bar (M3 Surface Container Lowest: #0c0e13)
   ========================================================================== */
.app-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 16px;
  background-color: var(--md-sys-color-surface-container-lowest);
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  color: var(--md-sys-color-outline);
  flex-shrink: 0;
  z-index: 10;
}

.status-left, .status-center, .status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-bold {
  font-weight: 600;
  color: var(--md-sys-color-primary);
}

.status-filename {
  color: var(--md-sys-color-on-surface-variant);
}

.status-terms-link {
  background: none;
  border: none;
  color: var(--md-sys-color-outline);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}

.status-terms-link:hover {
  color: var(--md-sys-color-primary);
}

/* ==========================================================================
   5.6 Dialogs & Modals (M3 Specification: 28px Radius, Elevation Level 5)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.modal-card {
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-extra-large);
  box-shadow: var(--md-sys-elevation-5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px 28px;
  background-color: transparent;
}

.modal-header h3 {
  font-size: 22px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--md-sys-color-outline);
  cursor: pointer;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--md-sys-shape-full);
  transition: background-color 150ms ease, color 150ms ease;
}

.close-modal-btn:hover {
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-highest);
}

.modal-body {
  padding: 8px 28px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-tables-section {
  margin-top: 16px;
}

.tables-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.table-tag {
  padding: 4px 10px;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-extra-small);
  font-size: 12px;
  font-family: var(--md-sys-typescale-font-mono);
  color: var(--md-sys-color-secondary);
}

/* ==========================================================================
   Terms of Service Modal (M3 Dialog Architecture)
   ========================================================================== */
.terms-modal-card {
  width: 760px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
}

.terms-modal-body {
  padding: 8px 28px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.terms-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terms-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terms-section-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.terms-card {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-medium);
  padding: 16px 20px;
  box-shadow: var(--md-sys-elevation-0);
  font-size: 13px;
  line-height: 22px;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.terms-card strong {
  color: var(--md-sys-color-on-surface);
}

.terms-caps {
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 18px;
  color: var(--md-sys-color-primary);
}

.terms-modal-footer {
  padding: 16px 28px 24px 28px;
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   5.7 Progress Indicators & Snackbars (M3 Toast / Notification)
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 48px;
  left: 24px;
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  padding: 12px 20px;
  border-radius: var(--md-sys-shape-small);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--md-sys-elevation-3);
  z-index: 200;
  animation: fadeIn 200ms ease;
}

.toast-icon {
  color: var(--md-sys-color-tertiary);
  font-weight: 700;
}

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

/* Synonym Suggestions in Empty State */
.synonym-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 16px 20px;
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-large);
  max-width: 540px;
  box-shadow: var(--md-sys-elevation-1);
}

.synonym-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-primary);
}

.synonym-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.synonym-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-small);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 150ms ease;
}

.synonym-chip:hover {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: var(--md-sys-elevation-1);
}

.synonym-count {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  padding: 1px 6px;
  border-radius: var(--md-sys-shape-full);
}

/* ==========================================================================
   Google Fonts Modal (M3 Full Dialog)
   ========================================================================== */
.gf-modal-card {
  width: 760px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-icon {
  font-size: 22px;
}

.gf-modal-search {
  padding: 14px 28px;
  background-color: var(--md-sys-color-surface-container);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gf-categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.gf-categories::-webkit-scrollbar {
  display: none;
}

.gf-cat-btn {
  height: 32px;
  padding: 0 14px;
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-small);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 150ms ease;
}

.gf-cat-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--md-sys-color-on-surface);
}

.gf-cat-btn.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
  font-weight: 600;
}

.gf-font-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  max-height: 420px;
}

.gf-font-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-medium);
  box-shadow: var(--md-sys-elevation-1);
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.gf-font-card:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-2);
}

.gf-font-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gf-font-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gf-font-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.gf-font-cat-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-extra-small);
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-secondary);
  font-weight: 500;
}

.gf-font-cat-tag.emoji {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}

.gf-font-preview {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.gf-load-btn {
  height: 36px;
  padding: 0 16px;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-radius: var(--md-sys-shape-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: all 150ms ease;
  white-space: nowrap;
}

.gf-load-btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--md-sys-elevation-2);
}

.gf-loading, .gf-empty-list {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--md-sys-color-outline);
  font-size: 14px;
}

.gf-modal-footer {
  padding: 14px 28px;
  background-color: var(--md-sys-color-surface-container);
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Custom Scrollbar (M3 Subtle Outline Pill) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-outline);
}

/* ==========================================================================
   2. Responsive Breakpoints & Mobile Friendly Layout
   M3 Breakpoint Classes: Compact (<600px), Medium (600-839px), Expanded (>=840px)
   ========================================================================== */

/* Mobile Drawer Header & Controls */
.inspector-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background-color: var(--md-sys-color-surface-container);
  box-shadow: var(--md-sys-elevation-1);
  flex-shrink: 0;
}

.inspector-mobile-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.close-inspector-btn {
  background: var(--md-sys-color-surface-container-high);
  border: none;
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-sys-shape-full);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: all 150ms ease;
}

.close-inspector-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

.inspector-backdrop {
  display: none;
}

.mobile-only-btn {
  display: none !important;
}

/* Medium & Compact Viewports (<= 839px) */
@media (max-width: 839px) {
  .inspector-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(400px, 92vw);
    background-color: var(--md-sys-color-surface-container-high);
    z-index: 200;
    box-shadow: var(--md-sys-elevation-4);
    transform: translateX(100%);
    transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .inspector-panel.open {
    transform: translateX(0);
  }

  .inspector-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 190;
    animation: fadeIn 150ms ease;
  }

  .inspector-backdrop.open {
    display: block;
  }

  .inspector-mobile-header {
    display: flex;
  }

  .mobile-only-btn {
    display: inline-flex !important;
  }

  .status-center {
    display: none;
  }

  .status-filename {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Compact Viewports (< 600px) */
@media (max-width: 599px) {
  .app-header {
    padding: 0 12px;
    gap: 8px;
    height: 56px;
  }

  .header-left, .header-right {
    gap: 6px;
  }

  .font-badges {
    display: none !important;
  }

  .header-center {
    flex: 1;
    min-width: 0;
  }

  .search-box {
    height: 40px;
    padding: 0 12px;
    gap: 6px;
  }

  .search-box input {
    font-size: 13px;
    min-width: 40px;
  }

  .category-bar {
    padding: 8px 12px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .cat-pill {
    padding: 0 12px;
    font-size: 12px;
  }

  .grid-container {
    padding: 10px 12px;
  }

  .density-group {
    display: none;
  }

  .open-font-label {
    display: none;
  }

  .split-main-btn {
    padding: 0 10px;
  }

  .welcome-card {
    padding: 28px 20px;
    max-width: calc(100vw - 24px);
    border-radius: var(--md-sys-shape-large);
  }

  .welcome-card h2 {
    font-size: 20px;
  }

  .welcome-card p {
    font-size: 13px;
  }

  .welcome-actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .drag-drop-card {
    padding: 32px 20px;
    max-width: calc(100vw - 28px);
  }

  .drag-icon {
    font-size: 40px;
  }

  .gf-modal-card {
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 24px);
    border-radius: var(--md-sys-shape-large);
  }

  .modal-card {
    border-radius: var(--md-sys-shape-large);
  }

  .gf-font-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .gf-load-btn {
    width: 100%;
    text-align: center;
  }
}
