:root {
  --ink: #172033;
  --muted: #697386;
  --line: #dfe4ec;
  --soft: #f3f6fa;
  --surface: #ffffff;
  --brand: #3146a8;
  --brand-dark: #223582;
  --accent: #ffbf3f;
  --success: #26845c;
  --shadow: 0 10px 28px rgba(25, 38, 72, .08);
  --radius: 10px;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: .75rem 1rem;
  background: var(--surface);
  border-radius: .4rem;
  box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }

.topbar { background: #17245b; color: #fff; }
.topbar__inner,
.nav__inner,
.container {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}
.topbar__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 3.85rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: #fff;
  font-size: 1.22rem;
  font-weight: 780;
  letter-spacing: -.02em;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand__logo {
  display: block;
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
}
.topbar__note { color: #dfe5ff; font-size: .9rem; }

.nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.nav__inner { display: flex; align-items: center; min-height: 3rem; }
.nav a {
  padding: .82rem 1rem;
  color: #35405a;
  font-size: .92rem;
  font-weight: 680;
}
.nav a:first-child { padding-left: 0; }
.nav a[aria-current="page"] { color: var(--brand); }
.auth-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-left: auto;
  padding-left: .75rem;
  border-left: 1px solid var(--line);
}
.nav .auth-link {
  appearance: none;
  padding: .52rem .7rem;
  border: 0;
  border-radius: .45rem;
  color: #35405a;
  background: transparent;
  font: inherit;
  font-size: .88rem;
  font-weight: 740;
  cursor: pointer;
}
.nav .auth-link:hover { color: var(--brand); background: #f2f5ff; }
.nav .auth-link--primary { color: #fff; background: var(--brand); }
.nav .auth-link--primary:hover { color: #fff; background: var(--brand-dark); }

main { padding: 1.6rem 0 3rem; }
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .42rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .84rem;
}
.breadcrumbs span::before { content: "/"; margin-right: .42rem; color: #a1a8b5; }

.page-heading { margin: 0 0 1.2rem; }
.page-heading h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.15rem); letter-spacing: -.035em; line-height: 1.15; }
.page-heading p { max-width: 48rem; margin: .5rem 0 0; color: var(--muted); }

.forum-section,
.thread-list,
.post,
.notice,
.rules-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.forum-section { overflow: hidden; margin-bottom: 1.35rem; }
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: .78rem 1rem;
  color: #fff;
  background: var(--brand);
  font-size: 1rem;
  letter-spacing: .005em;
}
.section-title small { color: #dce3ff; font-size: .78rem; font-weight: 550; }

.forum-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.5rem minmax(13rem, 18rem);
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}
.forum-row:first-of-type { border-top: 0; }
.forum-row:hover { background: #fbfcff; }
.forum-main { display: grid; grid-template-columns: 2.7rem minmax(0, 1fr); gap: .85rem; align-items: center; }
.forum-icon {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: .75rem;
  color: var(--brand);
  background: #e9edff;
  font-weight: 850;
}
.forum-main h2,
.forum-main h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.forum-main p { margin: .23rem 0 0; color: var(--muted); font-size: .88rem; }
.counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; text-align: center; }
.count strong { display: block; font-size: .98rem; }
.count span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.latest { padding-left: 1rem; border-left: 1px solid var(--line); min-width: 0; }
.latest a { display: block; overflow: hidden; color: var(--ink); font-size: .88rem; font-weight: 690; text-overflow: ellipsis; white-space: nowrap; }
.latest small { color: var(--muted); font-size: .78rem; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 1.35rem; align-items: start; }
.sidebar { display: grid; gap: 1rem; }
.notice { padding: 1rem; }
.notice h2 { margin: 0 0 .65rem; font-size: 1rem; }
.notice p { margin: 0; color: var(--muted); font-size: .88rem; }
.notice ul { margin: .7rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .88rem; }
.notice li + li { margin-top: .38rem; }

.thread-list { overflow: hidden; }
.thread-row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 7rem 9rem;
  align-items: center;
  gap: .8rem;
  padding: .9rem 1rem;
  border-top: 1px solid var(--line);
}
.thread-row:first-child { border-top: 0; }
.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  color: #fff;
  background: var(--brand);
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 820;
}
.avatar--gold { color: #423000; background: #ffd36f; }
.avatar--green { background: #2b8c68; }
.avatar--coral { background: #d65c62; }
.thread-title { min-width: 0; }
.thread-title a { display: block; color: var(--ink); font-weight: 720; line-height: 1.3; }
.thread-title small,
.thread-stat { color: var(--muted); font-size: .8rem; }
.thread-stat strong { color: var(--ink); }

.thread-head {
  margin-bottom: 1rem;
  padding: 1.15rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.thread-head h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.2; letter-spacing: -.03em; }
.thread-meta { display: flex; flex-wrap: wrap; gap: .45rem .9rem; margin-top: .55rem; color: var(--muted); font-size: .84rem; }
.tag { display: inline-flex; padding: .15rem .5rem; color: var(--brand-dark); background: #e9edff; border-radius: 999px; font-size: .75rem; font-weight: 750; }

.posts { display: grid; gap: .85rem; }
.post { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); overflow: hidden; }
.post__author { padding: 1rem; background: #f8f9fc; border-right: 1px solid var(--line); text-align: center; }
.post__author .avatar { margin: 0 auto .55rem; width: 3.25rem; height: 3.25rem; font-size: .95rem; }
.post__author strong { display: block; font-size: .9rem; }
.post__author small { color: var(--muted); font-size: .74rem; }
.post__body { min-width: 0; }
.post__top {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .58rem 1rem;
  color: var(--muted);
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
  font-size: .78rem;
}
.post__content { padding: 1rem 1.1rem 1.2rem; }
.post__content p { margin: 0 0 .8rem; }
.post__content p:last-child { margin-bottom: 0; }
.post-quote {
  margin: 0 0 1rem;
  padding: .8rem 1rem;
  color: #3f4960;
  background: #f5f7fb;
  border-left: 3px solid #8796c8;
  border-radius: 0 .45rem .45rem 0;
}
.post-quote p { margin: 0 0 .35rem; }
.post-quote p:last-child { margin-bottom: 0; }
.post-quote strong { color: var(--brand-dark); font-size: .85rem; }
.post-number { color: var(--muted); }
.accepted { margin: 0 0 .8rem; color: var(--success); font-size: .8rem; font-weight: 800; }

.reply-template,
.edit-note {
  margin-top: 1.2rem;
  padding: 1rem 1.1rem;
  border: 1px dashed #aab5d6;
  border-radius: var(--radius);
  background: #f7f8ff;
}
.reply-template h2,
.edit-note h2 { margin: 0 0 .4rem; font-size: 1rem; }
.reply-template p,
.edit-note p { margin: 0; color: var(--muted); font-size: .88rem; }
.reply-template code { font-size: .8rem; }

.rules-card { padding: 1.2rem 1.35rem; }
.rules-card h2 { margin: 1.25rem 0 .35rem; font-size: 1.08rem; }
.rules-card h2:first-child { margin-top: 0; }
.rules-card p { margin: 0; color: #3f4960; }
.rules-card p + p { margin-top: .7rem; }
.rules-card ul { margin: .65rem 0 0; padding-left: 1.2rem; color: #3f4960; }
.rules-card li + li { margin-top: .4rem; }
.rules-card a { font-weight: 700; }
.page-updated { font-size: .88rem; }

.auth-dialog {
  width: min(27rem, calc(100% - 2rem));
  padding: 0;
  border: 0;
  border-radius: 1rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1.5rem 4rem rgba(15, 24, 61, .28);
}
.auth-dialog::backdrop { background: rgba(17, 25, 52, .62); backdrop-filter: blur(2px); }
.auth-panel { position: relative; padding: 1.5rem; }
.auth-panel h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.025em; }
.auth-panel > p { margin: .4rem 2rem 1.2rem 0; color: var(--muted); }
.auth-close {
  position: absolute;
  top: .8rem;
  right: .8rem;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #59647b;
  background: #f0f2f8;
  font: inherit;
  font-size: 1.3rem;
  cursor: pointer;
}
.auth-form { display: grid; gap: .9rem; }
.auth-form[hidden] { display: none; }
.auth-field { display: grid; gap: .35rem; color: #2f3950; font-size: .88rem; font-weight: 750; }
.auth-field input {
  width: 100%;
  min-height: 2.8rem;
  padding: .68rem .75rem;
  border: 1px solid #cbd2e2;
  border-radius: .55rem;
  color: var(--text);
  background: #fff;
  font: inherit;
}
.auth-field input:focus { outline: 3px solid rgba(49, 70, 168, .18); border-color: var(--brand); }
.auth-submit {
  min-height: 2.85rem;
  margin-top: .15rem;
  padding: .7rem 1rem;
  border: 0;
  border-radius: .55rem;
  color: #fff;
  background: var(--brand);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.auth-submit:hover { background: var(--brand-dark); }
.auth-switch { margin: .95rem 0 0; color: var(--muted); font-size: .88rem; text-align: center; }
.auth-switch button { padding: 0; border: 0; color: var(--brand); background: transparent; font: inherit; font-weight: 800; cursor: pointer; }
.auth-legal { margin: .9rem 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; text-align: center; }
.auth-error { min-height: 1rem; margin: -.3rem 0 0; color: #a32626; font-size: .8rem; font-weight: 700; }
.success-dialog { text-align: center; }
.success-mark { display: grid; place-items: center; width: 3rem; height: 3rem; margin: 0 auto .85rem; border-radius: 50%; color: #fff; background: var(--success); font-size: 1.35rem; font-weight: 900; }
.success-dialog .auth-submit { width: 100%; }

.footer { padding: 1.4rem 0 2.2rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .84rem; }
.footer__inner { display: flex; justify-content: space-between; gap: 1rem; }
.footer nav { display: flex; gap: 1rem; }

@media (max-width: 880px) {
  .home-grid { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, 1fr); }
  .forum-row { grid-template-columns: minmax(0, 1fr) 7.5rem; }
  .latest { grid-column: 1 / -1; padding: .75rem 0 0 3.55rem; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 650px) {
  .topbar__note { display: none; }
  .nav { overflow-x: auto; }
  .nav__inner { min-width: max-content; }
  .forum-row { grid-template-columns: 1fr; gap: .75rem; }
  .counts { display: flex; padding-left: 3.55rem; text-align: left; }
  .count strong, .count span { display: inline; }
  .count span::before { content: " "; }
  .latest { padding-left: 3.55rem; }
  .thread-row { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .thread-stat { grid-column: 2; }
  .thread-stat:last-child { display: none; }
  .post { grid-template-columns: 1fr; }
  .post__author { display: flex; align-items: center; gap: .7rem; text-align: left; border-right: 0; border-bottom: 1px solid var(--line); }
  .post__author .avatar { margin: 0; width: 2.6rem; height: 2.6rem; }
  .sidebar { grid-template-columns: 1fr; }
  .footer__inner { flex-direction: column; }
}
