:root {
  --bg: #e5f5e8;
  --panel: #f2fbf4;
  --card: #ffffff;
  --muted: #3e7055;
  --text: #0f2a20;
  --accent: #28c76f;
  --accent-strong: #1ea45a;
  --warn: #d97706;
  --danger: #e23f3f;
  --stroke: #b7d6c3;
  --chip: #d1ead7;
  --font: 'Space Grotesk', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at 25% 20%, #f7fff8, #e5f5e8 48%, #d9efdf 100%);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
  color: var(--muted);
}

main {
  display: grid;
  gap: 16px;
  padding: 16px;
  grid-template-columns: 1fr;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(215, 239, 223, 0.95), rgba(229, 245, 232, 0.9));
  border-bottom: 1px solid #c8e0d1;
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
}

.brand .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #28c76f, #93e7b0);
  box-shadow: 0 0 12px rgba(40, 199, 111, 0.5);
}

.view-toggle {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
  flex: 0 0 auto;
}

.chip {
  border: 1px solid #aad6b7;
  background: var(--chip);
  color: #0f2a20;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip.active {
  background: #b9f2cd;
  border-color: #28c76f;
  box-shadow: 0 0 0 1px rgba(40, 199, 111, 0.25), 0 8px 24px rgba(22, 101, 52, 0.2);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(79, 121, 100, 0.15);
}

.student-header, .teacher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2e6145;
}

.progress-pill, .pill {
  background: rgba(40, 199, 111, 0.1);
  border: 1px solid rgba(40, 199, 111, 0.2);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 500;
  color: #0f2a20;
}

.student-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

select, input, textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #b7d6c3;
  background: #f7fff8;
  color: #0f2a20;
  font-family: var(--font);
  font-size: 16px;
}

textarea {
  min-height: 64px;
}

button {
  border: none;
  font-family: var(--font);
  font-size: 16px;
  cursor: pointer;
}

.primary {
  background: linear-gradient(135deg, #a7f3d0, #28c76f);
  color: #0c2f24;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 600;
  box-shadow: 0 12px 25px rgba(40, 199, 111, 0.25);
}

.ghost {
  background: rgba(15, 42, 32, 0.05);
  color: #0f2a20;
  border-radius: 14px;
  padding: 12px 18px;
  border: 1px solid rgba(15, 42, 32, 0.12);
}

.success {
  background: #28c76f;
  color: #0c2f24;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 600;
  min-width: 120px;
}

.danger {
  border-color: rgba(226, 63, 63, 0.35);
  color: #b42318;
}

.block {
  width: 100%;
}

.student-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  justify-content: center;
}

.progress-visual {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #b7d6c3;
  background: #ecf7ef;
}

.progress-bar .bar {
  height: 100%;
}

.bar.known {
  background: linear-gradient(90deg, #28c76f, #7ee0a8);
}

.bar.unknown {
  background: linear-gradient(90deg, #fce7c3, #f4b183);
}

.progress-text {
  font-weight: 600;
  color: #1f4934;
}

.card-shell {
  background: linear-gradient(135deg, #f3fff5, #e0f4e4);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid #b7d6c3;
  perspective: 1200px;
}

.card {
  background: var(--card);
  color: #0f2a20;
  border-radius: 18px;
  padding: 20px;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  border: 1px solid #dbeee2;
  box-shadow: 0 14px 36px rgba(51, 92, 70, 0.12);
  transform-style: preserve-3d;
  transition: box-shadow 0.4s ease;
  perspective: 1200px;
}

.card-face {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 600;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  transform: rotateY(0deg);
  transition: transform 0.5s ease;
}

.front {
  transform: rotateY(0deg);
}

.back {
  background: #d3e8d9;
  transform: rotateY(180deg);
}

.card.flipped .front {
  transform: rotateY(-180deg);
}

.card.flipped .back {
  transform: rotateY(0deg);
}

.card.flipped {
  box-shadow: 0 16px 36px rgba(20, 74, 46, 0.16);
}

.audio-btn {
  margin-top: 12px;
  width: 100%;
  background: rgba(40, 199, 111, 0.12);
  color: #1f7c47;
  border: 1px solid rgba(40, 199, 111, 0.35);
  padding: 12px;
  border-radius: 14px;
  font-weight: 600;
}

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

.audio-btn.playing,
.pill-btn.playing {
  animation: pulse 1s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(40, 199, 111, 0.4);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(40, 199, 111, 0.35);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(40, 199, 111, 0.1);
    transform: translateY(-1px);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(40, 199, 111, 0);
    transform: translateY(0);
  }
}

.teacher-view .card {
  margin-bottom: 12px;
}

.teacher-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - 120px);
}

.create-delete .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.teacher-view > .card:first-of-type {
  width: 100%;
}

.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.share-link {
  color: #0f2a20;
  font-weight: 600;
  word-break: break-all;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-row {
  border: 1px solid #dbeee2;
  border-radius: 14px;
  padding: 12px;
  background: #f9fffa;
  color: #0f2a20;
}

.row-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.row-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pill-btn {
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid #b7d6c3;
  background: #ecf7ef;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #0f2a20;
}

.tag {
  background: rgba(15, 42, 32, 0.08);
  border-radius: 10px;
  padding: 6px 10px;
  color: #0f2a20;
  font-weight: 600;
  font-size: 12px;
}

.pill-btn.strong {
  background: #e9f5ed;
  border-color: #b7d6c3;
}

.pill-btn.danger {
  border-color: rgba(226, 63, 63, 0.35);
  color: #b42318;
  background: #fce8e6;
}

.pill-btn.primary {
  background: linear-gradient(135deg, #a7f3d0, #28c76f);
  color: #0c2f24;
  border-color: rgba(40, 199, 111, 0.4);
  box-shadow: 0 8px 16px rgba(40, 199, 111, 0.2);
}

.row-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.right-tag {
  margin-left: auto;
}
.hidden {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #2fd17a;
  color: #0b281f;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(25, 84, 54, 0.25);
}

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

@media (min-width: 960px) {
  main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .student-actions {
    flex-direction: column;
  }

  .student-controls {
    flex-direction: column;
  }

  .row-top {
    flex-direction: column;
    align-items: stretch;
  }
}

.set-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 280px;
  flex-wrap: wrap;
}

.set-switcher select {
  min-width: 140px;
  flex: 0 1 auto;
}

.share-chip {
  padding: 10px 12px;
  border-radius: 12px;
  background: #ecf7ef;
  border: 1px solid #b7d6c3;
  font-weight: 600;
  color: #0f2a20;
  min-width: 140px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 160px;
}

.cards-panel {
  flex: 1;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
}

.cards-list {
  flex: 1;
  overflow: auto;
}
