/* CSV Duplicate Remover — source, matching options, results and tables.
   Colours come from the shared tokens, so the panel follows the light and dark themes. */
.cdd {
  display: grid;
  gap: 1.25rem;
  padding: clamp(16px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
}
.cdd *, .cdd *::before, .cdd *::after { box-sizing: border-box; }
.cdd [hidden] { display: none !important; }
.cdd h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
/* Status lines and notes can hold a long file name, which must wrap at 375 px. */
.cdd p { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; }
.cdd-head p { max-width: 78ch; }
.cdd label { display: grid; gap: .3rem; min-width: 0; font-size: .85rem; font-weight: 650; }
.cdd-sub { font-size: .82rem; font-weight: 450; color: var(--ink-soft); }
.cdd textarea, .cdd select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .5rem .6rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.cdd textarea { min-height: 12rem; font-family: var(--font-mono); font-size: .85rem; line-height: 1.5; white-space: pre; overflow: auto; resize: vertical; }
.cdd select:disabled { opacity: .6; }
.cdd :is(input, textarea, select, button, .cdd-table-wrap):focus-visible, .cdd .cdd-pick:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.cdd button, .cdd .cdd-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .5rem .95rem;
  font: inherit;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.cdd button:disabled { opacity: .5; cursor: default; }
.cdd .cdd-primary, .cdd .cdd-pick { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.cdd .cdd-primary:hover:not(:disabled), .cdd .cdd-pick:hover { background: var(--primary-dark); }
.cdd .cdd-pick { position: relative; font-size: .95rem; }
.cdd .cdd-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cdd .cdd-check { display: flex; align-items: center; gap: .55rem; min-height: 42px; font-size: .95rem; font-weight: 500; }
.cdd .cdd-check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--action); }
.cdd .cdd-quiet { justify-self: start; min-height: 38px; padding: .35rem .8rem; font-size: .88rem; border-width: 1.5px; }

/* Pill switches: a visually hidden radio inside each label. */
.cdd-pills { display: flex; flex-wrap: wrap; gap: .5rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.cdd-pills legend { width: 100%; margin-bottom: .45rem; padding: 0; font-weight: 700; }
.cdd .cdd-pills label { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: .45rem .9rem; font-size: .95rem; background: var(--bg-2); border: 2px solid var(--line); border-radius: 999px; cursor: pointer; }
.cdd-pills input { position: absolute; opacity: 0; pointer-events: none; }
.cdd .cdd-pills label:has(input:checked) { color: var(--on-action); background: var(--action); box-shadow: 2px 2px 0 var(--shade); }
.cdd .cdd-pills label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Source and options. */
.cdd-top { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; align-items: stretch; }
@media (max-width: 860px) { .cdd-top { grid-template-columns: minmax(0, 1fr); } }
.cdd-settings { display: grid; align-content: start; gap: .85rem; min-width: 0; }
/* The paste box grows to the height of the options beside it. */
.cdd-source { display: flex; flex-direction: column; gap: .85rem; min-width: 0; }
.cdd .cdd-paste { display: flex; flex: 1 1 auto; flex-direction: column; }
.cdd .cdd-paste textarea { flex: 1 1 auto; }
.cdd-settings { padding: 1rem; background: var(--blue-tint); border: 2px solid var(--line); border-radius: 10px; }
.cdd-settings > .cdd-sub { margin-top: -.35rem; }
.cdd-drop { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: 1.1rem 1rem; background: var(--blue-tint); border: 2px dashed var(--line); border-radius: 10px; }
.cdd-drop p { flex: 1 1 14rem; font-size: .9rem; color: var(--ink); }
.cdd-drop.is-over { background: var(--action-tint); border-style: solid; }
.cdd-file { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .55rem .8rem; background: var(--paper-3); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.cdd-file p { min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.cdd-row { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem 1rem; }
.cdd-row > label:not(.cdd-check) { flex: 1 1 10rem; }
.cdd-box { display: grid; gap: .45rem; min-width: 0; margin: 0; padding: .7rem .9rem .85rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.cdd-box legend { padding: 0 .3rem; font-weight: 700; }
.cdd-box .cdd-check { min-height: 38px; }
.cdd-key-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0 .9rem; max-height: 14rem; overflow: auto; }
.cdd .cdd-key-list .cdd-check { min-height: 36px; font-size: .9rem; overflow-wrap: anywhere; }

/* Results. */
.cdd-results { display: grid; gap: .8rem; min-width: 0; padding-top: 1.15rem; border-top: 2px solid var(--line); }
.cdd-results[aria-busy="true"] :is(.cdd-stats, .cdd-view) { opacity: .55; }
.cdd-status { min-height: 1.4em; font-size: 1.02rem; font-weight: 650; color: var(--ink) !important; }
.cdd-status[data-error="true"] { padding: .55rem .8rem; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.cdd-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin: 0; }
@media (max-width: 560px) { .cdd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cdd-stats div { min-width: 0; padding: .6rem .8rem; background: var(--paper-3); border: 2px solid var(--line); border-radius: 10px; }
.cdd-stats dt { font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.cdd-stats dd { margin: .15rem 0 0; font-size: 1.5rem; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cdd-hint { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; padding: .45rem .75rem; color: var(--ink) !important; background: var(--warning-soft); border-left: 4px solid var(--warning); border-radius: 6px; }
.cdd .cdd-hint button { min-height: 36px; padding: .3rem .75rem; font-size: .9rem; }
.cdd-format { font-size: .85rem; }
.cdd-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.cdd-note { min-height: 1.3em; font-size: .88rem; font-weight: 600; }
.cdd-view { display: grid; gap: .5rem; min-width: 0; }
.cdd-table-wrap { max-height: 30rem; overflow: auto; background: var(--field); border: 1.5px solid var(--border-soft); border-radius: 8px; }
/* Columns keep their natural width, up to 22rem, and the box scrolls sideways. */
.cdd table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .85rem; }
.cdd th, .cdd td { max-width: 22rem; padding: .4rem .65rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-faint); white-space: pre-wrap; overflow-wrap: break-word; }
.cdd thead th { position: sticky; top: 0; z-index: 1; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); white-space: normal; overflow-wrap: anywhere; background: var(--paper-3); }
.cdd td.cdd-num { min-width: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cdd td small { display: block; margin-top: .1rem; font-size: .75rem; color: var(--ink-soft); }
.cdd td.cdd-result { white-space: nowrap; }
.cdd tr.is-duplicate td.cdd-result { font-weight: 650; color: var(--ink); }
.cdd tr.is-duplicate td { color: var(--ink-soft); background: var(--pink-wash); }
.cdd tr.is-blank td { color: var(--ink-soft); background: var(--paper-3); }
.cdd td.cdd-changed small { font-family: var(--font-mono); color: var(--ink); }
.cdd td.cdd-changed > span { text-decoration: underline dotted var(--warning); text-underline-offset: 3px; }
.cdd-pager { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; font-size: .88rem; }
.cdd-groups { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.cdd-groups li { display: grid; gap: .2rem; padding: .6rem .8rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.cdd .cdd-group-head { display: flex; flex-wrap: wrap; gap: .25rem .75rem; color: var(--ink); overflow-wrap: anywhere; }
.cdd-group-head strong { flex: none; }
.cdd-foot { font-size: .85rem; }

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply csv-duplicate-remover. */
.tool-view-placeholder[data-tool="csv-duplicate-remover"] { min-height: 1558px; }
@media (max-width: 860px) { .tool-view-placeholder[data-tool="csv-duplicate-remover"] { min-height: 2188px; } }
@media (max-width: 472px) { .tool-view-placeholder[data-tool="csv-duplicate-remover"] { min-height: 2655px; } }
