:root {
  --bg: #101015;
  --bg-strong: #171720;
  --bg-soft: #20202b;
  --panel: #191923;
  --panel-2: #202433;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7f4ec;
  --muted: #b5b2aa;
  --soft: #7f808a;
  --fire: #ff6a21;
  --fire-2: #ff9f1c;
  --gold: #f8c64f;
  --green: #36d887;
  --blue: #5da8ff;
  --purple: #8f6cff;
  --danger: #ff5c7a;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 106, 33, 0.24), transparent 32rem),
    linear-gradient(145deg, #101015 0%, #15151f 46%, #0f1320 100%);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--gold);
}

.app-root {
  min-height: 100vh;
}

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

.loading-screen {
  text-align: center;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: inline-grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--fire), var(--gold));
  color: #15120d;
  font-weight: 950;
  font-size: 1.5rem;
  box-shadow: var(--shadow);
}

.auth-card,
.status-panel,
.form-card,
.surface-panel,
.admin-panel {
  width: min(100%, 560px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 25, 35, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-card,
.status-panel {
  padding: 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--fire-2);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

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

.auth-card h1,
.status-panel h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1;
}

.subtitle {
  color: var(--muted);
  line-height: 1.5;
}

.copy-strong {
  color: var(--text);
  font-weight: 800;
}

.google-button,
.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.small-button,
.action-button,
.save-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  font-weight: 850;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.google-button,
.primary-button,
.save-button {
  width: 100%;
  color: #17120b;
  background: linear-gradient(135deg, var(--fire), var(--gold));
  box-shadow: 0 12px 28px rgba(255, 106, 33, 0.22);
}

.secondary-button,
.ghost-button,
.small-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.danger-button {
  color: #fff;
  background: rgba(255, 92, 122, 0.18);
  border: 1px solid rgba(255, 92, 122, 0.44);
}

.google-button:hover,
.primary-button:hover,
.save-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.small-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.form-grid,
.beast-form,
.admin-form {
  display: grid;
  gap: 14px;
}

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

.field label,
.field .label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.field select {
  color-scheme: dark;
}

.field option {
  color: var(--text);
  background: #171720;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(255, 159, 28, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.12);
}

.app-shell,
.admin-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 92px;
}

.member-header,
.admin-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: -14px -14px 14px;
  padding: 14px;
  background: rgba(16, 16, 21, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-left {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: center;
}

.header-copy {
  min-width: 0;
}

.header-copy h1 {
  margin: 0;
  font-size: 1.05rem;
}

.header-copy p {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
  font-weight: 950;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--text);
  background: rgba(255, 106, 33, 0.16);
  border: 1px solid rgba(255, 106, 33, 0.28);
  font-size: 0.82rem;
  font-weight: 850;
}

.version-chip {
  background: rgba(93, 168, 255, 0.14);
  border-color: rgba(93, 168, 255, 0.3);
  color: #dcecff;
  font-size: 0.68rem;
}

.main-content {
  display: grid;
  gap: 14px;
}

.dashboard-hero {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 159, 28, 0.24);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 106, 33, 0.26), rgba(143, 108, 255, 0.12)),
    rgba(25, 25, 35, 0.86);
  box-shadow: var(--shadow);
}

.dashboard-hero h2 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 8vw, 3.8rem);
  line-height: 0.98;
}

.dashboard-hero p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-actions,
.action-grid,
.quick-grid,
.admin-actions,
.inline-actions {
  display: grid;
  gap: 10px;
}

.action-grid,
.quick-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-button {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 94px;
  padding: 13px;
  color: var(--text);
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
}

.action-button span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.stat-grid,
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card,
.metric-card,
.today-card,
.progress-card,
.announcement-card,
.challenge-card,
.badge-card,
.leaderboard-card,
.member-card,
.request-card,
.log-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 25, 35, 0.88);
}

.stat-card,
.metric-card {
  min-height: 102px;
  padding: 14px;
}

.stat-card .label,
.metric-card .label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-card .value,
.metric-card .value {
  font-size: clamp(1.35rem, 7vw, 2.1rem);
  font-weight: 950;
}

.stat-card .hint,
.metric-card .hint {
  margin-top: 5px;
  color: var(--soft);
  font-size: 0.78rem;
}

.progress-card,
.today-card,
.announcement-card,
.form-card,
.surface-panel,
.admin-panel {
  padding: 16px;
}

.section-title {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 1.05rem;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--fire-2));
  transition: width 240ms ease;
}

.progress-meta,
.split-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.progress-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.today-card.good {
  border-color: rgba(54, 216, 135, 0.35);
  background: rgba(35, 85, 60, 0.2);
}

.today-card.hot {
  border-color: rgba(255, 159, 28, 0.38);
  background: rgba(255, 106, 33, 0.13);
}

.card-list,
.leaderboard-list,
.badge-grid {
  display: grid;
  gap: 10px;
}

.badge-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.badge-card {
  min-height: 130px;
  padding: 13px;
}

.badge-icon {
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.badge-card h3,
.challenge-card h3,
.leaderboard-card h3,
.member-card h3,
.request-card h3,
.log-card h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.badge-card p,
.challenge-card p,
.leaderboard-card p,
.member-card p,
.request-card p,
.log-card p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.88rem;
}

.badge-card.locked {
  color: var(--soft);
  filter: grayscale(0.75);
  opacity: 0.62;
}

.challenge-card,
.leaderboard-card,
.member-card,
.request-card,
.log-card {
  padding: 14px;
}

.challenge-meta,
.member-meta,
.log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 750;
}

.tag.gold {
  color: #251804;
  background: var(--gold);
  border-color: transparent;
}

.tag.green {
  color: #062115;
  background: var(--green);
  border-color: transparent;
}

.tag.red {
  color: #fff;
  background: rgba(255, 92, 122, 0.18);
  border-color: rgba(255, 92, 122, 0.42);
}

.leaderboard-tabs,
.admin-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.admin-audio-jump {
  margin-bottom: 12px;
}

.segment-button,
.admin-tab-button {
  min-height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.segment-button.active,
.admin-tab-button.active {
  color: #17120b;
  background: var(--gold);
  border-color: transparent;
}

.leaderboard-card {
  display: grid;
  grid-template-columns: auto 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.rank-number {
  min-width: 34px;
  font-size: 1.1rem;
  font-weight: 950;
  text-align: center;
}

.leaderboard-card.top-one {
  border-color: rgba(248, 198, 79, 0.58);
  background: linear-gradient(135deg, rgba(248, 198, 79, 0.16), rgba(25, 25, 35, 0.9));
}

.leaderboard-name {
  min-width: 0;
}

.leaderboard-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-xp {
  text-align: right;
  font-weight: 950;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(var(--nav-count, 5), minmax(0, 1fr));
  gap: 4px;
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  background: rgba(16, 16, 21, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
}

.nav-item .nav-icon {
  font-size: 1.2rem;
}

.nav-item.active {
  color: #17120b;
  background: linear-gradient(135deg, var(--fire), var(--gold));
}

.result-panel {
  border: 1px solid rgba(54, 216, 135, 0.38);
  border-radius: 8px;
  padding: 16px;
  background: rgba(54, 216, 135, 0.13);
}

.result-panel h3 {
  margin-bottom: 6px;
}

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

.radio-pill {
  position: relative;
}

.radio-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-pill span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 850;
}

.radio-pill input:checked + span {
  color: #17120b;
  border-color: transparent;
  background: var(--green);
}

.empty-state {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.admin-shell {
  padding-bottom: 24px;
}

.admin-header {
  align-items: flex-start;
}

.admin-panel {
  width: 100%;
}

.admin-grid {
  display: grid;
  gap: 14px;
}

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

.small-button {
  min-height: 38px;
  padding: 7px 10px;
}

.inline-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.inline-actions.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.xp-adjust {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-top: 10px;
}

.xp-adjust input {
  min-width: 0;
}

.conversation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(25, 25, 35, 0.9);
}

.conversation-card audio {
  width: 100%;
  margin-top: 12px;
}

.conversation-head {
  display: grid;
  gap: 12px;
}

.conversation-head h3 {
  margin: 10px 0 6px;
  font-size: 1.08rem;
}

.conversation-head p,
.transcript-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.conversation-xp {
  align-self: start;
  border: 1px solid rgba(248, 198, 79, 0.36);
  border-radius: 8px;
  padding: 10px;
  color: var(--gold);
  background: rgba(248, 198, 79, 0.09);
  font-weight: 950;
  text-align: center;
}

.conversation-xp span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.audio-player {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.audio-progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.audio-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--fire));
  transition: width 180ms linear;
}

.audio-time,
.conversation-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.audio-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.transcript-box {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.transcript-box summary {
  color: var(--gold);
  cursor: pointer;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 90px;
  left: 14px;
  z-index: 30;
  display: none;
  max-width: 560px;
  margin: 0 auto;
  border: 1px solid rgba(255, 159, 28, 0.36);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(24, 24, 32, 0.96);
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
  animation: toast-in 220ms ease;
}

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

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-card {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin-bottom: 6px;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

.fine-print {
  color: var(--soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (min-width: 720px) {
  .app-shell,
  .admin-shell {
    padding: 20px 20px 30px;
  }

  .member-header,
  .admin-header {
    margin: -20px -20px 20px;
    padding: 18px 20px;
  }

  .dashboard-hero {
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
    align-items: center;
    padding: 24px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .stat-grid,
  .admin-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .action-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .badge-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card-list,
  .admin-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .conversation-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .audio-actions {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  }

  .bottom-nav {
    right: 20px;
    bottom: 18px;
    left: 20px;
    max-width: 720px;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .modal-layer {
    place-items: center;
  }
}

@media (min-width: 980px) {
  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .card-list,
  .admin-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
