: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: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  margin-bottom: 18px;
}

.top-nav .back-button {
  justify-self: start;
  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));
  }
}

.journey-link {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--white);
  border-radius: 10px;
}
.journey-link svg { width: 34px; height: 34px; }
.journey-link path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.journey-link:hover { background: rgba(255,255,255,.06); }
.top-nav :focus-visible { outline: 2px solid var(--white); outline-offset: 4px; }

.top-nav .home-button { justify-self: start; }

/* Keep drawn cards close to navigation after removing category headings. */
.draw-inner > .top-nav { margin-bottom: clamp(44px, 6.6vh, 70.4px); }
.draw-inner > .draw-grid { margin: 0; }

/* Spread the draw layout through the available phone screen height. */
@media (max-width: 700px) {
  .draw-inner > .top-nav { flex-shrink: 0; }
  .draw-inner > .draw-grid {
    flex-shrink: 0;
    margin: auto 0;
  }
  .draw-inner > .draw-actions {
    flex-shrink: 0;
    padding-top: 32px;
  }
}

/* Saving is the primary action; native sharing works on capable devices. */
.share-button { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.85); }
@media (max-width: 700px) {
  .share-button { flex-basis: 100%; width: 100%; min-height: 48px; }
  .notes-actions .small-button { min-height: 44px; }
}

.standalone-audio-share { margin-top: 4px; }

/* V34: one note area with three input modes. */
[hidden] { display: none !important; }
.mode-buttons { display: grid; grid-template-columns: .8fr 1.2fr 1.2fr; gap: 8px; }
.mode-button { padding: 12px 6px; min-height: 48px; letter-spacing: .04em; }
.mode-button.selected, .unified-save { background: #fff; color: #000; border-color: #fff; }
.shared-note-box { min-height: 260px; border: 1px solid rgba(255,255,255,.7); border-radius: 13px; overflow: hidden; display: flex; flex-direction: column; background: rgba(0,0,0,.28); }
.shared-note-box .journal-textarea { border: 0; border-radius: 0; background: transparent; min-height: 260px; resize: vertical; flex: 1; }
.shared-note-box:has(.voice-controls:not([hidden])) .journal-textarea { min-height: 185px; }
.voice-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 14px 14px; }
.unified-audio { min-height: 260px; padding: 20px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; text-align: center; }
.unified-audio audio { width: 100%; }
.audio-wave { font-size: 2rem; letter-spacing: .12em; opacity: .7; }
.audio-wave.recording { animation: audio-pulse .8s ease-in-out infinite alternate; }
@keyframes audio-pulse { to { opacity: 1; transform: scaleY(.65); } }
@media (prefers-reduced-motion: reduce) { .audio-wave.recording { animation: none; } }
.recording-timer { font-variant-numeric: tabular-nums; font-size: 1.2rem; }
.unified-save { width: 100%; min-height: 50px; font-weight: 700; }
@media (max-width: 700px) { .mode-button { font-size: .68rem; } .shared-note-box { min-height: 250px; } }

/* V35: keep portrait-phone actions above the hosting badge. */
@media (max-width: 700px) and (orientation: portrait) {
  .draw-inner { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .record-inner { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}

/* V36: equal, compact draw actions on mobile. */
@media (max-width: 700px) {
  .draw-actions > button {
    width: min(360px, 78vw);
    padding: 11px 16px;
    font-size: .82rem;
    letter-spacing: .11em;
    border-width: 1.25px;
    border-radius: 12px;
  }
}

.howto-intro { color: var(--white); line-height: 1.6; margin: 18px 0; }
