:root {
  --bg: #f0f2f5; --card: #fff; --text: #1c1e21; --muted: #65676b; --line: #e4e6eb;
  --primary: #1877f2; --primary-d: #166fe5; --danger: #d93025; --ok: #31a24c; --warn: #f7b928;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f5; padding: 2px 5px; border-radius: 4px; font-size: .92em; }

.topbar { display: flex; align-items: center; gap: 28px; padding: 0 24px; min-height: 56px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
/* nav + who behave as direct topbar items on desktop; the wrapper only exists for the mobile drawer */
.topmenu { display: contents; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover, .topbar nav a.active { background: var(--bg); color: var(--primary); text-decoration: none; }
.who { display: flex; align-items: center; gap: 16px; margin-left: auto; color: var(--muted); font-size: 14px; }
.who-name { white-space: nowrap; }
.navtoggle { display: none; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 38px; margin-left: auto; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; }
.navtoggle span { display: block; height: 2px; border-radius: 2px; background: var(--muted); }
.navtoggle[aria-expanded="true"] { background: var(--bg); }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 24px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 0 12px; }
  .has-nav .navtoggle { display: flex; }
  .has-nav .topmenu { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 6px; padding-bottom: 12px; }
  .has-nav.open .topmenu { display: flex; }
  .topbar nav { flex-direction: column; gap: 2px; padding-top: 6px; border-top: 1px solid var(--line); }
  .topbar nav a { padding: 10px 12px; }
  .has-nav .who { flex-wrap: wrap; margin-left: 0; padding-top: 10px; border-top: 1px solid var(--line); }
}
.muted { color: var(--muted); } .bad { color: var(--danger); } .ok { color: var(--ok); } .tiny { font-size: 12px; } .nowrap { white-space: nowrap; } .right { margin-left: auto; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.tile-v { font-size: 30px; font-weight: 700; line-height: 1.1; }
.tile-sub { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.tile-l { color: var(--muted); font-size: 13px; margin-top: 4px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar-fill { background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.bar-x { font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-weight: 600; }
.posts .snippet { color: var(--muted); font-size: 13px; margin-top: 2px; max-width: 420px; }
.posts .reply { max-width: 320px; font-size: 14px; }
.author { font-weight: 500; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e4e6eb; color: #444; }
.s-posted { background: #e3f4e8; color: #1b7a34; } .s-failed { background: #fde8e6; color: #b3261e; }
.s-skipped { background: #f3f0e6; color: #7a6a1b; } .s-drafted, .s-queued, .s-posting { background: #e7f0fd; color: #1b4f9e; }

/* plan + credit meters */
.plan-card h2 { margin-bottom: 18px; }
.plan-free { background: #e4e6eb; color: #444; }
.plan-basic { background: #e7f0fd; color: #1b4f9e; }
.plan-pro { background: #efe6fb; color: #5b2ca8; }
a.badge:hover { text-decoration: none; filter: brightness(.96); }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 22px; }
.meter-v { font-size: 30px; font-weight: 700; line-height: 1.1; }
.meter-v.extra { color: #8a5a00; } /* extra credit: same amber as the extension's "Extra" pill */
.meter-l { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.meter-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.bad { background: var(--danger); }
.meter-f { font-size: 12px; color: var(--muted); margin-top: 6px; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #e4e6eb; font-size: 12px; color: var(--text); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .chip.active { background: var(--primary); color: #fff; }
.pager { display: flex; gap: 4px; margin-top: 14px; }
.pager a { padding: 4px 10px; border-radius: 6px; } .pager a.active { background: var(--primary); color: #fff; }

form label { display: block; margin: 0 0 12px; font-size: 14px; font-weight: 500; }
form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid #ccd0d5; border-radius: 8px; font: inherit; background: #fff; }
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
form.inline { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
form.inline input { margin: 0; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid #ccd0d5; background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); }
.btn:hover { background: #f5f6f7; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); } .btn.small { padding: 4px 10px; font-size: 13px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert.error { background: #fde8e6; color: #b3261e; } .alert.success { background: #e3f4e8; color: #1b7a34; }
.token { display: block; margin: 8px 0; word-break: break-all; font-size: 13px; }
.steps { padding-left: 20px; } .steps li { margin-bottom: 8px; }
.auth-card { max-width: 400px; margin: 60px auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth-card h1 { text-align: center; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-card .muted { text-align: center; margin-top: 16px; }

/* source lists (targets / skip) */
.srclist { margin-bottom: 14px; }
.srclist > label { margin-bottom: 4px; }
.srcerr { min-height: 0; margin: 4px 0; }
.srcerr.warn { color: #9a6700; }
.srcerr.ok { color: var(--ok); }
.srcadd { display: flex; gap: 6px; }
.srcadd input { margin: 0; flex: 1; }
.srcplus { padding: 0 16px; font-size: 20px; line-height: 1; }
.srcitems { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.srcitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.srcitem:last-child { border-bottom: 0; }
.srcempty { padding: 10px; font-size: 13px; }
.srcimg { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 40px; background: #e4e6eb; }
.srcicon { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.srcmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.srcmeta b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srcmeta small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srcdel { border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1; }
.srcdel:hover { color: var(--danger); }
/* settings page: one card per topic */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-grid .card { margin-bottom: 0; }
.card-desc { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }
.savebar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }

/* language switcher — a select, so adding a language needs no layout change */
.langswitch { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.langswitch select {
  display: inline-block; width: auto; margin: 0; padding: 4px 26px 4px 10px; font-size: 13px;
  color: var(--muted); border-color: var(--line); border-radius: 8px; cursor: pointer;
  appearance: none; background-repeat: no-repeat; background-position: right 8px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2365676b' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
}
.langswitch select:hover { background-color: var(--bg); }
.langswitch select:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* admin – user list and the per-user panel */
.adminsearch { margin: 0 0 14px; }
.adminsearch input { max-width: 320px; }
.users .author { font-weight: 600; }
.users td .btn { white-space: nowrap; }
.section-gap { margin-top: 24px; }
.danger-zone { border-color: #f3c6c2; }
.danger-zone h2 { color: var(--danger); }
