/* CleanSilly – shared theme and components.
   Tool-specific tweaks belong in each tool's own assets/app.css. */

:root, [data-theme="light"] {
  --bg: #ECF0F2;
  --panel: #FFFFFF;
  --panel-2: #F4F7F8;
  --ink: #14203A;
  --muted: #5A6678;
  --line: #D2D9DE;
  --line-soft: #E4E9EC;
  --accent: #0B2378;
  --accent-hover: #081A5C;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7ECF9;
  --brand-teal: #22DDCB;
  --teal-soft: #DDF7F4;
  --keep: #2A7550;
  --keep-bar: #2E8A5C;
  --keep-tint: #E1F1E7;
  --review: #955F0D;
  --review-bar: #D0912A;
  --review-tint: #F8ECD4;
  --remove: #B0332D;
  --remove-bar: #C8413A;
  --remove-tint: #F7E0DD;
  --hatch-a: #D8DFE3;
  --hatch-b: #E9EEF0;
  --focus: #2F6FD0;
  --shadow: 0 18px 40px rgba(20, 32, 58, 0.18);
  --app-bg: url('bg.jpg') center / cover fixed no-repeat, #ECF0F2;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.74);
  --glass-line: rgba(255, 255, 255, 0.9);
  --glass-divider: rgba(20, 32, 58, 0.08);
  --gl-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.18));
  --gl-fill-hover: linear-gradient(135deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.28));
  --gl-edge: rgba(255, 255, 255, 0.7);
  --gl-shadow: 0 8px 32px rgba(31, 44, 90, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -1px 0 rgba(255, 255, 255, 0.2);
  --gl-shadow-hover: 0 16px 44px rgba(31, 44, 90, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(255, 255, 255, 0.25);
  --gl-bar: rgba(255, 255, 255, 0.3);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0D1322;
  --panel: #141C2F;
  --panel-2: #1A2339;
  --ink: #E5E9F1;
  --muted: #9AA5B8;
  --line: #2B3652;
  --line-soft: #222C45;
  --accent: #22DDCB;
  --accent-hover: #4BE6D7;
  --accent-ink: #06163F;
  --accent-soft: #16324A;
  --brand-teal: #22DDCB;
  --teal-soft: #13333D;
  --keep: #5BC894;
  --keep-bar: #3DA673;
  --keep-tint: #173529;
  --review: #E6AE4E;
  --review-bar: #C98B26;
  --review-tint: #3A2E17;
  --remove: #F2847D;
  --remove-bar: #D2524A;
  --remove-tint: #3D1F20;
  --hatch-a: #1E2840;
  --hatch-b: #182137;
  --focus: #7DB3FF;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  --app-bg: linear-gradient(rgba(11, 17, 31, 0.84), rgba(11, 17, 31, 0.9)) center / cover fixed, url('bg.jpg') center / cover fixed no-repeat, #0D1322;
  --glass: rgba(20, 28, 47, 0.6);
  --glass-strong: rgba(20, 28, 47, 0.72);
  --glass-line: rgba(255, 255, 255, 0.08);
  --glass-divider: rgba(255, 255, 255, 0.06);
  --gl-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  --gl-fill-hover: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  --gl-edge: rgba(255, 255, 255, 0.14);
  --gl-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --gl-shadow-hover: 0 16px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --gl-bar: rgba(20, 28, 47, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--app-bg);
  min-height: 100vh;
  color: var(--ink);
  font: 400 15px/1.5 "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--accent); }
[data-theme="dark"] a { color: var(--brand-teal); }
code { font-size: .92em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num-tab { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--gl-bar); border-bottom: 1px solid var(--gl-edge);
  -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
  box-shadow: 0 4px 24px rgba(31, 44, 90, 0.06), inset 0 -1px 0 rgba(255, 255, 255, 0.15);
}
.top .theme-btn { background: var(--gl-fill); border-color: var(--gl-edge); box-shadow: var(--gl-shadow); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.top .theme-btn:hover { background: var(--gl-fill-hover); }
.top-in { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink) !important; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand img { display: block; }
.crumb-sep { color: var(--line); font-size: 20px; }
.crumb { font-weight: 500; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.quiet-link { color: var(--muted) !important; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.quiet-link:hover { color: var(--ink) !important; }
.theme-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.theme-btn:hover { border-color: var(--muted); }
.theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: block; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  padding: 10px 16px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--remove); border-color: var(--remove-tint); }
.btn.danger:hover:not(:disabled) { background: var(--remove-bar); border-color: var(--remove-bar); color: #fff; }
.btn.danger-solid { background: var(--remove-bar); border-color: var(--remove-bar); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.flash { background: var(--keep-bar); border-color: var(--keep-bar); color: #fff; }
.quiet { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.quiet:hover { color: var(--ink); }

/* ---------- Tool page ---------- */
.tool-head { padding: 26px 0 16px; }
.tool-head h1 { font-size: 28px; }
.tool-head p { margin: 4px 0 0; color: var(--muted); max-width: 72ch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px 26px; }

/* Loader: file drop + paste, shown until a list is loaded */
.loader { display: grid; grid-template-columns: 1fr 1.3fr; gap: 18px; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 24px; min-height: 170px;
  cursor: pointer; text-align: center; color: var(--muted); background: var(--panel-2);
}
.drop strong { color: var(--ink); font-weight: 600; }
.drop small { font-size: 12.5px; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.paste { display: flex; flex-direction: column; }
.field-label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 6px; }
.paste textarea {
  flex: 1; min-height: 124px; resize: vertical; font-family: inherit; font-size: 13px; line-height: 1.5;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); color: var(--ink); tab-size: 16;
}
.paste .btn { margin-top: 10px; align-self: flex-start; }

/* Source bar: what's loaded, replaces the loader */
.sourcebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.sourcebar .src { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sourcebar .src-icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--teal-soft); color: var(--accent); flex: none; }
[data-theme="dark"] .sourcebar .src-icon { color: var(--brand-teal); }
.sourcebar b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sourcebar small { color: var(--muted); font-size: 13px; }

/* Options + main action */
.optbar { display: flex; justify-content: space-between; align-items: center; gap: 14px 24px; flex-wrap: wrap; margin-top: 16px; }
.opts-inline { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: 14px; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.check input:disabled + span { opacity: .6; }
.opt-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; max-width: 90ch; }

/* ---------- Results workspace ---------- */
.workspace { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line-soft); }

.bar {
  display: flex; height: 34px; border-radius: 8px; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--hatch-a) 0 7px, var(--hatch-b) 7px 14px);
  border: 1px solid var(--line);
}
.seg { display: block; height: 100%; width: 0; transition: width .45s ease; }
.seg.keep { background: var(--keep-bar); }
.seg.review { background: var(--review-bar); }
.seg.remove { background: var(--remove-bar); }
.tally { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 12px; }
.t { display: inline-flex; align-items: baseline; gap: 8px; background: none; border: 0; padding: 2px 0; font-family: inherit; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.t b { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.t.keep b { color: var(--keep); }
.t.review b { color: var(--review); }
.t.remove b { color: var(--remove); }
.t.pending { cursor: default; }
.t:not(.pending):hover { color: var(--ink); }
.runctl { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding: 12px 0 16px; border-top: 1px solid var(--line-soft); }
.runstatus { color: var(--muted); font-size: 14px; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.filter .ct { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }
.btn.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.btn.filter[aria-pressed="true"] .ct { color: var(--line); }
.tool-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.btn.icon { width: 40px; height: 36px; padding: 0; display: inline-grid; place-items: center; }
.btn.icon svg { width: 18px; height: 18px; }
.deleted-note { margin: 0; color: var(--muted); font-size: 13px; align-self: center; }

.bulk { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.bulk .check { font-weight: 500; }
.selcount { color: var(--muted); font-size: 13px; margin-right: 4px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 600; font-size: 12.5px; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; color: var(--muted); width: 1%; white-space: nowrap; }
td.sel { width: 1%; }
td.sel input, .bulk input { width: 16px; height: 16px; accent-color: var(--accent); margin: 2px 0 0; cursor: pointer; }
tr.picked td { background: var(--accent-soft); }
.was { display: block; color: var(--muted); font-size: 12px; text-decoration: line-through; word-break: break-all; }
.none { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.why ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.why li { position: relative; padding-left: 14px; }
.why li::before { content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.why li.remove::before { background: var(--remove-bar); }
.why li.review::before { background: var(--review-bar); }
.why li.info { color: var(--muted); }
.why li.fix { color: var(--accent); }
[data-theme="dark"] .why li.fix { color: var(--brand-teal); }
.why li.fix::before { background: none; border: 1.5px solid currentColor; width: 5px; height: 5px; }
td.why { min-width: 260px; }

.pill { display: inline-block; font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.keep { background: var(--keep-tint); color: var(--keep); }
.pill.review { background: var(--review-tint); color: var(--review); }
.pill.remove { background: var(--remove-tint); color: var(--remove); }
.pill.pending { background: var(--panel-2); color: var(--muted); }
td.st { white-space: nowrap; }
.bymanual { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Keep / Remove decision boxes */
td.decide { width: 1%; white-space: nowrap; border-left: 1px solid var(--line-soft); }
.decide-in { display: flex; flex-direction: column; gap: 6px; }
.dc { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 500; cursor: pointer; padding: 3px 10px 3px 6px; border-radius: 6px; border: 1px solid transparent; }
.dc input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.dc.keep input { accent-color: var(--keep-bar); }
.dc.remove input { accent-color: var(--remove-bar); }
.dc:hover { border-color: var(--line); }
.dc.keep:has(input:checked) { background: var(--keep-tint); color: var(--keep); }
.dc.remove:has(input:checked) { background: var(--remove-tint); color: var(--remove); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 13px; }

.exports { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.exports h3 { font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; max-width: 70ch; }

/* ---------- Notices, resume banner, dialog ---------- */
#notices:empty { display: none; }
.notice { margin-bottom: 14px; padding: 12px 16px; border-radius: 8px; border: 1px solid; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.notice.warn { background: var(--review-tint); border-color: var(--review-bar); color: var(--ink); }
.notice.error { background: var(--remove-tint); border-color: var(--remove-bar); color: var(--ink); }
.notice.ok { background: var(--keep-tint); border-color: var(--keep-bar); color: var(--ink); }
.notice button { background: none; border: 0; font: inherit; cursor: pointer; color: inherit; text-decoration: underline; flex: none; }
.resume { margin-bottom: 14px; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 14px 18px; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.resume p { margin: 0; }

.modal-back { position: fixed; inset: 0; background: rgba(8, 14, 30, 0.5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(440px, 100%); box-shadow: var(--shadow); }
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { margin: 0 0 20px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- Dashboard ---------- */
.hero { display: flex; justify-content: center; padding: 64px 0 48px; }
.tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; padding-bottom: 20px; }
.tool-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  width: 320px; max-width: 100%; height: 196px; padding: 24px; border-radius: 16px; text-align: center;
  border: 1px solid var(--gl-edge); background: var(--gl-fill);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--gl-shadow);
  color: var(--ink) !important; text-decoration: none;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.tool-card::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand-teal), var(--accent));
  transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
[data-theme="dark"] .tool-card::after { background: linear-gradient(90deg, var(--brand-teal), #6D86FF); }
.tool-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 38%);
  opacity: .7;
}
[data-theme="dark"] .tool-card::before { background: linear-gradient(115deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 38%); }
.tool-card > * { position: relative; }
.tool-card:hover, .tool-card:focus-visible { background: var(--gl-fill-hover); transform: translateY(-3px); box-shadow: var(--gl-shadow-hover); }
.tool-card:hover::after, .tool-card:focus-visible::after { transform: scaleX(1); }
.tool-card .ic {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.6); color: var(--accent);
  border: 1px solid var(--gl-edge);
  box-shadow: 0 6px 18px rgba(31, 44, 90, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
[data-theme="dark"] .tool-card .ic { color: var(--brand-teal); background: rgba(255, 255, 255, 0.07); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.tool-card .ic svg { width: 30px; height: 30px; }
.tool-card .ic-glyph {
  display: block; width: 42px; height: 42px; background: currentColor;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.tool-card h2 { font-size: 18px; }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 40px; font-size: 13px; color: var(--muted); }

@media (max-width: 800px) {
  .wrap { padding: 0 14px; }
  .panel { padding: 18px 14px; }
  .loader { grid-template-columns: 1fr; }
  .crumb-sep, .crumb { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .modal-back { animation: csFade .15s ease; }
  .modal { animation: csPop .18s ease; }
  @keyframes csFade { from { opacity: 0; } }
  @keyframes csPop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
}
@media (prefers-reduced-motion: reduce) {
  .seg, .tool-card, .tool-card::after { transition: none; }
  .tool-card:hover { transform: none; }
}

/* ---------- Logo with spinning dotted rings ---------- */
:root, [data-theme="light"] { --ring-1: #8A949E; --ring-2: #A7B0B8; --ring-3: #C3CAD0; }
[data-theme="dark"] { --ring-1: #8E98A8; --ring-2: #6B7588; --ring-3: #4E586B; }
.ringed { --gap: 4px; --w: 2px; position: relative; display: inline-grid; place-items: center; flex: none; margin: calc(var(--gap) * 2); }
.ringed img { position: relative; display: block; border-radius: 50%; }
.ringed .r { position: absolute; border-radius: 50%; border: var(--w) dotted; pointer-events: none; }
.ringed .r1 { inset: calc(var(--gap) * -1); border-color: #9AA4AF; animation: csSpin 14s linear infinite; }
.ringed .r2 { inset: calc(var(--gap) * -2); border-color: #B3BBC4; animation: csSpin 22s linear infinite reverse; }
[data-theme="dark"] .ringed .r1 { border-color: #7C8698; }
[data-theme="dark"] .ringed .r2 { border-color: #5E687B; }
.ringed-sm { --gap: 3.5px; --w: 2px; }
.ringed-lg { --gap: 11px; --w: 3px; }
@keyframes csSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ringed .r { animation: none; } }
