/* Tidy Folders: 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; }
.small { font-size: var(--step--1); margin: 6px 0; }
#drop { min-height: 200px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.browser-note { border-left: 4px solid var(--primary); background: var(--surface); border-radius: var(--radius-s); padding: 10px 14px; max-width: 72ch; }

.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; }
.scope { margin: 18px 0 0; display: grid; gap: 10px; max-width: 72ch; min-width: 0; }
.scope legend { font-weight: 700; padding: 0 6px; }
.scope p { margin: 0; }
#scope-slot .scope { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 0 0; margin: 14px 0 0; background: none; max-width: none; }
#scope-slot .scope legend { padding: 0; float: left; width: 100%; margin-bottom: 8px; font-size: var(--step--1); }
#scope-slot .scope .check { font-size: var(--step--1); }
.check { align-items: flex-start; }
.check input { flex: none; margin-top: 3px; }

.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); }

#scanning { max-width: 640px; margin: 40px auto; }
#scanning h2:focus { outline: none; }
#scan-progress { margin: 18px 0 8px; }

.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 { font-size: var(--step--1); margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.results-head .actions { margin-top: 0; }

.problems { border-left: 4px solid var(--danger); background: var(--surface); border-radius: var(--radius-s); padding: 10px 14px; margin: 0 0 16px; }
.problems h3 { font-size: var(--step-0); margin: 0 0 4px; }
.problems ul, .putback-list, .done-list { margin: 6px 0 0; padding-left: 1.2em; font-size: var(--step--1); display: grid; gap: 4px; overflow-wrap: anywhere; }

/* Putting back from an earlier tidy */
.logs { margin: 0 0 16px; border-left: 4px solid var(--primary); }
.logs .field.inline { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.logs select { max-width: 100%; }
.putback { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.putback:focus { outline: none; }
.putback:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
.putback p { margin: 0; }

/* Rules on the left; the button and the before and after on the right. On narrow screens: rules,
   then the before and after, then the button, so every move is seen before it can be made. */
.work-grid { display: grid; gap: 20px; margin-top: 8px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "rules" "preview" "go"; align-items: start; }
#rules-panel { grid-area: rules; }
#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: "rules go" "rules preview"; grid-template-rows: auto 1fr; }
}

/* Presets and rules */
.small-label { display: block; font-weight: 700; font-size: var(--step--1); margin-bottom: 6px; }
.presets { margin: 4px 0 14px; }
.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.add::before { content: "+ "; color: var(--muted); }
.chip:hover:not([disabled]) { border-color: var(--primary); }
.chip[disabled] { opacity: 0.5; cursor: default; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rule { border: 1px solid var(--line); border-left: 4px solid #65A30D; border-radius: var(--radius-s); background: var(--bg); padding: 10px 12px; }
.rule > fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.rule > fieldset > 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; min-width: 0; }
.rule-body .field label { font-size: 0.8rem; font-weight: 600; }
.rule-body input[type="text"] { width: 11em; }
.rule-body input[type="number"] { width: 6em; }
.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-body input[type="checkbox"]:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.type-checks { flex-basis: 100%; border: 0; padding: 0; margin: 0; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr)); gap: 4px 10px; }
.type-checks legend { font-size: 0.8rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
.rule-help { flex-basis: 100%; margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.rule-help code { color: var(--fg); }
.rule-problem { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }
.rule-problem[data-kind="error"] { color: var(--danger); font-weight: 600; }
.add-rule { margin-top: 12px; }
.dates-field { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.dates-field select { font-size: var(--step--1); padding: 0.4em 0.5em; max-width: 100%; }

/* Types and their folders */
.types-editor { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.types-editor summary { cursor: pointer; font-weight: 700; font-size: var(--step--1); }
.type-row { display: grid; grid-template-columns: minmax(0, 7.5em) minmax(0, 9em) minmax(0, 1fr); gap: 4px 10px; align-items: end; padding: 8px 0; border-top: 1px solid var(--line); }
.type-name { font-weight: 600; font-size: var(--step--1); padding-bottom: 0.45em; overflow-wrap: anywhere; }
.type-row .field { gap: 2px; }
.type-row .field label { font-size: 0.8rem; }
.type-row input, .type-row textarea { font-size: var(--step--1); padding: 0.35em 0.5em; width: 100%; }
.type-row textarea { resize: vertical; min-height: 2.6em; line-height: 1.35; }
.type-other { margin: 0; padding-bottom: 0.45em; }
#types-note { color: var(--muted); }
.small-btn { padding: 0.3em 0.8em; font-size: var(--step--1); }

/* The button */
.counts { list-style: none; margin: 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; flex: none; }
.counts .note, .counts .err { padding-left: calc(2.5em + 8px); }
.counts .err { color: var(--danger); font-weight: 600; }
.counts button { font: inherit; padding: 0; border: 0; background: none; color: var(--primary); text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; }
.move-note { color: var(--muted); }
#move-progress { margin-top: 12px; }
.done { border: 2px solid var(--ok); border-radius: var(--radius-m); background: var(--surface); padding: 14px 18px; margin: 14px 0 0; }
.done:focus { outline: none; }
.done:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.done h3 { margin: 0 0 6px; }
.done p { margin: 0; overflow-wrap: anywhere; }
.report { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 2px; }

/* Before and after */
.trees { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; align-items: start; }
.tree-box h3 { margin-bottom: 6px; }
.tree-help { margin: 0 0 8px; }
.tree-root { margin: 0 0 4px; font-weight: 700; font-size: var(--step--1); overflow-wrap: anywhere; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; font-size: var(--step--1); }
.tree ul { margin-left: 9px; padding-left: 12px; border-left: 1px solid var(--line); }
.tree li { padding: 2px 0; min-width: 0; }
.tree .row { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.tree .row .check { gap: 6px; align-items: center; }
.tree .row .check input { margin: 0; width: 16px; height: 16px; }
.tree .row .check input:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.dname { font-weight: 600; overflow-wrap: anywhere; }
.dname::before { content: ""; display: inline-block; width: 15px; height: 12px; margin-right: 6px; vertical-align: -1px; background: currentColor; opacity: 0.55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 1.5A1.5 1.5 0 0 1 1.5 0h3.8l1.5 1.6h6.7A1.5 1.5 0 0 1 15 3.1v7.4a1.5 1.5 0 0 1-1.5 1.5h-12A1.5 1.5 0 0 1 0 10.5z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 1.5A1.5 1.5 0 0 1 1.5 0h3.8l1.5 1.6h6.7A1.5 1.5 0 0 1 15 3.1v7.4a1.5 1.5 0 0 1-1.5 1.5h-12A1.5 1.5 0 0 1 0 10.5z'/%3E%3C/svg%3E") no-repeat center / contain; }
.tree .count { color: var(--muted); font-size: 0.8rem; }
.tree .file { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.fname { overflow-wrap: anywhere; min-width: 0; }
.tree .file.leave .fname, .tree .file.stay .fname { color: var(--muted); }
.tree .more { color: var(--muted); font-style: italic; }
.tree .dir.off > .row .dname { color: var(--muted); }
.tag { font-size: 0.72rem; font-weight: 700; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.new { background: #CFF3E8; border-color: #9ADFC9; color: #0B4F3E; }
.tag.num { background: #FFE58F; border-color: #E6C65C; color: #16213B; }

/* Every file */
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 20px 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; }
.table-wrap { overflow: auto; max-height: min(520px, 70vh); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.table-wrap:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
#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 input[type="checkbox"]:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
#preview .from { width: 30%; }
#preview .to { width: 32%; }
#preview .to b { font-weight: 600; }
#preview .why { color: var(--muted); }
#preview tr.leave .from, #preview tr.stay .from { color: var(--muted); }
.how { margin-top: 24px; font-size: var(--step--1); max-width: 85ch; }

/* Phones: each file as a block (where it is, where it goes, why), so nothing 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.from, #preview tbody td.to, #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 3; }
  #preview tbody td.to::before { content: "→ "; color: var(--muted); }
  #preview tbody td[colspan] { grid-column: 1 / -1; }
  .type-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .type-row .type-name { grid-column: 1 / -1; padding-bottom: 0; }
  .type-row .field.grow, .type-row .type-other { 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%; }
}
