/* Shared styles: typography, backend pages, forms, join screens. */

@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: italic; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-700-italic.woff2) format("woff2"); }

:root {
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #16181d;
  --ink-2: #3b3f47;
  --muted: #646a73;
  --line: #e2e0da;
  --line-2: #cfccc4;
  --moderator: #1d4ed8;      /* bold blue: moderator and administrator */
  --moderator-bg: #eef3ff;
  --observer: #15803d;       /* green: observers, backchannel only */
  --observer-bg: #edf8f0;
  --private: #6d3fb0;        /* private messages: strongly separated */
  --private-bg: #f4effc;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --ok: #146c43;
  --ok-bg: #e8f5ee;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 4px 16px rgba(20, 20, 30, .05);
  --focus: 0 0 0 3px rgba(29, 78, 216, .35);
  font-size: 16px;
}
html[data-ts="2"] { font-size: 18.5px; }
html[data-ts="3"] { font-size: 21px; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--moderator); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }
.inline { display: inline; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- top bar (moderator backend) */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; letter-spacing: -.01em; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); }
.mainnav a:hover { background: var(--bg); }
.mainnav a.active { color: var(--ink); font-weight: 700; background: var(--bg); }
.topbar-tools { display: flex; align-items: center; gap: 16px; }

.page { max-width: 1160px; margin: 0 auto; padding: 28px 24px 64px; }
.footer { max-width: 1160px; margin: 0 auto; padding: 16px 24px 40px; color: var(--muted); font-size: .875rem; }
.footer a { color: var(--muted); }

.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* ---------- text size control */
.textsize { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; background: var(--surface); }
.textsize button { border: 0; background: none; padding: 4px 9px; cursor: pointer; color: var(--ink-2); font-family: var(--font); line-height: 1; min-width: 30px; min-height: 30px; }
.textsize button[data-ts="1"] { font-size: 13px; }
.textsize button[data-ts="2"] { font-size: 16px; }
.textsize button[data-ts="3"] { font-size: 19px; }
.textsize button.on { background: var(--ink); color: #fff; }

/* ---------- cards, notices */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card.narrow { max-width: 460px; margin: 0 auto; }
.card.medium { max-width: 640px; margin: 0 auto; }
.card h2:first-child, .card h1:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid transparent; }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cf; }
.notice.error { background: var(--danger-bg); color: var(--danger); border-color: #f5c2bd; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: #f2dca4; }
.notice.info { background: var(--moderator-bg); color: #1e3a8a; border-color: #c9d7fb; }

.imp-banner { background: #111827; color: #fff; padding: 10px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .95rem; position: sticky; top: 0; z-index: 30; }
.imp-banner.write { background: var(--danger); }
.imp-banner form { margin-left: auto; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; line-height: 1.2;
  padding: 10px 16px; min-height: 42px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #b9b5ab; }
.btn.primary { background: var(--moderator); border-color: var(--moderator); color: #fff; }
.btn.primary:hover { background: #1a43bd; }
.btn.danger { color: var(--danger); border-color: #efb4ae; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .875rem; }
.btn.big { padding: 14px 22px; font-size: 1.1rem; min-height: 52px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.linkbtn { background: none; border: 0; color: var(--moderator); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.iconbtn { background: none; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; padding: 6px; color: var(--ink-2); line-height: 0; }
.iconbtn:hover { background: var(--bg); border-color: var(--line); }

/* ---------- forms */
label { display: block; font-weight: 700; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field .hint { color: var(--muted); font-size: .875rem; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; color: var(--ink); width: 100%;
  padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--moderator); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--moderator); vertical-align: -3px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ---------- tables */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data td.actions { white-space: nowrap; text-align: right; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.live { background: var(--danger); color: #fff; border-color: var(--danger); }
.badge.waiting { background: var(--warn-bg); color: var(--warn); border-color: #f2dca4; }
.badge.closed { color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cf; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f2dca4; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: #f5c2bd; }
.badge.group { background: var(--private-bg); color: var(--private); border-color: #dccdf3; }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.tabs a:hover { color: var(--ink); }

/* ---------- empty state */
.empty { text-align: center; padding: 56px 24px; }
.empty h2 { font-size: 1.4rem; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 22px; }

/* ---------- lists */
.plainlist { list-style: none; padding: 0; margin: 0; }
.plainlist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plainlist li:last-child { border-bottom: 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.copybox { font-family: var(--mono); font-size: .85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; white-space: pre-wrap; word-break: break-all; max-height: 320px; overflow: auto; }

/* ---------- guide editor */
.guide-section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.guide-section > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.guide-section > header h3 { margin: 0; flex: 1; }
.guide-section ol { margin: 0; padding: 6px 14px 6px 40px; }
.guide-section li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.guide-section li:last-child { border-bottom: 0; }
.phrase-row { display: flex; gap: 10px; align-items: flex-start; }
.phrase-row .text { flex: 1; }
.guide-section .add { padding: 10px 14px; border-top: 1px solid var(--line); }

/* ---------- plain pages (sign-in, join) */
body.plain { min-height: 100vh; }
.plain-tools { display: flex; justify-content: flex-end; padding: 14px 18px 0; }
.plain-main { padding: 24px 16px 64px; }
.plain-brand { text-align: center; font-weight: 700; margin: 10px 0 22px; color: var(--ink-2); }
.authcard h1 { font-size: 1.45rem; }

.consent-list { padding-left: 1.2em; margin: 0 0 18px; }
.consent-list li { margin-bottom: 8px; }
.confirm-name { font-size: 1.5rem; font-weight: 700; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 6px 0 16px; text-align: center; }
.big-username { font-size: 1.35rem; font-weight: 700; }
.countdown { font-variant-numeric: tabular-nums; font-size: 2rem; font-weight: 700; letter-spacing: .02em; }

.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg, .qr img { width: 200px; height: 200px; }
.codes { columns: 2; font-family: var(--mono); font-size: 1rem; list-style: none; padding: 0; }
.codes li { padding: 3px 0; }

.picker-list { list-style: none; margin: 0 0 16px; padding: 0; }
.picker-list li { margin-bottom: 8px; }
.picker-list label { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; background: #fff; }
.picker-list label:has(input:checked) { border-color: var(--moderator); background: var(--moderator-bg); }
.picker-list .ptitle { font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }
.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--ink-2); border-radius: 999px; }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
.plan.current { border: 2px solid var(--moderator); }
.plan ul { padding-left: 1.1em; flex: 1; }
.plan .price { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }

@media (max-width: 760px) {
  .topbar-inner { padding: 0 16px; gap: 12px; height: auto; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; }
  .page { padding: 20px 16px 48px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
