:root {
  /* Palette pulled from the reference image */
  --teal-1: #5fd0d3;
  --teal-2: #43b9bf;
  --teal-3: #2f9aa2;
  --teal-deep: #1f7c86;
  --ink: #0f4c52;
  --paper: #ffffff;
  --paper-soft: #f4fbfb;
  --shadow: rgba(15, 76, 82, 0.22);
  --radius: 16px;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper-soft);
}

/* ---------- 3-way split layout (stacked vertically) ---------- */
/* Fills the whole browser window edge-to-edge; the three sections
   each take an equal third of the window height and scale with it. */
.layout {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-columns: 1fr;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.panel {
  min-height: 0;
  padding: 24px 40px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-title {
  margin: 0 0 18px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--teal-3);
}

/* ---------- Section 1: Hero (horizontal banner) ---------- */
.hero {
  position: relative;
  background: linear-gradient(110deg, var(--teal-1) 0%, var(--teal-2) 45%, var(--teal-3) 100%);
  color: var(--paper);
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 34px;
}

/* Ko-fi support button (widget renders its own <a class="kofi-button">) */
.kofi-wrap {
  position: absolute;
  right: 48px;
  bottom: 20px;
}
.kofi-wrap .kofi-button {
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(15, 76, 82, 0.5) !important;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
}
.kofi-wrap .kofi-button:hover {
  filter: brightness(1.02);
  box-shadow: 0 12px 26px rgba(15, 76, 82, 0.55) !important;
  transform: translateY(-1px);
}
.kofi-wrap .kofi-button:active { transform: translateY(0); }

.hero-art {
  flex: 0 0 auto;
  height: min(78%, 190px);
  aspect-ratio: 200 / 240; /* reserve width from height (Safari-safe) */
  color: rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
}
.hero-art svg { display: block; width: 100%; height: 100%; }
.hero-art .rays { opacity: 0.9; }

.hero-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.wordmark {
  margin: 0;
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.wordmark span { color: var(--ink); }

.tagline {
  margin: 8px 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.blurb {
  margin: 12px 0 0;
  max-width: 42ch;
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.92);
}
.blurb strong { color: var(--ink); font-weight: 700; }

/* ---------- Section 2: Editor ---------- */
.editor {
  border-top: 1px solid rgba(47, 154, 162, 0.15);
  border-bottom: 1px solid rgba(47, 154, 162, 0.15);
  background: var(--paper);
}

/* The scrolling region — never taller than its 1/3 column */
.rows {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Contact prompt pinned below the scrolling rows */
.editor-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 14px;
}
.editor-foot-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.contact-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--paper);
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 76, 82, 0.5);
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
}
.contact-btn:hover {
  filter: brightness(1.02);
  box-shadow: 0 12px 26px rgba(15, 76, 82, 0.55);
  transform: translateY(-1px);
}
.contact-btn:active { transform: translateY(0); }

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

.row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 11px 12px;
  border: 1.5px solid rgba(47, 154, 162, 0.35);
  border-radius: 10px;
  background: var(--paper-soft);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.row input::placeholder { color: rgba(15, 76, 82, 0.4); }
.row input:focus {
  outline: none;
  border-color: var(--teal-2);
  box-shadow: 0 0 0 3px rgba(67, 185, 191, 0.18);
  background: var(--paper);
}

.row button {
  flex: 0 0 auto;
  min-width: 88px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--paper);
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(15, 76, 82, 0.45);
  transition: transform 0.08s, filter 0.15s, background 0.15s, box-shadow 0.15s;
}
.row button:active { transform: translateY(1px); }
.row button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Button states */
.row button.generate { background: var(--teal-2); }
.row button.generate:hover:not(:disabled) { filter: brightness(1.06); }
.row button.delete   { background: #e2725b; }
.row button.delete:hover   { filter: brightness(1.06); }
.row button.update   { background: var(--ink); }
.row button.update:hover   { filter: brightness(1.15); }

/* Scrollbar styling for the editor */
.rows::-webkit-scrollbar { width: 8px; }
.rows::-webkit-scrollbar-thumb {
  background: rgba(47, 154, 162, 0.35);
  border-radius: 8px;
}

/* ---------- Section 3: Deck ---------- */
.deck { background: var(--paper-soft); }

.deck-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.deck-head .section-title { margin-bottom: 18px; }

.export-wrap { position: relative; margin-right: 8px; }

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--paper);
  background: var(--teal-2);
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(15, 76, 82, 0.45);
  transition: filter 0.15s, transform 0.08s, box-shadow 0.15s;
}
.export-btn:hover { filter: brightness(1.06); }
.export-btn:active { transform: translateY(1px); }
.export-btn .caret { font-size: 0.7rem; transition: transform 0.15s; }
.export-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 240px;
  background: var(--paper);
  border: 1px solid rgba(47, 154, 162, 0.2);
  border-radius: 12px;
  box-shadow: 0 12px 26px rgba(15, 76, 82, 0.2);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.export-menu[hidden] { display: none; }

.export-menu button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  font-family: var(--font);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  color: var(--ink);
}
.export-menu button:hover { background: var(--paper-soft); }
.export-menu button strong { font-size: 0.86rem; font-weight: 700; white-space: nowrap; }
.export-menu button small { font-size: 0.72rem; color: rgba(15, 76, 82, 0.6); }

.stack {
  flex: 1;
  min-height: 0;
  position: relative;
}

.empty-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  text-align: center;
  color: rgba(15, 76, 82, 0.4);
  font-size: 0.95rem;
}

.card {
  position: absolute;
  left: 50%;
  top: 16px;
  width: min(260px, 60%);
  aspect-ratio: 3 / 2;
  transform: translateX(-50%);
  border-radius: var(--radius);
  background: linear-gradient(155deg, var(--teal-1), var(--teal-3));
  color: var(--paper);
  box-shadow: 0 10px 22px var(--shadow);
  cursor: pointer;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.card:hover { box-shadow: 0 16px 30px var(--shadow); }

.card .card-face { font-weight: 600; font-size: 1.05rem; line-height: 1.4; }
.card .card-label {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.75;
}
.card .card-hint {
  position: absolute;
  bottom: 12px;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* Flipped = showing the answer */
.card.flipped {
  background: linear-gradient(155deg, #ffffff, var(--paper-soft));
  color: var(--ink);
}
.card.flipped .card-label { color: var(--teal-3); opacity: 1; }

/* ---------- Contact modal (Formspree) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 76, 82, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  position: relative;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  padding: 30px 28px 24px;
  box-shadow: 0 24px 60px rgba(15, 76, 82, 0.4);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--teal-3);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
}
.modal-close:hover { background: var(--paper-soft); }
.modal h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}
.modal-sub {
  margin: 0 0 12px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(15, 76, 82, 0.75);
}
.modal-pricing-label {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}
.modal-pricing {
  margin: 0 0 18px;
  padding-left: 20px;
  font-size: 0.86rem;
  line-height: 1.55;
  color: rgba(15, 76, 82, 0.8);
}
.modal-pricing li { margin-bottom: 2px; }
.modal-pricing strong { color: var(--ink); font-weight: 700; }

.contact-form { display: flex; flex-direction: column; gap: 14px; }
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.contact-form input,
.contact-form textarea {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 12px;
  border: 1.5px solid rgba(47, 154, 162, 0.35);
  border-radius: 10px;
  background: var(--paper-soft);
  color: var(--ink);
  resize: vertical;
}
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--teal-2);
  box-shadow: 0 0 0 3px rgba(67, 185, 191, 0.18);
  background: var(--paper);
}
.submit-btn {
  margin-top: 4px;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--paper);
  background: var(--teal-2);
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15, 76, 82, 0.3);
  transition: filter 0.15s, transform 0.08s;
}
.submit-btn:hover { filter: brightness(1.06); }
.submit-btn:active { transform: translateY(1px); }
.submit-btn:disabled { opacity: 0.6; cursor: default; }
.form-status {
  margin: 4px 0 0;
  font-size: 0.82rem;
  text-align: center;
  min-height: 1em;
}
.form-status.ok { color: var(--teal-3); font-weight: 600; }
.form-status.err { color: #c0492f; font-weight: 600; }

/* Each of the three sections always fills an equal 1/3 of the viewport,
   at every width, per the original design. */
