/* Neutral warm-grey base, one lime accent reserved for progress and the primary action. */
:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --sunken: #ecece8;
  --line: #e2e2dc;
  --text: #161714;
  --muted: #676b63;
  --faint: #9a9d95;
  --accent: #b9f13f;
  --accent-ink: #151a06;
  --bar: #74b80c;
  --bar-idle: #c4c6bf;
  --danger: #c93a26;
  --ring: rgba(116, 184, 12, 0.35);
  --r-sm: 6px;
  --r-md: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f100e;
    --surface: #171815;
    --sunken: #1e1f1b;
    --line: #272924;
    --text: #ecede8;
    --muted: #92968c;
    --faint: #5f6259;
    --bar: #b9f13f;
    --bar-idle: #3a3d36;
    --danger: #ff6a55;
    --ring: rgba(185, 241, 63, 0.28);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--bar); outline-offset: 2px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px 80px; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 28px 0 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 650; letter-spacing: -0.02em; text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.meters { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 13px; }
.meter { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.meter svg { width: 14px; height: 14px; color: var(--faint); }
.meter b { color: var(--text); font-weight: 550; }
.signout { white-space: nowrap; background: none; border: 0; padding: 4px 0; color: var(--muted); cursor: pointer; font-size: 13px; }
.signout:hover { color: var(--text); }

/* Add bar */
.add {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 7px 7px 7px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.add:focus-within { border-color: var(--bar); box-shadow: 0 0 0 4px var(--ring); }
.add input[type=text] {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  padding: 8px 0; font-size: 15px;
}
.add input::placeholder { color: var(--faint); }
.hint { margin: 10px 2px 30px; color: var(--faint); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, transform .06s;
}
.btn:hover { background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(0.95); }
.btn:disabled { opacity: .55; cursor: default; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--r-sm); border: 0; background: none; color: var(--muted); cursor: pointer;
  text-decoration: none; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.danger:hover { color: var(--danger); }
.confirm {
  height: 32px; padding: 0 10px; border-radius: var(--r-sm); border: 0; cursor: pointer;
  background: var(--danger); color: #fff; font-size: 12.5px; font-weight: 600;
}

/* Torrent list */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 10px; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.section-head span { color: var(--faint); font-size: 12.5px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.row { border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 4px 10px; align-items: center;
  padding: 14px 12px 14px 10px;
}
.chev {
  width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: none;
  color: var(--faint); cursor: pointer; border-radius: 4px; transition: transform .18s, color .12s;
}
.chev:hover { color: var(--text); }
.chev svg { width: 14px; height: 14px; }
.row.open .chev { transform: rotate(90deg); }
.name {
  min-width: 0; font-size: 15px; font-weight: 560; letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.name.pending { color: var(--muted); font-weight: 450; font-family: var(--mono); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 2px; }
.actions .btn { height: 32px; padding: 0 12px; margin-left: 6px; }
.row-sub { grid-column: 2 / 4; display: grid; gap: 8px; }

.bar { height: 4px; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--bar); border-radius: 2px; transition: width .6s ease; }
.row[data-state=paused] .bar i { background: var(--bar-idle); }
.row[data-state=metadata] .bar i {
  width: 30% !important;
  animation: seek 1.4s ease-in-out infinite alternate;
  background: var(--bar-idle);
}
@keyframes seek { from { transform: translateX(-100%); } to { transform: translateX(330%); } }
@media (prefers-reduced-motion: reduce) { .row[data-state=metadata] .bar i { animation: none; } }

.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; }
.meta .state { color: var(--text); font-weight: 550; }
.row[data-state=complete] .meta .state { color: var(--bar); }
.row[data-state=paused] .meta .state { color: var(--muted); }

/* Files */
.files { border-top: 1px dashed var(--line); background: var(--bg); padding: 6px 12px 8px 44px; }
.file {
  display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center;
  padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px;
}
.file:first-child { border-top: 0; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name .dir { color: var(--faint); }
.file-size { color: var(--muted); font-size: 12.5px; text-align: right; min-width: 120px; }
.file-actions { display: flex; gap: 0; }
.files-note { padding: 10px 0; color: var(--muted); font-size: 13px; }

/* Empty state */
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 6px; }

/* Drop overlay */
.drop {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.drop.on { opacity: 1; }
.drop div {
  padding: 48px 72px; border: 2px dashed var(--bar); border-radius: 16px;
  font-size: 17px; font-weight: 600; background: var(--surface);
}

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  padding: 10px 16px; border-radius: var(--r-sm); background: var(--text); color: var(--bg);
  font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toast-in .2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.offline { color: var(--danger); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; display: grid; gap: 14px; }
.login .brand { justify-content: center; font-size: 24px; margin-bottom: 14px; }
.login .brand svg { width: 28px; height: 28px; }
.field {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); outline: 0; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--bar); box-shadow: 0 0 0 4px var(--ring); }
.login .btn { height: 44px; font-size: 14.5px; }
.login .error { margin: 0; color: var(--danger); font-size: 13px; text-align: center; min-height: 1em; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px 60px; }
  .top { padding: 18px 0 16px; }
  .meters { gap: 12px; }
  .meter.disk, .meter.up { display: none; }
  .add { flex-wrap: wrap; padding: 8px; }
  .add input[type=text] { flex-basis: 100%; padding: 6px 6px 8px; font-size: 16px; }
  .add .btn { flex: 1; }
  .row-main { grid-template-columns: 24px 1fr; }
  .actions { grid-column: 2; grid-row: 3; justify-content: flex-start; margin-left: -8px; }
  .row-sub { grid-column: 2; }
  .files { padding-left: 12px; }
  .file { grid-template-columns: 1fr auto; }
  .file-size { display: none; }
}
