:root {
  --bg: #eef3ee;
  --header: #2e7d5b;
  --assistant-bubble: #ffffff;
  --user-bubble: #cdeec2;
  --text: #22302a;
  --muted: #7d8a83;
  --accent: #2e7d5b;
  --danger: #c0564f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
}

.app-title { font-weight: 700; font-size: 17px; letter-spacing: .05em; }

.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  padding: 4px 8px;
  cursor: pointer;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  display: flex;
  margin-bottom: 10px;
}

.msg .bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}

.msg.assistant { justify-content: flex-start; }
.msg.assistant .bubble {
  background: var(--assistant-bubble);
  border-top-left-radius: 4px;
}

.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble);
  border-top-right-radius: 4px;
}

.msg.system { justify-content: center; }
.msg.system .bubble {
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.msg.pending .bubble { opacity: .6; }

.typing .bubble::after {
  content: "…";
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: .3; } }

.input-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: #f7faf7;
  border-top: 1px solid #dde5de;
}

.input-bar input {
  flex: 1;
  border: 1px solid #ccd6cf;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 16px;
  background: #fff;
  outline: none;
  min-width: 0;
}
.input-bar input:focus { border-color: var(--accent); }

.mic-btn, .send-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}

.mic-btn.recording {
  background: var(--danger);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192,86,79,.5); }
  70% { box-shadow: 0 0 0 12px rgba(192,86,79,0); }
  100% { box-shadow: 0 0 0 0 rgba(192,86,79,0); }
}

.mic-btn:disabled { background: #b8c4bc; cursor: default; }

/* 設定パネル */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 10;
}

.settings {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(320px, 85vw);
  background: #fff;
  z-index: 11;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px 18px;
  overflow-y: auto;
  box-shadow: -2px 0 12px rgba(0,0,0,.15);
}

.settings h2 { font-size: 15px; margin: 18px 0 10px; color: var(--accent); }
.settings h2:first-child { margin-top: 0; }

.settings label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.settings input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font-size: 15px;
  border: 1px solid #ccd6cf;
  border-radius: 8px;
  color: var(--text);
}

.settings-actions { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }

.settings button {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #ccd6cf;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}
.settings button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.archive-list { font-size: 13.5px; }
.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eef1ee;
}
.archive-item .t { flex: 1; word-break: break-word; }
.archive-item button {
  flex: none;
  font-size: 12px;
  padding: 5px 10px;
}

.version { color: var(--muted); font-size: 11px; margin-top: 24px; text-align: center; }

.hidden { display: none; }
