:root {
  --bg: #0f172a;
  --card: #0b1220;
  --accent: #f59e0b;
  --muted: #94a3b8;
  --glass: rgba(255, 255, 255, 0.04);
  --radius: 14px;
  --gap: 16px;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, Segoe UI, Roboto, 'Helvetica Neue', Arial
}

body {
  background: #002252;
  color: #e6eef8;
  padding: 28px
}

.wrap {
  max-width: 900px;
  margin: 0 auto
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px
}

header h1 {
  font-size: 20px;
  margin: 0
}

header p {
  color: var(--muted);
  margin: 0;
  font-size: 13px
}

.controls {
  display: flex;
  gap: 10px
}

button {
  background: var(--accent);
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  color: #08101a;
  font-weight: 600;
  cursor: pointer
}

.outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  padding: 8px 12px
}

/* form area */
.form-card {
  background: var(--card);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 18px;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6)
}

.form-row {
  display: flex;
  gap: 10px
}

textarea {
  width: 100%;
  min-height: 70px;
  padding: 8px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.03);
  color: inherit;
  resize: vertical
}

label {
  font-size: 13px;
  color: var(--muted);
  display: block;
  margin-bottom: 6px
}

.row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  align-items: end
}

/* cards grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px
}

/* flip card */
.card {
  perspective: 1200px
}

.card-inner {
  position: relative;
  width: 100%;
  height: 180px;
  transform-style: preserve-3d;
  transition: transform 600ms cubic-bezier(.2, .9, .3, 1)
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg)
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  padding: 14px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.6)
}

.front {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.03)
}

.back {
  background: linear-gradient(180deg, rgba(5, 10, 20, 0.9), rgba(2, 6, 12, 0.9));
  transform: rotateY(180deg);
  border: 1px solid rgba(255, 255, 255, 0.03)
}

.q,
.a {
  font-size: 15px;
  line-height: 1.4;
  color: #e6eef8;
  margin: 0
}

/* preserve whitespace and new lines exactly as user types */
.q,
.a {
  white-space: pre-wrap
}

.meta {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center
}

.meta small {
  color: var(--muted);
  font-size: 12px
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px
}

.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px
}

.empty {
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  color: var(--muted)
}

footer {
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center
}

@media (max-width:520px) {
  .row {
    grid-template-columns: 1fr
  }
}