:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --accent: #0b84ff;
  --muted: #6b7280;
  --text: #111827;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: var(--bg);
  color: var(--text);
}

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

.site-header {
  background: linear-gradient(90deg, rgba(11,132,255,0.08), rgba(6,204,255,0.04));
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.app-title {
  margin: 0;
  font-weight: 600;
}

.btn {
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
  background: white;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: white;
  border: none;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  align-items: start;
}

.sidebar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.04);
}

.sidebar-header {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.decks-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.decks-list li {
  padding: 0.25rem 0.25rem;
  border-radius: 6px;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.decks-list li .deck-title-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 0.6rem;
  text-align: left;
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.decks-list li .deck-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding-right: 0.4rem;
}

.btn.small {
  padding: 0.25rem 0.45rem;
  font-size: 0.85rem;
  border-radius: 6px;
}

.decks-list li.active {
  background: linear-gradient(90deg, rgba(11,132,255,0.08), rgba(6,204,255,0.04));
}

.main {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.04);
}

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

.search {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.06);
}

.card-area {
  display: grid;
  gap: 1rem;
  place-items: center;
}

.card {
  width: min(520px, 100%);
  height: 320px;
  perspective: 1200px;
  position: relative;
}

.card .face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  backface-visibility: hidden;
  padding: 1.5rem;
  font-size: 1.2rem;
  text-align: center;
}

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

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 400ms ease;
}

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

.card-controls {
  display: flex;
  gap: 0.5rem;
}

.card-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
    margin-bottom: 0.5rem;
  }

  .card {
    height: 260px;
  }
}

.site-footer {
  margin: 0.5rem auto 2rem;
  padding: 0.6rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p { margin: 0; }

/* Modal styles */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.35);
  z-index: 60;
}

.modal[hidden] { display: none; }

.modal-box {
  background: var(--surface);
  color: var(--text);
  padding: 1rem 1.1rem;
  border-radius: 10px;
  width: min(520px, calc(100% - 2rem));
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.modal-box h3 { margin: 0 0 0.25rem 0; }
.modal-box p { margin: 0 0 0.75rem 0; color: var(--muted); }

.modal-input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
  margin-bottom: 0.75rem;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
