:root {
  --bg: #edf1ee;
  --panel: #ffffff;
  --ink: #15211c;
  --muted: #5d6b64;
  --line: #d3dcd6;
  --accent: #3b3fd1;
  --accent-ink: #ffffff;
  --soft: #e3e6fb;
  --danger: #c0392b;
  --caution: #a86a00;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161a;
    --panel: #192026;
    --ink: #e7ece9;
    --muted: #93a19a;
    --line: #2b353c;
    --accent: #9a9dff;
    --accent-ink: #12142e;
    --soft: #262a4d;
    --danger: #ef6b5d;
    --caution: #e0a63a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161a;
  --panel: #192026;
  --ink: #e7ece9;
  --muted: #93a19a;
  --line: #2b353c;
  --accent: #9a9dff;
  --accent-ink: #12142e;
  --soft: #262a4d;
  --danger: #ef6b5d;
  --caution: #e0a63a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
img, table { max-width: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 46rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; padding-left: max(1.25rem, env(safe-area-inset-left)); padding-right: max(1.25rem, env(safe-area-inset-right)); padding-bottom: max(4rem, env(safe-area-inset-bottom)); }
h1 {
  font: 600 clamp(1.9rem, 5vw, 2.9rem)/1.1 Georgia, "Iowan Old Style", "Times New Roman", serif;
  letter-spacing: -0.01em;
  margin: 0 0 .6rem;
  max-width: 20ch;
}
#sub { color: var(--muted); margin: 0 0 1.75rem; max-width: 60ch; }
button, input[type="search"], input[type="number"], select { font: inherit; color: inherit; }
button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .45rem .8rem;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--soft); padding: .05em .35em; border-radius: 4px; }

select, input[type="number"] {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .35rem .5rem;
}
input[type="number"] { width: 4.5rem; }

.drop {
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 1.5rem;
  text-align: center;
}
.drop.over { border-color: var(--accent); background: var(--soft); }
.drop p { margin: .2rem 0; }
.drop #pick { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hint { color: var(--muted); font-size: .92rem; }
.loaded { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.loaded li { background: var(--soft); border-radius: 999px; padding: .15rem .7rem; font-size: .88rem; }

.backup { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .9rem; }
.backup button { font-size: .88rem; padding: .3rem .7rem; color: var(--muted); }
.backup button.danger { color: var(--danger); }

.toggle-loader {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  justify-content: center;
  color: var(--muted);
}
.toggle-loader .arrow { display: inline-block; font-size: 1.1rem; line-height: 1; }
.toggle-loader[aria-expanded="true"] .arrow { transform: rotate(180deg); }
.toggle-loader[hidden], #loader[hidden] { display: none; }
#loader { margin-top: .6rem; }
.toggle-loader:not([hidden]) + #loader { margin-top: .6rem; }

.msg { margin: 1rem 0 0; padding: .7rem .9rem; border-left: 4px solid var(--accent); background: var(--panel); border-radius: 0 6px 6px 0; }
.msg.error { border-left-color: var(--danger); }

#results { margin-top: 2rem; }

.today {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .9rem;
  margin: 0 0 1rem;
}
.today strong { font: 600 1.3rem/1 Georgia, serif; }
.today .lim { margin-left: auto; color: var(--muted); font-size: .9rem; display: inline-flex; align-items: center; gap: .4rem; }
.today .warnmsg { flex-basis: 100%; color: var(--danger); font-size: .92rem; }
.today.warn { border-color: var(--danger); }
.today.warn strong { color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .75rem; margin: 0 0 1.5rem; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { margin: 0; font: 600 1.5rem/1.2 Georgia, serif; }

.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.tools input[type="search"] {
  flex: 1 1 12rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .45rem .7rem;
}
.check { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .92rem; }
.note { margin: 0 0 .5rem; padding: .55rem .8rem; background: var(--soft); border-radius: 6px; font-size: .92rem; }
.count { color: var(--muted); margin: .25rem 0 .5rem; font-size: .92rem; }

.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem .9rem; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li.is-hidden { opacity: .55; }
.who { display: flex; flex-direction: column; min-width: 0; }
.when { color: var(--muted); font-size: .8rem; }
.list a { color: var(--ink); text-decoration: none; font-weight: 500; overflow-wrap: anywhere; }
.list a:hover { color: var(--accent); text-decoration: underline; }
.list button { padding: .2rem .6rem; font-size: .88rem; color: var(--muted); flex: none; }
.empty { padding: 1rem .9rem; color: var(--muted); }

/* Unfollow + Hide buttons side by side */
.actions { display: flex; gap: .4rem; flex: none; }
.list button.unfollow {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Daily limit progress bar */
.today .bar { flex-basis: 100%; height: .5rem; background: var(--soft); border-radius: 999px; overflow: hidden; }
.today .bar > div { height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
.today.near { border-color: var(--caution); }
.today.near .bar > div { background: var(--caution); }
.today.near .warnmsg { color: var(--caution); }
.today.warn .bar > div { background: var(--danger); }

/* Close friend badge + paging */
.who .line { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .5rem; }
.badge { font-size: .72rem; background: var(--soft); border-radius: 999px; padding: .05rem .5rem; color: var(--ink); }
.more { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .9rem; }
.more[hidden] { display: none; }

.how { margin-top: 2.5rem; color: var(--muted); }
.how summary { cursor: pointer; color: var(--ink); }
.how li { margin: .35rem 0; }

@media (prefers-reduced-motion: no-preference) {
  button { transition: border-color .15s, background-color .15s; }
  .today .bar > div { transition: width .3s ease, background-color .3s; }
}
/* ---------- login / admin ---------- */
main.narrow { max-width: 26rem; padding-top: 4rem; }
main.wide { max-width: 60rem; }
.topbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: flex-end; margin-bottom: 1rem; }
.topbar[hidden], .topbar [hidden] { display: none; }
.topbar .hint { margin: 0 auto 0 0; }
a.btn {
  display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: .45rem .8rem; color: var(--ink); text-decoration: none;
}
a.btn:hover { border-color: var(--accent); }
.topbar #adminLink { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .6; cursor: default; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; display: flex; flex-direction: column; gap: .6rem; margin-top: 1.25rem; }
.auth-card label { color: var(--muted); font-size: .9rem; }
.field { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; font: inherit; color: inherit; }
.auth-card .msg { margin: .25rem 0 0; }
.row-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.row-form .f { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 10rem; }
.row-form .inline { display: flex; gap: .4rem; }
.row-form .inline .field { width: 6rem; }
.row-form .inline select { flex: 1; }
h2 { font: 600 1.3rem/1.2 Georgia, serif; margin: 2rem 0 .75rem; }
.fresh { background: var(--soft); border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; }
.fresh p { margin: 0 0 .5rem; }
.fresh-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .35rem; }
.fresh-list code { font-size: 1.05rem; letter-spacing: .06em; padding: .15em .5em; background: var(--panel); }
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { color: var(--muted); font-weight: 500; }
.tbl .mono { font-family: ui-monospace, Consolas, monospace; }
.tbl .act { display: flex; gap: .4rem; }
.tbl .act button { padding: .2rem .6rem; font-size: .88rem; }
.pill { display: inline-block; padding: .05rem .6rem; border-radius: 999px; font-size: .82rem; background: var(--soft); }
.pill.active { background: #d5f0dd; color: #14532d; }
.pill.unused { background: var(--soft); }
.pill.expired, .pill.revoked { background: #f6d9d5; color: #7a1d12; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill.active { background: #17402a; color: #b6f0c8; }
  :root:not([data-theme="light"]) .pill.expired, :root:not([data-theme="light"]) .pill.revoked { background: #4a2420; color: #f5c0b8; }
}
:root[data-theme="dark"] .pill.active { background: #17402a; color: #b6f0c8; }
:root[data-theme="dark"] .pill.expired, :root[data-theme="dark"] .pill.revoked { background: #4a2420; color: #f5c0b8; }

/* ---------- access warnings, sync line, admin tools ---------- */
.topbar .hint.warn { color: var(--caution); font-weight: 600; }
.topbar .hint.urgent { color: var(--danger); font-weight: 600; }
.sync { margin: .6rem 0 0; text-align: center; }
.tbl .act { display: flex; flex-wrap: wrap; gap: .4rem; max-width: 14.5rem; }
.pill.paused { background: #fbefcf; color: #6b4a00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill.paused { background: #4a3a14; color: #f3dca0; }
}
:root[data-theme="dark"] .pill.paused { background: #4a3a14; color: #f3dca0; }
.locked { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .4rem; }
.locked li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .8rem; }
.locked[hidden], #noLocked[hidden], #noLog[hidden] { display: none; }

/* ---------- mobile ---------- */
@media (hover: none) and (pointer: coarse), (max-width: 40rem) {
  /* 16px+ inputs stop iOS Safari zooming in on focus; bigger tap targets */
  input, select, textarea, .field { font-size: 16px; }
  button, a.btn { min-height: 2.5rem; }
  .list button, .tbl .act button { min-height: 2.25rem; }
  .check input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
}
@media (max-width: 40rem) {
  main { padding-top: 1.25rem; padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  main.narrow { padding-top: 2rem; }
  h1 { max-width: none; }
  h2 { margin-top: 1.5rem; }
  .drop { padding: 1rem; }

  .topbar { justify-content: stretch; }
  .topbar .hint { flex-basis: 100%; margin: 0; }
  .topbar > * { flex: 1 1 auto; text-align: center; }

  .backup button { flex: 1 1 40%; }

  .today { padding: .7rem; }
  .today .lim { margin-left: 0; flex-basis: 100%; justify-content: space-between; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .stats dd { font-size: 1.3rem; }

  /* tabs scroll sideways in one row instead of wrapping into a tall block */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding: 0 1rem .25rem; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; white-space: nowrap; }
  .tabs button[hidden] { display: none; }

  .tools { gap: .5rem; }
  .tools input[type="search"] { flex: 1 1 100%; }
  .tools .check { flex: 1 1 auto; }
  .tools button { flex: 1 1 40%; }

  /* list rows: name on top, buttons underneath at full width */
  .list li { flex-direction: column; align-items: stretch; gap: .5rem; padding: .7rem .8rem; }
  .list .actions { width: 100%; }
  .list .actions button, .list li > button { flex: 1; }
  .list li > button { width: 100%; }

  .more button { flex: 1 1 40%; }

  .auth-card { padding: 1rem; }
  .row-form { flex-direction: column; align-items: stretch; }
  .row-form .f { flex: none; }
  .row-form .inline .field { width: 40%; }
  .row-form button[type="submit"] { width: 100%; }

  .tbl { font-size: .88rem; }
  .tbl .act { max-width: none; }
  .tbl-wrap { margin-inline: -1rem; border-radius: 0; border-left: 0; border-right: 0; }
  .locked li { flex-wrap: wrap; }
  .fresh-list code { word-break: break-all; }
}

/* ---------- theme + language controls ---------- */
.prefs { display: flex; justify-content: flex-end; align-items: center; gap: .4rem; margin: 0 0 .75rem; }
.prefs button { font-size: 1.25rem; line-height: 1; width: 2.5rem; height: 2.5rem; padding: 0; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; }
.prefs button:hover { border-color: var(--accent); }

/* ---------- banned page ---------- */
.ban { text-align: center; padding-top: 3rem; }
.ban .big { font-size: 4rem; line-height: 1; margin: 0 0 .5rem; }
.ban h1 { margin-inline: auto; }
.ban .funny { font-size: 1.15rem; margin: 1rem auto 1.5rem; max-width: 30ch; }
.ban-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .4rem; }
.ban-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .8rem; }
.ban-list[hidden] { display: none; }

/* ---------- admin: compact table, actions menu, alerts, filters ---------- */
.filters { margin-bottom: .6rem; }
.filters select { padding: .45rem .6rem; }
.h-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.h-row h2 { margin-bottom: .5rem; }
.tbl td { vertical-align: middle; }
.tbl td.who-cell { white-space: normal; min-width: 9rem; max-width: 18rem; }
.who-cell .nm { font-weight: 600; display: block; }
.who-cell .sub { display: block; color: var(--muted); font-size: .8rem; }
.who-cell .note { display: block; font-size: .85rem; font-style: italic; overflow-wrap: anywhere; }
.tbl .loc { display: block; color: var(--muted); font-size: .8rem; }
.tbl tr.soon td:first-child { box-shadow: inset 3px 0 0 var(--caution); }
.tbl tr.flag td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.soon-tag { display: inline-block; font-size: .72rem; color: var(--caution); border: 1px solid var(--caution); border-radius: 999px; padding: 0 .45rem; margin-left: .3rem; }
.flag-tag { display: inline-block; font-size: .72rem; color: var(--danger); border: 1px solid var(--danger); border-radius: 999px; padding: 0 .45rem; margin-left: .3rem; }
.act-btn { white-space: nowrap; }
.menu { position: fixed; z-index: 50; min-width: 11rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .3rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 2px; }
.menu[hidden] { display: none; }
.menu button { border: 0; background: none; text-align: left; padding: .5rem .7rem; border-radius: 6px; width: 100%; font-size: .92rem; }
.menu button:hover { background: var(--soft); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: .2rem 0; width: 100%; }
.alert-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.alert-list li { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--caution); border-radius: 8px; padding: .6rem .8rem; display: flex; flex-direction: column; gap: .4rem; }
.alert-list li.high { border-left-color: var(--danger); }
.alert-list .meta { color: var(--muted); font-size: .85rem; }
.alert-list .btns { display: flex; flex-wrap: wrap; gap: .4rem; }
.alert-list .btns button { font-size: .88rem; padding: .25rem .65rem; }
.ban-list .auto { font-size: .75rem; color: var(--muted); }

/* ---------- follower history chart ---------- */
.history { margin-top: 2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
.history h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.history svg { width: 100%; height: auto; display: block; }
.history .legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-bottom: .4rem; }
.history .legend i { display: inline-block; width: 1.4rem; height: 0; border-top: 3px solid var(--accent); vertical-align: middle; margin-right: .35rem; }
.history .legend i.b { border-top: 3px dashed var(--caution); }
.history[hidden] { display: none; }
@media (max-width: 40rem) {
  /* the Actions button stays visible while the rest of the table scrolls sideways */
  .tbl-wrap .tbl td:last-child, .tbl-wrap .tbl th:last-child { position: sticky; right: 0; background: var(--panel); box-shadow: -6px 0 6px -6px rgba(0,0,0,.25); }
}

/* ---------- security box, expiry banner ---------- */
.qr { background: #fff; padding: 12px; border-radius: 8px; width: max-content; max-width: 100%; }
.qr svg { display: block; width: 200px; height: 200px; }
#tfaKey { letter-spacing: .08em; word-break: break-all; }
#tfa .auth-card { margin-top: .5rem; }
.msg.ok { border-left-color: #2e8b57; }
.fresh-list .row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.fresh-list .row button { padding: .15rem .6rem; font-size: .85rem; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--caution); border-left-width: 5px; border-radius: 8px; padding: .7rem .9rem; margin: 0 0 1rem; }
.banner.urgent { border-color: var(--danger); }
.banner[hidden] { display: none; }
.banner strong { font-weight: 600; }
[hidden] { display: none !important; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.ban-list .grow { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.ban-list .grow small { display: block; color: var(--muted); }
.ban-list .btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.ban-list .btns button, .ban-list .btns a.btn { font-size: .85rem; padding: .2rem .6rem; min-height: 0; }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #2e8b57; margin-right: .4rem; }

.today #extendLimit { flex-basis: auto; }
.today.warn #extendLimit { margin-left: auto; }
