:root {
  --wood: #1f1812;
  --wood-2: #2b2118;
  --parchment: #f3e1b9;
  --parchment-2: #ecdcba;
  --ink: #2a2118;
  --sepia: #5b4631;
  --brass: #b8914c;
  --brass-hi: #e2c27f;
  --brass-lo: #7a5a26;
  --glow: #9fe7ff;
  --danger: #b4483a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at top, #3a2c1f 0%, var(--wood) 60%) fixed, var(--wood);
  color: var(--parchment);
  font-family: Georgia, 'Times New Roman', serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.screen {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
.orn { color: var(--brass); }
.muted { color: #b8a581; font-style: italic; }
.error { color: #ffb4a6; min-height: 1.2em; }

/* sign-in */
#signin { display: flex; align-items: center; justify-content: center; }
.card {
  width: 100%; text-align: center; padding: 28px 20px;
  background: var(--parchment); color: var(--ink);
  border: 3px double var(--brass-lo); border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.signin-face { width: 140px; height: 150px; object-fit: cover; border-radius: 50%; border: 3px solid var(--brass); }
.card h1 { letter-spacing: 8px; font-weight: normal; margin: 12px 0 4px; }
.card .sub { color: var(--sepia); font-style: italic; margin: 0 0 18px; }
.card input {
  width: 100%; font: inherit; font-size: 20px; text-align: center; letter-spacing: 6px;
  padding: 12px; border: 1px solid var(--brass-lo); border-radius: 4px; background: #fffaf0; color: var(--ink);
}
.card button { margin-top: 12px; width: 100%; }

/* buttons */
.brass-btn {
  font: inherit; font-size: 17px; letter-spacing: 1px; color: #2a1d0c; cursor: pointer;
  padding: 11px 22px; border: 1px solid var(--brass-lo); border-radius: 4px;
  background: linear-gradient(#ecd197, var(--brass) 60%, #9b7738);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 2px 6px rgba(0,0,0,.35);
}
.plain-btn {
  font: inherit; font-size: 17px; color: var(--parchment); cursor: pointer;
  padding: 11px 22px; border: 1px solid var(--brass); border-radius: 4px; background: transparent;
}
.icon-btn { background: none; border: 0; color: var(--brass-hi); font-size: 24px; cursor: pointer; padding: 6px 4px; }

/* header + menu */
.top { display: flex; align-items: center; justify-content: space-between; }
.title { letter-spacing: 6px; font-size: 15px; color: var(--brass-hi); }
.menu {
  position: absolute; right: 16px; z-index: 5; display: flex; flex-direction: column;
  background: var(--wood-2); border: 1px solid var(--brass-lo); border-radius: 6px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.menu a, .menu button {
  font: inherit; font-size: 15px; color: var(--parchment); text-decoration: none; text-align: left;
  padding: 12px 16px; background: none; border: 0; border-bottom: 1px solid #3d2f22; cursor: pointer;
}
.banner {
  margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--brass); border-radius: 4px;
  background: rgba(184,145,76,.12); font-size: 14px;
}
.banner a { color: var(--brass-hi); }

/* portrait */
.stage { text-align: center; margin-top: 10px; }
.portrait {
  width: 190px; height: 203px; margin: 0 auto; border-radius: 50% / 46%; overflow: hidden;
  border: 4px solid var(--brass); box-shadow: 0 0 0 3px #3a2a17, 0 12px 30px rgba(0,0,0,.55);
  background: var(--parchment); transition: box-shadow .3s;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; transition: opacity .25s; }
body.listening .portrait { box-shadow: 0 0 0 3px #3a2a17, 0 0 28px 6px rgba(159,231,255,.55); }
body.speaking .portrait { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.025); } }
.status { color: var(--brass-hi); font-style: italic; margin: 12px 0 0; min-height: 1.3em; }

/* conversation */
.exchange { min-height: 64px; margin: 10px 0 6px; text-align: center; }
.heard { color: #c9b58f; font-size: 14px; margin: 4px 0; }
.heard:not(:empty)::before { content: 'You: '; color: var(--brass); }
.reply { font-size: 18px; line-height: 1.45; margin: 6px 0; }
.confirm { display: flex; gap: 12px; justify-content: center; margin-top: 10px; }
.confirm button { min-width: 110px; }

/* mic */
.controls { text-align: center; }
.mic {
  width: 96px; height: 96px; border-radius: 50%; cursor: pointer; margin-top: 4px;
  border: 2px solid var(--brass-lo);
  background: radial-gradient(circle at 35% 30%, #f5dfa6, var(--brass) 45%, #6f5021 100%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.6), inset 0 -4px 8px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.5);
  display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation;
}
.mic svg { width: 42px; height: 42px; fill: #2a1d0c; }
body.listening .mic { background: radial-gradient(circle at 35% 30%, #ffd2c8, #d0604c 45%, #7d2a1e 100%); animation: pulse 1.2s infinite; }
body.busy .mic { opacity: .55; pointer-events: none; }
@keyframes pulse { 50% { box-shadow: inset 0 2px 3px rgba(255,255,255,.6), 0 0 0 12px rgba(208,96,76,.15), 0 6px 18px rgba(0,0,0,.5); } }
.hint { font-size: 13px; color: #b8a581; margin: 8px 0 12px; }
.type-form input {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; color: var(--parchment);
  background: rgba(0,0,0,.25); border: 1px solid #4a3a28; border-radius: 4px;
}

/* diary */
.diary {
  margin-top: 22px; background: var(--parchment); color: var(--ink);
  border: 3px double var(--brass-lo); border-radius: 4px; padding: 14px 16px;
}
.diary h2 { margin: 0 0 8px; text-align: center; font-weight: normal; font-size: 17px; letter-spacing: 3px; text-transform: uppercase; }
.day { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--sepia); margin: 12px 0 4px; border-bottom: 1px solid #c9b48c; padding-bottom: 3px; }
.entry { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dotted #b7a07a; }
.entry:last-child { border-bottom: 0; }
.entry .time { flex: 0 0 64px; font-weight: bold; color: var(--brass-lo); font-variant: small-caps; }
.entry .what small { display: block; color: var(--sepia); font-style: italic; }
.entry.reminder .what::before { content: '☐ '; color: var(--brass-lo); }
