:root {
  --soil:   #2C1A0E;
  --bark:   #4A2C17;
  --leaf:   #3B6E35;
  --sprout: #6BAF5E;
  --wheat:  #D4A843;
  --cream:  #F5EDD8;
  --fog:    #EDE5CF;
  --text:   #1C1208;
  --muted:  #7A6040;
  --white:  #FFFDF7;
  --r: 12px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream); color: var(--text); min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 10% 20%, rgba(107,175,94,0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 90% 80%, rgba(212,168,67,0.10) 0%, transparent 55%);
}
.page { max-width: 960px; margin: 0 auto; padding: 56px 24px 80px; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 40px; display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: var(--leaf); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { opacity: 0.5; }

.hero { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 24px; margin-bottom: 44px; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--leaf); color: #fff; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 12px; border-radius: 100px; margin-bottom: 14px; }
.hero-badge::before { content: "●"; font-size: 8px; animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
h1 { font-family: 'Playfair Display', serif; font-size: clamp(30px,5vw,50px); line-height: 1.12; color: var(--soil); margin-bottom: 12px; }
h1 em { color: var(--leaf); font-style: normal; }
.hero-sub { font-size: 15px; color: var(--muted); max-width: 480px; line-height: 1.65; }
.lang-pills { display: flex; gap: 8px; margin-top: 16px; }
.lang-pill { background: var(--fog); border: 1.5px solid rgba(74,44,23,0.15); border-radius: 100px; padding: 4px 14px; font-size: 13px; color: var(--bark); }
.hero-icon { width: 88px; height: 88px; background: var(--bark); border-radius: 22px; display: flex; align-items: center; justify-content: center; font-size: 40px; flex-shrink: 0; box-shadow: 0 8px 32px rgba(44,26,14,0.18); }

.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 28px; }
.mode-tab { border: 2px solid transparent; background: var(--white); border-radius: var(--r); padding: 20px 22px; cursor: pointer; transition: all 0.2s; text-align: left; box-shadow: 0 2px 12px rgba(44,26,14,0.07); position: relative; overflow: hidden; }
.mode-tab::before { content:''; position:absolute; inset:0; opacity:0; transition: opacity 0.2s; }
.mode-tab.chat-tab::before  { background: linear-gradient(135deg, rgba(59,110,53,0.06), transparent); }
.mode-tab.voice-tab::before { background: linear-gradient(135deg, rgba(212,168,67,0.08), transparent); }
.mode-tab:hover { box-shadow: 0 4px 20px rgba(44,26,14,0.12); transform: translateY(-2px); }
.mode-tab:hover::before, .mode-tab.active::before { opacity: 1; }
.mode-tab.active.chat-tab  { border-color: var(--leaf);  box-shadow: 0 0 0 4px rgba(59,110,53,0.10),  0 4px 20px rgba(44,26,14,0.10); }
.mode-tab.active.voice-tab { border-color: var(--wheat); box-shadow: 0 0 0 4px rgba(212,168,67,0.12), 0 4px 20px rgba(44,26,14,0.10); }
.tab-icon  { font-size: 26px; margin-bottom: 8px; display: block; }
.tab-title { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--soil); margin-bottom: 4px; }
.tab-desc  { font-size: 13px; color: var(--muted); line-height: 1.5; }
.tab-langs { margin-top: 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.mode-tab.active.chat-tab  .tab-langs { color: var(--leaf); }
.mode-tab.active.voice-tab .tab-langs { color: var(--wheat); }

.panel { background: var(--white); border-radius: var(--r); box-shadow: 0 4px 28px rgba(44,26,14,0.09); overflow: hidden; border: 1.5px solid rgba(74,44,23,0.08); animation: panelIn 0.28s ease; }
@keyframes panelIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.panel-header { padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(74,44,23,0.08); flex-wrap: wrap; gap: 8px; }
.panel-header-left { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--bark); flex-wrap: wrap; }
.header-right { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sprout); animation: blink 2s infinite; flex-shrink: 0; }
.memory-badge { font-size: 11px; color: var(--muted); background: var(--fog); padding: 2px 10px; border-radius: 100px; border: 1px solid rgba(74,44,23,0.12); font-weight: 400; }

/* Language toggle pill */
.lang-toggle { display: flex; background: var(--fog); border-radius: 8px; padding: 3px; border: 1px solid rgba(74,44,23,0.14); gap: 2px; }
.ltbtn { padding: 4px 12px; border: none; background: none; border-radius: 6px; font-family: inherit; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; transition: all 0.15s; line-height: 1; white-space: nowrap; }
.ltbtn.active { background: var(--white); color: var(--soil); box-shadow: 0 1px 4px rgba(44,26,14,0.12); }
.ltbtn:hover:not(.active) { color: var(--bark); }

.clear-btn { background: none; border: 1px solid rgba(74,44,23,0.15); border-radius: 6px; padding: 4px 12px; font-size: 12px; color: var(--muted); cursor: pointer; font-family: inherit; transition: all 0.15s; }
.clear-btn:hover { background: var(--fog); }

/* Chat messages */
.chat-messages { height: 430px; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(74,44,23,0.15); border-radius: 3px; }
.msg { display: flex; gap: 10px; max-width: 84%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.msg.bot  .msg-avatar { background: var(--soil); }
.msg.user .msg-avatar { background: var(--leaf); }
.msg-bubble { padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.7; }
.msg.bot  .msg-bubble { background: var(--cream); color: var(--text); border-bottom-left-radius: 4px; }
.msg.user .msg-bubble { background: var(--leaf);  color: #fff;        border-bottom-right-radius: 4px; }
.msg-bubble.streaming::after { content: '▋'; animation: blink 0.65s infinite; font-size: 12px; opacity: 0.7; }
.msg-time { font-size: 10px; color: var(--muted); margin-top: 3px; opacity: 0.65; }
.msg.user .msg-time { text-align: right; }
.typing-indicator { display: flex; gap: 4px; align-items: center; padding: 11px 15px; background: var(--cream); border-radius: 14px; border-bottom-left-radius: 4px; }
.typing-dot { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }
.history-divider { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 6px; opacity: 0.65; }

/* Chat input */
.chat-input-row { padding: 12px 16px; border-top: 1px solid rgba(74,44,23,0.08); display: flex; gap: 9px; align-items: flex-end; background: var(--fog); }
.chat-input { flex: 1; border: 1.5px solid rgba(74,44,23,0.15); border-radius: 10px; padding: 11px 15px; font-family: inherit; font-size: 14px; resize: none; background: var(--white); color: var(--text); outline: none; transition: border-color 0.2s; line-height: 1.5; max-height: 120px; }
.chat-input:focus { border-color: var(--leaf); }
.chat-input::placeholder { color: var(--muted); opacity: 0.65; }
.chat-input:disabled, .send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn { width: 42px; height: 42px; background: var(--leaf); border: none; border-radius: 10px; color: #fff; font-size: 17px; cursor: pointer; flex-shrink: 0; transition: background 0.2s, transform 0.15s; display: flex; align-items: center; justify-content: center; }
.send-btn:hover:not(:disabled) { background: var(--soil); transform: scale(1.05); }

/* Voice */
.voice-area { padding: 36px 24px; display: flex; flex-direction: column; align-items: center; gap: 20px; min-height: 420px; justify-content: center; }
.voice-lang-hint { font-size: 13px; color: var(--muted); background: var(--fog); padding: 5px 18px; border-radius: 100px; border: 1px solid rgba(74,44,23,0.12); }
.voice-lang-hint strong { color: var(--leaf); }
.voice-ring { position: relative; width: 138px; height: 138px; }
.voice-btn-wrap { position: absolute; inset: 0; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--wheat); opacity: 0; }
.voice-btn-wrap.listening .ring:nth-child(1) { animation: ringOut 1.6s infinite 0s; }
.voice-btn-wrap.listening .ring:nth-child(2) { animation: ringOut 1.6s infinite 0.4s; }
.voice-btn-wrap.listening .ring:nth-child(3) { animation: ringOut 1.6s infinite 0.8s; }
@keyframes ringOut { 0%{opacity:0.6;transform:scale(0.8)} 100%{opacity:0;transform:scale(1.7)} }
.voice-btn { position: absolute; inset: 20px; background: var(--bark); border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 34px; color: #fff; transition: background 0.2s, transform 0.15s; box-shadow: 0 8px 28px rgba(44,26,14,0.22); }
.voice-btn:hover { background: var(--soil); transform: scale(1.05); }
.voice-btn.active { background: #C0392B; animation: glow 1s infinite alternate; }
@keyframes glow { from{box-shadow:0 0 0 0 rgba(192,57,43,0.4)} to{box-shadow:0 0 0 14px rgba(192,57,43,0)} }
.voice-status { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--soil); text-align: center; }
.voice-sub { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.6; max-width: 300px; }
.voice-transcripts { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.voice-transcript-box { background: var(--cream); border-radius: 10px; padding: 12px 16px; min-height: 55px; font-size: 14px; line-height: 1.65; color: var(--text); border: 1.5px solid rgba(74,44,23,0.10); }
.voice-transcript-box.reply { background: rgba(59,110,53,0.07); border-color: rgba(59,110,53,0.2); }
.transcript-label { font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.transcript-label.green { color: var(--leaf); }

.tip-bar { margin-top: 18px; background: rgba(59,110,53,0.07); border: 1px solid rgba(59,110,53,0.18); border-radius: 10px; padding: 11px 16px; font-size: 13px; color: var(--muted); display: flex; align-items: flex-start; gap: 8px; line-height: 1.55; }
.tip-bar strong { color: var(--leaf); }
.config-note { margin-top: 12px; font-size: 11.5px; color: var(--muted); text-align: center; opacity: 0.65; }
.config-note code { background: var(--fog); padding: 1px 6px; border-radius: 4px; font-family: monospace; font-size: 11px; color: var(--bark); }

@media (max-width: 600px) {
  .hero { grid-template-columns: 1fr; }
  .hero-icon { display: none; }
  .mode-tabs { grid-template-columns: 1fr; }
  .chat-messages { height: 300px; }
}
