.site-header,
.site-footer {
  width: min(var(--content-width), calc(100% - 32px));
  margin-inline: auto;
  border: 1px solid var(--color-line);
  background: rgba(18, 27, 44, 0.88);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.site-header {
  position: relative;
  z-index: 50;
  margin-top: 20px;
  padding: 14px 16px 14px 20px;
  border-radius: var(--radius-lg);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  text-decoration: none;
}

.site-brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(109, 156, 255, 0.38);
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, rgba(109, 156, 255, 0.32), rgba(57, 116, 237, 0.12));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 8px 18px rgba(57, 116, 237, 0.18);
}

.site-brand-mark svg {
  width: 22px;
  height: 22px;
}

.site-brand-copy {
  display: flex;
  min-height: 42px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  line-height: 1;
}

.site-brand-copy strong {
  font-size: 1.65rem;
  letter-spacing: -0.045em;
}

.site-header-menu-panel {
  display: block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
  transition: color var(--transition), background var(--transition), border-color var(--transition), transform var(--transition);
}

.site-nav-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.site-nav-link.is-active {
  border-color: rgba(109, 156, 255, 0.36);
  color: white;
  background: linear-gradient(135deg, rgba(109, 156, 255, 0.28), rgba(57, 116, 237, 0.18));
  box-shadow: 0 6px 18px rgba(57, 116, 237, 0.13);
}

.site-auth-link {
  min-width: 76px;
  border-color: rgba(109, 156, 255, 0.22);
  background: rgba(109, 156, 255, 0.08);
}

.site-auth-link.is-authenticated {
  color: #aec8ff;
}

.button:disabled {
  cursor: wait;
  filter: saturate(0.65);
  opacity: 0.72;
  transform: none;
}

.site-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--color-line-strong);
  border-radius: 12px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}

.site-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  border-radius: var(--radius-pill);
  background: currentColor;
  transition: transform var(--transition), opacity var(--transition);
}

.site-footer {
  margin-top: 12px;
  margin-bottom: 20px;
  padding: 17px 20px;
  border-radius: var(--radius-md);
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-align: center;
}

.site-footer-inner p {
  margin: 0;
  color: inherit;
}

.site-footer-links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.site-footer-links a {
  color: #aec8ff;
  font-weight: 700;
  text-decoration: none;
}

.site-footer-links a:hover {
  color: white;
  text-decoration: underline;
}

.panel {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(23, 35, 58, 0.9), rgba(16, 25, 42, 0.92));
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-line);
}

.panel-header h2 {
  margin-bottom: 4px;
  font-size: var(--text-xl);
}

.panel-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.panel-body {
  padding: var(--space-6);
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid rgba(109, 156, 255, 0.28);
  border-radius: var(--radius-pill);
  color: #aec8ff;
  background: var(--color-primary-soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--warning {
  border-color: rgba(255, 180, 84, 0.3);
  color: var(--color-warning);
  background: rgba(255, 180, 84, 0.1);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-pill);
  color: white;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
  box-shadow: 0 10px 24px rgba(57, 116, 237, 0.25);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--transition), filter var(--transition), box-shadow var(--transition);
}

.button:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 13px 30px rgba(57, 116, 237, 0.32);
}

.button--secondary {
  border: 1px solid var(--color-line-strong);
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: none;
}

.button svg {
  width: 18px;
  height: 18px;
}

.auth-modal {
  width: min(580px, calc(100% - 24px));
  max-width: none;
  max-height: min(94vh, 900px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-xl);
  color: var(--color-text);
  background: transparent;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.auth-modal::backdrop {
  background: rgba(3, 7, 13, 0.78);
  backdrop-filter: blur(7px);
}

.auth-modal[open] {
  animation: auth-modal-in 180ms ease-out both;
}

.auth-modal-card {
  position: relative;
  max-height: min(94vh, 900px);
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 0%, rgba(57, 116, 237, 0.13), transparent 24rem),
    linear-gradient(155deg, #121d31, #0b1424 70%);
}

.auth-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--color-muted);
  background: transparent;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.auth-modal-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.065);
}

.auth-modal-header {
  padding: 38px 72px 10px 36px;
}

.auth-modal-header h2 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 6vw, 2.45rem);
}

.auth-modal-header p {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-lg);
}

.auth-modal-content {
  padding: 22px 36px 34px;
}

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

.auth-modal-field label {
  margin: 0;
  font-size: 0.96rem;
}

.auth-modal-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: 8px;
}

.auth-modal-forgot {
  color: #aec8ff;
  font-size: var(--text-xs);
  font-weight: 700;
  text-decoration: none;
}

.auth-modal-forgot:hover {
  color: white;
  text-decoration: underline;
}

.auth-modal-input-wrap {
  position: relative;
}

.auth-modal-input-wrap input {
  min-height: 58px;
  padding: 13px 18px 13px 52px;
  border-color: var(--color-line-strong);
  border-radius: 18px;
  background: rgba(9, 17, 31, 0.72);
  font-size: 1rem;
}

.auth-modal-input-icon {
  position: absolute;
  top: 50%;
  left: 17px;
  z-index: 1;
  color: #8fa0bd;
  pointer-events: none;
  transform: translateY(-50%);
}

.auth-modal-input-icon svg {
  width: 22px;
  height: 22px;
}

.auth-modal .auth-field-state,
.auth-modal .auth-field-error {
  display: block;
  min-height: 0;
  margin-top: 5px;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.auth-modal .auth-field-state:empty,
.auth-modal .auth-field-error:empty {
  display: none;
}

.auth-modal .auth-field-state.is-success {
  color: var(--color-success);
}

.auth-modal .auth-field-state.is-error,
.auth-modal .auth-field-error {
  color: var(--color-danger);
}

.auth-modal .auth-status {
  min-height: 0;
  margin: -4px 0 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.auth-modal .auth-status:empty {
  display: none;
}

.auth-modal .auth-status.is-error,
.auth-modal .auth-captcha-status.is-error {
  color: var(--color-danger);
}

.auth-modal .auth-status.is-success {
  color: var(--color-success);
}

.auth-modal .auth-captcha {
  display: grid;
  gap: 6px;
}

.auth-modal .turnstile-widget {
  width: 100%;
  min-height: 65px;
}

.auth-modal .auth-captcha-status {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.auth-modal-submit,
.auth-modal-google {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  font-size: var(--text-md);
}

.auth-modal-submit {
  margin-top: 2px;
}

.auth-modal-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 30px 0 26px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.auth-modal-divider::before,
.auth-modal-divider::after {
  height: 1px;
  background: var(--color-line);
  content: "";
}

.auth-modal-divider span {
  padding: 0 8px;
  background: #0e1829;
}

.auth-modal-google {
  border-color: var(--color-line-strong);
  background: rgba(255, 255, 255, 0.065);
  box-shadow: none;
}

.auth-modal-google svg {
  width: 23px;
  height: 23px;
}

.auth-modal-legal {
  margin: 28px 0 0;
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-align: center;
}

.auth-modal-legal a {
  color: #aec8ff;
  font-weight: 700;
}

.auth-modal-footer {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 28px;
  border-top: 1px solid var(--color-line);
  color: var(--color-muted);
  font-size: var(--text-md);
  text-align: center;
}

.auth-modal-footer button {
  padding: 2px 4px;
  border: 0;
  color: #aec8ff;
  background: none;
  font-weight: 800;
  cursor: pointer;
}

.auth-modal-footer button:hover {
  color: white;
  text-decoration: underline;
}

.auth-modal.is-username-mode .auth-modal-content {
  padding-bottom: 38px;
}

@keyframes auth-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .auth-modal {
    width: min(100% - 16px, 580px);
    max-height: calc(100vh - 16px);
    border-radius: var(--radius-lg);
  }

  .auth-modal-card {
    max-height: calc(100vh - 16px);
  }

  .auth-modal-header {
    padding: 28px 62px 8px 22px;
  }

  .auth-modal-header h2 {
    font-size: 1.85rem;
  }

  .auth-modal-header p {
    font-size: var(--text-md);
  }

  .auth-modal-content {
    padding: 18px 22px 28px;
  }

  .auth-modal-close {
    top: 12px;
    right: 12px;
  }

  .auth-modal-footer {
    min-height: 72px;
    flex-wrap: wrap;
    padding: 16px 18px;
    font-size: var(--text-sm);
  }
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.field {
  min-width: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  font-weight: 700;
}

.field-hint {
  display: block;
  margin-top: 7px;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  outline: 0;
  color: var(--color-text);
  background: var(--color-surface-muted);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder,
textarea::placeholder {
  color: #62718d;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(109, 156, 255, 0.7);
  background: #0e1a30;
  box-shadow: 0 0 0 4px rgba(109, 156, 255, 0.12);
}

.cselect {
  position: relative;
  width: 100%;
  outline: 0;
  cursor: pointer;
  user-select: none;
}

.cselect-trigger {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  background: var(--color-surface-muted);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.cselect-label {
  flex: 1;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cselect:focus-visible .cselect-trigger,
.cselect.is-open .cselect-trigger {
  border-color: rgba(109, 156, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(109, 156, 255, 0.12);
}

.cselect-arrow {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  opacity: .6;
  transition: opacity var(--transition), transform var(--transition);
}

.cselect-arrow::after {
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--color-text-soft);
  border-bottom: 2px solid var(--color-text-soft);
  content: "";
  transform: rotate(45deg) translate(-1px, -1px);
}

.cselect.is-open .cselect-arrow {
  opacity: 1;
  transform: rotate(180deg);
}

.cselect-listbox {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  z-index: 100;
  display: none;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-md);
  background: #111d32;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5);
}

.cselect.is-open .cselect-listbox {
  display: block;
  animation: select-in 140ms ease both;
}

.cselect-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  color: var(--color-text-soft);
  font-size: var(--text-sm);
}

.cselect-option + .cselect-option {
  border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.cselect-option:hover,
.cselect-option.is-focused {
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.cselect-option.is-selected {
  color: #aec8ff;
  font-weight: 700;
}

.cselect-option.is-selected::before {
  color: var(--color-primary);
  content: "✓";
}

.cselect-option.is-disabled {
  color: #53617a;
  background: transparent;
  cursor: not-allowed;
  opacity: 0.58;
}

.cselect.is-invalid .cselect-trigger,
input.is-invalid {
  border-color: rgba(251, 113, 133, 0.72);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.1);
}

.cselect.is-disabled {
  cursor: not-allowed;
  opacity: .55;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: var(--space-8);
  border: 1px dashed rgba(109, 156, 255, 0.26);
  border-radius: var(--radius-md);
  text-align: center;
  background: rgba(9, 16, 29, 0.5);
}

.empty-state-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto var(--space-4);
  place-items: center;
  border: 1px solid rgba(109, 156, 255, 0.24);
  border-radius: 18px;
  color: var(--color-primary);
  background: rgba(109, 156, 255, 0.09);
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  margin-bottom: var(--space-2);
}

.empty-state p {
  max-width: 400px;
  margin: 0 auto;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

#toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  max-width: min(380px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid rgba(109, 156, 255, 0.34);
  border-radius: var(--radius-md);
  color: white;
  background: rgba(17, 29, 50, 0.96);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 700;
  animation: toast-in 180ms ease both;
  pointer-events: auto;
  cursor: pointer;
}

.toast.is-leaving {
  animation: toast-out 180ms ease both;
}

@keyframes select-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

@media (max-width: 760px) {
  .site-header,
  .site-footer {
    width: calc(100% - 20px);
  }

  .site-header {
    margin-top: 10px;
    padding: 9px 10px 9px 13px;
  }

  .site-brand-mark {
    width: 38px;
    height: 38px;
  }

  .site-brand-copy {
    min-height: 38px;
  }

  .site-brand-copy strong {
    font-size: 1.45rem;
  }

  .site-menu-toggle {
    display: block;
  }

  .site-header-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    display: none;
    padding: 10px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: rgba(18, 27, 44, 0.98);
    box-shadow: var(--shadow-lg);
  }

  .site-header.is-menu-open .site-header-menu-panel {
    display: block;
    animation: select-in 160ms ease both;
  }

  .site-header.is-menu-open .site-menu-toggle span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .site-header.is-menu-open .site-menu-toggle span:nth-child(2) {
    opacity: 0;
  }

  .site-header.is-menu-open .site-menu-toggle span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .site-nav {
    align-items: stretch;
    flex-direction: column;
  }

  .site-nav-link {
    justify-content: flex-start;
    border-radius: 10px;
  }

  .site-footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .field--wide {
    grid-column: auto;
  }

  .panel-header,
  .panel-body {
    padding: 20px;
  }
}
