@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/ibm-plex-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/ibm-plex-sans-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-muted: #475569;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #f0fdfa;
  --danger-ink: #b91c1c;
  --danger-bg: #fef2f2;
  --warn-ink: #b45309;
  --warn-bg: #fffbeb;
  --ok-ink: #15803d;
  --ok-bg: #f0fdf4;

  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text-heading: 1.5rem;
  --text-body: 1rem;
  --text-sm: 0.875rem;
  --text-grid: 0.8125rem;
  --radius: 8px;
  --radius-sm: 6px;
}

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

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: clip;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: var(--text-sm);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  min-width: 0;
}

/* Top Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 8px 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-link:hover {
  color: var(--ink);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: nowrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--ink);
}

.nav-links a[aria-current="page"] {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.btn:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: #94a3b8;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.btn-sm {
  padding: 6px 11px;
  font-size: var(--text-sm);
}

.pro-active-btn {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

/* Main Workbench Opening */
.page-main {
  padding: 24px 0 64px;
}

.workbench-intro {
  margin-bottom: 18px;
}

.workbench-intro h1 {
  margin: 0 0 6px;
  font-size: clamp(1.75rem, 2.8vw, 2.25rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.workbench-lead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
}

.workbench-lead-row p {
  margin: 0;
  font-size: var(--text-body);
  color: var(--ink-muted);
  max-width: 65ch;
}

.privacy-note {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Workbench Shell */
.workbench-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.mode-tab {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  padding: 11px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms cubic-bezier(0.22, 1, 0.36, 1),
    color 150ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 150ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mode-tab:hover {
  background: #e2e8f0;
  color: var(--ink);
}

.mode-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.workbench-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Dropzones */
.dropzone-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.dropzone-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  transition: border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    background-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
}

.dropzone-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}

.dropzone-sub {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.dropzone-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Loaded Files Strip */
.loaded-files-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.file-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
}

.file-meta-item {
  color: var(--ink);
  font-weight: 500;
}

.file-meta-item span {
  color: var(--ink-muted);
  font-weight: 400;
}

/* Tool Controls Bar */
.controls-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.controls-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  max-width: 100%;
}

.field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
}

.field select,
.field input[type="text"],
.field input[type="number"] {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
}

.check-label input[type="checkbox"],
.check-label input[type="radio"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  margin: 0;
}

.controls-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Mapping Table (Merge) & Issues / Clusters Drawer */
.sub-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 240px;
}

.sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-grid);
}

.sub-table th,
.sub-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.sub-table th {
  background: var(--surface-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}

.sub-table input[type="text"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  width: 100%;
  min-width: 130px;
  font-size: var(--text-grid);
}

/* Inline Status Banner */
.notice-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: var(--text-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notice-banner.warn {
  background: var(--warn-bg);
  border-color: #fde68a;
  color: var(--warn-ink);
}

.notice-banner.error {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger-ink);
}

.notice-banner.ok {
  background: var(--ok-bg);
  border-color: #bbf7d0;
  color: var(--ok-ink);
}

/* Data Grid (Paginated 100 rows/page) */
.grid-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--text-sm);
}

.grid-stats {
  color: var(--ink-muted);
}

.grid-stats strong {
  color: var(--ink);
}

.pagination-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.grid-scroll {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 440px;
  background: var(--surface);
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-grid);
  font-variant-numeric: tabular-nums;
}

.data-grid th,
.data-grid td {
  padding: 7px 11px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-grid th:last-child,
.data-grid td:last-child {
  border-right: 0;
}

.data-grid th {
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 3;
}

.data-grid td.row-num,
.data-grid th.row-num {
  width: 56px;
  text-align: right;
  color: var(--ink-muted);
  background: var(--bg);
}

.data-grid tbody tr:hover td {
  background: #f8fafc;
}

.cell-status-error {
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-weight: 600;
}

.cell-status-warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-weight: 500;
}

.cell-status-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-weight: 500;
}

/* Export Bar */
.export-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.empty-grid-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

/* Below-the-fold Editorial Guide & Directory */
.content-stack {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 44px;
  min-width: 0;
  width: 100%;
}

.tool-directory {
  border-top: 1px solid var(--border);
  padding-top: 32px;
  min-width: 0;
  width: 100%;
}

.section-heading {
  margin: 0 0 10px;
  font-size: var(--text-heading);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--ink);
}

.section-sub {
  margin: 0 0 20px;
  font-size: var(--text-body);
  color: var(--ink-muted);
  max-width: 65ch;
}

.directory-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.directory-item {
  padding: 18px 20px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.directory-item h3 {
  margin: 0;
  font-size: var(--text-body);
  font-weight: 600;
}

.directory-item h3 a {
  color: var(--ink);
  text-decoration: none;
}

.directory-item h3 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.directory-item p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.prose-section {
  border-top: 1px solid var(--border);
  padding-top: 32px;
  min-width: 0;
  width: 100%;
}

.prose-section > h2,
.prose-section > h3,
.prose-section > .prose-table-wrap,
.prose-section > .faq-list {
  max-width: 780px;
}

.prose-table-wrap {
  margin: 18px 0 22px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  min-width: 0;
}

.prose-section h2 {
  margin: 0 0 12px;
  font-size: var(--text-heading);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.prose-section h3 {
  margin: 24px 0 8px;
  font-size: var(--text-body);
  font-weight: 600;
}

.prose-section p,
.prose-section li {
  font-size: var(--text-body);
  color: var(--ink-muted);
  max-width: 65ch;
}

.prose-section p {
  margin: 0 0 14px;
}

.prose-section ul,
.prose-section ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.prose-section li {
  margin-bottom: 6px;
}

.prose-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.prose-table th,
.prose-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.prose-table th {
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
}

.prose-table tr:last-child td {
  border-bottom: 0;
}

/* Native FAQ Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.faq-item summary {
  cursor: pointer;
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.faq-item summary::after {
  content: "+";
  font-weight: 500;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item p {
  margin: 10px 0 0;
  font-size: var(--text-body);
  color: var(--ink-muted);
  max-width: 65ch;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.footer-links a {
  color: var(--ink-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* License Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-form input[type="text"] {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 100%;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Responsive */
@media (max-width: 960px) {
  .header-inner {
    flex-wrap: wrap;
  }
  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
  }
  .dropzone-grid.two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 14px;
  }
  .header-inner {
    gap: 10px;
  }
  .nav-links {
    gap: 14px;
    max-width: 100%;
  }
  .workbench-body {
    padding: 14px;
  }
  .mode-tab {
    padding: 9px 10px;
    flex: 1 1 50%;
    text-align: center;
    font-size: 0.8125rem;
  }
  .check-label {
    white-space: normal;
    max-width: 100%;
  }
  .field {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
