/* ATorrent: a dense, tool-like interface for investigators. All sizes in rem. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --fg: #1c2230;
  --muted: #5d6677;
  --line: #d9dde5;
  --accent: #2b55b8;
  --accent-fg: #ffffff;
  --ok: #1d7a49;
  --ok-bg: #e2f3ea;
  --warn: #8a5b00;
  --warn-bg: #fbf0d8;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --info-bg: #e6ecfa;
  --code-bg: #eef1f6;
  --radius: 0.375rem;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13161c;
    --surface: #1b1f27;
    --fg: #e3e6ec;
    --muted: #98a1b0;
    --line: #2d333e;
    --accent: #8aa6f4;
    --accent-fg: #0f1320;
    --ok: #7fd2a5;
    --ok-bg: #173226;
    --warn: #f0c46b;
    --warn-bg: #3a2e14;
    --bad: #f29b93;
    --bad-bg: #3d1d1b;
    --info-bg: #1f2944;
    --code-bg: #232935;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 0.9375rem/1.5 var(--font); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.125rem;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.125rem; margin: 1.5rem 0 0.5rem; }
code, .mono { font-family: var(--mono); font-size: 0.8125rem; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem;
  padding: 0.625rem 1rem; background: var(--surface); border-bottom: 0.0625rem solid var(--line);
}
.brand { font-weight: 700; color: var(--fg); text-decoration: none; letter-spacing: 0.02em; }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 0.125rem 0; border-bottom: 0.125rem solid transparent; }
.nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.account { display: flex; gap: 0.25rem; align-items: center; }
.account .icon-button { padding: 0.375rem; color: var(--muted); }
.account .icon-button:hover, .account .icon-button[aria-current="page"] { color: var(--fg); }
.account .icon { width: 1.25rem; height: 1.25rem; }
.account form { margin: 0; }

.page { max-width: 90rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.narrow { max-width: 32rem; }
.card { background: var(--surface); border: 0.0625rem solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: 1.5rem; }
.card h2 { margin-top: 0; }

.stack { display: grid; gap: 0.75rem; }
.stack label, .search-bar label { display: grid; gap: 0.25rem; font-weight: 600; font-size: 0.875rem; }
.stack label .muted { font-weight: 400; }
.stack label:has(> input[type="checkbox"]) { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
.row { display: flex; gap: 1rem; align-items: center; }
.inline-form { display: inline-flex; gap: 0.5rem; align-items: center; margin: 0; }
.filters { margin-bottom: 1rem; flex-wrap: wrap; }
.filters label { display: inline-flex; gap: 0.375rem; align-items: center; white-space: nowrap; }
.filters select { width: auto; }
.small-form { margin-top: 0.5rem; }

input, select, button, .button { font: inherit; }
input[type="text"], input[type="search"], input[type="password"], input[type="url"], input[type="number"], input:not([type]), select {
  width: 100%; padding: 0.4375rem 0.625rem; border: 0.0625rem solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); min-width: 0;
}
input.short { width: 5rem; }
button, .button {
  display: inline-block; padding: 0.4375rem 0.875rem; border: 0.0625rem solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; line-height: 1.4;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.small, .button.small { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
button.danger { color: var(--bad); }
button.danger-solid { background: var(--bad); border-color: var(--bad); color: var(--surface); font-weight: 600; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error, .error-text { color: var(--bad); }
.error:empty, .validation-summary-valid { display: none; }
.error ul { margin: 0; padding-left: 1.25rem; }
.notice { padding: 0.5rem 0.75rem; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

.search-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }
.search-bar .grow { flex: 1 1 20rem; }
.plugins { border: 0.0625rem solid var(--line); border-radius: var(--radius); background: var(--surface); margin-top: 1rem; padding: 0.75rem 1rem 1rem; }
.plugins legend { font-weight: 600; padding: 0 0.25rem; }
.plugin-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.plugin-tools input { max-width: 18rem; }
.plugin-group h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1rem 0 0.25rem; }
.plugin-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.125rem 1rem; }
.plugin-list label { display: flex; gap: 0.375rem; align-items: center; padding: 0.125rem 0; cursor: pointer; }
.plugin-list label.disabled { color: var(--muted); cursor: not-allowed; }
.tag { display: inline-block; font-size: 0.6875rem; padding: 0 0.375rem; border-radius: 1rem; background: var(--code-bg); color: var(--muted); margin-right: 0.25rem; }

.table-wrap { overflow-x: auto; border: 0.0625rem solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
table.data th, table.data td { padding: 0.4375rem 0.625rem; border-bottom: 0.0625rem solid var(--line); text-align: left; vertical-align: middle; }
table.data th { background: var(--code-bg); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[aria-sort="ascending"]::after { content: " ▲"; }
table.data th[aria-sort="descending"]::after { content: " ▼"; }
table.data tr:last-child td { border-bottom: 0; }
table.data.compact td { padding: 0.25rem 0.625rem; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.hash { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
table.data tr.dupe td { opacity: 0.65; }
table.data tr.group-head td.col-name::before { content: attr(data-count) "× "; color: var(--muted); font-size: 0.75rem; }
table.data th[draggable="true"]:active { cursor: grabbing; }
table.data.fit { table-layout: fixed; }
table.data.fit th, table.data.fit td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data.fit th { position: relative; }
table.data.fit td.col-name { white-space: normal; overflow-wrap: anywhere; }
.col-resizer { position: absolute; top: 0; bottom: 0; width: 0.5rem; cursor: col-resize; touch-action: none; }
.col-resizer[data-side="right"] { right: 0; }
.col-resizer[data-side="left"] { left: 0; }
.col-resizer::after { content: ""; position: absolute; top: 25%; bottom: 25%; left: 50%; border-left: 0.0625rem solid var(--line); }
.col-resizer:hover::after, .col-resizing .col-resizer:active::after { border-left: 0.125rem solid var(--accent); }
body.col-resizing { cursor: col-resize; user-select: none; }
table.data th.drop-target { box-shadow: inset 0.1875rem 0 0 var(--accent); }

.status { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.0625rem 0.5rem; border-radius: 1rem; background: var(--code-bg); color: var(--muted); white-space: nowrap; }
.status-succeeded, .status-completed { background: var(--ok-bg); color: var(--ok); }
.status-failed, .status-timedout { background: var(--bad-bg); color: var(--bad); }
.status-running, .status-queued, .status-pending { background: var(--info-bg); color: var(--accent); }
.status-notconfigured, .status-cancelled { background: var(--warn-bg); color: var(--warn); }

.search-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: start; }
.search-head h1 { position: relative; margin-bottom: 0.25rem; overflow-wrap: anywhere; }
/* The (i) button's details appear under the heading on hover or keyboard focus (a tap focuses it on touch screens). */
.info-button { vertical-align: middle; color: var(--muted); }
.info-button .icon { width: 1.125rem; height: 1.125rem; }
.info .tooltip {
  position: absolute; left: 0; top: calc(100% + 0.25rem); z-index: 20; width: max-content; max-width: min(36rem, calc(100vw - 2rem));
  padding: 0.375rem 0.625rem; border-radius: var(--radius); background: var(--fg); color: var(--bg);
  font-size: 0.8125rem; font-weight: 400; line-height: 1.4; visibility: hidden; opacity: 0; transition: opacity 0.1s;
}
.info:hover .tooltip, .info:focus-within .tooltip { visibility: visible; opacity: 1; }
.search-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.runs { margin: 1rem 0; }
.runs summary { cursor: pointer; font-weight: 600; margin-bottom: 0.5rem; }
.results-tools { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; margin-bottom: 0.75rem; }
.results-tools input[type="search"] { max-width: 22rem; }
.results-tools label { display: inline-flex; gap: 0.375rem; align-items: center; font-size: 0.875rem; }
.column-picker { position: relative; }
.column-picker summary { list-style: none; }
.column-picker summary::-webkit-details-marker { display: none; }
.column-menu {
  position: absolute; z-index: 10; top: calc(100% + 0.25rem); left: 0; width: 17rem; padding: 0.75rem;
  background: var(--surface); border: 0.0625rem solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.18);
}
.column-menu p { margin: 0 0 0.5rem; font-size: 0.8125rem; }
.column-list { list-style: none; margin: 0 0 0.75rem; padding: 0; max-height: min(32rem, 70vh); overflow-y: auto; }
.column-list li { display: flex; gap: 0.25rem; align-items: center; padding: 0.0625rem 0; }
.column-list label { flex: 1; }
.column-list button.small { padding: 0 0.5rem; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
.dialog {
  width: min(40rem, calc(100vw - 2rem)); padding: 1rem 1.25rem; border: 0.0625rem solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--fg);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-small { width: min(28rem, calc(100vw - 2rem)); }
.dialog .stack label { font-weight: 600; }
.dialog h2 { margin-top: 0; }
.dialog textarea {
  width: 100%; padding: 0.4375rem 0.625rem; border: 0.0625rem solid var(--line); border-radius: var(--radius);
  background: var(--code-bg); color: var(--fg); font-family: var(--mono); font-size: 0.8125rem; word-break: break-all; resize: vertical;
}
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.75rem; }
.icon { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-busy { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; padding: 0.1875rem; border: 0;
  border-radius: var(--radius); background: none; color: var(--accent); line-height: 1; cursor: pointer;
}
.icon-button:hover { background: var(--info-bg); }
.icon-button.done { color: var(--ok); }
.icon-button.danger { color: var(--muted); }
.icon-button.danger:hover { color: var(--bad); background: var(--bad-bg); }
table.data td.actions { width: 1%; text-align: right; }
table.data td.actions form { margin: 0; }
.icon-button:disabled { opacity: 1; cursor: progress; }
/* Cells clip their content, so the focus ring is drawn inside the button. */
.icon-button:focus-visible { outline-offset: -0.125rem; }
table.data td.links { padding-top: 0.25rem; padding-bottom: 0.25rem; }
table.data td.links > * + * { margin-left: 0.25rem; }
table.data td .ago { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 0.75rem; color: var(--muted); }
.meter { display: block; height: 0.1875rem; margin-top: 0.1875rem; border-radius: 0.125rem; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; }
.meter-seeders > span { background: var(--ok); }
.meter-leechers > span { background: var(--warn); }
.meter-peers > span { background: var(--accent); }
.results-pager { flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.875rem; }
.results-pager label { display: inline-flex; gap: 0.375rem; align-items: center; margin-left: auto; }
.results-pager select { width: auto; padding: 0.25rem 0.5rem; }
.link-list { columns: 16rem; padding-left: 1.25rem; }

@media (max-width: 40rem) {
  .page { padding: 1rem 1rem 2rem; }
  .account { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
