:root {
  --white: #fff;
  --black: #000;
  --line: rgba(255,255,255,.9);
  --muted: rgba(255,255,255,.74);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: #000;
  color: var(--white);
  font-family: Georgia, 'Times New Roman', serif;
}
button, input, textarea { font: inherit; }

.app-shell {
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: #000;
}

.app-shell::before,
.app-shell::after {
  content: '';
  position: absolute;
  inset: -8%;
  pointer-events: none;
  z-index: -1;
}

.app-shell::before,
.app-shell::after {
  content: none;
}

.screen {
  display: none;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}
.screen.active { display: block; }
.screen-inner {
  width: min(980px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home-inner { justify-content: center; gap: clamp(34px, 7vh, 78px); }
.draw-inner {
  justify-content: flex-start;
  padding-top: max(34px, env(safe-area-inset-top));
  min-height: 100dvh;
}
.record-inner { justify-content: flex-start; padding-top: max(30px, env(safe-area-inset-top)); }

h1, h2 {
  margin: 0;
  text-align: center;
  font-weight: 500;
  letter-spacing: .16em;
  text-shadow: 0 2px 18px rgba(0,0,0,.55);
}
h1 { font-size: clamp(2rem, 6vw, 4.2rem); }
h2 { font-size: clamp(1.55rem, 4.5vw, 3rem); margin-top: 8px; }
.subtitle {
  margin: 9px 0 24px;
  color: var(--muted);
  font-size: clamp(.95rem, 2vw, 1.18rem);
}


.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.text-link-button {
  border: 0;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  letter-spacing: .13em;
  font-size: .86rem;
  padding: 3px 6px;
  border-bottom: 1px solid rgba(255,255,255,.45);
}
.text-link-button:hover { border-bottom-color: rgba(255,255,255,.9); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(88dvh, 820px);
  overflow: auto;
  padding: 26px 24px 24px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 72% 24%, rgba(255,255,255,.09) 0%, transparent 40%),
    linear-gradient(180deg, rgba(7,10,15,.98) 0%, rgba(4,6,10,.98) 100%);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.modal-panel h2 {
  margin-bottom: 18px;
  padding-right: 30px;
}
.modal-close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.howto-list {
  margin: 0;
  padding-left: 1.4rem;
  display: grid;
  gap: 14px;
  line-height: 1.55;
  color: rgba(255,255,255,.92);
}
.howto-list li::marker {
  color: rgba(255,255,255,.82);
}

.deck-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 3vw, 28px);
  width: min(760px, 100%);
}
.deck-card {
  aspect-ratio: 1 / 1;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: rgba(0,0,0,.78);
  display: grid;
  place-items: center;
  letter-spacing: .12em;
  font-size: clamp(.95rem, 2.2vw, 1.45rem);
  box-shadow: 0 12px 32px rgba(0,0,0,.38);
}

.primary-button,
.small-button {
  color: var(--white);
  background: rgba(0,0,0,.46);
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, opacity .18s ease;
}
.primary-button {
  width: min(520px, 92vw);
  padding: 16px 20px;
  border-radius: 14px;
  letter-spacing: .13em;
}
.secondary-button { background: rgba(0,0,0,.28); }
.primary-button:hover, .small-button:hover { background: rgba(255,255,255,.08); }
.primary-button:active, .small-button:active { transform: scale(.99); }
button:disabled { opacity: .35; cursor: default; }


.top-nav {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.top-nav .back-button {
  margin-bottom: 0;
}

.home-button {
  border: 1px solid rgba(255,255,255,.75);
  background: transparent;
  color: var(--white);
  border-radius: 10px;
  padding: 8px 12px;
  letter-spacing: .11em;
  font-size: .78rem;
  cursor: pointer;
}
.home-button:hover {
  background: rgba(255,255,255,.06);
}

.back-button {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 2rem;
  cursor: pointer;
  padding: 2px 6px;
  margin-bottom: 18px;
}

.draw-grid {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2.4vw, 26px);
  margin: auto 0;
  align-self: center;
}
.draw-column { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.category-label {
  border: 1.5px solid var(--line);
  border-radius: 11px;
  text-align: center;
  padding: 10px 8px;
  background: rgba(0,0,0,.42);
  letter-spacing: .12em;
  font-size: clamp(.8rem, 1.8vw, 1rem);
}
.card-crop,
.record-card-crop {
  aspect-ratio: 1 / 1;
  overflow: visible;
  background: #000;
  border-radius: 0;
  box-shadow: 0 14px 34px rgba(0,0,0,.38);
}
.draw-card,
.record-card {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.button-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.draw-actions { margin-top: 0; padding: 18px 0 18px; }
.small-record-button {
  color: var(--white);
  background: rgba(0,0,0,.36);
  border: 1.25px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: .11em;
  width: min(360px, 78vw);
  padding: 11px 16px;
  font-size: .82rem;
  transition: background .18s ease, transform .18s ease, opacity .18s ease;
}
.small-record-button:hover { background: rgba(255,255,255,.08); }
.small-record-button:active { transform: scale(.99); }


.record-card-row {
  width: min(570px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.record-card-crop { width: 100%; border-radius: 0; }

.journal-form {
  width: min(680px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 30px;
}
.journal-input,
.journal-textarea {
  width: 100%;
  color: var(--white);
  background: rgba(0,0,0,.56);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  outline: none;
}
.journal-input { padding: 14px 15px; }
.journal-textarea {
  min-height: 190px;
  resize: vertical;
  padding: 15px;
  line-height: 1.45;
}
.journal-input::placeholder,
.journal-textarea::placeholder { color: rgba(255,255,255,.55); }

.tool-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.small-button {
  padding: 10px 14px;
  border-radius: 11px;
  letter-spacing: .09em;
  font-size: .78rem;
}
.status-text {
  color: var(--muted);
  font-size: .86rem;
  min-height: 1.2em;
}
.audio-panel {
  padding: 13px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 13px;
  background: rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.audio-panel audio { width: 100%; }
.download-link {
  align-self: flex-start;
  color: var(--white);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.6);
  letter-spacing: .08em;
  font-size: .82rem;
  padding-bottom: 2px;
}
.save-button { width: 100%; margin-top: 2px; }
.save-status { text-align: center; }

@media (max-width: 700px) {
  .screen-inner { padding-left: 16px; padding-right: 16px; }
  .home-inner { gap: 42px; }
  .deck-row, .draw-grid { gap: 8px; }
  .deck-card { border-radius: 11px; }
  .card-crop { border-radius: 9px; }
  .category-label { font-size: .68rem; padding: 8px 4px; letter-spacing: .08em; }
  .draw-grid { margin-top: 2vh; }
  .record-card-row { gap: 8px; }
  .record-card-crop { border-radius: 0; }
  .journal-textarea { min-height: 165px; }
}

.recording-actions,
.notes-actions { display:flex; flex-wrap:wrap; align-items:center; gap:10px; }
.notes-actions { justify-content:center; padding-top:2px; }
.danger-button { border-color:rgba(255,255,255,.55); opacity:.78; }
.danger-button:hover { background:rgba(255,255,255,.08); opacity:1; }
.privacy-note { margin:4px 0 0; color:rgba(255,255,255,.62); font-size:.82rem; line-height:1.45; text-align:center; }

@media (max-width: 700px) {
  /* Make the three-card draw the visual center of the phone screen. */
  .draw-inner {
    min-height: 100dvh;
    justify-content: flex-start;
    padding-top: max(22px, env(safe-area-inset-top));
  }
  .draw-grid {
    width: 100%;
    margin: auto 0;
    gap: 10px;
  }
  .draw-column {
    gap: 10px;
  }
  .category-label {
    min-height: 48px;
    display: grid;
    place-items: center;
  }
  .draw-actions {
    margin-top: 0;
    padding: 20px 0 max(22px, env(safe-area-inset-bottom));
  }
}
