/* Grayscale dark theme. Color is reserved for things that need attention. */
:root{
  --bg:#0d0d0d;          /* page */
  --surface:#161616;     /* cards, header */
  --surface-2:#1f1f1f;   /* inputs, track */
  --line:#2c2c2c;
  --fg:#ededed;
  --muted:#9a9a9a;
  --btn:#f2f2f2;         /* buttons: white with dark letters */
  --btn-fg:#111;
  --btn-hover:#fff;
  /* semantic — used sparingly, only where it matters */
  --err:#e5484d;
  --warn:#e2a03f;
  --ok:#3fb950;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--fg);
  font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
body.center{display:grid;place-items:center;min-height:100vh;padding:1rem}

header{display:flex;justify-content:space-between;align-items:center;gap:1rem;
  padding:1rem 1.25rem;background:var(--surface);border-bottom:1px solid var(--line);flex-wrap:wrap}
header h1{font-size:1.1rem;margin:0;letter-spacing:.02em}
.who{display:flex;align-items:center;gap:.75rem;font-size:.9rem;color:var(--muted)}
.who a{color:var(--fg);text-decoration:none;border-bottom:1px solid var(--line)}
.who a:hover{border-bottom-color:var(--fg)}
main{max-width:820px;margin:0 auto;padding:1.25rem}

.card{background:var(--surface);border:1px solid var(--line);border-radius:12px;
  padding:1.5rem;width:min(380px,100%);display:flex;flex-direction:column;gap:.75rem}
.card h1{margin:0;font-size:1.3rem}
.card .sub{margin:0;color:var(--muted);font-size:.9rem}

label{display:flex;flex-direction:column;gap:.3rem;font-size:.85rem;color:var(--muted)}
input,select{padding:.6rem .7rem;border:1px solid var(--line);border-radius:8px;
  background:var(--surface-2);color:var(--fg);font-size:1rem;width:100%}
input::placeholder{color:#6e6e6e}
input:focus,select:focus{outline:none;border-color:#5a5a5a;box-shadow:0 0 0 2px #ffffff1a}

button{padding:.6rem 1rem;border:1px solid var(--btn);border-radius:8px;
  background:var(--btn);color:var(--btn-fg);font-size:.95rem;font-weight:600;cursor:pointer}
button:hover:not(:disabled){background:var(--btn-hover);border-color:var(--btn-hover)}
button:disabled{opacity:.45;cursor:default}
button:focus-visible{outline:2px solid #fff;outline-offset:2px}

.searchbar{display:flex;gap:.5rem;margin-bottom:1rem;flex-wrap:wrap}
.searchbar input{flex:1 1 240px}

.row{display:flex;justify-content:space-between;align-items:center;gap:1rem;
  background:var(--surface);border:1px solid var(--line);border-radius:10px;
  padding:.75rem .9rem;margin-bottom:.5rem}
.row:hover{border-color:#3a3a3a}
.title{font-weight:600}
.sub,.jsub{font-size:.82rem;color:var(--muted)}
.muted{color:var(--muted)}
.small{font-size:.85rem}
.err{color:var(--err)}
.ok{color:var(--ok)}

/* labels stay grayscale; they are information, not alerts */
.pill{font-size:.7rem;padding:.1rem .45rem;border-radius:99px;margin-left:.35rem;
  border:1px solid var(--line);color:var(--muted)}
.pill.free{background:transparent;border-color:#5a5a5a;color:var(--fg)}
.badge{font-size:.75rem;padding:.15rem .5rem;border-radius:99px;
  border:1px solid var(--line);color:var(--muted)}
.badge.ok{background:transparent;border-color:#5a5a5a;color:var(--fg)}
/* the one status worth coloring: downloads are restricted */
.badge.warn{background:transparent;border-color:var(--warn);color:var(--warn)}

/* notifications keep their color */
.notice{background:var(--surface);border-left:3px solid var(--warn);
  padding:.6rem .8rem;border-radius:6px;font-size:.88rem}
.notice.ok{border-left-color:var(--ok)}
.notice.err{border-left-color:var(--err)}

.job{background:var(--surface);border:1px solid var(--line);border-radius:10px;
  padding:.75rem .9rem;margin-bottom:.5rem}
.jtitle{font-weight:600;font-size:.95rem;margin-bottom:.4rem}
.bar{height:8px;background:var(--surface-2);border:1px solid var(--line);border-radius:99px;overflow:hidden}
.fill{height:100%;background:#8a8a8a;transition:width .4s}
.fill.done{background:var(--fg)}
.files{display:flex;flex-direction:column;gap:.25rem;margin-top:.5rem}
.files a{color:var(--fg);text-decoration:none;font-size:.88rem;
  border-bottom:1px solid var(--line);align-self:flex-start}
.files a:hover{border-bottom-color:var(--fg)}

h2{font-size:1rem;margin:1.25rem 0 .5rem;color:var(--fg)}
.admin{margin-top:2rem;border-top:1px solid var(--line);padding-top:1rem}
.userform{display:flex;gap:.5rem;flex-wrap:wrap;margin:.75rem 0}
.userform input{flex:1 1 180px}
.urow{display:flex;justify-content:space-between;align-items:center;gap:1rem;
  background:var(--surface);border:1px solid var(--line);border-radius:10px;
  padding:.6rem .9rem;margin-bottom:.4rem}
.uname{font-weight:600}
/* destructive: outlined, not filled — reads as a warning without shouting */
.urow .del{background:transparent;color:var(--err);border-color:var(--err);font-weight:500}
.urow .del:hover:not(:disabled){background:var(--err);color:#fff;border-color:var(--err)}

/* --- small caps tag: replaces the filled oval, reads as a label not a pill -- */
.tag{display:inline-block;margin-left:.4rem;padding:.05rem .3rem;font-size:.62rem;
  font-weight:600;letter-spacing:.08em;text-transform:uppercase;
  color:var(--muted);border:1px solid var(--line);border-radius:3px;vertical-align:.08em}
.uwrap{display:inline-flex;align-items:center;color:var(--fg)}

/* --- hamburger --- */
.hamburger{display:flex;flex-direction:column;justify-content:center;gap:4px;
  width:38px;height:34px;padding:0 8px;background:transparent;border:1px solid var(--line);
  border-radius:8px;cursor:pointer}
.hamburger span{display:block;height:2px;width:100%;background:var(--fg);border-radius:2px;
  transition:transform .2s,opacity .2s}
.hamburger:hover{border-color:#4a4a4a;background:var(--surface-2)}
.hamburger.is-open span:nth-child(1){transform:translateY(6px) rotate(45deg)}
.hamburger.is-open span:nth-child(2){opacity:0}
.hamburger.is-open span:nth-child(3){transform:translateY(-6px) rotate(-45deg)}

/* --- drawer --- */
.scrim{position:fixed;inset:0;background:#000000a6;z-index:40}
.drawer{position:fixed;top:0;right:0;height:100%;width:min(420px,92vw);z-index:50;
  background:var(--surface);border-left:1px solid var(--line);
  transform:translateX(100%);transition:transform .22s ease;
  display:flex;flex-direction:column;visibility:hidden}
.drawer.open{transform:none;visibility:visible}
.drawerhead{display:flex;justify-content:space-between;align-items:center;
  padding:1rem 1.1rem;border-bottom:1px solid var(--line)}
.drawerhead h2{margin:0}
.drawerbody{padding:1.1rem;overflow-y:auto;flex:1}
.drawerfoot{padding:.9rem 1.1rem;border-top:1px solid var(--line)}
.drawerfoot a{color:var(--fg);text-decoration:none;border-bottom:1px solid var(--line);font-size:.9rem}
.iconbtn{background:transparent;border:1px solid var(--line);color:var(--fg);
  width:32px;height:32px;line-height:1;padding:0;border-radius:8px;font-size:1.2rem}
.iconbtn:hover{background:var(--surface-2);border-color:#4a4a4a}
body.noscroll{overflow:hidden}
.dsection{margin-top:1.5rem;padding-top:1.1rem;border-top:1px solid var(--line)}
.dsection h3{margin:0 0 .3rem;font-size:.95rem}
.stack{display:flex;flex-direction:column;gap:.5rem;margin-top:.6rem}
.connstate{font-size:.85rem;color:var(--muted);display:flex;align-items:center;gap:.4rem}
.dot{width:8px;height:8px;border-radius:99px;background:var(--muted);flex:none}
.dot.ok{background:var(--ok)} .dot.bad{background:var(--err)}

/* --- branding --- */
.brand{display:flex;align-items:center;gap:.6rem;min-width:0}
.brand h1{margin:0;font-size:1.05rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.logo{width:30px;height:30px;object-fit:contain;flex:none;color:var(--fg)}
.logo-lg{width:84px;height:84px;align-self:center;margin-bottom:.25rem}
@media(max-width:520px){.brand h1{font-size:.95rem}}

/* login card: centered wordmark */
.card h1{text-align:center;margin-bottom:.25rem}
.row.blocked{opacity:.55}
.pill.toobig{border-color:var(--warn);color:var(--warn)}

/* --- nav --- */
.nav{display:flex;gap:.25rem;order:3;width:100%}
@media(min-width:700px){.nav{order:0;width:auto;margin-left:.5rem}}
.nav a{color:var(--muted);text-decoration:none;font-size:.9rem;padding:.35rem .7rem;
  border:1px solid transparent;border-radius:8px;display:inline-flex;align-items:center;gap:.35rem}
.nav a:hover{color:var(--fg);background:var(--surface-2)}
.nav a.active{color:var(--fg);border-color:var(--line);background:var(--surface-2)}
.count{background:var(--fg);color:var(--bg);border-radius:99px;font-size:.68rem;
  font-weight:700;padding:0 .35rem;min-width:1.1em;text-align:center}
.pagetitle{margin:.25rem 0 .25rem;font-size:1.05rem}
.jhead{display:flex;justify-content:space-between;align-items:flex-start;gap:.75rem}
.jhead .jtitle{margin-bottom:.2rem}
.job .jsub{margin-top:.25rem}
.frow{display:flex;align-items:center;justify-content:space-between;gap:.75rem;
  padding:.3rem 0;flex-wrap:wrap}
.frow a{flex:1 1 auto}
.help{margin-top:1.5rem;background:var(--surface);border:1px solid var(--line);border-radius:10px}
.help summary{padding:.75rem .9rem;cursor:pointer;font-size:.9rem;font-weight:600;
  list-style:none;display:flex;align-items:center;gap:.4rem}
.help summary::-webkit-details-marker{display:none}
.help summary::before{content:'▸';color:var(--muted)}
.help[open] summary::before{content:'▾'}
.helpbody{padding:0 .9rem .9rem}
.helpbody h4{margin:.9rem 0 .3rem;font-size:.85rem;color:var(--fg)}
.helpbody ol{margin:0;padding-left:1.1rem;color:var(--muted)}
.helpbody li{margin:.2rem 0}
.helpbody a{color:var(--fg)}
.helpbody code{background:var(--surface-2);padding:.05rem .25rem;border-radius:3px;font-size:.85em}
.frow{align-items:center}
.fname{flex:1 1 220px;min-width:0;overflow-wrap:anywhere}
.factions{display:flex;align-items:center;gap:.4rem;flex:none}
/* Download and Send to Kindle are peer actions - identical treatment.
   Outlined, filling white on hover, so neither outranks the other. */
.btn-sm,.k2k{display:inline-block;padding:.3rem .6rem;border-radius:8px;
  font-size:.8rem;font-weight:500;line-height:1.4;text-decoration:none;
  background:transparent;color:var(--fg);border:1px solid var(--line);
  white-space:nowrap;cursor:pointer}
.btn-sm:hover,.k2k:hover:not(:disabled){background:var(--btn);color:var(--btn-fg);
  border-color:var(--btn)}
