/* Rename Files: page-specific styles. Shared look comes from brand.css and app-shell.css. */
.app-title { font-size: var(--step-3); margin-bottom: 0.3em; }
.intro { color: var(--muted); max-width: 72ch; margin-bottom: 20px; }
#drop { min-height: 220px; }
.small { font-size: var(--step--1); margin: 6px 0; }
.browser-note { max-width: 62ch; }

.howto { margin-top: 20px; max-width: 80ch; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); padding: 12px 16px; }
.howto summary { cursor: pointer; font-weight: 700; }
.howto p { margin: 10px 0 0; color: var(--muted); }
.howto b { color: var(--fg); font-weight: 600; }

.results-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.results-head > div:first-child { flex: 1 1 420px; min-width: 0; }
.results-head h2 { font-size: var(--step-2); margin: 0 0 4px; overflow-wrap: anywhere; }
.results-head h2:focus { outline: none; }
.results-head .muted { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.results-head .actions { margin-top: 0; }
.subfolders { margin: 0 0 12px; font-size: var(--step--1); }

/* Rules on the left; the live preview and then the button on the right. On narrow screens the
   same order, one below the other: the new names are always seen before the button. */
.work-grid { display: grid; gap: 20px; margin-top: 8px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "names" "preview" "go"; align-items: start; }
#names-panel { grid-area: names; }
#go-panel { grid-area: go; }
.preview-area { grid-area: preview; min-width: 0; }
@media (min-width: 980px) {
  .work-grid { grid-template-columns: minmax(340px, 410px) minmax(0, 1fr); grid-template-areas: "names preview" "names go"; grid-template-rows: auto 1fr; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px; min-width: 0; }
.panel h3 { font-size: var(--step-1); margin: 0 0 10px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Choosing rules or a spreadsheet */
.tabs { border: 0; padding: 0; margin: 0 0 14px; display: flex; gap: 0; flex-wrap: wrap; }
.tab { position: relative; cursor: pointer; }
.tab input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tab span { display: inline-block; padding: 0.45em 1em; border: 2px solid var(--line); background: var(--bg); color: var(--fg); font-weight: 600; font-size: var(--step--1); }
.tab:first-of-type span { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.tab:last-of-type span { border-radius: 0 var(--radius-s) var(--radius-s) 0; margin-left: -2px; }
.tab input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tab input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* The rules */
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rule { border: 1px solid var(--line); border-left: 4px solid #B45309; border-radius: var(--radius-s); background: var(--bg); padding: 10px 12px; }
.rule fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
/* The legend floats so the move and remove buttons can sit on the same line. */
.rule legend { padding: 0; font-weight: 700; font-size: var(--step--1); float: left; line-height: 32px; }
.rule-tools { display: flex; gap: 4px; justify-content: flex-end; margin-bottom: 8px; }
.icon-btn { font: inherit; font-size: var(--step--1); line-height: 1; min-width: 32px; min-height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); cursor: pointer; }
.icon-btn:hover:not([disabled]) { border-color: var(--primary); }
.icon-btn[disabled] { opacity: 0.4; cursor: default; }
.rule-body { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; clear: both; }
.rule-body .field { gap: 2px; }
.rule-body .field label, .rule-body .lbl { font-size: 0.8rem; font-weight: 600; }
.rule-body input[type="text"] { width: 12em; }
.rule-body input[type="number"] { width: 5em; }
.rule-body input, .rule-body select { font: inherit; font-size: var(--step--1); padding: 0.35em 0.5em; border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--fg); min-width: 0; max-width: 100%; }
.rule-body input:focus, .rule-body select:focus { border-color: var(--primary); outline: none; }
.rule-body .check { font-size: var(--step--1); }
.rule-body .check input { width: 16px; height: 16px; padding: 0; }
.rule-help { flex-basis: 100%; margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.rule-help code { color: var(--fg); }
.add-rule { margin-top: 12px; }
.small-label { display: block; font-weight: 700; font-size: var(--step--1); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 0.85rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--fg); cursor: pointer; }
.chip::before { content: "+ "; color: var(--muted); }
.chip:hover { border-color: var(--primary); }

/* From a spreadsheet */
.list-file { overflow-wrap: anywhere; }
.list-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.list-cols select { font-size: var(--step--1); padding: 0.4em 0.5em; }
.list-details { margin-top: 8px; font-size: var(--step--1); }
.list-details summary { cursor: pointer; font-weight: 600; }
.list-details ul { margin: 6px 0 0; padding-left: 1.2em; max-height: 180px; overflow: auto; overflow-wrap: anywhere; }

.order { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; display: grid; gap: 8px; }
.order .field label { font-size: var(--step--1); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.inline select { font: inherit; font-size: var(--step--1); padding: 0.4em 0.5em; border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--bg); color: var(--fg); max-width: 100%; }
.order p { margin: 0; }
.order .check { font-size: var(--step--1); }

/* Renaming */
.mode { border: 0; padding: 0; margin: 0 0 8px; display: grid; gap: 10px; }
.mode legend { font-weight: 700; font-size: var(--step--1); padding: 0; margin-bottom: 4px; }
.mode .check { align-items: flex-start; font-size: var(--step--1); }
.mode .check input { flex: none; margin-top: 2px; }
.mode b { overflow-wrap: anywhere; }
#out-note { margin-top: 0; }
.counts { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: var(--step--1); }
.counts li { display: flex; gap: 8px; align-items: baseline; }
.counts b { font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }
.counts .err { color: var(--danger); font-weight: 600; }
.counts button { font: inherit; padding: 0; border: 0; background: none; color: var(--primary); text-decoration: underline; cursor: pointer; }
#go-progress { margin-top: 14px; max-width: 420px; }
.done { border: 2px solid var(--ok); border-radius: var(--radius-m); background: var(--surface); padding: 14px 18px; margin: 14px 0 0; }
.done.failed { border-color: var(--danger); }
.done:focus { outline: none; }
.done h3 { margin: 0 0 6px; }
.done p { margin: 0 0 10px; }
.done .muted { margin: 10px 0 0; }
.stuck { margin: 0 0 10px; padding-left: 1.2em; font-size: var(--step--1); overflow-wrap: anywhere; }

/* The preview */
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.preview-head h3 { font-size: var(--step-1); margin: 0; }
.preview-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: var(--step--1); }
.preview-tools select { font: inherit; padding: 0.3em 0.5em; border: 2px solid var(--line); border-radius: var(--radius-s); background: var(--bg); color: var(--fg); }
.inline-field { font-weight: 600; }
.small-btn { padding: 0.3em 0.8em; font-size: var(--step--1); }
.table-wrap { overflow: auto; max-height: min(560px, 70vh); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
#preview { border-collapse: collapse; width: 100%; min-width: 600px; font-size: var(--step--1); }
#preview th, #preview td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
#preview thead th { position: sticky; top: 0; z-index: 1; background: var(--hero); color: var(--on-hero); }
#preview tbody tr:last-child td { border-bottom: 0; }
#preview td:first-child { width: 2.2em; }
#preview input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); margin: 1px 0 0; }
#preview .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); width: 3.5em; }
#preview .old { width: 27%; }
#preview .new { width: 37%; }
#preview .new b { font-weight: 600; }
#preview .in { display: block; color: var(--muted); font-size: 0.8rem; }
#preview tr.same .new, #preview tr.off .new { color: var(--muted); }
#preview tr.off .old { color: var(--muted); }
#preview tr.err { background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
#preview .move { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
#preview .move .icon-btn { min-width: 26px; min-height: 26px; padding: 0 4px; }
.notes { display: grid; gap: 3px; }
.flag { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0 6px; margin-right: 6px; border-radius: 999px; border: 1px solid; vertical-align: 1px; }
.flag.err { color: var(--danger); border-color: var(--danger); }
.flag.warn { color: var(--highlight-ink); background: var(--highlight); border-color: color-mix(in srgb, var(--highlight) 60%, #000); }
.flag.info { color: var(--muted); border-color: var(--line); }
.how { margin-top: 20px; font-size: var(--step--1); max-width: 85ch; }

/* Phones: each file as a block (current name, then the new one, then any notes), so nothing
   important hides behind a sideways scroll. The rows keep their table roles (set in the HTML). */
@media (max-width: 600px) {
  #preview { min-width: 0; }
  #preview thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #preview tbody tr { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  #preview tbody tr:last-child { border-bottom: 0; }
  #preview tbody td, #preview tbody td.old, #preview tbody td.new, #preview tbody td.num, #preview tbody td:first-child { display: block; padding: 0; border: 0; width: auto; grid-column: 2; }
  #preview tbody td:first-child { grid-column: 1; grid-row: 1 / span 4; }
  #preview tbody td.num { text-align: left; }
  #preview tbody td.num:not(:has(.move)) { display: none; }
  #preview tbody td.new::before { content: "→ "; color: var(--muted); }
  #preview tbody td:last-child:empty { display: none; }
  #preview tbody td[colspan] { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .rule-body input[type="text"] { width: 100%; }
  .rule-body .field.grow { flex: 1 1 100%; }
  .results-head .actions { width: 100%; }
}
