/* GoDD Matrix DESIGN.md Library Stylesheet
   Default: dark theme
*/

:root {
  --bg: oklch(16% 0.014 260);
  --bg-panel: oklch(20% 0.014 260);
  --bg-card: oklch(22% 0.014 260);
  --bg-input: oklch(18% 0.012 260);
  --bg-hover: oklch(26% 0.016 260);
  --text: oklch(94% 0.01 260);
  --text-muted: oklch(72% 0.014 260);
  --text-soft: oklch(78% 0.012 260);

  --accent: oklch(72% 0.16 275);
  --accent-hover: oklch(78% 0.14 275);
  --accent-light: oklch(28% 0.06 275);
  --accent-pill-text: oklch(88% 0.08 275);

  --border: oklch(32% 0.016 260);
  --border-hover: oklch(42% 0.02 260);

  --bg-code: oklch(14% 0.012 260);
  --text-code: oklch(90% 0.01 260);

  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.35);

  --transition: all 0.15s ease-out;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@supports (color: contrast-color(red)) {
  body {
    color: contrast-color(var(--bg));
  }

  .nav-bar,
  .filter-sidebar,
  .filter-accordion,
  .card,
  .related-card,
  .scroll-fab,
  .action-btn,
  .sort-btn,
  .facet-chip,
  .color-family-btn,
  .locale-select,
  .page-size-select,
  .search-bar-wrapper input,
  .color-editor-input,
  .pager button {
    color: contrast-color(var(--bg-card));
  }

  .nav-bar,
  .filter-sidebar {
    color: contrast-color(var(--bg-panel));
  }

  .locale-select,
  .page-size-select,
  .search-bar-wrapper input,
  .color-editor-input,
  .pager-jump {
    color: contrast-color(var(--bg-input));
  }

  .facet-chip.selected,
  .color-family-btn.selected {
    color: contrast-color(var(--accent));
  }

  .sort-btn.active,
  .action-btn.primary {
    color: contrast-color(var(--accent));
  }

  .brand-subtitle,
  .facet-label,
  .facet-sublabel,
  .text-muted,
  .matches-count-label,
  .sample-label,
  .card-footer,
  .meta-key,
  .site-footer p,
  .related-title,
  .related-card-title-en,
  .swatch-hex,
  .pills-label {
    color: color-mix(in oklch, contrast-color(var(--bg)) 68%, transparent);
  }
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Sticky Nav Bar */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: block;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.locale-field,
.page-size-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.locale-field-label {
  white-space: nowrap;
}

.locale-select,
.page-size-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23c4c9d4' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

.locale-select:hover,
.page-size-select:hover {
  border-color: var(--accent);
}

/* Main Content Area — edge-to-edge, search-first */
.main-content {
  max-width: none;
  margin: 0;
  padding: 12px 16px 24px;
  width: 100%;
  flex: 1;
}

.search-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.filter-toggle-btn {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.filter-drawer-backdrop {
  display: none;
}

.filter-sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-height: calc(100vh - 88px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.filter-close-btn {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.filter-accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  overflow: visible;
  flex-shrink: 0;
}

.filter-accordion[open] {
  /* Avoid flex-on-<details>: it does not constrain children, so body grows to content
     and parent overflow:hidden clips chips with no inner scroll (prod PC regression). */
  display: block;
  max-height: none;
  flex-shrink: 0;
  overflow: visible;
}

.filter-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  user-select: none;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card);
}

.filter-accordion > summary::-webkit-details-marker {
  display: none;
}

.filter-accordion > summary::after {
  content: "▾";
  float: right;
  color: var(--text-muted);
  font-size: 12px;
}

.filter-accordion:not([open]) > summary::after {
  content: "▸";
}

.filter-accordion-body {
  /* Explicit scrollport — required because <details> will not flex-constrain height. */
  padding: 0 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(42vh, 360px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.facet-subsection {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.facet-sublabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facet-list-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  align-content: flex-start;
}

.facet-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.facet-checkbox input {
  accent-color: var(--accent);
}

.search-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.facet-list-scroll {
  max-height: none;
  overflow: visible;
  padding-right: 2px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 960px) {
  .search-layout {
    grid-template-columns: 1fr;
  }

  .filter-toggle-btn {
    display: inline-flex;
    grid-column: 1 / -1;
  }

  .filter-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(15, 18, 28, 0.45);
  }

  .filter-drawer-backdrop.hidden {
    display: none;
  }

  .filter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    width: min(92vw, 420px);
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0 14px 14px 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease-out;
    box-shadow: 8px 0 32px rgba(15, 18, 28, 0.18);
    overflow-y: auto;
  }

  .filter-sidebar.open {
    transform: translateX(0);
  }

  .filter-accordion[open] {
    max-height: none;
  }

  .filter-accordion-body {
    max-height: min(48dvh, 420px);
  }

  body.filter-drawer-open {
    overflow: hidden;
  }

  .filter-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

.view-section {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Search Bar */
.search-bar-wrapper {
  max-width: none;
  margin: 0 0 12px;
  position: relative;
  width: 100%;
}

.search-bar-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}

.search-bar-wrapper input {
  width: 100%;
  padding: 16px 20px 16px 48px;
  font-size: 15px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-soft);
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  color: var(--text);
}

.search-bar-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.facet-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.facet-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Chips & Buttons */
.facet-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  text-align: left;
  line-height: 1.25;
}

.facet-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.facet-chip.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Color-family chip buttons */
.color-family-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.color-family-btn .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.color-family-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.color-family-btn.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-pill-text);
}

/* Active pills */
.active-pills-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.pills-label {
  font-size: 12px;
  color: var(--text-muted);
}

.pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-light);
  color: var(--accent-pill-text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.pill-btn:hover {
  filter: brightness(0.95);
}

.clear-all-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.clear-all-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text);
}

/* Matches header */
.matches-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.matches-count {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.matches-count-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.sample-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sort-actions {
  display: flex;
  gap: 8px;
}

.sort-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.sort-btn:hover {
  background: var(--bg-hover);
}

/* Active = accent fill + dark ink (avoid light-on-light from contrast-color + --text bg). */
.sort-btn.active {
  background: var(--accent);
  color: oklch(16% 0.02 275);
  border-color: var(--accent);
  font-weight: 650;
}

/* Results Grid & Cards */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  align-items: stretch;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 296px;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.card:focus-visible,
.related-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.card-thumbnail {
  display: block;
  height: 140px;
  flex: 0 0 140px;
  position: relative;
  overflow: hidden;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.08em;
  pointer-events: none;
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
  min-height: 0;
}

.card-title-ja {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-weight: 650;
  font-size: 15px;
  line-height: 1.35;
  min-height: calc(1.35em * 2);
  max-height: calc(1.35em * 2);
  margin: 0;
}

.card-title-en {
  display: none;
}

/* Compact color differentiator for popular-order color twins (#97). */
.card-color-cue {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-height: 18px;
  max-height: 18px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-color-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.card-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  margin: 0;
  margin-top: auto;
  min-height: 28px;
  max-height: 28px;
  overflow: hidden;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tag[data-kind="source"] {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text-soft);
  font-weight: 500;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}

.no-results-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 20px;
}

.pager-bottom {
  margin: 28px 0 40px;
}

.scroll-fabs {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 160;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scroll-fab {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  font-family: inherit;
  transition: var(--transition);
}

.scroll-fab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 960px) {
  .scroll-fabs {
    right: 14px;
    bottom: 16px;
  }
}

.pager button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.pager button:hover:not(:disabled) {
  border-color: var(--border-hover);
}

.pager-jump {
  width: 5.5rem;
  margin-left: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 6px;
  font: inherit;
  background: var(--bg-input);
  color: inherit;
}

.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Detail View Layout */
.back-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 24px;
  transition: var(--transition);
  align-self: flex-start;
}

.back-btn:hover {
  border-color: var(--border-hover);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 40px;
}

.detail-preview-box {
  height: 340px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.detail-preview-box .preview-overlay {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
}

.lightweight-preview-shell {
  position: absolute;
  inset: 22px;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--preview-bg) 12%, white);
  color: var(--preview-fg, #18202a);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  font-family: var(--preview-font, system-ui, sans-serif);
}

.lightweight-preview-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(24, 32, 42, 0.12);
  font-size: 9px;
}

.lightweight-preview-brand {
  font-weight: 800;
  letter-spacing: .12em;
}
.lightweight-preview-menu {
  opacity: 0.55;
}
.lightweight-preview-content {
  padding: 22px 26px;
}
.lightweight-preview-kicker {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: 0.58;
}
.lightweight-preview-content h2 {
  margin: 8px 0 6px;
  font-size: 21px;
  line-height: 1.1;
}
.lightweight-preview-content p {
  max-width: 34ch;
  margin: 0;
  font-size: 11px;
  opacity: 0.68;
}
.lightweight-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.lightweight-preview-actions button {
  border: 0;
  border-radius: var(--preview-radius, 5px);
  padding: 8px 12px;
  font-size: 10px;
}
.lightweight-preview-swatches {
  display: flex;
  gap: 6px;
  margin-top: 26px;
}
.lightweight-preview-swatches span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.65);
}

.preview-site-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.preview-site-main,
.preview-site-sidebar {
  border: 1px solid color-mix(in srgb, var(--preview-fg, #18202a) 16%, transparent);
  border-radius: var(--preview-radius, 8px);
  padding: 12px;
  background: color-mix(in srgb, var(--preview-bg) 6%, white);
}

.preview-site-eyebrow,
.preview-site-card-label {
  display: block;
  font-size: 8px;
  opacity: 0.6;
}

.preview-site-title {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 760;
}

.preview-site-line {
  width: 72%;
  height: 5px;
  border-radius: 999px;
  margin: 10px 0;
  background: var(--preview-primary, #4f8cff);
}

.preview-site-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.preview-site-card {
  min-width: 0;
  padding: 8px;
  border-radius: var(--preview-radius, 6px);
  background: color-mix(in srgb, var(--preview-secondary, #7c3aed) 18%, white);
}

.preview-site-card strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.preview-site-sidebar {
  display: grid;
  gap: 8px;
  font-size: 9px;
}

.preview-site-side-item {
  padding-top: 7px;
  border-top: 1px solid color-mix(in srgb, var(--preview-fg, #18202a) 13%, transparent);
  opacity: 0.7;
}

.preview-layout-sidebar .preview-site-content,
.preview-layout-split-view .preview-site-content {
  grid-template-columns: minmax(0, 1.8fr) minmax(100px, 1fr);
}

.preview-layout-modular-grid .preview-site-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preview-density-compact .preview-site-main,
.preview-density-compact .preview-site-sidebar,
.preview-density-compact .preview-site-card {
  padding: 7px;
}

.preview-density-spacious .preview-site-content {
  margin-top: 24px;
  gap: 14px;
}

.lightweight-preview-shell.preview-style-swiss,
.lightweight-preview-shell.preview-style-flat {
  box-shadow: none;
  border: 1px solid color-mix(in srgb, var(--preview-fg, #18202a) 18%, transparent);
}

.lightweight-preview-shell.preview-style-brutalist,
.lightweight-preview-shell.preview-style-industrial {
  border-radius: 0;
  border: 3px solid var(--preview-fg, #18202a);
  box-shadow: 7px 7px 0 var(--preview-secondary, #7c3aed);
}

.preview-style-brutalist .preview-site-main,
.preview-style-industrial .preview-site-main,
.preview-style-brutalist .preview-site-card,
.preview-style-industrial .preview-site-card {
  border-radius: 0;
}

.lightweight-preview-shell.preview-style-glass {
  background: color-mix(in srgb, white 68%, var(--preview-bg));
  backdrop-filter: blur(12px);
}

.lightweight-preview-shell.preview-style-dark {
  background: color-mix(in srgb, #10131a 88%, var(--preview-bg));
  color: #f8fafc;
}

.preview-style-editorial .lightweight-preview-content h2 {
  font-family: ui-serif, Georgia, serif;
  font-size: 27px;
}

.preview-style-playful .preview-site-card,
.preview-style-organic .preview-site-card {
  border-radius: 18px;
}

@media (max-width: 720px) {
  .preview-layout-sidebar .preview-site-content,
  .preview-layout-split-view .preview-site-content {
    grid-template-columns: 1fr;
  }
}

.detail-code-section {
  margin-top: 24px;
}

.section-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.code-wrapper {
  background: var(--bg-code);
  color: var(--text-code);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.code-wrapper pre {
  margin: 0;
  padding: 20px;
  overflow: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.code-wrapper pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.code-wrapper pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Detail Sidebar */
.detail-filename {
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-title-ja {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.detail-title-en {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 16px;
}

.detail-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.detail-color-section {
  margin: 16px 0;
}

.detail-color-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-editor-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-editor-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-editor-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.color-editor-swatch:hover,
.color-editor-swatch[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.color-editor-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--bg-card);
}

.color-editor-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.color-editor-palette {
  display: none;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.color-editor-palette.open {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.color-editor-palette-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.color-editor-preset {
  aspect-ratio: 1;
  width: 100%;
  min-height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease-out;
}

.color-editor-preset:hover {
  transform: scale(1.08);
  border-color: var(--accent);
}

.color-editor-custom-btn {
  align-self: stretch;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.color-editor-custom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.color-editor-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.detail-swatches {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.swatch-color {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--border);
}

.swatch-hex {
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
  color: var(--text-muted);
}

.detail-desc-ja {
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 4px;
}

.detail-desc-en {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* Synthesis notice styling */
.detail-virtual-notice {
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge.warn {
  background: var(--accent-light);
  color: var(--accent-pill-text);
  border: 1px solid var(--accent);
}

/* Meta table */
.meta-table {
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.meta-key {
  color: var(--text-muted);
}

.meta-val {
  font-weight: 600;
}

.detail-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

.action-btn:hover {
  border-color: var(--border-hover);
}

.action-btn.primary {
  background: var(--accent);
  color: oklch(16% 0.02 275);
  border: 1px solid var(--accent);
}

.action-btn.primary:hover {
  background: var(--accent-hover);
  color: oklch(16% 0.02 275);
}

/* Related Files Section */
.related-section {
  margin-top: 48px;
}

.related-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.related-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
}

.related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.related-thumb {
  display: block;
  height: 110px;
  position: relative;
  overflow: hidden;
}

.related-body {
  display: block;
  padding: 12px;
}

.related-card-title-ja {
  display: block;
  font-weight: 600;
  font-size: 13px;
}

.related-card-title-en {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* Site Footer */
.site-footer {
  text-align: center;
  padding: 24px 16px 16px;
  border-top: 1px solid var(--border);
  max-width: none;
  margin: 24px 0 0;
  width: 100%;
}

.site-footer p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: -60px;
  right: 24px;
  background: var(--bg-code);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  bottom: 24px;
}

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

/* Responsive grid overrides */
@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .nav-bar {
    padding: 10px 12px;
  }
  .main-content {
    padding: 10px 12px 20px;
  }
}
