:root {
  --bg: #0b1018;
  --bg-2: #0f1622;
  --card: #121a27;
  --line: #223145;
  --text: #ecf2ff;
  --muted: #9baec9;
  --primary: #52b6ff;
  --primary-2: #2f8de0;
  --danger: #ff8f8f;
  --ok: #95f5aa;
  --warn: #ffd78c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  overflow-x: hidden;
}

.shell {
  width: min(1160px, calc(100% - 2rem));
  margin: 7rem auto 4rem;
  display: grid;
  gap: 1rem;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 16, 24, 0.96);
  border-bottom: 1px solid var(--line);
}

.app-header-inner {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  min-height: 68px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
}

.discord-header-link {
  position: absolute;
  top: 0.85rem;
  left: 1rem;
  min-height: 2.45rem;
  padding: 0 0.95rem 0 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f0f7ff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 18px rgba(47, 141, 224, 0.25);
  flex: 0 0 auto;
}

.discord-header-link svg {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
}

.discord-header-link span {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.discord-header-link:hover {
  filter: brightness(1.06);
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.auth-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.active-team-badge {
  margin: 0;
  padding: 0.35rem 0.68rem;
  border: 1px solid #2a3b52;
  border-radius: 999px;
  font-size: 0.84rem;
  color: var(--muted);
  background: #151f2d;
  text-align: center;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.hero h1,
h2,
h3 {
  margin: 0 0 0.6rem;
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.02em;
}

.hero p {
  margin: 0.2rem 0;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.13em;
  color: var(--primary);
}

.field-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.help-icon {
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #3a5578;
  color: #b7cce3;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  user-select: none;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border-radius: 10px;
  border: 1px solid #2a3b52;
  background: #0f1723;
  color: var(--text);
  padding: 0.7rem 0.85rem;
}

textarea {
  resize: vertical;
  min-height: 220px;
}

.full-width {
  margin-top: 0.9rem;
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

button,
.auth-link.btn-primary,
.auth-link.btn-secondary {
  cursor: pointer;
  border: 1px solid #2a3b52;
  border-radius: 10px;
  padding: 0.66rem 1rem;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

button:hover,
.auth-link.btn-primary:hover,
.auth-link.btn-secondary:hover {
  border-color: #3f5b80;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  pointer-events: auto;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f0f7ff;
  font-weight: 700;
  border-color: transparent;
}

.btn-secondary {
  background: #172233;
  color: var(--text);
  border-color: #2a3b52;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.link-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.link-status.is-linked {
  color: #9ff0bb;
  border: 1px solid rgba(105, 220, 146, 0.45);
  background: rgba(27, 62, 39, 0.45);
}

.link-status.is-unlinked {
  color: #ffc5c5;
  border: 1px solid rgba(227, 111, 111, 0.45);
  background: rgba(74, 34, 34, 0.45);
}

.hidden {
  display: none;
}

.status {
  margin: 0;
  color: #dff3ff;
}

.summary-grid {
  margin: 0.7rem 0 1rem;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.stat {
  border: 1px solid rgba(150, 201, 230, 0.25);
  border-radius: 10px;
  padding: 0.65rem;
  background: rgba(12, 26, 36, 0.62);
}

.stat b {
  display: block;
  font-size: 1.2rem;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.toolbar-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.status-filter-menu {
  position: relative;
}

.status-filter-menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(145, 184, 210, 0.4);
  border-radius: 10px;
  padding: 0.52rem 0.85rem;
  font-size: 0.9rem;
  background: rgba(4, 10, 14, 0.6);
}

.status-filter-menu > summary::-webkit-details-marker {
  display: none;
}

.status-filter-menu[open] > summary {
  border-color: rgba(107, 228, 176, 0.5);
}

.status-filter-list {
  position: absolute;
  right: 0;
  margin-top: 0.45rem;
  min-width: 260px;
  border: 1px solid rgba(145, 184, 210, 0.4);
  border-radius: 12px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: rgba(5, 14, 20, 0.96);
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

#analyzeSpellFilterList {
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 0.45rem;
}

.status-filter-list label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.87rem;
}

.status-filter-list input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.pull-block {
  border-top: 1px solid rgba(146, 200, 233, 0.2);
  padding-top: 1rem;
  margin-top: 1rem;
}

.pull-head {
  list-style: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  cursor: pointer;
}

.pull-head::-webkit-details-marker {
  display: none;
}

.pull-toggle {
  font-size: 0.8rem;
  color: var(--primary);
  border: 1px solid rgba(107, 228, 176, 0.45);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  line-height: 1.1;
  margin-top: 0.1rem;
  flex-shrink: 0;
}

.pull-block[open] .pull-toggle::before {
  content: "Collapse";
}

.pull-block:not([open]) .pull-toggle::before {
  content: "Expand";
}

.pull-block[open] .pull-toggle {
  color: #042530;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
}

.pull-block .table-wrap {
  margin-top: 0.7rem;
}

.pull-title {
  margin-bottom: 0.2rem;
}

.pull-meta,
.pull-score {
  margin: 0.1rem 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.7rem;
}

th,
td {
  border-bottom: 1px solid rgba(145, 198, 230, 0.18);
  text-align: left;
  padding: 0.54rem;
  font-size: 0.88rem;
}

.stats-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.stats-sort-btn:hover {
  color: #9fdbff;
}

.stats-sort-btn.is-active {
  color: var(--primary);
}

.stats-sort-indicator {
  font-size: 0.74rem;
  line-height: 1;
  opacity: 0.9;
}

.pill {
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.22rem 0.52rem;
  display: inline-block;
}

.pill.ok {
  color: #072f16;
  background: var(--ok);
}

.pill.warn {
  color: #402600;
  background: var(--warn);
}

.pill.miss {
  color: #3f0505;
  background: var(--danger);
}

.spell-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  text-decoration: none;
  vertical-align: middle;
}

.spell-link:hover .spell-name {
  text-decoration: underline;
  color: var(--primary);
}

.spell-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(145, 198, 230, 0.3);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.spell-icon-placeholder {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: rgba(145, 198, 230, 0.1);
  border-radius: 4px;
  flex-shrink: 0;
  vertical-align: middle;
}

.spell-name {
  font-size: 0.85rem;
  vertical-align: middle;
}

.pill.na {
  color: #1a2a38;
  background: #5a7a94;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: reveal 0.5s ease forwards;
}

.delay-1 {
  animation-delay: 0.06s;
}

.delay-2 {
  animation-delay: 0.12s;
}

.delay-3 {
  animation-delay: 0.18s;
}

.top-nav {
  margin-top: 0;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  width: 100%;
}

.nav-btn {
  background: #172233;
  color: var(--text);
  border-color: #2a3b52;
}

.nav-btn.is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f0f7ff;
  border-color: transparent;
  font-weight: 700;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.stats-controls {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
  margin: 0.75rem 0;
}

.stats-mode-toggle {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.stats-mode-toggle .btn-secondary.is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f0f7ff;
  border-color: transparent;
}

.stats-view {
  margin-top: 0.75rem;
}

.stats-raid-card {
  border: 1px solid #2a3b52;
  border-radius: 12px;
  background: #111a28;
  padding: 0.65rem;
  margin-bottom: 0.7rem;
}

.stats-raid-card > summary {
  list-style: none;
  cursor: pointer;
}

.stats-raid-card > summary::-webkit-details-marker {
  display: none;
}

.stats-raid-head h3 {
  margin: 0 0 0.22rem;
}

.add-raid-panel {
  margin-top: 0.8rem;
  border: 1px solid #2a3b52;
  border-radius: 12px;
  padding: 0.8rem;
  background: #111a28;
}

.raids-toolbar {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.raid-search-label {
  min-width: min(520px, 100%);
}

#raidSearchInput {
  width: 100%;
}

.raid-list {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.8rem;
}

.raid-card {
  border: 1px solid #2a3b52;
  border-radius: 12px;
  background: #111a28;
  padding: 0.75rem;
}

.raid-card-head {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.summary-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.raid-card-head::-webkit-details-marker {
  display: none;
}

.raid-card-head h3 {
  margin-bottom: 0.2rem;
}

.raid-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.warcraftlogs-link {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 14, 24, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  text-decoration: none;
}

.warcraftlogs-link:hover {
  border-color: rgba(109, 178, 255, 0.75);
}

.warcraftlogs-link img {
  width: 16px;
  height: 16px;
  display: block;
}

.raid-card-body {
  margin-top: 0.7rem;
}

.danger-btn {
  border-color: rgba(255, 143, 143, 0.5);
  color: #ffd3d3;
}

.member-deactivate-btn {
  background: linear-gradient(135deg, #8d2222, #b63a3a);
  border-color: #d26f6f;
  color: #ffeaea;
}

.member-activate-btn {
  background: linear-gradient(135deg, #1f6f3f, #2f9555);
  border-color: #66c48b;
  color: #ecfff3;
}

.saved-notes-browser {
  margin-top: 0.9rem;
}

.saved-notes-table td,
.saved-notes-table th {
  white-space: nowrap;
}

.saved-notes-table td:nth-child(2),
.saved-notes-table th:nth-child(2) {
  width: 100%;
  white-space: normal;
}

.saved-notes-row-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.pull-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
}

.pull-item {
  border: 1px solid #2a3b52;
  border-radius: 10px;
  padding: 0.65rem;
}

.pull-item-head {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.pull-item-head::-webkit-details-marker {
  display: none;
}

.pull-item-head::after {
  content: ">";
  color: #9db0c7;
  font-size: 1rem;
  line-height: 1;
  margin-left: 0.75rem;
  transition: transform 160ms ease, color 160ms ease;
}

.pull-item[open] .pull-item-head::after {
  transform: rotate(90deg);
  color: #d4e5ff;
}

.pull-item-body {
  margin-top: 0.6rem;
}

.manual-mistake-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mistake-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.mistake-table thead th {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: var(--color-muted, #888);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mistake-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

.mistake-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
}

.mistake-col-player { white-space: nowrap; }
.mistake-col-reason { width: 99%; }
.mistake-col-source { white-space: nowrap; }
.mistake-col-action { white-space: nowrap; text-align: right; }

.btn-danger-sm {
  background: transparent;
  border: 1px solid rgba(220,60,60,0.5);
  color: #e06060;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.btn-danger-sm:hover {
  background: rgba(220,60,60,0.2);
  color: #ff8080;
}

.team-selector-row {
  margin-top: 0.9rem;
  max-width: 360px;
}

.team-detail {
  margin-top: 0.9rem;
}

.team-card {
  padding: 0.95rem;
}

.team-member-grid {
  margin-top: 0.8rem;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-shell.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.68);
}

.modal-panel {
  position: relative;
  width: min(900px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.analyze-top-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.analyze-top-row .full-width {
  flex: 1 1 auto;
}

.analyze-tolerance-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 0 0 90px;
  font-size: 0.875rem;
}

.analyze-tolerance-label input {
  width: 100%;
}

.spell-filter-wrap {
  flex: 0 0 280px;
}

.discord-notify-modal-panel {
  width: min(720px, 100%);
}

.discord-notify-actions {
  margin-bottom: 0.5rem;
}

.discord-recipient-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 360px;
  overflow: auto;
  padding: 0.25rem;
}

.discord-recipient-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.discord-recipient-item input[type="checkbox"] {
  margin-top: 0.2rem;
}

#analyzeSpellFilterSearchInput {
  width: 100%;
}

#analyzeSpellFilterMenu {
  width: 100%;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(1160px, calc(100% - 1rem));
    margin-top: 7.3rem;
  }

  .card {
    padding: 0.9rem;
    border-radius: 14px;
  }

  .status-filter-list {
    right: auto;
    left: 0;
    min-width: 170px;
  }

  .spell-filter-wrap {
    flex: 1 1 auto;
  }

  .app-header-inner {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .discord-header-link {
    top: 0.75rem;
    left: 0.5rem;
    min-height: 2.2rem;
    padding-left: 0.7rem;
    padding-right: 0.8rem;
  }

  .discord-header-link svg {
    width: 1.2rem;
    height: 1.2rem;
  }

  .discord-header-link span {
    font-size: 0.82rem;
  }
}
