:root {
  color-scheme: light;
  --bg: #f7f3ec;
  --panel: #fffaf3;
  --text: #1e293b;
  --muted: #6b7280;
  --line: #eadfce;
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --accent: #f97316;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --soft: #f1e8ff;
  --shadow: 0 22px 70px rgba(88, 63, 34, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.18), transparent 26rem),
    radial-gradient(circle at bottom right, rgba(249, 115, 22, 0.16), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.is-busy {
  cursor: wait !important;
}

.busy-message,
.sync-hint {
  min-height: 20px;
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.panel,
.swipe-card {
  background: rgba(255, 250, 243, 0.94);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 500px);
  padding: 36px;
}

.auth-card h1,
.topbar h1 {
  margin: 0;
  letter-spacing: -0.06em;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 15px;
  background: white;
  color: var(--text);
}

textarea {
  min-height: 320px;
  margin-top: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  resize: vertical;
}

.auth-actions,
.user-panel,
.profile-actions,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-message {
  min-height: 22px;
  color: var(--danger);
  margin: 0;
}

.button,
.tab,
.nav-item,
.link-button,
a.button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: 0.18s ease;
}

.button {
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 900;
}

.button.primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.button.primary:hover {
  filter: brightness(0.95);
}

.button.secondary {
  color: var(--primary);
  background: var(--soft);
}

.button.ghost {
  color: var(--primary);
  background: white;
  border: 1px solid var(--line);
}

.button.danger {
  color: white;
  background: var(--danger);
}

.link-button {
  margin-top: 18px;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 900;
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 30px) 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

main {
  max-width: 1180px;
  margin: 0 auto 112px;
  padding: 0 clamp(18px, 4vw, 30px);
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr) minmax(220px, 320px);
  gap: 18px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted,
.label {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 14px;
  border-radius: 999px;
  background: #f2eadf;
  color: #475569;
  font-weight: 800;
}

.tab.active {
  color: white;
  background: var(--primary);
}

.pill,
.tag {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 950;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.swipe-layout {
  display: grid;
  grid-template-columns: 150px minmax(280px, 540px) 150px;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
  position: relative;
}

.swipe-card {
  min-height: 450px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 3;
  touch-action: none;
  user-select: none;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  will-change: transform;
}

.swipe-card.dragging {
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.swipe-card.is-advancing {
  pointer-events: none;
}

.swipe-card.is-advancing::after,
.is-busy::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.swipe-card.is-advancing::after {
  position: absolute;
  top: 22px;
  right: 22px;
  color: var(--primary);
}

.swipe-card.swipe-known {
  border-color: rgba(22, 163, 74, 0.55);
  box-shadow: 0 24px 76px rgba(22, 163, 74, 0.18);
}

.swipe-card.swipe-unknown {
  border-color: rgba(217, 119, 6, 0.55);
  box-shadow: 0 24px 76px rgba(217, 119, 6, 0.18);
}

.swipe-card h3 {
  margin: 24px 0 10px;
  font-size: clamp(42px, 8vw, 76px);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.word-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--primary);
  font-weight: 900;
}

.word-meta span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff3e7;
}

.meaning {
  font-size: 22px;
  color: var(--muted);
}

.example {
  margin-top: 18px;
  padding-left: 14px;
  border-left: 4px solid var(--accent);
  font-size: 18px;
}

.card-status {
  margin-top: 22px;
  color: var(--muted);
  font-weight: 900;
}

.card-status.known {
  color: var(--success);
}

.card-status.unknown {
  color: var(--warning);
}

.swipe-side {
  min-height: 170px;
  border: 2px dashed var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-weight: 950;
  position: relative;
  z-index: 1;
}

.swipe-layout.dragging .swipe-side {
  pointer-events: none;
}

.swipe-side.left:hover {
  border-color: var(--warning);
  color: var(--warning);
}

.swipe-side.right:hover {
  border-color: var(--success);
  color: var(--success);
}

.swipe-hint {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 20px;
  color: var(--muted);
}

.sync-hint.synced {
  color: var(--success);
}

.sync-hint.syncing {
  color: var(--primary);
}

.sync-hint.local {
  color: var(--muted);
}

.phrase-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.phrase {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: white;
}

.phrase strong {
  display: block;
  margin: 14px 0 8px;
  font-size: 18px;
}

.profile-grid,
.admin-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin: 20px 0;
}

.stat {
  display: block;
  font-size: 42px;
  font-weight: 950;
  letter-spacing: -0.06em;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 6px;
  margin-top: 18px;
}

.day {
  aspect-ratio: 1;
  border-radius: 5px;
  background: #e5e7eb;
}

.day.level-1 {
  background: #c4b5fd;
}

.day.level-2 {
  background: #8b5cf6;
}

.day.level-3 {
  background: #5b21b6;
}

.toggle-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.toggle-row input {
  width: auto;
}

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.user-row span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  width: min(94vw, 680px);
  padding: 8px;
  background: rgba(255, 250, 243, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.nav-item {
  flex: 1;
  padding: 13px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 950;
}

.nav-item.active {
  color: white;
  background: var(--primary);
}

@media (max-width: 900px) {
  .topbar,
  .controls,
  .profile-grid,
  .admin-grid,
  .phrase-list {
    grid-template-columns: 1fr;
  }

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

  .topbar,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .swipe-layout {
    grid-template-columns: 1fr;
  }

  .swipe-side {
    min-height: 56px;
  }

  .swipe-card {
    min-height: 380px;
  }
}
