:root {
  --bg: #faf6ef;
  --bg-warm: #f6ead8;
  --fg: #2b2520;
  --muted: #8a7f75;
  --accent: #c4654a;
  --accent-soft: #e8a897;
  --accent-warm: #d4a97a;
  --border: #ece4d7;
  --card: #fffdf9;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(228, 178, 138, 0.35), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(212, 169, 122, 0.18), transparent 60%);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  font-size: 1.6rem;
  line-height: 1;
  display: inline-block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(196, 101, 74, 0.2));
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ===== Signed-in header: status chip + close icon ===== */
.user-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--fg);
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a8a3e;
  box-shadow: 0 0 0 3px rgba(42, 138, 62, 0.15);
}

.close-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.close-btn:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--bg-warm);
  transform: rotate(90deg);
}

.close-btn:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* ===== Landing (signed-out) ===== */
#landing {
  display: flex;
  justify-content: center;
  padding: 2rem 0 3rem;
}

.landing-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.75rem 2.25rem 2rem;
  box-shadow: 0 12px 40px -22px rgba(196, 101, 74, 0.35);
  animation: riseIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.landing-emblem {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 150px;
  height: 150px;
  margin: 0 auto 1.25rem;
  filter: drop-shadow(0 6px 16px rgba(196, 101, 74, 0.25));
}

.emblem-decoration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.emblem-glyph {
  position: relative;
  z-index: 1;
  font-size: 4.25rem;
  line-height: 1;
}

.landing-title {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.landing-copy {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.landing-poem {
  margin: 0.25rem 0 1.25rem;
  font-family: var(--serif);
  color: #4a3f37;
  font-size: 1rem;
  line-height: 1.85;
  text-align: center;
}

.landing-poem p {
  margin: 0 0 0.75rem;
}

.landing-poem p:last-child {
  margin-bottom: 0;
}

.landing-poem .stanza {
  margin: 1.15rem auto;
  padding: 0.1rem 0;
}

.landing-poem .stanza p {
  margin: 0 0 0.2rem;
  color: #5a4a40;
}

.landing-poem .closing {
  font-style: italic;
  color: var(--accent);
}

.landing-poem .closing + .closing {
  margin-top: 0;
}

.ornament {
  margin: 0.25rem 0 1.75rem;
  color: var(--accent-soft);
  font-size: 0.95rem;
  opacity: 0.65;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.google-btn:hover {
  box-shadow: 0 2px 6px rgba(60, 64, 67, 0.15);
  border-color: #c6cacd;
  color: #3c4043;
}

.google-btn:active {
  background: #f7f8f8;
}

.google-g {
  flex-shrink: 0;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.55rem 1.1rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.install-btn:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--bg-warm);
}

.signout-btn {
  padding: 0.4rem 0.85rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.signout-btn:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--card);
}

.landing-footnote {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ===== iOS install instructions ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ios-install {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.25rem;
  background: rgba(43, 37, 32, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease both;
}

.ios-install-card {
  position: relative;
  max-width: 360px;
  width: 100%;
  background: var(--card);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: 0 20px 60px -20px rgba(43, 37, 32, 0.35);
  animation: riseIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.ios-install-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.ios-install-close:hover {
  color: var(--accent);
  background: var(--bg-warm);
}

.ios-install-glyph {
  font-size: 2.25rem;
  line-height: 1;
  text-align: center;
  margin-bottom: 0.75rem;
}

.ios-install-title {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  text-align: center;
}

.ios-install-copy {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.93rem;
  text-align: center;
}

.ios-install-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--fg);
}

.ios-install-steps li {
  margin-bottom: 0.45rem;
}

.ios-install-note {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
}

button {
  font: inherit;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.primary:hover:not(:disabled) {
  background: #b35741;
  color: #fff;
}

button.primary.recording {
  background: var(--accent);
  border-color: var(--accent);
  animation: breath 3.2s ease-in-out infinite;
}

@keyframes breath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 101, 74, 0.38); }
  50%      { box-shadow: 0 0 0 16px rgba(196, 101, 74, 0); }
}

/* ===== Record button (primary, icon + label) ===== */
.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  font-weight: 500;
}

.record-btn .icon-mic {
  transition: transform 0.2s ease;
}

.record-btn:hover .icon-mic {
  transform: scale(1.08);
}

#user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.lang-btn {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.5rem 1.1rem;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

.lang-btn.active:hover {
  color: #fff;
}

.prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  padding-left: 0.25rem;
}

#transcript-box {
  min-height: 240px;
  padding: 1.5rem 1.6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.75;
  outline: none;
  white-space: pre-wrap;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.03),
              0 8px 24px -18px rgba(196, 101, 74, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#transcript-box:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.03),
              0 8px 24px -14px rgba(196, 101, 74, 0.35);
}

#transcript-box:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-style: italic;
  pointer-events: none;
}

.interim {
  color: var(--muted);
  font-style: italic;
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.4em;
}

.status.error { color: #c0392b; }
.status.success { color: #2a8a3e; }

/* ===== Past Gratitude Logs ===== */
.history-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.history-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 auto;
  padding: 0.4rem 0.75rem;
  background: transparent;
  color: var(--muted);
  border: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
}

.history-toggle:hover {
  color: var(--accent);
  background: transparent;
}

.chevron {
  transition: transform 0.25s ease;
}

.history-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

#history-panel {
  margin-top: 1.25rem;
  animation: riseIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.history-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.history-label input[type="date"] {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.history-label input[type="date"]:focus {
  outline: none;
  border-color: var(--accent-soft);
}

.history-entries {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.entry-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.03),
              0 8px 24px -20px rgba(196, 101, 74, 0.2);
}

.entry-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border);
}


.entry-lang {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-warm);
  color: #7a4a35;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.entry-text {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.9;
  margin: 0;
  color: #3d342c;
}

.poem-line {
  display: block;
  padding-left: 0.25rem;
  border-left: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.entry-card:hover .poem-line {
  border-left-color: var(--accent-soft);
}

.poem-line + .poem-line {
  margin-top: 0.15rem;
}

.poem-line:first-child::first-letter {
  font-size: 1.3em;
  color: var(--accent);
  font-weight: 500;
  margin-right: 0.05em;
}

.history-empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 1.5rem 0;
  font-family: var(--serif);
}

.history-empty.error { color: #b74934; font-style: normal; }

/* ===== Document pages (privacy / terms) ===== */
.doc {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
  line-height: 1.7;
}
.doc h1 { font-size: 1.75rem; margin: 0 0 0.25rem; }
.doc .updated { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }
.doc h2 { font-size: 1.15rem; margin-top: 2rem; margin-bottom: 0.5rem; }
.doc p, .doc li { color: #3b3b3b; }
.doc ul { padding-left: 1.25rem; }
.doc a { color: var(--accent); }
.doc .back { display: inline-block; margin-top: 2rem; color: var(--muted); font-size: 0.9rem; }

