/* =========================================================
   CTW — MISSION: Conquer The World
   Sistema visual: verde/beige, cálido, orgánico, minimalista.
   ========================================================= */

:root {
  --ctw-green-900: #12291f;
  --ctw-green-800: #1c4136;
  --ctw-green-700: #2a594c; /* verde CTW */
  --ctw-green-600: #386b5c;
  --ctw-green-500: #4c8271;
  --ctw-green-400: #6d9c8c;

  --ctw-beige-100: #fbf7ec;
  --ctw-beige-200: #f7f2e4; /* beige claro */
  --ctw-beige-300: #ece2c6; /* beige CTW */
  --ctw-beige-400: #d8c9a0;
  --ctw-beige-500: #c2ae7d;

  --ctw-earth-500: #b3835a;
  --ctw-earth-600: #8f6743;

  --ctw-ink-900: #21261f;
  --ctw-ink-700: #454a3f;
  --ctw-ink-500: #6d7264;
  --ctw-ink-300: #a3a595;

  --ctw-danger: #a4543f;
  --ctw-danger-bg: #f3e3dc;

  --ctw-white: #fffdf8;

  --ctw-shadow-soft: 0 8px 24px -12px rgba(18, 41, 31, 0.35);
  --ctw-shadow-lift: 0 16px 40px -18px rgba(18, 41, 31, 0.45);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --nav-height: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--ctw-beige-200);
  color: var(--ctw-ink-900);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

/* El logo CTW nunca debe verse con esquinas rectas, se use donde se use. */
img[src$="logo.png"] {
  border-radius: 22%;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

/* Todo texto libre (nombres, comentarios) puede ser largo y sin espacios:
   nunca debe forzar overflow horizontal de su contenedor. */
p, h1, h2, h3, span, div {
  overflow-wrap: anywhere;
}

/* ---------- Iconos ----------
   Los SVG de icons.js no llevan width/height propios (solo viewBox): sin esta
   regla, el navegador los renderiza a su tamaño de reemplazo por defecto
   (~300x150px) y rompe el layout. .icon fija un tamaño base sensato en
   cualquier contexto; las reglas de componentes más específicas (definidas
   más abajo en este archivo) lo sobreescriben cuando hace falta otro tamaño. */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.icon svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

:focus-visible {
  outline: 3px solid var(--ctw-green-500);
  outline-offset: 2px;
}

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

/* ---------- Layout shell ---------- */

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.screen {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--nav-height) + var(--space-6) + var(--safe-bottom));
}

.screen--wide {
  max-width: 720px;
}

.screen--no-nav {
  padding-bottom: var(--space-6);
  max-width: 720px;
}

@media (min-width: 720px) {
  .screen {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  background: linear-gradient(to bottom, var(--ctw-beige-200) 70%, transparent);
}

@media (min-width: 720px) {
  .topbar {
    max-width: 720px;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ctw-green-700);
}

.topbar__brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.avatar-button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 2px solid var(--ctw-beige-300);
  background: var(--ctw-green-700);
  color: var(--ctw-beige-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  overflow: hidden;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.avatar-button:active {
  transform: scale(0.94);
}

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

/* ---------- Bottom navigation ---------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: var(--ctw-white);
  border-top: 1px solid var(--ctw-beige-400);
}

.bottom-nav__inner {
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  position: relative;
  padding: 0 var(--space-4);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-2);
  color: var(--ctw-ink-500);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: color 0.15s ease;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item[aria-current='page'] {
  color: var(--ctw-green-700);
}

.nav-item--home {
  justify-self: center;
  transform: translateY(-22px);
}

.nav-item--home .nav-item__circle {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: var(--ctw-green-700);
  color: var(--ctw-beige-200);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ctw-shadow-lift);
  border: 4px solid var(--ctw-beige-200);
  transition: transform 0.15s ease;
}

.nav-item--home:active .nav-item__circle {
  transform: scale(0.92);
}

.nav-item--home svg {
  width: 26px;
  height: 26px;
}

.nav-item--home span {
  color: var(--ctw-ink-500);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 24px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--ctw-green-700);
  color: var(--ctw-beige-100);
  box-shadow: var(--ctw-shadow-soft);
}

.btn-secondary {
  background: var(--ctw-beige-300);
  color: var(--ctw-green-800);
}

.btn-ghost {
  background: transparent;
  color: var(--ctw-green-700);
}

.btn-danger {
  background: var(--ctw-danger-bg);
  color: var(--ctw-danger);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 14px;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
}

.btn-sm {
  padding: 8px 16px;
  min-height: 36px;
  font-size: 0.82rem;
}

.icon-btn {
  background: var(--ctw-beige-100);
  border: 1px solid var(--ctw-beige-400);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ctw-ink-700);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.back-button {
  margin-bottom: var(--space-4);
}

/* ---------- Cards & surfaces ---------- */

.card {
  background: var(--ctw-white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--ctw-shadow-soft);
}

.card + .card {
  margin-top: var(--space-4);
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ctw-ink-500);
  margin-bottom: var(--space-3);
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  min-width: 0;
}

.field input,
.field textarea {
  width: 100%;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ctw-ink-700);
}

.field input,
.field textarea {
  background: var(--ctw-beige-100);
  border: 1.5px solid var(--ctw-beige-400);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--ctw-ink-900);
  transition: border-color 0.15s ease;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--ctw-green-600);
  outline: none;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--ctw-ink-500);
}

.field-error {
  font-size: 0.8rem;
  color: var(--ctw-danger);
}

/* ---------- Landing ---------- */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 90% at 50% -10%, var(--ctw-green-600) 0%, var(--ctw-green-800) 55%, var(--ctw-green-900) 100%);
  color: var(--ctw-beige-100);
}

.landing__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-5);
  gap: var(--space-5);
  max-width: 480px;
  margin: 0 auto;
}

.landing__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.landing__brand img {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
}

.landing__brand h1 {
  font-size: 1.6rem;
  letter-spacing: 0.05em;
  font-weight: 800;
}

.landing__tagline {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ctw-beige-300);
}

.landing__scene {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 0.9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.landing__footer {
  padding: var(--space-5);
  text-align: center;
  font-size: 0.75rem;
  color: var(--ctw-green-400);
}

/* ---------- Login modal / view ---------- */

.login-card {
  background: var(--ctw-beige-100);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  color: var(--ctw-ink-900);
  box-shadow: var(--ctw-shadow-lift);
}

.login-card h2 {
  font-size: 1.2rem;
  margin-bottom: var(--space-4);
  color: var(--ctw-green-800);
}

/* ---------- Home ---------- */

.home-header {
  text-align: center;
  margin-bottom: var(--space-4);
}

.home-header__category {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ctw-green-600);
}

.home-header__name {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--ctw-green-800);
}

.scene-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 46vh;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(180deg, var(--ctw-beige-100), var(--ctw-beige-300));
  box-shadow: var(--ctw-shadow-soft);
  margin-bottom: var(--space-5);
  touch-action: pan-y;
}

.mountain-scene,
.mountain-scene svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ctw-marker__halo {
  transform-box: fill-box;
  transform-origin: center;
  animation: marker-pulse 2.2s ease-in-out infinite;
}

@keyframes marker-pulse {
  0%, 100% { transform: scale(1); opacity: 0.22; }
  50% { transform: scale(1.6); opacity: 0.4; }
}

.ctw-marker--summit .ctw-marker__halo {
  animation-duration: 1.4s;
}

.ctw-clouds ellipse:first-child {
  animation: cloud-drift 30s ease-in-out infinite alternate;
}

.ctw-clouds ellipse:last-child {
  animation: cloud-drift 24s ease-in-out infinite alternate-reverse;
}

@keyframes cloud-drift {
  from { transform: translateX(0); }
  to { transform: translateX(14px); }
}

.progress-block {
  text-align: center;
  margin-bottom: var(--space-5);
}

.progress-block__meters {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--ctw-green-800);
  font-variant-numeric: tabular-nums;
}

.progress-block__meters small {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ctw-ink-500);
}

.progress-bar {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--ctw-beige-400);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--ctw-green-600), var(--ctw-green-700));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-block__meta {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  font-size: 0.85rem;
  color: var(--ctw-ink-700);
}

.progress-block__meta strong {
  color: var(--ctw-green-700);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-5);
}

.quick-action {
  background: var(--ctw-white);
  border: 1.5px solid var(--ctw-beige-400);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ctw-green-800);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--ctw-shadow-soft);
  transition: transform 0.12s ease;
  position: relative;
}

.quick-action:active {
  transform: scale(0.95);
}

.quick-action--empty {
  color: var(--ctw-ink-500);
  border-style: dashed;
  font-weight: 600;
}

.quick-action__flash {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ctw-green-700);
  opacity: 0;
  pointer-events: none;
}

.quick-action__flash.is-active {
  animation: flash-up 0.9s ease forwards;
}

@keyframes flash-up {
  0% { opacity: 0; transform: translate(-50%, 4px); }
  25% { opacity: 1; transform: translate(-50%, -6px); }
  100% { opacity: 0; transform: translate(-50%, -22px); }
}

.home-cta {
  display: flex;
  justify-content: center;
}

/* ---------- Empty states ---------- */

.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--ctw-ink-500);
}

.empty-state__icon {
  margin: 0 auto var(--space-3);
  color: var(--ctw-green-500);
}

.empty-state__icon svg {
  width: 56px;
  height: 56px;
}

.empty-state h3 {
  color: var(--ctw-ink-700);
  font-size: 1rem;
  margin-bottom: var(--space-2);
}

/* ---------- Activity list ---------- */

.day-group {
  margin-bottom: var(--space-5);
}

.day-group__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ctw-ink-500);
  margin: var(--space-4) 0 var(--space-2);
  text-transform: capitalize;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--ctw-white);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  box-shadow: var(--ctw-shadow-soft);
}

.activity-row__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--ctw-beige-300);
  color: var(--ctw-green-700);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-row__icon svg {
  width: 20px;
  height: 20px;
}

.activity-row__body {
  flex: 1;
  min-width: 0;
}

.activity-row__title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ctw-ink-900);
}

.activity-row__meta {
  font-size: 0.78rem;
  color: var(--ctw-ink-500);
}

.activity-row__comment {
  font-size: 0.82rem;
  color: var(--ctw-ink-700);
  margin-top: 2px;
}

.activity-row__meters {
  font-weight: 800;
  color: var(--ctw-green-700);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.activity-row__actions {
  display: flex;
  gap: var(--space-1);
}

/* ---------- Users list ---------- */

.user-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--ctw-white);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  box-shadow: var(--ctw-shadow-soft);
  width: 100%;
  text-align: left;
  border: none;
}

.user-row__avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--ctw-green-700);
  color: var(--ctw-beige-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

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

.user-row__body {
  flex: 1;
  min-width: 0;
}

.user-row__name {
  font-weight: 700;
  color: var(--ctw-ink-900);
}

.user-row__challenge {
  font-size: 0.78rem;
  color: var(--ctw-ink-500);
}

.user-row__pct {
  font-weight: 800;
  color: var(--ctw-green-700);
  font-variant-numeric: tabular-nums;
}

/* ---------- Profile ---------- */

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.profile-avatar {
  position: relative;
  width: 96px;
  height: 96px;
}

.profile-avatar__img {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  background: var(--ctw-green-700);
  color: var(--ctw-beige-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  overflow: hidden;
  border: 4px solid var(--ctw-white);
  box-shadow: var(--ctw-shadow-soft);
}

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

.profile-avatar__edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--ctw-green-700);
  color: var(--ctw-beige-100);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ctw-white);
}

.profile-avatar__edit svg {
  width: 14px;
  height: 14px;
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ctw-green-800);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat-tile {
  background: var(--ctw-white);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--ctw-shadow-soft);
}

.stat-tile__value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ctw-green-700);
  font-variant-numeric: tabular-nums;
}

.stat-tile__label {
  font-size: 0.75rem;
  color: var(--ctw-ink-500);
  margin-top: 2px;
}

.chart-card canvas {
  width: 100%;
  height: 160px;
}

.qa-editor-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--ctw-beige-300);
}

.qa-editor-row:last-child {
  border-bottom: none;
}

.qa-editor-row__body {
  flex: 1;
  min-width: 0;
}

.qa-editor-row__name {
  font-weight: 700;
}

.qa-editor-row__meters {
  font-size: 0.8rem;
  color: var(--ctw-ink-500);
}

.completed-challenge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--ctw-beige-200);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}

/* ---------- Celebration ---------- */

.celebration {
  min-height: 70vh;
  border-radius: var(--radius-lg);
  background: radial-gradient(120% 80% at 50% 0%, var(--ctw-green-600), var(--ctw-green-900));
  color: var(--ctw-beige-100);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-5);
  gap: var(--space-5);
  box-shadow: var(--ctw-shadow-lift);
}

.celebration__badge {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-full);
  background: var(--ctw-beige-300);
  color: var(--ctw-green-800);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.celebration__badge svg {
  width: 40px;
  height: 40px;
}

@keyframes pop-in {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.celebration h1 {
  font-size: 1.7rem;
  font-weight: 800;
}

.celebration__meters {
  font-size: 2.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.celebration__stats {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--ctw-beige-300);
}

.celebration__stats strong {
  display: block;
  font-size: 1.05rem;
  color: var(--ctw-beige-100);
}

.celebration__brand {
  margin-top: var(--space-4);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--ctw-green-400);
  font-weight: 700;
}

/* ---------- Toast / feedback ---------- */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-4));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ctw-ink-900);
  color: var(--ctw-beige-100);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 90vw;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--error {
  background: var(--ctw-danger);
}

/* ---------- Overlays / sheets ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 41, 31, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  animation: fade-in 0.15s ease;
}

@media (min-width: 720px) {
  .overlay {
    align-items: center;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  background: var(--ctw-beige-100);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  animation: slide-up 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: calc(var(--space-5) + var(--safe-bottom));
}

@media (min-width: 720px) {
  .sheet {
    border-radius: var(--radius-lg);
  }
}

@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.sheet__header h2 {
  font-size: 1.1rem;
  color: var(--ctw-green-800);
}

.menu-list {
  display: flex;
  flex-direction: column;
}

.menu-list button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: none;
  border: none;
  padding: 14px 4px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ctw-ink-900);
  text-align: left;
  border-bottom: 1px solid var(--ctw-beige-300);
}

.menu-list button:last-child {
  border-bottom: none;
}

.menu-list button svg {
  width: 20px;
  height: 20px;
  color: var(--ctw-green-700);
  flex-shrink: 0;
}

.menu-list button.danger {
  color: var(--ctw-danger);
}

.menu-list button.danger svg {
  color: var(--ctw-danger);
}

/* ---------- Misc ---------- */

.center-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--ctw-ink-500);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--ctw-beige-400);
  border-top-color: var(--ctw-green-700);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.text-muted {
  color: var(--ctw-ink-500);
}

.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }

.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.form-actions .btn {
  flex: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--ctw-beige-300);
  color: var(--ctw-green-800);
  font-size: 0.72rem;
  font-weight: 700;
  max-width: 100%;
}

.badge svg {
  width: 14px;
  height: 14px;
}

.badge--superuser {
  background: var(--ctw-green-700);
  color: var(--ctw-beige-100);
}

.divider {
  height: 1px;
  background: var(--ctw-beige-400);
  margin: var(--space-5) 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
