/* =============================================================================
 * PBdesign — global/design-system.css
 * -----------------------------------------------------------------------------
 * FROZEN CONTRACT. Sections use these tokens and component classes and must
 * not redefine them. To add a component, append it here and document it in
 * docs/DESIGN-SYSTEM.md.
 *
 * Deliberately minimal: no animation, no transition, no external font.
 * It must work offline and render identically in all three regions.
 * ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */
:root {
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-alt:   #eef1f5;
  --border:        #d6dbe3;
  --border-strong: #b9c1cd;

  --text:          #16191d;
  --text-muted:    #5b6472;
  --text-faint:    #8b94a3;

  --accent:        #1f5fd0;
  --accent-dark:   #17489e;
  --accent-soft:   #e8effb;

  --ok:            #1a7f4b;
  --ok-soft:       #e4f4ea;
  --warn:          #9a6100;
  --warn-soft:     #fdf1dc;
  --danger:        #b3261e;
  --danger-soft:   #fbe9e7;

  --radius:        6px;
  --radius-sm:     4px;
  --gap:           16px;
  --gap-sm:        8px;
  --gap-lg:        32px;

  --max-width:     1080px;
  --line:          1.55;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- 2. Reset ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: var(--line);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--gap-sm); font-weight: 650; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

p { margin: 0 0 var(--gap-sm); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 var(--gap-sm); padding-left: 1.25rem; }
li { margin-bottom: 4px; }

code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--gap-lg) 0; }

/* No animation anywhere, including focus. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- 3. Layout ---------------------------------------------------------- */
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gap); }

.page { padding: var(--gap-lg) 0; }

.section { margin-bottom: var(--gap-lg); }

.stack > * + * { margin-top: var(--gap); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
}

.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* --- 4. Nav ------------------------------------------------------------- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gap);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
  min-height: 52px;
}

.nav-brand { font-weight: 700; color: var(--text); font-size: 0.98rem; }
.nav-brand:hover { text-decoration: none; }

.nav-links { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }

.nav-links a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
}

.nav-links a:hover { color: var(--text); background: var(--surface-alt); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* --- 5. Page header ----------------------------------------------------- */
.page-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--gap);
  margin-bottom: var(--gap-lg);
}

.page-head h1 { margin-bottom: 4px; }
.page-head .sub { color: var(--text-muted); margin: 0; white-space: pre-line; font-size: 0.92rem; }

/* --- 6. Card ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}

.card-flat { background: var(--surface-alt); border-color: transparent; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--gap-sm);
}

.card h3 { margin-bottom: 4px; }
.card .meta { color: var(--text-muted); font-size: 0.86rem; }

/* --- 7. Tags and pills -------------------------------------------------- */
.tag {
  display: inline-block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  font-size: 0.76rem;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-accent { background: var(--accent-soft); border-color: #c3d6f5; color: var(--accent-dark); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill-planning   { background: var(--surface-alt); color: var(--text-muted); }
.pill-active     { background: var(--accent-soft);  color: var(--accent-dark); }
.pill-blocked    { background: var(--danger-soft);  color: var(--danger); }
.pill-review     { background: var(--warn-soft);    color: var(--warn); }
.pill-done       { background: var(--ok-soft);      color: var(--ok); }
.pill-unassigned { background: var(--warn-soft);    color: var(--warn); }

/* --- 8. Notices --------------------------------------------------------- */
.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.notice-warn   { border-left-color: var(--warn);   background: var(--warn-soft);   color: #6b4300; }
.notice-ok     { border-left-color: var(--ok);     background: var(--ok-soft);     color: #10603a; }
.notice-info   { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

.notice strong { color: inherit; }

/* --- 9. Stat ------------------------------------------------------------ */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px var(--gap);
}

.stat .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--text-muted); font-size: 0.82rem; }

/* --- 10. Definition list ------------------------------------------------ */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 0.9rem; }
.dl dt { color: var(--text-faint); }
.dl dd { margin: 0; }

/* --- 11. Table ---------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--surface); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-alt); font-weight: 650; font-size: 0.83rem; color: var(--text-muted); }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

/* --- 12. Utilities ------------------------------------------------------ */
.muted      { color: var(--text-muted); }
.faint      { color: var(--text-faint); }
.small      { font-size: 0.86rem; }
.tiny       { font-size: 0.78rem; }
.bold       { font-weight: 650; }
.center     { text-align: center; }
.nowrap     { white-space: nowrap; }
.pre-wrap   { white-space: pre-wrap; }
.mb-0       { margin-bottom: 0; }
.mt-0       { margin-top: 0; }
.mt-1       { margin-top: var(--gap-sm); }
.mt-2       { margin-top: var(--gap); }
.mt-3       { margin-top: var(--gap-lg); }
.hidden     { display: none !important; }

/* --- 13. Member --------------------------------------------------------- */
.member-name { font-weight: 650; }
.member-nick { color: var(--text-faint); font-weight: 400; font-size: 0.88rem; }
.member-role { color: var(--accent-dark); font-size: 0.86rem; font-weight: 600; }
.member-org  { color: var(--text-muted); font-size: 0.84rem; }

/* --- 14. Channel -------------------------------------------------------- */
.channel-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm) var(--gap);
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.channel-row:last-child { border-bottom: 0; }
.channel-name { font-family: var(--font-mono); font-weight: 650; font-size: 0.92rem; min-width: 190px; }
.channel-topic { color: var(--text-muted); font-size: 0.88rem; flex: 1 1 320px; }

/* --- 15. Chat placeholder ---------------------------------------------- */
.chat-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
}

/* --- 16. Controls ------------------------------------------------------- */
/* Filter buttons are <button class="tag filter-btn"> so they inherit the tag
 * look. Add .filter-btn-on to show the selected state. Sections must not
 * restyle these inline. */
.filter-btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  border: 1px solid var(--border);
}

button.filter-btn { background: var(--surface-alt); color: var(--text-muted); }
.filter-btn:hover { border-color: var(--border-strong); color: var(--text); }
.filter-btn-on { background: var(--accent); border-color: var(--accent); color: #ffffff; }
button.filter-btn-on { background: var(--accent); color: #ffffff; }

.input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
  min-width: 220px;
}

.btn {
  font: inherit;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn:hover { border-color: var(--border-strong); }

.label { color: var(--text-faint); font-size: 0.82rem; }

.input-block { width: 100%; min-width: 0; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.row-between { justify-content: space-between; }

/* --- 17. Dialog: the quest-board claim editor --------------------------- */
.dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
  max-width: 620px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop { background: rgba(22, 25, 29, 0.5); }

.dialog-inner { padding: var(--gap); }

.dialog-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--gap-sm);
  margin-bottom: var(--gap);
}

.dialog-head h2 { margin: 0; font-size: 1.1rem; }

.dialog-body { max-height: 60vh; overflow-y: auto; }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: var(--gap);
  margin-top: var(--gap);
}

.form-row { margin-bottom: var(--gap); }

.check-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface-alt);
}

.check-row {
  display: flex;
  gap: var(--gap-sm);
  align-items: baseline;
  padding: 5px 10px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: var(--accent-soft); }
.check-row input { margin: 0; }

textarea.input { resize: vertical; font: inherit; }

/* --- 17b. Onboarding cards (training.html) ----------------------------- */
.onb-card { display: flex; gap: var(--gap); align-items: flex-start; }

.onb-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onb-body { flex: 1 1 auto; min-width: 0; }
.onb-body .card-head { margin-bottom: 2px; }

/* --- 18. Principles highlight (index.html) ------------------------------ */
/* The one visually loud block on the site. Everything else stays quiet, so
 * this must not be reused as a generic panel. */
.principles {
  background: var(--text);
  color: #ffffff;
  border-radius: var(--radius);
  padding: var(--gap-lg) var(--gap);
}

.principles-lead {
  margin: 0 0 var(--gap);
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #c9d2df;
}

.principles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap);
}

.principle { text-align: center; }

.principle-zh {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.principle-en {
  font-size: 0.82rem;
  color: #a9b6c7;
  margin-top: 2px;
}

.principles-foot {
  margin: var(--gap) 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: #8d9bb0;
  letter-spacing: 0.04em;
}

/* --- 18. Footer --------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: var(--gap-lg);
  padding: var(--gap) 0;
}

.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gap); }
.footer .notice { margin-bottom: var(--gap-sm); }
