/* Riposta – editors' site and admin panel. Calm, functional, same type family as the paper. */

:root {
  --ink: #16181b;
  --ink-soft: #3d4248;
  --muted: #6c727a;
  --line: #e2e4e7;
  --line-strong: #c9cdd2;
  --bg: #f5f5f3;
  --surface: #ffffff;
  --brand: #16181b;          /* top bar: editors' site */
  --brand-text: #ffffff;
  --accent: #b3121b;
  --ok: #1d6b3a;   --ok-bg: #e5f3ea;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --bad: #a3141c;  --bad-bg: #fbe7e8;
  --info: #24527a; --info-bg: #e6eff7;
  --sans: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --display: "Playfair Display", Georgia, serif;
  --radius: 6px;
}
body.site-panel { --brand: #7a0d13; }  /* admin panel gets a deep red bar so it is never confused with the editors' site */

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--info); }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 26px; margin: 0 0 4px; font-family: var(--serif); }
h2 { font-size: 18px; margin: 28px 0 12px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- Top bar ----- */
.bar { background: var(--brand); color: var(--brand-text); }
.bar__inner {
  max-width: 1240px; margin: 0 auto; padding: 0 20px; min-height: 58px;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.bar__brand { display: flex; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; }
.bar__brand img { max-height: 30px; width: auto; align-self: center; }
.bar__wordmark { font-family: var(--display); font-weight: 900; font-size: 26px; letter-spacing: -.01em; }
.bar__label {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .8;
  border-left: 1px solid rgba(255,255,255,.35); padding-left: 10px;
}
.bar nav { flex: 1; }
.bar nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.bar nav a {
  display: block; color: var(--brand-text); text-decoration: none; padding: 8px 12px; border-radius: var(--radius);
  font-weight: 600; font-size: 14px; opacity: .85;
}
.bar nav a:hover, .bar nav a[aria-current="page"] { background: rgba(255,255,255,.12); opacity: 1; }
.bar__user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.bar__user a { color: var(--brand-text); }
.bar__user form { margin: 0; }
.bar__user button {
  font: inherit; font-weight: 600; color: var(--brand-text); background: transparent; cursor: pointer;
  border: 1px solid rgba(255,255,255,.45); border-radius: var(--radius); padding: 5px 10px;
}
.bar__user button:hover { background: rgba(255,255,255,.12); }

/* ----- Layout ----- */
.main { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
.main--narrow { max-width: 520px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card + .card { margin-top: 18px; }
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }
.grid-2 + .card, .grid-2 + .table-wrap { margin-top: 20px; }
.stack > * + * { margin-top: 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }

/* ----- Stats ----- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: inherit; }
.stat:hover { border-color: var(--line-strong); text-decoration: none; }
.stat__value { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-size: 13px; }
.stat--alert .stat__value { color: var(--bad); }

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafaf9; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.title-cell a { font-weight: 600; color: var(--ink); }

/* ----- Badges ----- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: #eceef0; color: var(--ink-soft); white-space: nowrap;
}
.badge--published, .badge--ok, .badge--active { background: var(--ok-bg); color: var(--ok); }
.badge--draft, .badge--info { background: var(--info-bg); color: var(--info); }
.badge--archived, .badge--expired, .badge--used { background: #eceef0; color: var(--muted); }
.badge--bad, .badge--revoked, .badge--deleted { background: var(--bad-bg); color: var(--bad); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--admin { background: #7a0d13; color: #fff; }

/* ----- Filters / tabs ----- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--ink-soft); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--ink); }
.tabs .count { color: var(--muted); font-weight: 400; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters input, .filters select { min-width: 140px; }

/* ----- Forms ----- */
.form-row { margin-bottom: 18px; }
.form-row > label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--bad); font-size: 13px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="email"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 9px 11px;
}
.filters input, .filters select { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(22,24,27,.08); }
input[name="title"] { font-family: var(--serif); font-size: 22px; font-weight: 700; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink);
}
.btn:hover { background: #f2f2f2; text-decoration: none; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover { background: #000; }
.btn--danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn--danger:hover { background: #7f0f15; }
.btn--ghost-danger { color: var(--bad); border-color: #e9b9bc; }
.btn--ghost-danger:hover { background: var(--bad-bg); }
.btn--small { padding: 5px 10px; font-size: 13px; }
.btn--block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.inline-form { display: inline; margin: 0; }

/* ----- Messages ----- */
.messages { list-style: none; margin: 0 0 20px; padding: 0; }
.messages li { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px; font-weight: 600; border: 1px solid transparent; }
.messages .success { background: var(--ok-bg); color: var(--ok); border-color: #bfe0cb; }
.messages .error { background: var(--bad-bg); color: var(--bad); border-color: #f0c2c5; }
.messages .info { background: var(--info-bg); color: var(--info); border-color: #c4d8ea; }
.messages .warning { background: var(--warn-bg); color: var(--warn); border-color: #f0d9a0; }
.alert { padding: 12px 16px; border-radius: var(--radius); background: var(--bad-bg); color: var(--bad); font-weight: 600; margin-bottom: 18px; }
.notice { padding: 14px 16px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); margin-bottom: 18px; }

/* ----- Auth pages ----- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth__box { width: 100%; max-width: 420px; }
.auth__brand { text-align: center; margin-bottom: 18px; }
.auth__brand .bar__wordmark { font-size: 42px; color: var(--ink); }
.auth__brand img { max-height: 54px; width: auto; }
.auth__brand p { margin: 2px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.auth .card { padding: 28px; }
.site-panel .auth__brand p { color: #7a0d13; }

/* ----- Editor ----- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.editor-side { position: sticky; top: 16px; }
.editor-side .card + .card { margin-top: 14px; }
#rich-editor { min-height: 420px; background: #fff; font-family: var(--serif); font-size: 18px; }
#rich-editor .ql-editor { min-height: 420px; line-height: 1.65; }
#rich-editor .ql-editor p { margin-bottom: .8em; }
#rich-editor .ql-editor h2, #rich-editor .ql-editor h3 { margin: 1em 0 .4em; }
.ql-toolbar.ql-snow { border-radius: var(--radius) var(--radius) 0 0; background: #fafaf9; border-color: var(--line-strong); }
.ql-container.ql-snow { border-radius: 0 0 var(--radius) var(--radius); border-color: var(--line-strong); }
.has-rich-editor textarea.js-rich-text { display: none; }
.cover-preview img { border-radius: var(--radius); margin-bottom: 8px; }
.cover-preview input[type="file"] { width: 100%; font-size: 13px; }

/* ----- Invitation link ----- */
.link-box { display: flex; gap: 8px; }
.link-box input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* ----- QR code ----- */
.qr { background: #fff; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); display: inline-block; }
.qr svg { width: 220px; height: 220px; display: block; }

/* ----- Revision / log details ----- */
.revision-body { font-family: var(--serif); font-size: 17px; line-height: 1.6; }
pre.json { background: #f6f7f8; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow-x: auto; font-size: 13px; }
dl.props { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0; }
dl.props dt { color: var(--muted); font-weight: 600; }
dl.props dd { margin: 0; word-break: break-word; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 18px 0 0; }

.empty { padding: 36px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .grid-2, .editor-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  dl.props { grid-template-columns: 1fr; }
  dl.props dt { margin-top: 6px; }
}
@media (max-width: 640px) {
  .bar__inner { gap: 10px; padding: 10px 16px; }
  .bar nav { order: 3; flex-basis: 100%; }
  .bar nav ul { flex-wrap: nowrap; overflow-x: auto; }
  .bar nav a { white-space: nowrap; }
  .main { padding: 20px 16px 48px; }
  .link-box { flex-direction: column; }
}
