:root {
  --ink: #101114;
  --muted: #656b74;
  --line: #d9dde3;
  --soft: #f5f6f8;
  --paper: #ffffff;
  --navy: #17314f;
  --navy-2: #243b5a;
  --success: #1f6f43;
  --warn: #8a5a00;
  --danger: #9d1d22;
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 0 5vw;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand,
.nav-links,
.hero-actions,
.help-actions,
.form-actions,
.admin-top,
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 800;
}

.brand-mark {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 50%;
}

.nav-links a {
  color: var(--muted);
  font-size: 14px;
}

.nav-links a:hover {
  color: var(--ink);
}

.hero {
  position: relative;
  min-height: calc(100svh - 64px);
  display: grid;
  align-items: end;
  isolation: isolate;
  overflow: hidden;
  background: #111;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.24) 56%, rgba(0, 0, 0, 0.12));
}

.hero-copy {
  width: min(720px, 90vw);
  padding: 12vh 5vw 14vh;
  color: #fff;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--navy-2);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #dbe6f3;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 640px;
  margin-bottom: 18px;
  font-size: clamp(42px, 8vw, 88px);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.08;
}

h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.hero p:not(.eyebrow) {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 18px;
  line-height: 1.7;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 750;
  white-space: nowrap;
}

.button:hover,
.icon-button:hover {
  background: var(--soft);
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

.button.primary:hover {
  background: var(--navy);
}

.button.ghost {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 48px;
  padding: 0;
}

.icon-button svg,
.row-menu svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.lang-button {
  width: auto;
  min-width: 64px;
  padding: 0 10px;
}

.section {
  padding: 86px clamp(18px, 5vw, 72px);
}

.section-heading {
  max-width: 860px;
  margin-bottom: 34px;
}

.section-heading.compact {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  max-width: none;
}

.intro-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 18px;
}

.intro-grid article,
.join-form,
.filters,
.group-card,
.admin-form,
.admin-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.intro-grid article {
  padding: 24px;
}

.intro-grid p,
.intro-grid li {
  color: var(--muted);
  line-height: 1.7;
}

.steps {
  display: grid;
  gap: 10px;
  padding-left: 22px;
}

.finder,
.admin {
  background: var(--soft);
}

.finder-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.filters {
  position: sticky;
  top: 84px;
  padding: 18px;
  width: 100%;
}

.filter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.filter-head h3 {
  margin-bottom: 0;
}

.filter-confirm {
  min-height: 38px;
  padding: 0 16px;
}

.filter-block {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

#filterGroups .filter-block:first-child {
  border-top: 0;
}

.filter-block h4 {
  margin: 0 0 12px;
}

.check-list {
  display: grid;
  gap: 10px;
}

.check-pill {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  min-height: 28px;
  overflow-wrap: anywhere;
}

.check-pill input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--navy);
}

.check-pill span {
  line-height: 1.35;
}

.results-toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.results-toolbar p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.group-card {
  display: flex;
  flex-direction: column;
  min-height: 340px;
  padding: 20px;
}

.card-meta,
.card-lines {
  display: grid;
  gap: 8px;
}

.card-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 12px 0 18px;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--muted);
  font-size: 13px;
}

.status.open {
  color: var(--success);
  border-color: rgba(31, 111, 67, 0.28);
  background: rgba(31, 111, 67, 0.08);
}

.status.almost {
  color: var(--warn);
  border-color: rgba(138, 90, 0, 0.28);
  background: rgba(138, 90, 0, 0.08);
}

.status.full,
.status.paused {
  color: var(--danger);
  border-color: rgba(157, 29, 34, 0.24);
  background: rgba(157, 29, 34, 0.06);
}

.card-lines {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.card-action {
  margin-top: auto;
  padding-top: 20px;
}

.join {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 520px);
  gap: 34px;
  align-items: start;
}

.join-form,
.admin-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
}

.check-pill input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(23, 49, 79, 0.18);
  border-color: var(--navy);
}

.help-actions {
  flex-wrap: wrap;
}

.admin-top {
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.admin-top label {
  min-width: 220px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.table-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-header h3,
.table-header p {
  margin: 0;
}

.table-header p {
  color: var(--muted);
  font-size: 13px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 8px;
}

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

.small-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  padding: 0 10px;
}

.small-button.danger {
  color: var(--danger);
}

.status-log {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-log summary {
  cursor: pointer;
  font-weight: 800;
}

.status-log ol {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding-left: 18px;
}

.status-log li {
  line-height: 1.45;
}

.status-log strong,
.status-log span,
.status-log small {
  display: block;
}

.status-log small {
  color: var(--muted);
}

.row-menu {
  position: relative;
  width: 34px;
  height: 34px;
}

.row-menu[open] {
  z-index: 15;
}

.row-menu summary {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  list-style: none;
}

.row-menu summary::-webkit-details-marker {
  display: none;
}

.row-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  min-width: 128px;
  margin-top: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.14);
}

.menu-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0 10px;
  text-align: left;
}

.menu-button:hover {
  background: var(--soft);
}

.menu-button.danger {
  color: var(--danger);
}

.small-button:disabled,
.button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.mobile-only {
  display: none;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 25;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(16, 17, 20, 0.2);
}

.back-to-top:hover {
  background: var(--navy);
}

.back-to-top svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.no-scroll {
  overflow: hidden;
}

.filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.34);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 17, 20, 0.48);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow-y: auto;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(860px, calc(100svh - 44px));
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.message-modal {
  position: relative;
  width: min(420px, 100%);
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 38px 32px 30px;
  text-align: center;
}

.join-modal {
  width: min(520px, 100%);
}

.join-modal .modal-head {
  align-items: flex-start;
}

.join-modal .modal-head .eyebrow {
  margin-bottom: 6px;
}

.selected-group-summary {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 14px;
}

.selected-group-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.selected-group-summary strong {
  font-size: 16px;
}

.message-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  min-height: 38px;
  border-color: transparent;
}

.message-modal-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 50%;
  background: rgba(31, 111, 67, 0.1);
  color: var(--success);
}

.message-modal-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.message-modal h3 {
  margin-bottom: 10px;
  font-size: 24px;
}

.message-modal p {
  margin-bottom: 24px;
  color: var(--muted);
  line-height: 1.65;
}

#messageModal[data-type="error"] .message-modal-icon {
  background: rgba(157, 29, 34, 0.08);
  color: var(--danger);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 6px;
}

.modal-head h3 {
  margin: 0;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.modal-form-grid label:first-child {
  grid-column: 1 / -1;
}

.modal-actions {
  justify-content: flex-end;
  padding-top: 4px;
}

.admin-gate {
  min-height: calc(100svh - 64px);
  display: grid;
  place-items: center;
  background: var(--soft);
}

body[data-page="admin"] main {
  min-height: calc(100svh - 64px);
  background: var(--soft);
}

body[data-page="admin"] .admin {
  min-height: calc(100svh - 64px);
  padding-top: 52px;
}

.gate-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: clamp(24px, 5vw, 42px);
}

.gate-panel h1 {
  color: var(--ink);
  font-size: clamp(36px, 7vw, 64px);
}

.gate-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.gate-panel label {
  margin: 22px 0 14px;
}

@media (max-width: 1080px) {
  .group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-grid {
    grid-template-columns: 1fr;
  }

  .finder-shell,
  .join {
    grid-template-columns: 1fr;
  }

  .filters {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 40;
    width: min(420px, 92vw);
    max-width: 100vw;
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform 160ms ease;
    border-radius: 0;
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.16);
  }

  .filters.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }
}

@media (min-width: 1081px) {
  #openFilters,
  #closeFilters {
    display: none;
  }
}

@media (max-width: 720px) {
  .site-header {
    padding: 0 16px;
  }

  .nav-links {
    display: none;
  }

  .hero {
    min-height: 690px;
  }

  .hero::after {
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.18));
  }

  .hero-copy {
    padding: 80px 18px 64px;
  }

  .hero-actions,
  .help-actions,
  .admin-top,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions .button,
  .help-actions .button,
  .form-actions .button,
  .admin-top .button,
  .gate-panel .button {
    width: 100%;
  }

  .site-header .icon-button {
    width: auto;
    min-width: 58px;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
  }

  .section {
    padding: 64px 18px;
  }

  .section-heading.compact {
    align-items: start;
    flex-direction: column;
  }

  .intro-grid,
  .group-grid {
    grid-template-columns: 1fr;
  }

  .group-card {
    min-height: 0;
  }

  .card-meta {
    grid-template-columns: 1fr;
  }

  .filters {
    width: 100vw;
  }

  .table-header {
    align-items: start;
    flex-direction: column;
  }

  .modal-form-grid {
    grid-template-columns: 1fr;
  }

  .modal-shell {
    align-items: start;
    padding: 14px;
  }

  .modal-panel {
    max-height: calc(100svh - 28px);
  }

  table {
    min-width: 680px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 40px;
  }

  h2 {
    font-size: 30px;
  }

  .hero {
    min-height: 620px;
  }

  .card-meta {
    gap: 6px;
  }

  .join-form,
  .admin-form,
  .intro-grid article,
  .group-card {
    padding: 18px;
  }
}
