/* flashcards.css */

.study-page {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 46%, #ffffff 100%);
}

.study-hero {
  width: min(100%, 1320px);
  min-height: 228px;
  margin-bottom: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at 86% 18%, rgba(15, 76, 129, 0.1), transparent 34%),
    #ffffff;
  padding: 30px 34px;
  align-items: center;
  overflow: hidden;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.055);
}

.study-hero > div:first-child {
  max-width: 640px;
  position: relative;
  z-index: 1;
}

.study-hero h1 {
  max-width: 560px;
  font-size: clamp(32px, 4vw, 50px);
  letter-spacing: -0.035em;
}

.study-hero p:not(.study-eyebrow) {
  max-width: 610px;
  color: rgba(11, 15, 25, 0.62);
  font-size: 15px;
}

.flashcards-hero-media {
  flex: 0 0 330px;
  height: 194px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.flashcards-hero-media img {
  width: min(330px, 100%);
  max-height: 230px;
  object-fit: contain;
  filter: drop-shadow(0 22px 28px rgba(15, 23, 42, 0.14));
}

.flashcards-layout {
  width: min(100%, 1320px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

@media (min-width: 1200px) {
  .study-page:has(.flashcards-layout) {
    --study-suite-max: 1320px;
    padding-left: clamp(24px, 2.25vw, 36px);
    padding-right: clamp(24px, 2.25vw, 36px);
  }

  .study-page:has(.flashcards-layout) .study-hero,
  .study-page:has(.flashcards-layout) .flashcards-layout {
    width: min(100%, var(--study-suite-max));
    max-width: var(--study-suite-max);
    margin-left: auto;
    margin-right: auto;
  }

  .study-page:has(.flashcards-layout) .flashcards-layout .tool-panel {
    max-width: none;
  }
}

.flashcards-layout.is-empty .deck-stage {
  display: none;
}

.study-panel {
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.055);
}

.tool-panel {
  padding: 20px;
}

.tool-panel h2 {
  margin: 0 0 14px;
  color: #0b0f19;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.study-quick-start {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: #f8fbff;
}

.study-quick-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.study-quick-head span {
  color: #0b0f19;
  font-size: 13px;
  font-weight: 650;
}

.study-quick-head small {
  min-width: 0;
  color: rgba(11, 15, 25, 0.54);
  font-size: 11px;
  font-weight: 500;
  text-align: right;
}

.study-preset-group + .study-preset-group {
  margin-top: 14px;
}

.study-preset-group p {
  margin: 0 0 7px;
  color: rgba(11, 15, 25, 0.48);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.study-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.study-preset-btn {
  min-width: 0;
  min-height: 54px;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 16px;
  background: #ffffff;
  color: #111827;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.025);
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.study-preset-btn:hover {
  border-color: rgba(15, 76, 129, 0.26);
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.study-preset-btn:focus-visible {
  outline: 3px solid rgba(15, 76, 129, 0.22);
  outline-offset: 2px;
}

.study-preset-btn span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
}

.study-preset-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(15, 76, 129, 0.1);
  color: #0f4c81;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 750;
}

.pro-lock-preview {
  max-width: 520px;
  margin: 16px auto 0;
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}

.pro-lock-preview span {
  min-height: 30px;
  border: 1px solid rgba(15, 76, 129, 0.14);
  border-radius: 999px;
  background: rgba(15, 76, 129, 0.06);
  color: #0f4c81;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 620;
  line-height: 1;
}

.study-field {
  margin-top: 14px;
}

.study-field label {
  display: block;
  margin-bottom: 7px;
  color: rgba(11, 15, 25, 0.58);
  font-size: 12px;
  font-weight: 620;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.study-input,
.study-select,
.study-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  background-color: #fbfdff;
  color: #0b0f19;
  outline: none;
  font-size: 15px;
  font-weight: 400;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.study-input::placeholder,
.study-textarea::placeholder {
  color: rgba(11, 15, 25, 0.44);
  font-weight: 400;
}

.study-input,
.study-select {
  height: 44px;
  padding: 0 13px;
}

.study-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10L12 15L17 10' stroke='%230f4c81' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 13px center;
  background-repeat: no-repeat;
  background-size: 18px;
  cursor: pointer;
  padding-right: 42px;
  text-overflow: ellipsis;
}

.study-select.is-enhanced {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.study-custom-select {
  position: relative;
}

.study-custom-select-btn {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: #ffffff;
  color: #0b0f19;
  padding: 0 40px 0 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  text-align: left;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
}

.study-custom-select-btn::after {
  content: "";
  position: absolute;
  right: 13px;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10L12 15L17 10' stroke='%230f4c81' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 18px 18px no-repeat;
  transition: transform 0.16s ease;
}

.study-custom-select.is-open .study-custom-select-btn::after {
  transform: rotate(180deg);
}

.study-custom-select-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-custom-select-btn:focus-visible {
  border-color: rgba(15, 23, 42, 0.28);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
  outline: none;
}

.study-custom-select-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  box-shadow:
    0 8px 22px rgba(15, 23, 42, 0.08),
    0 1px 2px rgba(15, 23, 42, 0.04);
}

.study-custom-select.is-drop-up .study-custom-select-menu {
  top: auto;
  bottom: calc(100% + 5px);
}

.study-custom-select-menu[hidden] {
  display: none !important;
}

.study-custom-option {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(11, 15, 25, 0.82);
  padding: 8px 9px;
  display: flex;
  align-items: flex-start;
  overflow: hidden;
  text-align: left;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
}

.study-custom-option span {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.study-custom-option:hover,
.study-custom-option:focus-visible {
  background: rgba(15, 23, 42, 0.045);
  color: #0b0f19;
  outline: none;
}

.study-custom-option.is-selected {
  background: rgba(15, 23, 42, 0.065);
  color: #0b0f19;
}

.study-textarea {
  min-height: 158px;
  padding: 13px;
  resize: none;
  line-height: 1.45;
}

.study-input:focus,
.study-select:focus,
.study-textarea:focus {
  border-color: rgba(15, 76, 129, 0.28);
  background-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.04);
}

.study-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 12px;
}

.tool-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.tool-actions .study-primary-btn,
.tool-actions .study-secondary-btn {
  flex: 1;
  min-width: 0;
}

.tool-actions .study-primary-btn {
  min-height: 46px;
  border-radius: 14px;
  background: #0b63ce;
  border-color: #0b63ce;
  box-shadow: 0 12px 24px rgba(11, 99, 206, 0.18);
}

.tool-actions .study-primary-btn:hover {
  background: #0959b9;
  border-color: #0959b9;
}

.flashcards-layout .tool-panel {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  border-color: rgba(15, 23, 42, 0.1);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.07);
}

.flashcards-layout .tool-panel h2 {
  color: #07111f;
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.flashcards-layout .study-quick-start {
  padding: 14px;
  border-color: rgba(15, 23, 42, 0.11);
  border-radius: 15px;
  background: transparent;
  box-shadow: none;
}

.flashcards-layout .study-quick-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.flashcards-layout .study-quick-head span {
  color: #07111f;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.flashcards-layout .study-quick-head small {
  color: rgba(11, 15, 25, 0.56);
  font-size: 12px;
  font-weight: 560;
}

.flashcards-layout .study-preset-group {
  min-width: 0;
}

.flashcards-layout .study-preset-group p {
  margin-bottom: 10px;
  color: rgba(11, 15, 25, 0.54);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.flashcards-layout .study-preset-grid {
  gap: 9px 10px;
}

.flashcards-layout .study-preset-btn {
  position: relative;
  min-height: 72px;
  border-color: rgba(15, 23, 42, 0.11);
  border-radius: 12px;
  background: #ffffff;
  padding: 14px 18px 13px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 5px;
  align-content: start;
  align-items: start;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.035),
    0 8px 22px rgba(15, 23, 42, 0.035);
}

.flashcards-layout .study-preset-btn::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #0b63ce;
  border-radius: 12px 0 0 12px;
}

.flashcards-layout .study-preset-btn::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(11, 99, 206, 0.12);
  border-radius: 999px;
  background: #eff6ff
    url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%230b63ce' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M8 12h8'/%3E%3Cpath d='m12 16 4-4-4-4'/%3E%3C/svg%3E")
    center / 18px 18px no-repeat;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.flashcards-layout
  .study-preset-group
  + .study-preset-group
  .study-preset-btn::before {
  background: #dcecff;
}

.flashcards-layout .study-preset-btn:hover {
  border-color: rgba(11, 99, 206, 0.28);
  background: #fbfdff;
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.04),
    0 12px 26px rgba(15, 23, 42, 0.06);
}

.flashcards-layout .study-preset-btn:active {
  transform: translateY(0);
}

.flashcards-layout .study-preset-icon {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  width: auto;
  height: auto;
  max-width: calc(100% - 58px);
  min-height: 0;
  border-radius: 999px;
  background: rgba(15, 76, 129, 0.07);
  color: #0f4c81;
  padding: 3px 7px;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
}

.flashcards-layout
  .study-preset-group
  + .study-preset-group
  .study-preset-icon {
  background: rgba(15, 76, 129, 0.07);
  color: #0f4c81;
}

.flashcards-layout .study-preset-copy {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  padding-right: 42px;
  display: grid;
  gap: 2px;
}

.flashcards-layout .study-preset-title {
  color: #07111f;
  font-size: 14px;
  font-weight: 760;
  line-height: 1.16;
  letter-spacing: -0.01em;
  overflow-wrap: normal;
}

.flashcards-layout .study-preset-desc {
  color: rgba(11, 15, 25, 0.62);
  font-size: 12px;
  font-weight: 520;
  line-height: 1.22;
}

.flashcards-layout .study-preset-btn .study-preset-arrow {
  display: none !important;
}

.flashcard-create-form {
  min-width: 0;
  display: grid;
  gap: 14px 16px;
  --flashcard-label-offset: 22px;
}

.flashcard-control {
  position: relative;
  min-width: 0;
}

.flashcard-field-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  z-index: 2;
  width: 20px;
  height: 20px;
  color: rgba(15, 23, 42, 0.52);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.flashcard-field-icon svg,
.flashcard-field-icon [data-lucide] {
  display: block;
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}

.flashcard-control:not(.flashcard-control-textarea) .flashcard-field-icon {
  transform: translateY(-50%);
}

.flashcard-control-textarea .flashcard-field-icon {
  top: 13px;
}

.flashcard-control .study-custom-select {
  min-width: 0;
}

.flashcard-create-form .study-field {
  min-width: 0;
  margin-top: 0;
}

.flashcard-create-form .study-field label {
  margin-bottom: 7px;
  color: #07111f;
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0;
  text-transform: none;
}

.flashcard-create-form .study-input,
.flashcard-create-form .study-select,
.flashcard-create-form .study-textarea,
.flashcard-create-form .study-custom-select-btn {
  min-height: 48px;
  border-color: rgba(15, 23, 42, 0.13);
  border-radius: 13px;
  background-color: #ffffff;
  color: #07111f;
  font-size: 13.5px;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

.flashcard-create-form .study-input,
.flashcard-create-form .study-select,
.flashcard-create-form .study-custom-select-btn {
  height: 48px;
  padding-left: 46px;
}

.flashcard-create-form .study-textarea {
  min-height: 126px;
  padding: 14px 14px 14px 46px;
}

.flashcard-create-form .study-input:focus,
.flashcard-create-form .study-select:focus,
.flashcard-create-form .study-textarea:focus,
.flashcard-create-form .study-custom-select-btn:focus-visible {
  border-color: rgba(15, 23, 42, 0.28);
  box-shadow:
    0 0 0 3px rgba(15, 23, 42, 0.05),
    inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

.flashcard-control:focus-within .flashcard-field-icon {
  color: #0b63ce;
}

.flashcard-create-form .study-inline {
  grid-template-columns: minmax(0, 1fr) minmax(112px, 144px);
}

.flashcard-create-form .tool-actions {
  margin-top: 0;
}

.flashcard-create-form .tool-actions .study-primary-btn {
  min-height: 46px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 720;
  box-shadow: 0 6px 14px rgba(11, 99, 206, 0.14);
}

.flashcard-create-form .tool-actions .study-primary-btn svg,
.flashcard-create-form .tool-actions .study-primary-btn [data-lucide] {
  display: block;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  stroke-width: 1.9;
}

.flashcard-create-form .tool-actions .study-primary-btn:disabled {
  opacity: 0.78;
  cursor: wait;
}

.flashcard-create-form .tool-actions .study-primary-btn.is-loading svg,
.flashcard-create-form
  .tool-actions
  .study-primary-btn.is-loading
  [data-lucide] {
  animation: studyGenerateLive 0.9s ease-in-out infinite;
}

@keyframes studyGenerateLive {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }

  50% {
    transform: rotate(-10deg) scale(1.08);
  }
}

.deck-stage {
  scroll-margin-top: 72px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.deck-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 18px;
  align-items: center;
}

.deck-title {
  min-width: 0;
}

.deck-eyebrow {
  margin: 0 0 8px;
  color: #0b63ce;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.deck-title h2 {
  margin: 0;
  color: #0b0f19;
  font-size: clamp(23px, 2.6vw, 30px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.deck-title p:not(.deck-eyebrow) {
  margin: 6px 0 0;
  color: rgba(11, 15, 25, 0.55);
  font-size: 14px;
  font-weight: 500;
}

.deck-progress {
  display: grid;
  align-content: center;
  gap: 0;
  justify-items: end;
}

.flashcard-counter {
  display: none;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(11, 99, 206, 0.2);
  background: rgba(11, 99, 206, 0.07);
  color: #0b63ce;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.session-progress {
  width: 100%;
  max-width: 320px;
}

.session-progress-row {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: rgba(11, 15, 25, 0.58);
  font-size: 12px;
  font-weight: 650;
}

.session-progress-row span:last-child {
  color: #0b63ce;
}

.session-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.1);
  overflow: hidden;
}

.session-progress-track span {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #0b63ce;
  display: block;
  transition: width 180ms ease;
}

.flashcard-card {
  width: 100%;
  min-height: 340px;
  height: clamp(340px, 36vh, 420px);
  position: relative;
  display: block;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  text-align: center;
  user-select: none;
  touch-action: manipulation;
  perspective: 1400px;
  transform: translate3d(0, 0, 0);
  transition:
    transform 220ms ease,
    opacity 220ms ease;
  will-change: transform;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.flashcard-card:hover {
  border-color: rgba(15, 76, 129, 0.24);
}

.flashcard-card.is-empty {
  cursor: default;
}

.flashcard-card.is-empty .flashcard-label,
.flashcard-card.is-empty .flashcard-hint {
  display: none;
}

.flashcard-card.is-empty .flashcard-text {
  color: rgba(11, 15, 25, 0.52);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.flashcard-card.is-flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-card.is-dragging {
  transition: none;
}

.flashcard-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition:
    transform 260ms ease,
    opacity 220ms ease;
  will-change: transform;
}

.flashcard-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 34px 36px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-y: visible;
  overscroll-behavior: auto;
}

.flashcard-back {
  transform: rotateY(180deg);
}

.flashcard-swipe-cue {
  position: absolute;
  top: 18px;
  z-index: 2;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(15, 76, 129, 0.1);
  color: #0f4c81;
  font-size: 12px;
  font-weight: 620;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.flashcard-swipe-cue.is-left {
  left: 18px;
}

.flashcard-swipe-cue.is-right {
  right: 18px;
}

.flashcard-card.is-swipe-prev .flashcard-swipe-cue.is-left,
.flashcard-card.is-swipe-next .flashcard-swipe-cue.is-right {
  opacity: 1;
}

.flashcard-label {
  margin-bottom: 12px;
  color: #0b63ce;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.flashcard-text {
  max-width: 720px;
  margin: 0 auto;
  color: #0b0f19;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.22;
  letter-spacing: -0.025em;
  font-weight: 700;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition:
    font-size 160ms ease,
    line-height 160ms ease;
}

.flashcard-hint {
  margin-top: 18px;
  color: rgba(11, 15, 25, 0.44);
  font-size: 13px;
  font-weight: 500;
}

.flashcard-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(132px, 166px);
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: #ffffff;
}

.flashcard-strip::-webkit-scrollbar {
  display: none;
}

.flashcard-strip-card {
  min-width: 0;
  min-height: 58px;
  scroll-snap-align: start;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #fbfdff;
  color: rgba(11, 15, 25, 0.64);
  padding: 9px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 560;
  line-height: 1.25;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.flashcard-strip-card.is-active {
  border-color: rgba(11, 99, 206, 0.45);
  background: rgba(11, 99, 206, 0.08);
  color: #0b63ce;
  box-shadow: 0 8px 18px rgba(11, 99, 206, 0.08);
  transform: translateY(-1px);
}

.flashcard-strip-card.is-known {
  border-color: rgba(22, 163, 74, 0.3);
  background: rgba(22, 163, 74, 0.07);
}

.flashcard-strip-card.is-review {
  border-color: rgba(217, 119, 6, 0.3);
  background: rgba(217, 119, 6, 0.07);
}

.flashcard-strip-card.is-active.is-known {
  color: #15803d;
}

.flashcard-strip-card.is-active.is-review {
  color: #b45309;
}

.flashcard-strip-number {
  display: block;
  margin-bottom: 4px;
  color: rgba(11, 15, 25, 0.42);
  font-size: 11px;
  font-weight: 600;
}

.flashcard-strip-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.flashcard-card.is-step-next {
  animation: flashcardSlideNext 300ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

.flashcard-card.is-step-prev {
  animation: flashcardSlidePrev 300ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

@keyframes flashcardSlideNext {
  from {
    opacity: 0;
    transform: translate3d(34px, 8px, 0) rotateZ(2.4deg) scale(0.985);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
  }

  58% {
    opacity: 1;
    transform: translate3d(-4px, 0, 0) rotateZ(-0.35deg) scale(1.002);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotateZ(0deg) scale(1);
  }
}

@keyframes flashcardSlidePrev {
  from {
    opacity: 0;
    transform: translate3d(-34px, 8px, 0) rotateZ(-2.4deg) scale(0.985);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
  }

  58% {
    opacity: 1;
    transform: translate3d(4px, 0, 0) rotateZ(0.35deg) scale(1.002);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotateZ(0deg) scale(1);
  }
}

.flashcard-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.study-mini-btn {
  min-width: 0;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #ffffff;
  color: #111827;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.025);
}

.study-mini-btn:hover {
  border-color: rgba(15, 76, 129, 0.24);
}

.study-mini-btn#revealCardBtn,
.study-mini-btn#nextCardBtn {
  color: #0b63ce;
}

.study-mini-btn#reviewCardBtn {
  border-color: rgba(217, 119, 6, 0.18);
  background: rgba(217, 119, 6, 0.04);
  color: #b45309;
}

.study-mini-btn.danger {
  border-color: rgba(220, 38, 38, 0.18);
  background: rgba(220, 38, 38, 0.035);
  color: #dc2626;
}

.study-mini-btn.success {
  border-color: rgba(22, 163, 74, 0.2);
  background: rgba(22, 163, 74, 0.045);
  color: #15803d;
}

.study-mini-btn.is-active {
  border-color: rgba(15, 76, 129, 0.28);
  background: rgba(15, 76, 129, 0.07);
  color: #0f4c81;
}

.study-mini-btn.success.is-active {
  border-color: rgba(22, 163, 74, 0.32);
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
}

.deck-stage.is-complete .flashcard-strip,
.deck-stage.is-complete #prevCardBtn,
.deck-stage.is-complete #nextCardBtn,
.deck-stage.is-complete #knowCardBtn {
  display: none;
}

.deck-stage.is-complete .flashcard-controls {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px;
  margin-inline: auto;
}

.deck-stage.is-complete .flashcard-text {
  font-size: clamp(24px, 2.3vw, 32px);
  line-height: 1.2;
}

@media (min-width: 1025px) {
  .study-page:has(.flashcards-layout:not(.is-empty)) {
    padding-top: 24px;
    padding-bottom: 28px;
  }

  .tool-panel {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px 18px;
    padding: 22px;
  }

  .tool-panel h2,
  .study-quick-start,
  .flashcard-create-form {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .study-quick-start {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .study-quick-head {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .study-preset-group + .study-preset-group {
    margin-top: 0;
  }

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

  .flashcard-create-form {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
  }

  .flashcard-chat-field {
    grid-column: span 4;
  }

  .flashcard-title-count {
    grid-column: span 8;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 160px);
  }

  .flashcard-notes-field {
    grid-column: 1 / 9;
    grid-row: 2 / 4;
  }

  .flashcard-notes-field .study-textarea {
    min-height: 130px;
  }

  .flashcard-generate-actions,
  .flashcard-saved-field {
    grid-column: 9 / 13;
  }

  .flashcard-generate-actions {
    grid-row: 2;
    align-self: start;
    padding-top: var(--flashcard-label-offset);
  }

  .flashcard-saved-field {
    grid-row: 3;
  }

  .deck-stage {
    padding: 16px;
    gap: 10px;
  }

  .deck-top {
    gap: 14px;
  }

  .deck-eyebrow {
    margin-bottom: 6px;
  }

  .deck-title h2 {
    font-size: clamp(22px, 2.2vw, 28px);
  }

  .deck-title p:not(.deck-eyebrow) {
    margin-top: 4px;
    font-size: 13px;
  }

  .deck-progress {
    gap: 0;
  }

  .session-progress-row {
    margin-bottom: 6px;
  }

  .flashcard-card {
    min-height: 320px;
    height: clamp(320px, 34vh, 380px);
  }

  .flashcard-face {
    padding: 26px 30px;
  }

  .flashcard-label {
    margin-bottom: 10px;
  }

  .flashcard-text {
    font-size: clamp(22px, 2.1vw, 30px);
    line-height: 1.22;
  }

  .flashcard-hint {
    margin-top: 14px;
  }

  .flashcard-strip {
    grid-auto-columns: minmax(126px, 158px);
    gap: 8px;
    padding: 8px;
    border-radius: 16px;
  }

  .flashcard-strip-card {
    min-height: 50px;
    padding: 7px 9px;
  }

  .flashcard-controls {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
  }

  .study-mini-btn {
    min-height: 42px;
    padding: 9px 12px;
  }
}

@media (max-width: 1024px) {
  .study-hero {
    min-height: 0;
    padding: 24px;
  }

  .study-page.is-study-mode .study-hero,
  .study-page.is-create-mode .study-hero {
    display: none;
  }

  .flashcards-hero-media {
    flex-basis: 220px;
    height: 150px;
  }

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

  .deck-stage {
    order: 2;
  }

  .flashcards-layout .tool-panel {
    order: 1;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
    padding: 20px;
  }

  .flashcards-layout.is-study-mode .deck-stage {
    order: 1;
  }

  .flashcards-layout.is-study-mode .tool-panel {
    order: 2;
  }

  .flashcards-layout.is-create-mode .tool-panel {
    order: 1;
  }

  .flashcards-layout.is-create-mode .deck-stage {
    order: 2;
  }

  .flashcards-layout.is-create-mode .flashcard-create-form {
    order: 1;
  }

  .flashcards-layout.is-create-mode .study-quick-start {
    order: 2;
  }

  .flashcards-layout .tool-panel h2,
  .flashcards-layout .study-quick-start,
  .flashcards-layout .flashcard-create-form {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .flashcards-layout .study-quick-start {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 14px;
  }

  .flashcards-layout .study-quick-head {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .flashcards-layout .study-preset-group + .study-preset-group {
    margin-top: 0;
  }

  .flashcards-layout .study-preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flashcards-layout .flashcard-create-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flashcard-chat-field,
  .flashcard-generate-actions,
  .flashcard-saved-field {
    grid-column: span 1;
  }

  .flashcard-title-count,
  .flashcard-notes-field {
    grid-column: 1 / -1;
  }

  .flashcard-notes-field .study-textarea {
    min-height: 120px;
  }

  .flashcards-layout.is-empty .tool-panel {
    order: 1;
  }

  .flashcards-layout.is-empty .deck-stage {
    order: 2;
  }

  .flashcard-card {
    height: 390px;
  }
}

@media (max-width: 900px) {
  .flashcards-layout .study-quick-start {
    grid-template-columns: 1fr;
  }

  .flashcards-layout .study-preset-group + .study-preset-group {
    margin-top: 0;
  }
}

@media (max-width: 640px) {
  .study-hero {
    margin-bottom: 14px;
    padding: 20px;
    border-radius: 18px;
  }

  .study-hero h1 {
    font-size: clamp(28px, 10vw, 36px);
  }

  .study-hero p:not(.study-eyebrow) {
    font-size: 14px;
  }

  .flashcards-hero-media {
    display: none;
  }

  .flashcards-layout {
    gap: 12px;
  }

  .tool-panel,
  .deck-stage {
    border-radius: 16px;
    padding: 14px;
  }

  .tool-panel h2 {
    font-size: 16px;
  }

  .flashcards-layout .tool-panel {
    display: grid;
    grid-template-columns: 1fr;
    padding: 14px;
    border-radius: 18px;
  }

  .flashcards-layout .study-quick-start {
    display: grid;
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 10px;
    border-radius: 16px;
  }

  .flashcards-layout .study-quick-head {
    display: block;
    padding-bottom: 10px;
  }

  .flashcards-layout .study-quick-head small {
    display: block;
    margin-top: 3px;
    text-align: left;
  }

  .flashcards-layout .study-preset-grid {
    grid-template-columns: 1fr;
  }

  .flashcards-layout .study-preset-btn {
    min-height: 68px;
    padding: 12px 14px 12px 16px;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .flashcards-layout .study-preset-btn::after {
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background-size: 16px 16px;
  }

  .flashcards-layout .study-preset-icon {
    padding: 3px 6px;
    font-size: 9.5px;
  }

  .flashcards-layout .study-preset-copy {
    padding-right: 34px;
  }

  .flashcards-layout .study-preset-title {
    font-size: 13.5px;
    line-height: 1.15;
  }

  .flashcards-layout .study-preset-desc {
    font-size: 11.5px;
    line-height: 1.2;
  }

  .flashcards-layout .flashcard-create-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .flashcards-layout .flashcard-create-form > .study-field,
  .flashcards-layout .flashcard-create-form > .study-inline,
  .flashcards-layout .flashcard-generate-actions,
  .flashcards-layout .flashcard-saved-field {
    grid-column: 1 / -1;
  }

  .pro-lock-preview {
    margin-top: 14px;
    gap: 6px;
  }

  .pro-lock-preview span {
    min-height: 28px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .study-inline {
    grid-template-columns: 1fr;
  }

  .flashcard-create-form .study-textarea {
    min-height: 104px;
  }

  .deck-stage {
    gap: 10px;
    padding-bottom: calc(14px + var(--safe-bottom));
  }

  .deck-top {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .deck-progress {
    width: 100%;
    justify-items: start;
    gap: 0;
  }

  .session-progress {
    max-width: none;
  }

  .deck-title h2 {
    font-size: 19px;
    letter-spacing: -0.025em;
  }

  .deck-title p:not(.deck-eyebrow) {
    font-size: 12px;
  }

  .flashcard-counter {
    padding: 6px 9px;
    font-size: 12px;
  }

  .flashcard-card {
    height: 300px;
    height: clamp(280px, 42svh, 350px);
    border-radius: 16px;
    touch-action: manipulation;
  }

  .flashcard-face {
    padding: 20px 16px;
    overflow-y: visible;
    overscroll-behavior: auto;
  }

  .flashcard-text {
    font-size: clamp(18px, 5.1vw, 22px);
    line-height: 1.24;
    letter-spacing: -0.02em;
  }

  .flashcard-text.is-long {
    font-size: clamp(16px, 4.4vw, 19px);
    line-height: 1.25;
    letter-spacing: -0.018em;
  }

  .flashcard-text.is-very-long {
    font-size: clamp(14.5px, 3.9vw, 17px);
    line-height: 1.27;
    letter-spacing: -0.012em;
    font-weight: 680;
  }

  .flashcard-hint {
    margin-top: 14px;
    font-size: 12px;
  }

  .flashcard-strip {
    grid-auto-columns: minmax(116px, 40vw);
    gap: 8px;
    padding: 8px;
  }

  .flashcard-strip-card {
    min-height: 52px;
    padding: 8px 9px;
  }

  .flashcard-controls {
    position: sticky;
    bottom: calc(8px + var(--safe-bottom));
    z-index: 12;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 -6px -6px;
    padding: 8px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(14px);
  }

  .study-mini-btn {
    min-height: 44px;
    padding: 9px 8px;
    font-size: 11.5px;
    white-space: normal;
  }

  #revealCardBtn {
    order: 1;
  }

  #reviewCardBtn {
    order: 2;
  }

  #knowCardBtn {
    order: 3;
  }

  #prevCardBtn {
    order: 4;
  }

  #nextCardBtn {
    order: 5;
  }

  #deleteDeckBtn {
    order: 6;
  }

  .study-mini-btn.danger {
    grid-column: auto;
  }
}

@media (max-width: 360px) {
  .flashcards-layout .study-preset-grid {
    grid-template-columns: 1fr;
  }

  .flashcards-layout .study-preset-btn {
    min-height: 70px;
    padding: 11px 12px 11px 14px;
  }

  .flashcards-layout .study-preset-title {
    font-size: 13.5px;
  }

  .flashcards-layout .study-preset-desc {
    font-size: 11.5px;
  }
}

@media (max-width: 380px) {
  .tool-panel,
  .deck-stage {
    padding: 12px;
  }

  .flashcards-layout .tool-panel {
    padding: 12px;
  }

  .flashcard-card {
    height: 292px;
    height: clamp(260px, 40svh, 320px);
  }

  .flashcard-face {
    padding: 18px 14px;
  }

  .flashcard-text {
    font-size: clamp(17px, 4.9vw, 20px);
  }

  .flashcard-label,
  .flashcard-hint {
    font-size: 11px;
  }

  .flashcard-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .study-mini-btn.danger {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-card,
  .flashcard-inner,
  .flashcard-swipe-cue,
  .flashcard-strip-card,
  .flashcard-create-form .tool-actions .study-primary-btn.is-loading svg,
  .flashcard-create-form
    .tool-actions
    .study-primary-btn.is-loading
    [data-lucide] {
    animation: none;
    transition: opacity 1ms linear;
  }

  .flashcard-card.is-step-next,
  .flashcard-card.is-step-prev {
    animation: none;
  }

  .flashcard-inner,
  .flashcard-back,
  .flashcard-card.is-flipped .flashcard-inner {
    transform: none;
  }

  .flashcard-back {
    opacity: 0;
  }

  .flashcard-card.is-flipped .flashcard-front {
    opacity: 0;
  }

  .flashcard-card.is-flipped .flashcard-back {
    opacity: 1;
  }
}
