:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #121212;
  color: #e3e3e3;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #121212;
  --surface-raised: #121212;
  --border: #e3e3e333;
  --muted: #e3e3e3;
  --faint: #e3e3e3;
  --accent: #8ab4ff;
  --accent-wash: #8ab4ff1a;
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-medium: 280ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: #121212;
}

body {
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: #121212;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
}

.page-view h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.03em;
}

.page-intro {
  margin: 8px 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.discord-button {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 0 24px;
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  color: #121212;
  background: var(--accent);
  cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}

.discord-button:hover:not(:disabled) {
  background: #a4c5ff;
}

.discord-button:active:not(:disabled) {
  transform: translateY(1px);
}

.discord-button:disabled {
  cursor: not-allowed;
}

.discord-button.is-failed,
.discord-button.is-failed:hover {
  background: var(--accent);
}

.button-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
}

.button-icon > svg {
  width: 24px;
  height: 24px;
}

.spinner,
.popup-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e3e3e355;
  border-top-color: #e3e3e3;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.failure-icon {
  overflow: visible;
}

.failure-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
  animation: draw-x .28s ease-out forwards;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes draw-x {
  to {
    stroke-dashoffset: 0;
  }
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--border);
  background: #121212;
}

.account-menu {
  position: relative;
  margin-left: auto;
}

.account-trigger {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px 3px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e3e3e3;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}

.account-trigger:hover,
.account-trigger[aria-expanded="true"] {
  border-color: var(--border);
  background: var(--accent-wash);
}

.account-trigger .avatar,
.avatar-fallback {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
}

.account-trigger .avatar {
  outline: 1px solid #8ab4ff66;
  outline-offset: 2px;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: #121212;
  color: #e3e3e3;
  font-size: 13px;
  font-weight: 600;
}

.account-trigger-name {
  overflow: hidden;
  max-width: 160px;
  font-size: 13px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--faint);
  transition: transform var(--motion-base) var(--ease-out), color var(--motion-fast) ease;
}

.account-chevron path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.account-trigger[aria-expanded="true"] .account-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.account-popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  width: min(280px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121212;
  box-shadow: 0 16px 40px #0009, 0 2px 8px #0008;
  animation: popover-in var(--motion-base) var(--ease-out) both;
  transform-origin: top right;
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popover-heading {
  display: grid;
  gap: 4px;
  padding: 2px 2px 12px;
}

.popover-name,
.popover-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover-name {
  color: #e3e3e3;
  font-size: 14px;
  font-weight: 600;
}

.popover-email {
  color: var(--muted);
  font-size: 12px;
}

.popover-details {
  margin: 0;
  padding: 8px 2px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.popover-details > div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
}

.popover-details dt {
  color: var(--muted);
}

.popover-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.popover-sign-out {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  padding: 0 6px;
  border: 0;
  border-radius: 5px;
  color: #e3e3e3;
  background: transparent;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease;
}

.popover-sign-out:hover {
  background: var(--accent-wash);
  color: var(--accent);
}

.popover-sign-out svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.sidebar-title {
  padding: 4px 10px 24px;
  color: #e3e3e3;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.015em;
  text-decoration: none;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.nav-link:hover {
  color: #e3e3e3;
  background: var(--accent-wash);
  transform: translateX(2px);
}

.nav-link[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-wash);
}

.nav-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.main-panel {
  min-width: 0;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--border);
  background: #121212;
}

.topbar .account-menu {
  flex: none;
}

.page-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.avatar {
  flex: none;
  border-radius: 50%;
  background: var(--surface-raised);
  object-fit: cover;
}

.page-content {
  width: min(100%, 960px);
  padding: 40px 32px 64px;
}

.app-shell:not([hidden]) .page-content {
  animation: page-in var(--motion-medium) var(--ease-out) both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-view h2 {
  font-size: 24px;
}

.sign-out-dialog {
  width: min(100% - 32px, 400px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #e3e3e3;
  background: #121212;
  box-shadow: 0 24px 70px #000b;
  animation: dialog-in var(--motion-medium) var(--ease-out) both;
}

.sign-out-dialog::backdrop {
  background: #000a;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 8px;
  color: #e3e3e3;
  background: #121212;
}

.dialog-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.sign-out-dialog h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
}

.sign-out-dialog > p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sign-out-dialog > .dialog-error {
  color: #e3e3e3;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.dialog-actions button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #e3e3e3;
  background: #121212;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.dialog-actions button:hover {
  color: #121212;
  background: #e3e3e3;
}

.dialog-actions .dialog-confirm {
  border-color: var(--accent);
  color: #121212;
  background: var(--accent);
}

.dialog-actions .dialog-confirm:hover {
  background: #a4c5ff;
}

.dialog-actions .dialog-confirm:disabled {
  cursor: wait;
  opacity: .65;
}

.empty-state {
  max-width: 680px;
  padding: 32px 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.status-message {
  margin: 18px 0 0;
  color: #e3e3e3;
  font-size: 13px;
  line-height: 1.5;
}

.popup-page {
  display: grid;
  place-items: center;
}

.popup-status {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.popup-spinner {
  width: 18px;
  height: 18px;
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .sidebar {
    min-height: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-title {
    padding: 0 8px;
  }

  .sidebar-nav {
    grid-row: 2;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    min-height: 68px;
    padding: 10px 20px;
  }

  .page-content {
    padding: 32px 20px 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none;
    animation: none !important;
  }
}
