/* Crossover web: ink and magenta from the mark, on a cool plan-grey ground. */
:root {
  --ink: #1A1A1A;
  --accent: #C8197D;
  --accent-ink: #FFFFFF;
  --ground: #F3F4F6;
  --panel: #FFFFFF;
  --rule: #D8DBE0;
  --muted: #5B616B;
  --faint: #7D838C;
  --warn: #9A5105;
  --warn-ground: #FDF4E7;
  --error: #B3261E;
  --field: #FFFFFF;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --focus-ring: 2px solid var(--accent);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
  accent-color: var(--accent);
  caret-color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ECEDEF;
    --accent: #F0578F;
    --accent-ink: #14161A;
    --ground: #14161A;
    --panel: #1C1F24;
    --rule: #33373F;
    --muted: #A2A8B2;
    --faint: #7C828C;
    --warn: #F0A24A;
    --warn-ground: #2A2218;
    --error: #FF8A80;
    --field: #14161A;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
}
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 22px;
}
.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.indent { padding-left: 26px; }

/* -- header -------------------------------------------------------------- */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 44px; height: 44px; }
h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.tagline { margin: 2px 0 0; color: var(--muted); }
.privacy { margin: 0; color: var(--muted); font-size: 13px; }

.curve-ink, .curve-accent {
  fill: none;
  stroke-width: 17;
  stroke-linecap: round;
}
.curve-ink { stroke: var(--ink); }
.curve-accent { stroke: var(--accent); }

/* -- layout: the form, and the source list beside it for a .dbpr ----------
   One grid, in reading order: file, route, source list, options, Convert. Wide,
   the source list moves to a column of its own, beside the form; narrow, it
   simply stays where it is in the order, before the options and Convert. */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 620px);
  gap: 14px 24px;
  align-items: start;
}
.layout > * { grid-column: 1; min-width: 0; }
/* the source list spans the form's rows (file, status, route, options, info,
   save as, Convert, warnings, log); any height it has beyond them goes to the
   last, so the form's rows keep their spacing */
.layout.with-sources {
  grid-template-columns: minmax(0, 620px) minmax(0, 1fr);
  grid-template-rows: repeat(8, auto) 1fr;
}
.layout.with-sources > .sources { grid-column: 2; grid-row: 1 / -1; }
@media (max-width: 980px) {
  .layout.with-sources { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .layout.with-sources > .sources {
    grid-column: 1; grid-row: auto; position: static; max-height: none;
  }
}

/* -- file drop ------------------------------------------------------------ */
.drop {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 22px;
  border: 1.5px dashed var(--rule);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop.over { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.drop:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus); border-color: var(--accent); }
.drop-name { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.drop-hint { color: var(--muted); font-size: 13px; }
.status { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.status:empty { display: none; }
.status.error { color: var(--error); }

/* -- the route: which way this file goes ---------------------------------- */
.route {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  align-items: center;
  column-gap: 14px;
  margin: -4px 0 -6px;
}
.route-end {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color .2s;
}
.route-from { text-align: right; }
.route-mark { width: 60px; height: 60px; transition: transform .35s ease; }
.route-what {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  min-height: 1.5em;
}
.route[data-dir=""] .route-end { color: var(--faint); }
.route[data-dir=""] .curve-accent { stroke: var(--faint); }
.route[data-dir="to-dbacv"] .route-mark { transform: scaleX(-1); }
@media (prefers-reduced-motion: reduce) {
  .route-mark, .route-end, .drop { transition: none; }
}

/* -- boxes ---------------------------------------------------------------- */
.box {
  margin: 0;
  padding: 12px 18px 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
  min-width: 0;
}
.box legend { padding: 0 6px; margin-left: -6px; font-weight: 600; }
.field + .field { margin-top: 12px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field:has(:disabled) { opacity: .45; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  flex-wrap: wrap;
}
.segmented label { position: relative; }
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  display: block;
  padding: 5px 14px;
  font-size: 14px;
  border-left: 1px solid var(--rule);
}
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--ink); color: var(--panel); }
.segmented input:focus-visible + span { outline: var(--focus-ring); outline-offset: -2px; }
.segmented input:not(:checked):not(:disabled):hover + span {
  background: color-mix(in srgb, var(--ink) 6%, var(--panel));
}
.segmented input:disabled { cursor: default; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.check input:disabled { cursor: default; }

.scaffold { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#scaffold-name { color: var(--muted); overflow-wrap: anywhere; }
.button {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.button:hover:not(:disabled) { border-color: var(--muted); }
.button:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.button:disabled { cursor: default; }

.row-field {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}
.row-field + .row-field { margin-top: 8px; }
.row-field > span { color: var(--muted); font-size: 14px; }
.indent-field { padding-left: 88px; }
input[type=text], textarea, select {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
textarea { resize: vertical; min-height: 64px; }
input[type=text]:focus, textarea:focus, select:focus {
  outline: 2px solid transparent;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
select:disabled { opacity: .5; }
.save { padding: 0 2px; }

/* -- convert, warnings, log ----------------------------------------------- */
.convert {
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}
.convert:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.convert:focus-visible { outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--ground), 0 0 0 5px var(--accent); }
.convert:disabled { background: var(--rule); color: var(--muted); cursor: default; }

.warnings {
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--rule));
  border-radius: 10px;
  background: var(--warn-ground);
}
.warnings-head { margin: 0 0 6px; font-weight: 600; color: var(--warn); }
.warnings ul { margin: 0; padding-left: 18px; }
.warnings li + li { margin-top: 6px; }

.log {
  margin: 0;
  min-height: 7.5em;
  max-height: 22em;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.log:empty::before { content: "The conversion log appears here."; color: var(--faint); }
.log .bad { color: var(--error); }
.log .warn { color: var(--warn); }
.log a { color: var(--accent); }

/* -- source elements ------------------------------------------------------ */
.sources {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
  max-height: calc(100vh - 32px);
  min-width: 0;
  container-type: inline-size;
}
.sources[hidden] { display: none; }
.sources h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.sources h2 .to { color: var(--muted); font-weight: 400; }
.source-list {
  overflow-y: auto;
  scrollbar-color: var(--rule) transparent;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 12px;
}
.source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px;
  padding: 10px 0;
  align-items: center;
}
.source + .source { border-top: 1px solid var(--rule); }
.source-name { font-weight: 600; overflow-wrap: anywhere; }
.source-desc { grid-column: 1; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.source-pick {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  width: 250px;
}
.source-pick .check { font-size: 13px; }
.source.skipped .source-desc { color: var(--muted); }
.sources-empty { margin: 12px 0; color: var(--muted); }
.sources-empty.error { color: var(--error); }
@container (max-width: 400px) {
  .source { grid-template-columns: minmax(0, 1fr); }
  .source-pick { grid-column: 1; grid-row: auto; width: auto; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .hint, .drop-hint, .status, .source-desc, .privacy, .foot { font-size: 14px; }
  .route-end { font-size: 18px; }
}
/* touch: 16px fields (no zoom on focus in iOS Safari) and fingertip targets */
@media (max-width: 980px), (pointer: coarse) {
  input[type=text], textarea, select { font-size: 16px; }
}
@media (pointer: coarse) {
  .segmented span { padding: 11px 16px; }
  .button { padding: 10px 14px; }
  .check { min-height: 44px; }
}

/* -- footer --------------------------------------------------------------- */
.foot {
  display: flex;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
}
.wordmark img { display: block; height: 17px; width: auto; }
.scope { flex: 1 1 280px; }
.foot a { color: var(--accent); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
