:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #111111;
  --surface-alt: #1a1a1a;
  --surface-strong: #0b0b0b;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --subtle: rgba(255, 255, 255, 0.42);
  --line: rgba(255, 214, 0, 0.22);
  --line-strong: rgba(255, 214, 0, 0.48);
  --accent: #ffd600;
  --red: #ff6b6b;
  --red-bg: rgba(183, 53, 53, 0.16);
  --blue: #69a7ff;
  --blue-bg: rgba(37, 94, 168, 0.18);
  --green: #9bdc65;
  --green-bg: rgba(86, 153, 49, 0.18);
  --warn: #ffd166;
  --warn-bg: rgba(164, 104, 9, 0.18);
  --purple: #b9a7ff;
  --purple-bg: rgba(99, 80, 184, 0.18);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.58);
  --radius: 8px;
  --radius-sm: 6px;
  --topbar-h: 76px;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 214, 0, 0.055), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(255, 214, 0, 0.45);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: var(--topbar-h);
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand strong {
  display: block;
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.12;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.top-actions,
.drawer-actions,
.data-tools,
.month-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 0;
  min-height: 0;
}

.calendar-region {
  min-width: 0;
  padding: 20px 24px 32px;
}

.inspector {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--surface-strong);
  overflow: auto;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  display: grid;
  gap: 28px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-form {
  display: grid;
  gap: 18px;
}

.detail-panel,
.upcoming-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
}

.calendar-toolbar,
.panel-heading,
.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.28;
}

.month-controls output {
  display: inline-grid;
  min-width: 112px;
  height: 38px;
  place-items: center;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.primary-button,
.ghost-button,
.danger-button,
.text-button,
.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  padding: 0 13px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.primary-button {
  border-color: rgba(255, 214, 0, 0.45);
  background: rgba(255, 214, 0, 0.1);
  color: var(--accent);
}

.primary-button:hover {
  border-color: var(--accent);
  background: rgba(255, 214, 0, 0.14);
}

.ghost-button,
.import-button {
  background: var(--surface);
  color: var(--text);
}

.ghost-button:hover,
.import-button:hover {
  background: var(--surface-alt);
}

.danger-button {
  margin-right: auto;
  border-color: rgba(255, 107, 107, 0.45);
  background: var(--red-bg);
  color: var(--red);
}

.danger-button:hover {
  border-color: var(--red);
}

.text-button {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.icon-button:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
  color: var(--accent);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-icon {
  display: inline-grid;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  place-items: center;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(126px, 1fr)) minmax(210px, 1.4fr);
  gap: 12px;
  margin: 24px 0 20px;
}

label,
.filter-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label > span,
.filter-field > span,
.checkbox-field legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  font-size: 14px;
  line-height: 1.4;
}

.multi-select-field {
  position: relative;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  gap: 10px;
  padding: 0 11px;
  text-align: left;
}

.multi-select-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-trigger svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.multi-select-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: none;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: 7px;
}

.multi-select.is-open .multi-select-menu {
  display: grid;
  gap: 3px;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border-radius: 4px;
  padding: 6px 7px;
}

.multi-select-option:hover {
  background: var(--surface-alt);
}

.multi-select-option input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.multi-select-option > span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.checkbox-field {
  display: grid;
  gap: 7px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface);
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.checkbox-grid input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.checkbox-grid span {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.file-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.file-status a {
  color: var(--accent);
  text-decoration: none;
}

.file-status a:hover {
  text-decoration: underline;
}

.form-inline-action {
  justify-self: start;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.group-details-section,
.group-summary {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.group-detail-scroll,
.group-summary-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.group-detail-table,
.group-summary-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  color: var(--text);
}

.group-detail-table th,
.group-detail-table td,
.group-summary-table th,
.group-summary-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.group-detail-table th:last-child,
.group-detail-table td:last-child,
.group-summary-table th:last-child,
.group-summary-table td:last-child {
  border-right: 0;
}

.group-detail-table tr:last-child th,
.group-detail-table tr:last-child td,
.group-summary-table tr:last-child th,
.group-summary-table tr:last-child td {
  border-bottom: 0;
}

.group-detail-table th,
.group-summary-table th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.group-detail-table td {
  min-width: 156px;
}

.group-detail-table input {
  min-width: 146px;
}

.group-summary {
  margin-top: 16px;
}

.group-summary h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.group-summary-table {
  min-width: 520px;
  font-size: 13px;
}

.group-summary-table a {
  color: var(--accent);
  text-decoration: none;
}

.group-summary-table a:hover {
  text-decoration: underline;
}

.muted-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.weekday {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.calendar-days {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day-cell {
  display: block;
  min-height: 126px;
  padding: 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.day-cell:hover {
  background: #161616;
}

.day-cell:nth-child(7n) {
  border-right: 0;
}

.day-cell.is-outside {
  background: #0b0b0b;
  color: var(--subtle);
}

.day-cell.is-today .date-number {
  background: var(--accent);
  color: #050505;
}

.day-cell.is-selected {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.date-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.day-events {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.event-pill {
  display: block;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-pill.level-city,
.level-chip.level-city {
  border-color: rgba(105, 167, 255, 0.45);
  background: var(--blue-bg);
  color: var(--blue);
}

.event-pill.level-invitational,
.level-chip.level-invitational {
  border-color: rgba(255, 214, 0, 0.45);
  background: rgba(255, 214, 0, 0.1);
  color: var(--accent);
}

.event-pill.level-regional,
.level-chip.level-regional {
  border-color: rgba(255, 209, 102, 0.45);
  background: var(--warn-bg);
  color: var(--warn);
}

.event-pill.level-wrc-regional,
.level-chip.level-wrc-regional {
  border-color: rgba(155, 220, 101, 0.52);
  background: rgba(86, 153, 49, 0.18);
  color: #9bdc65;
}

.event-pill.level-national,
.level-chip.level-national {
  border-color: rgba(255, 107, 107, 0.45);
  background: var(--red-bg);
  color: var(--red);
}

.event-pill.level-wrc-national,
.level-chip.level-wrc-national {
  border-color: rgba(45, 199, 111, 0.58);
  background: rgba(22, 122, 63, 0.22);
  color: #2dc76f;
}

.event-pill.level-signature,
.level-chip.level-signature {
  border-color: rgba(185, 167, 255, 0.45);
  background: var(--purple-bg);
  color: var(--purple);
}

.event-pill.level-worlds,
.level-chip.level-worlds {
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.event-pill:hover,
.event-pill:focus-visible,
.event-pill.is-selected {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 214, 0, 0.1);
  color: var(--accent);
}

.empty-state p {
  max-width: 250px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.detail-meta,
.event-list {
  display: grid;
  gap: 10px;
}

.detail-meta {
  margin-top: 16px;
}

.meta-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.meta-row span:first-child {
  color: var(--muted);
  font-weight: 750;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.schedule-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.78);
}

.schedule-modal-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(980px, 100%);
  height: min(860px, calc(100vh - 44px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.schedule-modal-header h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-modal-body {
  display: grid;
  min-height: 0;
  place-items: start center;
  overflow: auto;
  padding: 16px;
  background: #090909;
}

.schedule-modal-body img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.level-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.event-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.event-row:last-child {
  border-bottom: 0;
}

.event-row:hover {
  color: var(--text);
}

.event-row:hover h3 {
  color: var(--accent);
}

.event-date-badge {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.event-date-badge strong,
.event-date-badge small {
  display: block;
  text-align: center;
}

.event-date-badge strong {
  font-size: 20px;
  line-height: 1;
}

.event-date-badge small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.event-row h3 {
  margin: 0 0 5px;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
  transition: color 160ms ease;
}

.event-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.74);
}

.admin-drawer {
  position: fixed;
  top: 50vh;
  left: 50vw;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(920px, calc(100vw - 48px));
  max-width: 100vw;
  height: min(900px, calc(100vh - 48px));
  max-height: 100vh;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translate(-50%, -46%) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 220ms ease,
    visibility 220ms ease;
}

.admin-drawer.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.admin-form {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 22px 4px 22px 0;
}

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

.data-tools {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-button {
  cursor: pointer;
}

.import-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.site-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 48px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-separator {
  color: var(--line);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .inspector {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .ghost-button,
  .top-actions .primary-button {
    flex: 1;
  }

  .calendar-region,
  .inspector {
    padding: 16px;
  }

  .detail-panel,
  .upcoming-panel {
    padding: 16px;
  }

  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .month-controls {
    justify-content: space-between;
  }

  .filter-row,
  .inspector,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .weekday {
    font-size: 11px;
  }

  .day-cell {
    min-height: 92px;
    padding: 7px;
  }

  .date-number {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .event-pill {
    padding: 4px 5px;
    font-size: 11px;
  }

  .admin-drawer {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 25px;
  }

  .brand small {
    display: none;
  }

  .calendar-grid {
    overflow-x: auto;
    grid-template-columns: repeat(7, 96px);
  }

  .calendar-days {
    grid-template-columns: repeat(7, 96px);
  }

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

  .drawer-actions .primary-button,
  .drawer-actions .ghost-button,
  .drawer-actions .danger-button {
    flex: 1 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
