:root {
  --bg: #14110f;
  --bg-card: #1e1a17;
  --text: #f2ece3;
  --text-dim: #b8ada0;
  --accent: #e8b877;
  --accent-soft: rgba(232, 184, 119, 0.15);
  --border: #332c26;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #241d17 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 100px;
}

header {
  position: relative;
  text-align: center;
  margin-bottom: 20px;
  padding: 32px 16px 22px;
  border-radius: 20px;
  overflow: hidden;
}

header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('/img/miyu-hero.jpg');
  background-size: cover;
  background-position: center 32%;
  filter: blur(20px) brightness(0.5) saturate(1.05);
  transform: scale(1.15);
  z-index: 0;
}

header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(20, 17, 15, 0.25), var(--bg) 92%);
  z-index: 1;
}

header h1,
header .subtitle {
  position: relative;
  z-index: 2;
}

header h1 {
  font-weight: 500;
  font-size: 1.6rem;
  margin: 0;
}

header h1 span {
  color: var(--accent);
  font-weight: 300;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 4px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.starter {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}

.starter:hover { background: rgba(232, 184, 119, 0.28); }
.starter:active { transform: scale(0.97); }

.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

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

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: fadeInUp 0.35s ease both;
}

.msg-row.user {
  justify-content: flex-end;
}

.avatar {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-image: url('/img/miyu-avatar.png');
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px rgba(232, 184, 119, 0.35);
}

.msg {
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.55;
  max-width: 85%;
  white-space: pre-wrap;
}

.msg.user {
  background: var(--accent);
  color: #1a140c;
}

.msg.assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.msg strong { color: var(--accent); }
.msg.user strong { color: #1a140c; }

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.3s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.closing-card {
  border: 1px solid rgba(232, 184, 119, 0.45);
  border-radius: 14px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(232, 184, 119, 0.1), rgba(232, 184, 119, 0.02));
  max-width: 85%;
}

.closing-date {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.closing-row {
  margin-bottom: 12px;
  line-height: 1.5;
}

.closing-row:last-child { margin-bottom: 0; }

.closing-label {
  display: block;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  margin-bottom: 2px;
}

.closing-value {
  color: var(--text);
}

.composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
}

.composer-inner textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

.composer button, #save-button {
  background: var(--accent);
  color: #1a140c;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.composer button#mic {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0;
  width: 44px;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.composer button#mic.listening {
  background: rgba(215, 90, 90, 0.35);
  border-color: #d75a5a;
  animation: micPulse 1.2s infinite;
}

.composer button#mic.transcribing {
  opacity: 0.55;
  cursor: wait;
  animation: none;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215, 90, 90, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(215, 90, 90, 0); }
}

#save-panel input, #save-panel textarea {
  width: 100%;
  margin-top: 10px;
  background: #14110f;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
}

#save-button {
  margin-top: 12px;
  padding: 10px 16px;
}

.hidden { display: none; }

#save-panel {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#save-panel.visible {
  opacity: 1;
  transform: translateY(0);
}

#save-status { color: var(--accent); font-size: 0.85rem; }
