:root {
  --color-apple-black: #1d1d1f;
  --apple-gray-50: #f5f5f7;
  --radius-apple: 18px;
  --radius-button: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #ffffff;
  color: var(--color-apple-black);
  line-height: 1.5;
  overflow-x: hidden;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #f3f4f6;
}

.header-content {
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  cursor: pointer;
}

/* Buttons */
.apple-button-primary {
  background-color: var(--color-apple-black);
  color: white;
  border: none;
  border-radius: var(--radius-button);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.apple-button-primary:hover {
  background-color: #333336;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.apple-button-primary:active {
  transform: scale(0.96);
}

.apple-button-primary.compact {
  padding: 0.6rem 1.25rem;
}

.apple-button-primary.large {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
}

.apple-button-secondary {
  background-color: white;
  color: var(--color-apple-black);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-button);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.apple-button-secondary:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
}

.apple-button-secondary.large {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
}

.text-button {
  background: none;
  border: none;
  color: var(--color-apple-black);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: color 0.2s;
}

.text-button:hover {
  color: #666;
}

.back-link {
  background: none;
  border: none;
  color: #6b7280;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--color-apple-black);
}

/* Main Content */
.main-content {
  padding-top: 2rem;
  padding-bottom: 5rem;
}

.view {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Search */
.search-container {
  margin-bottom: 2.5rem;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

#search-input {
  width: 100%;
  background-color: white;
  border: 1px solid #f3f4f6;
  border-radius: 9999px;
  padding: 1rem 1.5rem 1rem 3rem;
  font-size: 1.125rem;
  outline: none;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

#search-input:focus {
  border-color: #e5e7eb;
  box-shadow: 0 0 0 4px rgba(29, 29, 31, 0.05);
}

/* Decks Grid */
.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.apple-card {
  background-color: white;
  border-radius: var(--radius-apple);
  border: 1px solid #f3f4f6;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.deck-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.deck-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.deck-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.deck-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.deck-desc {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.deck-footer {
  border-top: 1px solid #f9fafb;
  padding-top: 1.5rem;
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 500;
}

.no-decks-card {
  text-align: center;
  padding: 5rem 2rem;
}

.no-decks-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.no-decks-card p {
  color: #6b7280;
}

/* Editor */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.editor-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.editor-meta {
  margin-bottom: 2rem;
}

.input-group {
  margin-bottom: 1rem;
}

.input-group:last-child {
  margin-bottom: 0;
}

.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.375rem;
}

.input-group input, .input-group textarea {
  width: 100%;
  background-color: var(--apple-gray-50);
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  outline: none;
  transition: box-shadow 0.2s;
}

.input-group input:focus, .input-group textarea:focus {
  box-shadow: 0 0 0 2px rgba(29, 29, 31, 0.05);
}

.cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.editor-card-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-number {
  flex: none;
  width: 2rem;
  height: 2rem;
  background-color: var(--apple-gray-50);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #9ca3af;
}

.card-inputs {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .card-inputs {
    grid-template-columns: 1fr;
  }
}

.card-input-field label {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.card-input-field input {
  width: 100%;
  background-color: var(--apple-gray-50);
  border: none;
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.875rem;
  outline: none;
}

/* Study Session */
.study-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.study-info {
  flex-grow: 1;
}

.study-info h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.progress-bar-container {
  height: 0.25rem;
  background-color: #f3f4f6;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--color-apple-black);
  width: 0%;
  transition: width 0.3s ease;
}

.study-counter {
  font-size: 0.875rem;
  font-weight: 600;
  color: #9ca3af;
}

.study-card-container {
  perspective: 1000px;
  height: 400px;
  margin-bottom: 2rem;
}

.flashcard {
  width: 100%;
  height: 100%;
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

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

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.flashcard-front h2 {
  font-size: 2rem;
  font-weight: 700;
}

.flashcard-back {
  transform: rotateY(180deg);
  background-color: rgba(245, 245, 247, 0.5);
}

.flashcard-back p {
  font-size: 1.5rem;
  color: #4b5563;
}

.tap-hint {
  position: absolute;
  bottom: 2rem;
  font-size: 0.875rem;
  color: #9ca3af;
}

.study-controls {
  max-width: 400px;
  margin: 0 auto;
}

.answer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.answer-btn {
  padding: 1rem;
  border-radius: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.answer-btn.primary {
  background-color: var(--color-apple-black);
  color: white;
}

.answer-btn.primary:hover {
  background-color: #333336;
}

.answer-btn.secondary {
  background-color: #f3f4f6;
  color: var(--color-apple-black);
}

.answer-btn.secondary:hover {
  background-color: #e5e7eb;
}

/* Results */
.results-card {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
  padding: 3rem 2rem;
}

.check-icon {
  color: var(--color-apple-black);
  margin-bottom: 1.5rem;
}

.check-icon svg {
  width: 64px;
  height: 64px;
}

.results-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.results-card p {
  color: #6b7280;
  margin-bottom: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-item {
  background-color: var(--apple-gray-50);
  padding: 1rem;
  border-radius: 1rem;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  letter-spacing: 0.05em;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
