@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&family=Playfair+Display:wght@500;600;700&display=swap");

:root {
  --ink: #1c1b1f;
  --sand: #f4f1ea;
  --gold: #c29f4b;
  --rose: #e7d4c0;
  --mist: #f8f7f4;
  --shadow: rgba(20, 15, 5, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 20%, #f9f1e1 0%, #f3eee6 38%, #ede6db 100%);
  min-height: 100vh;
}

.page {
  padding: 48px 6vw 64px;
}

.hero {
  max-width: 720px;
  margin-bottom: 48px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  margin-bottom: 12px;
  color: #6b5f4b;
}

.hero h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(2.4rem, 3vw, 3.6rem);
  margin: 0 0 16px;
}

.logo-button {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.logo-button:focus-visible {
  outline: 2px solid rgba(194, 159, 75, 0.6);
  outline-offset: 4px;
  border-radius: 6px;
}

.subhead {
  font-size: 1.05rem;
  color: #50483c;
}

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

.panel {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(18px);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 45px var(--shadow);
  border: 1px solid rgba(194, 159, 75, 0.18);
}

.panel h2 {
  font-family: "Playfair Display", serif;
  margin-top: 0;
  margin-bottom: 16px;
}

#auth-panel {
  max-width: 520px;
}

.auth-copy {
  margin-top: 0;
  color: #6b5f4b;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.auth-form input {
  padding: 12px 14px;
  border: 1px solid #d5c8b1;
  border-radius: 12px;
  font-size: 1rem;
  background: #fffdf8;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--ink);
}

.source-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  border: 1px solid transparent;
  background: var(--mist);
  color: #564a38;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--ink);
  color: var(--sand);
}

.source-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.source-content.hidden {
  display: none;
}

.file-drop {
  border: 1px dashed #b9aa92;
  padding: 22px;
  border-radius: 16px;
  text-align: center;
  background: #fffdf9;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-drop input {
  display: none;
}

.file-meta {
  font-size: 0.9rem;
  color: #6b5f4b;
}

.paste-row {
  display: flex;
  gap: 8px;
}

.paste-row[hidden] {
  display: none;
}

.paste-row input {
  flex: 1;
  border-radius: 14px;
  border: 1px solid #d5c8b1;
  padding: 12px 14px;
  font-size: 0.95rem;
  background: #fffdf8;
  cursor: pointer;
}

.hint {
  font-size: 0.85rem;
  color: #786a55;
  margin: 0;
}

.card-types {
  display: grid;
  gap: 10px;
}

.model-control {
  margin-top: 16px;
}

.model-control label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

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

.model-pill {
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 999px;
  padding: 10px 14px;
  background: #fffefc;
  cursor: pointer;
  font-weight: 600;
  color: #5b4f3e;
}

.model-pill.locked {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.model-pill.locked::after {
  content: "Pro";
  margin-left: 6px;
  font-size: 0.75rem;
  color: #8a7a65;
}

.pro-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(194, 159, 75, 0.18);
  color: #6b5f4b;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.model-pill.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--sand);
}

.level-control {
  margin-top: 16px;
}

.level-control label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

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

.level-pill {
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 999px;
  padding: 10px 14px;
  background: #fffefc;
  cursor: pointer;
  font-weight: 600;
  color: #5b4f3e;
}

.level-pill.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--sand);
}

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

.count-pill {
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 999px;
  padding: 10px 14px;
  background: #fffefc;
  cursor: pointer;
  font-weight: 600;
  color: #5b4f3e;
}

.count-pill.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--sand);
}

.custom-count-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.custom-count-row[hidden] {
  display: none;
}

.custom-count-row input {
  flex: 1;
  border-radius: 14px;
  border: 1px solid #d5c8b1;
  padding: 12px 14px;
  font-size: 0.95rem;
  background: #fffdf8;
}

.next-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.type-card {
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 18px;
  padding: 14px 16px;
  text-align: left;
  background: #fffefc;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.type-card strong {
  font-size: 1rem;
}

.type-card span {
  font-size: 0.85rem;
  color: #6c5f4e;
}

.type-card.active {
  border-color: var(--ink);
  box-shadow: 0 12px 24px rgba(49, 36, 14, 0.2);
}

.count-control {
  margin-top: 18px;
}

.count-control label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.count-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#card-count {
  flex: 1;
}

.primary {
  margin-top: 20px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(120deg, #1c1b1f, #433824);
  color: var(--sand);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ghost {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #cdbca3;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.status {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #805f2f;
  min-height: 20px;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  margin: 10px 0 6px;
  border-radius: 50%;
  border: 3px solid rgba(28, 27, 31, 0.12);
  border-top-color: var(--ink);
  animation: spin 1.1s linear infinite;
}

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

.output {
  grid-column: span 2;
}

.output-meta {
  font-size: 0.9rem;
  color: #6b5f4b;
  margin-bottom: 16px;
}

.output-gate {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  background: rgba(28, 27, 31, 0.04);
  border: 1px solid rgba(194, 159, 75, 0.3);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.output-gate-copy {
  display: grid;
  gap: 4px;
  color: #5b5042;
}

.output-gate-copy strong {
  font-size: 1rem;
  color: var(--ink);
}

.cards {
  display: grid;
  gap: 12px;
}

.card {
  border-radius: 16px;
  padding: 16px;
  background: #fffefb;
  border: 1px solid rgba(125, 101, 61, 0.2);
  display: grid;
  gap: 10px;
}

.card h3 {
  margin: 0;
  font-size: 1rem;
}

.card p {
  margin: 0;
  color: #5b5042;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-header h3 {
  flex: 1;
}

.card-edit-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: #9a8b75;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.card-edit-btn:hover {
  background: rgba(125, 101, 61, 0.1);
  color: var(--ink);
}

.card.editing {
  background: #fffdf8;
  border-color: var(--ink);
}

.card-edit-form {
  display: grid;
  gap: 12px;
}

.card-edit-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b5f4b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-edit-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d5c8b1;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: "Manrope", sans-serif;
  background: #fff;
  resize: vertical;
  min-height: 60px;
}

.card-edit-field textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.card-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.card-edit-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.card-save-btn {
  background: var(--ink);
  color: var(--sand);
  border: none;
}

.card-discard-btn {
  background: transparent;
  border: 1px solid #cdbca3;
  color: var(--ink);
}

.export {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .output {
    grid-column: span 1;
  }

  .paste-row {
    flex-direction: column;
  }

  .auth-form {
    grid-template-columns: 1fr;
  }
}

.paste-modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 8, 0.5);
  display: grid;
  place-items: center;
  z-index: 20;
}

.paste-modal.hidden {
  display: none;
}

.paste-card {
  background: #fffefb;
  border-radius: 20px;
  padding: 24px;
  width: min(90vw, 420px);
  display: grid;
  gap: 12px;
  box-shadow: 0 24px 50px rgba(20, 15, 5, 0.2);
}

.paste-card h3 {
  margin: 0;
  font-family: "Playfair Display", serif;
}

.paste-card textarea {
  width: 100%;
  min-height: 80px;
  border-radius: 12px;
  border: 1px solid #d5c8b1;
  padding: 10px 12px;
  font-size: 0.95rem;
  resize: none;
}

#custom-count {
  -moz-appearance: textfield;
}

#custom-count::-webkit-outer-spin-button,
#custom-count::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Hamburger Menu */
.hamburger {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(194, 159, 75, 0.2);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: -10px 0 40px rgba(20, 15, 5, 0.15);
  z-index: 200;
  padding: 24px;
  transition: right 0.3s ease;
}

.sidebar.open {
  right: 0;
}

.sidebar-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--ink);
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 60px 0 0 0;
}

.sidebar-menu li {
  margin-bottom: 8px;
}

body.logged-out .auth-only {
  display: none;
}

body.pro-user #nav-pricing {
  display: none;
}

.sidebar-menu button {
  width: 100%;
  padding: 14px 18px;
  border: none;
  background: transparent;
  font-family: "Manrope", sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-menu button:hover {
  background: rgba(194, 159, 75, 0.15);
}

.menu-badge {
  background: rgba(194, 159, 75, 0.25);
  color: #6b5f4b;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 8, 0.4);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Saved Decks */
.saved-decks-list {
  display: grid;
  gap: 16px;
}

.empty-state {
  color: #6b5f4b;
  font-style: italic;
}

.deck-card {
  background: #fffefb;
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 16px;
  padding: 18px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.deck-card:hover {
  box-shadow: 0 8px 24px rgba(49, 36, 14, 0.15);
  transform: translateY(-2px);
}

.deck-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.deck-card h3 {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: 1.1rem;
}

.deck-card-meta {
  font-size: 0.85rem;
  color: #6b5f4b;
}

.deck-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.deck-card-actions button {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.btn-danger {
  border-color: #c9534a;
  color: #c9534a;
}

.btn-danger:hover {
  background: #c9534a;
  color: white;
}

#saved-decks-panel {
  grid-column: span 2;
}

@media (max-width: 900px) {
  #saved-decks-panel {
    grid-column: span 1;
  }

  .hamburger {
    top: 16px;
    right: 16px;
  }
}

/* Custom Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 8, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #fffefb;
  border-radius: 20px;
  padding: 28px;
  width: min(90vw, 400px);
  box-shadow: 0 24px 50px rgba(20, 15, 5, 0.25);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal h3 {
  margin: 0 0 8px 0;
  font-family: "Playfair Display", serif;
  font-size: 1.3rem;
}

.modal p {
  margin: 0 0 20px 0;
  color: #6b5f4b;
  font-size: 0.95rem;
}

.modal input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d5c8b1;
  border-radius: 12px;
  font-size: 1rem;
  background: #fffdf8;
  margin-bottom: 20px;
}

.modal input[type="text"]:focus {
  outline: none;
  border-color: var(--ink);
}

.inquiry-modal {
  width: min(92vw, 480px);
}

.inquiry-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.inquiry-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b5f4b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inquiry-field input,
.inquiry-field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d5c8b1;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: "Manrope", sans-serif;
  background: #fffdf8;
}

.inquiry-field input:focus,
.inquiry-field textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.modal-btn-secondary {
  background: transparent;
  border: 1px solid #cdbca3;
  color: var(--ink);
}

.modal-btn-primary {
  background: var(--ink);
  border: none;
  color: var(--sand);
}

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

/* Compare Mode Toggle */
.compare-toggle {
  display: block;
  margin-top: 16px;
  padding: 10px 16px;
  background: transparent;
  border: 1px dashed #c9b896;
  border-radius: 12px;
  color: #6b5f4b;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: center;
}

.compare-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(28, 27, 31, 0.03);
}

.compare-toggle.active {
  border-style: solid;
  border-color: var(--ink);
  background: rgba(28, 27, 31, 0.05);
  color: var(--ink);
}

.compare-hint {
  font-weight: 400;
  color: #9a8b75;
  font-size: 0.85rem;
}

.model-pill.compare-selected {
  border-color: var(--gold);
  background: linear-gradient(135deg, #f9f3e3, #fff8eb);
  color: var(--ink);
  box-shadow: 0 0 0 2px rgba(194, 159, 75, 0.3);
}

/* Comparison Panel */
.comparison-panel {
  grid-column: span 2;
}

.comparison-instruction {
  color: #6b5f4b;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.comparison-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  min-height: 400px;
}

.comparison-column {
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

.comparison-divider {
  width: 1px;
  background: linear-gradient(to bottom, transparent, #d5c8b1, transparent);
  margin: 0 8px;
}

.comparison-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(28, 27, 31, 0.03);
  border-radius: 12px;
  margin-bottom: 16px;
}

.comparison-model-icon {
  width: 12px;
  height: 12px;
  background: var(--ink);
  border-radius: 50%;
}

.comparison-model-name {
  font-weight: 600;
  font-size: 1rem;
}

.comparison-cards {
  flex: 1;
  overflow-y: auto;
  max-height: 500px;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.comparison-cards .card {
  padding: 14px;
  font-size: 0.9rem;
}

.comparison-cards .card h3 {
  font-size: 0.9rem;
}

.comparison-cards .card p {
  font-size: 0.85rem;
}

.comparison-select-btn {
  margin-top: auto;
}

@media (max-width: 900px) {
  .comparison-panel {
    grid-column: span 1;
  }

  .comparison-container {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .comparison-divider {
    display: none;
  }

  .comparison-column {
    padding: 0;
  }
}

/* Streaming Content */
.streaming-content {
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  font-size: 0.85rem;
  background: #fffdf8;
  border: 1px solid #e5ddd0;
  border-radius: 12px;
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #5b5042;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}

.streaming-content::-webkit-scrollbar {
  width: 6px;
}

.streaming-content::-webkit-scrollbar-track {
  background: transparent;
}

.streaming-content::-webkit-scrollbar-thumb {
  background: #d5c8b1;
  border-radius: 3px;
}

.stream-error {
  color: #c9534a;
  font-family: "Manrope", sans-serif;
  padding: 12px;
  background: rgba(201, 83, 74, 0.08);
  border-radius: 8px;
}

.stream-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: #6b5f4b;
  font-size: 0.95rem;
}

.stream-status::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid #d5c8b1;
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* Study Dashboard */
#study-dashboard-panel {
  grid-column: span 2;
}

.study-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: linear-gradient(135deg, #fffdf8 0%, #f9f3e3 100%);
  border: 1px solid rgba(194, 159, 75, 0.2);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
}

.stat-label {
  font-size: 0.85rem;
  color: #6b5f4b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.study-decks-list {
  display: grid;
  gap: 12px;
}

.study-deck-card {
  background: #fffefb;
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.study-deck-card::after {
  content: "Tap to study";
  font-size: 0.8rem;
  color: #8b7b67;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s ease;
  justify-self: end;
  pointer-events: none;
}

.study-deck-card:hover {
  box-shadow: 0 8px 24px rgba(49, 36, 14, 0.15);
  transform: translateY(-2px);
}

.study-deck-card:hover::after {
  opacity: 1;
}

.study-deck-info h4 {
  margin: 0 0 6px 0;
  font-family: "Playfair Display", serif;
  font-size: 1.1rem;
}

.study-deck-counts {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: #6b5f4b;
}

.study-deck-counts .count-new {
  color: #3d8b40;
}

.study-deck-counts .count-due {
  color: #c9534a;
}

.study-deck-action {
  display: flex;
  gap: 8px;
}

/* Study Session Panel */
.study-session-panel {
  grid-column: span 2;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.study-session-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(194, 159, 75, 0.2);
}

.study-exit-btn {
  padding: 8px 16px;
}

.study-progress {
  font-size: 0.9rem;
  color: #6b5f4b;
  margin-left: auto;
}

.study-deck-name {
  font-weight: 600;
  color: var(--ink);
}

.flashcard-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.flashcard {
  width: 100%;
  max-width: 600px;
  min-height: 280px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard.no-flip .flashcard-inner {
  transition: none;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 280px;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

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

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  min-height: 280px;
  backface-visibility: hidden;
  background: linear-gradient(135deg, #fffefb 0%, #f9f5ed 100%);
  border: 1px solid rgba(194, 159, 75, 0.25);
  border-radius: 24px;
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 12px 40px rgba(20, 15, 5, 0.1);
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #f9f5ed 0%, #f4efe5 100%);
}

.flashcard-front p,
.flashcard-back p {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--ink);
}

.study-actions {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.show-answer-btn {
  padding: 14px 48px;
  font-size: 1rem;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 16px 0;
  max-width: 500px;
  margin: 0 auto;
}

.rating-btn {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #d5c8b1;
  background: #fffefb;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  color: var(--ink);
}

.rating-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  border-color: var(--ink);
}

.rating-btn:active {
  transform: translateY(0);
}

.rating-label {
  font-size: 0.9rem;
  font-weight: 600;
}

.rating-interval {
  font-size: 0.8rem;
  color: #6b5f4b;
  font-weight: 500;
}

.rating-again:hover {
  border-color: #c9534a;
  color: #c9534a;
}

.rating-good:hover {
  border-color: #3d8b40;
  color: #3d8b40;
}

.rating-easy:hover {
  border-color: #3a78a8;
  color: #3a78a8;
}

.study-complete {
  text-align: center;
  padding: 48px 24px;
}

.study-complete h3 {
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
  margin: 0 0 12px 0;
}

.study-complete p {
  color: #6b5f4b;
  margin: 0 0 24px 0;
}

/* Deck Detail Panel */
#deck-detail-panel {
  grid-column: span 2;
}

.deck-detail-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.deck-detail-header h2 {
  margin: 0;
}

.back-btn {
  padding: 6px 14px;
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 999px;
}

.deck-detail-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 0.95rem;
  color: #6b5f4b;
}

.deck-stat strong {
  color: var(--ink);
}

.deck-detail-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  margin-bottom: 0;
}

.deck-detail-actions button {
  margin-top: 0;
  padding: 10px 18px;
  min-width: 160px;
}

.deck-cards-list {
  display: grid;
  gap: 10px;
}

.deck-card-item {
  background: #fffefb;
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.deck-card-content {
  display: grid;
  gap: 6px;
}

.deck-card-front {
  font-weight: 600;
  color: var(--ink);
}

.deck-card-back {
  font-size: 0.9rem;
  color: #5b5042;
}

.deck-card-actions {
  display: flex;
  gap: 6px;
}

.deck-card-actions button {
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* Settings Panel */
#settings-panel {
  max-width: 480px;
}

/* Pricing Panel */
.pricing-panel {
  grid-column: span 2;
}

.pricing-subhead {
  color: #6b5f4b;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.pricing-gate {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  background: rgba(28, 27, 31, 0.04);
  border: 1px solid rgba(194, 159, 75, 0.3);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.pricing-gate-copy {
  display: grid;
  gap: 4px;
  color: #5b5042;
}

.pricing-gate-copy strong {
  font-size: 1rem;
  color: var(--ink);
}

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

.pricing-card {
  background: #fffefb;
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 20px;
  padding: 20px;
  display: grid;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(49, 36, 14, 0.08);
}

.pricing-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(194, 159, 75, 0.18);
  color: #6b5f4b;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.billing-toggle {
  display: inline-flex;
  gap: 6px;
  background: rgba(28, 27, 31, 0.05);
  padding: 6px;
  border-radius: 999px;
  width: fit-content;
}

.billing-option {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #6b5f4b;
  cursor: pointer;
}

.billing-option.active {
  background: #1c1b1f;
  color: var(--sand);
}

.pricing-card.featured {
  background: linear-gradient(160deg, #fff7e6 0%, #fffdf8 100%);
  border-color: rgba(194, 159, 75, 0.45);
  box-shadow: 0 18px 40px rgba(194, 159, 75, 0.2);
}

.pricing-header h3 {
  margin: 0 0 6px 0;
  font-family: "Playfair Display", serif;
  font-size: 1.4rem;
}

.price {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
}

.price span {
  font-size: 1rem;
  font-weight: 600;
  color: #6b5f4b;
}

.price-note {
  font-size: 0.85rem;
  color: #8a7a65;
}

.price-note[hidden] {
  display: none;
}

.pricing-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: #5b5042;
  font-size: 0.95rem;
}

.pricing-cta {
  margin-top: 0;
}

.pricing-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(194, 159, 75, 0.5), transparent);
  margin: 28px 0 20px;
}

.pricing-enterprise {
  display: grid;
  gap: 16px;
}

.pricing-table {
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 16px;
  overflow: hidden;
  background: #fffefb;
}

.pricing-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.pricing-row:nth-child(even) {
  background: rgba(248, 243, 232, 0.7);
}

.pricing-row-head {
  font-weight: 700;
  background: rgba(194, 159, 75, 0.15);
}

.pricing-footnote {
  font-size: 0.85rem;
  color: #7b6d59;
}

/* Why Flashcards Panel */
.why-panel {
  grid-column: span 2;
}

.why-lead {
  color: #5b5042;
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 20px;
}

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

.why-card {
  background: #fffefb;
  border: 1px solid rgba(125, 101, 61, 0.2);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.why-card h3 {
  margin: 0;
  font-family: "Playfair Display", serif;
}

.why-card p {
  margin: 0;
  color: #6b5f4b;
  font-size: 0.95rem;
}

.why-cta {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: #6b5f4b;
}

.settings-form {
  display: grid;
  gap: 20px;
}

.setting-row {
  display: grid;
  gap: 8px;
}

.setting-row label {
  font-weight: 600;
  color: var(--ink);
}

.setting-row input[type="number"] {
  padding: 12px 14px;
  border: 1px solid #d5c8b1;
  border-radius: 12px;
  font-size: 1rem;
  background: #fffdf8;
  width: 120px;
}

.setting-row input[type="number"]:focus {
  outline: none;
  border-color: var(--ink);
}

.setting-checkbox {
  flex-direction: row;
  align-items: center;
  display: flex;
  gap: 12px;
}

.setting-checkbox label {
  order: 2;
  cursor: pointer;
}

.setting-checkbox input[type="checkbox"] {
  order: 1;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Responsive adjustments for study panels */
@media (max-width: 900px) {
  #study-dashboard-panel,
  .study-session-panel,
  #deck-detail-panel,
  .pricing-panel,
  .why-panel {
    grid-column: span 1;
  }

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

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

  .study-deck-action {
    justify-content: flex-start;
  }

  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .why-grid {
    grid-template-columns: 1fr;
  }

  .pricing-gate {
    flex-direction: column;
    align-items: flex-start;
  }

  .rating-buttons {
    grid-template-columns: 1fr;
    max-width: 300px;
  }

  .flashcard {
    min-height: 200px;
  }

  .flashcard-inner {
    min-height: 200px;
  }

  .deck-detail-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .flashcard-front,
  .flashcard-back {
    min-height: 200px;
    padding: 24px;
  }

  .flashcard-front p,
  .flashcard-back p {
    font-size: 1.1rem;
  }
}
