/* ============================================================
   Got it! — Global Styles
   Art Nouveau dark mode
   ============================================================ */

:root {
  --bg:        #0D0F1A;
  --bg-card:   #13162A;
  --bg-raised: #1A1E36;
  --gold:      #C9A84C;
  --gold-dim:  #8A6F30;
  --ivory:     #F2ECD8;
  --ivory-dim: #9E9580;
  --danger:    #C94C4C;
  --radius:    12px;
  --radius-sm: 8px;
  --gap:       16px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ivory);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---- Typography ---- */

h1, h2, h3 {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.02em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Layout ---- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--gap);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding-bottom: var(--gap);
  border-bottom: 1px solid var(--bg-raised);
  margin-bottom: var(--gap);
}

.screen-header h1,
.screen-header h2 {
  flex: 1;
}

/* ---- Buttons ---- */

button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

button:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gold);
  color: var(--bg);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-ghost {
  background: transparent;
  color: var(--ivory-dim);
  border: 1px solid var(--bg-raised);
}

.btn-ghost:hover {
  color: var(--ivory);
  border-color: var(--ivory-dim);
}

.btn-danger {
  background: var(--danger);
  color: var(--ivory);
}

.btn-icon {
  background: transparent;
  color: var(--ivory-dim);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: var(--ivory);
  background: var(--bg-raised);
}

/* ---- Cards / surfaces ---- */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: var(--gap);
  border: 1px solid var(--bg-raised);
}

.card + .card {
  margin-top: 10px;
}

/* ---- Form inputs ---- */

input, textarea, select {
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-raised);
  color: var(--ivory);
  border: 1px solid var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--gold-dim);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--ivory-dim);
  margin-bottom: 6px;
}

.field {
  margin-bottom: var(--gap);
}

/* ---- Deck list item ---- */

.deck-item {
  display: flex;
  align-items: center;
  gap: var(--gap);
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px var(--gap);
  border: 1px solid var(--bg-raised);
  cursor: pointer;
  transition: border-color 0.15s;
  margin-bottom: 10px;
}

.deck-item:hover {
  border-color: var(--gold-dim);
}

.deck-item-info {
  flex: 1;
}

.deck-item-name {
  font-weight: 600;
  color: var(--ivory);
}

.deck-item-meta {
  font-size: 0.8rem;
  color: var(--ivory-dim);
  margin-top: 2px;
}

/* ---- Review card ---- */

.review-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--bg-raised);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px var(--gap);
  text-align: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: border-color 0.15s;
  margin-bottom: var(--gap);
  position: relative;
}

.review-card:hover {
  border-color: var(--gold-dim);
}

.review-card .tap-hint {
  position: absolute;
  bottom: 12px;
  font-size: 0.75rem;
  color: var(--ivory-dim);
}

/* ---- FSRS rating buttons ---- */

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.rating-btn .label  { font-size: 0.7rem; color: var(--ivory-dim); }
.rating-btn.again   { background: #3D1515; color: #FF6B6B; }
.rating-btn.hard    { background: #2E2010; color: #FFB347; }
.rating-btn.good    { background: #0F2E1A; color: #6BCB77; }
.rating-btn.easy    { background: #0F2040; color: #6BA8FF; }

/* ---- Sync status ---- */

.sync-status {
  font-size: 0.75rem;
  color: var(--ivory-dim);
  text-align: center;
  padding: 8px;
}

.sync-status.syncing { color: var(--gold-dim); }
.sync-status.error   { color: var(--danger); }

/* ---- Empty state ---- */

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--gap);
  color: var(--ivory-dim);
  padding: 40px var(--gap);
}

.empty-state p {
  max-width: 280px;
  font-size: 0.95rem;
}

/* ---- Utility ---- */

.text-gold    { color: var(--gold); }
.text-dim     { color: var(--ivory-dim); }
.text-danger  { color: var(--danger); }
.text-sm      { font-size: 0.85rem; }
.text-center  { text-align: center; }
.mt           { margin-top: var(--gap); }
.mt-sm        { margin-top: 8px; }
.hidden       { display: none !important; }

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

.row.end     { justify-content: flex-end; }
.row.between { justify-content: space-between; }

/* ---- Toggle switch ---- */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-raised);
  border-radius: 26px;
  border: 1px solid var(--bg-raised);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--ivory-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--gold-dim);
  border-color: var(--gold-dim);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--gold);
}

/* ---- Canvas drawing ---- */

.drawing-screen {
  overflow: hidden; /* prevent canvas scroll */
}

.canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: var(--gap);
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: var(--radius);
  border: 1px solid var(--bg-raised);
  touch-action: none;
  cursor: crosshair;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  max-width: 360px;
  margin: 8px auto 0;
  width: 100%;
  gap: 8px;
}

.canvas-toolbar .btn-ghost {
  flex: 1;
  padding: 8px;
  font-size: 0.8rem;
}

.reveal-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

/* ---- Snapshot (drawing review revealed state) ---- */

.snapshot-img {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 0 auto;
}

/* ---- Scope modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}

.modal-sheet {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px var(--gap) calc(var(--gap) + env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  border-top: 1px solid var(--bg-raised);
}

.scope-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--bg-raised);
}

.scope-check-row:last-child {
  border-bottom: none;
}

.scope-check-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--gold);
}
