:root {
  --paper: #f3ecdf;
  --ink: #1a1612;
  --muted: #6b6156;
  --line: #e0d3c2;
  --card: #fffaf3;
  --red: #9d1c16;
  --red-ink: #fff7f2;
  --focus: #1a1612;
  --shadow: 0 18px 50px rgba(40, 24, 12, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

body.is-recording {
  background: #140e0c;
  color: #f6efe4;
}

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

body.is-recording :focus-visible { outline-color: #f6efe4; }

.wrap {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.brand h1 {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0;
}

.brand p, .lede, .hint, .meta {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

body.is-recording .brand p,
body.is-recording .hint { color: #d9cbb8; }

.who { font-size: 1.05rem; margin: 0 0 14px; }

.record-btn {
  width: 100%;
  min-height: 220px;
  height: 38vh;
  max-height: 420px;
  border: 0;
  border-radius: 32px;
  background: var(--red);
  color: var(--red-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  box-shadow: 0 16px 40px rgba(157, 28, 22, 0.28);
}

.record-btn .mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.16);
}

.record-btn-label {
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.record-btn.is-live {
  background: #f4efe6;
  color: #9d1c16;
  box-shadow: none;
  animation: pulse 1.4s ease-in-out infinite;
}

.record-btn.is-live .mark {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #9d1c16;
  box-shadow: none;
}

.record-btn:disabled { opacity: 0.7; cursor: wait; animation: none; }

@keyframes pulse {
  50% { transform: scale(0.985); }
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 12vw, 5.5rem);
  letter-spacing: -0.05em;
  margin: 8px 0 12px;
  text-align: center;
}

.live {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.45rem;
  line-height: 1.45;
  min-height: 4.5rem;
  margin: 0 0 18px;
}

.live:empty::before {
  content: "Listening…";
  color: #d9cbb8;
}

.banner {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 14px 0;
  line-height: 1.45;
}

body.is-recording .banner {
  background: #2a1814;
  border-color: #4a2c24;
}

.banner strong { display: block; margin-bottom: 4px; }

.banner button, .text-btn, .summary-btn {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.row-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.stack { display: grid; gap: 14px; }

.card, .login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.login-card { margin-top: 12vh; padding: 28px 22px; }

label { display: grid; gap: 6px; font-size: 0.95rem; }

input, textarea {
  width: 100%;
  background: #fff;
  border: 1.5px solid #d9cbb8;
  border-radius: 14px;
  padding: 16px 14px;
  font-size: 1.15rem;
}

textarea {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  min-height: 110px;
  line-height: 1.45;
  resize: vertical;
}

.primary, .record-secondary {
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: #f6efe4;
  font-size: 1.35rem;
  font-weight: 700;
}

.primary.danger, .link-danger { color: var(--red); }

.section-title {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.7rem;
  margin: 28px 0 8px;
}

.day {
  margin: 22px 0 10px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.memoir time {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
}

audio { width: 100%; margin: 8px 0 12px; }

.person {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.person h3 { margin: 0; font-size: 1.15rem; }

.person p { margin: 2px 0 0; color: var(--muted); }

details { margin-top: 6px; }

.saved-note { min-height: 1.2em; color: var(--muted); font-size: 0.92rem; }

.save-text {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.live, .memoir, .banner, textarea {
  overflow-wrap: anywhere;
}

.include {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 700;
}

.include input {
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  accent-color: var(--ink);
}

.memoir.is-picked { border-color: var(--ink); }

.share-bar {
  position: fixed;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  width: min(696px, calc(100% - 24px));
  bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.share-bar p { margin: 0 0 8px; font-weight: 700; }

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.share-actions button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #f6efe4;
  font-weight: 700;
}

.home.is-sharing { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }

  body { overflow-x: clip; }

  .wrap {
    width: min(720px, calc(100% - 24px));
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .home {
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
  }

  .home.is-sharing .record-btn { position: static; width: 100%; min-height: 84px; }

  .home.is-sharing { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

  .brand { align-items: flex-start; margin-bottom: 14px; }

  .brand h1 { font-size: 1.65rem; }

  .login-card { margin-top: 4vh; padding: 22px 16px; }

  .record-btn {
    position: fixed;
    z-index: 5;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    min-height: 84px;
    max-height: none;
    border-radius: 22px;
    touch-action: manipulation;
  }

  .record-btn-label { font-size: 1.65rem; }

  .record-btn .mark {
    width: 22px;
    height: 22px;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.16);
  }

  body.is-recording {
    height: 100dvh;
    overflow: hidden;
  }

  body.is-recording .wrap {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  body.is-recording .live {
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 12px;
    overflow: auto;
  }

  body.is-recording .record-btn {
    position: static;
    width: 100%;
    flex: none;
    margin-top: auto;
  }

  .timer { font-size: clamp(2.6rem, 16vw, 4rem); }

  .section-title { font-size: 1.4rem; margin-top: 18px; }

  input, textarea { font-size: 16px; }

  .primary { width: 100%; }

  .text-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .person {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  audio { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .record-btn.is-live { animation: none; }
}
