@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root{
  --ink: #14121c;
  --ink-2: #1c1926;
  --panel: #211d2e;
  --panel-2: #2a2438;
  --line: #3a3350;
  --cream: #f1ece1;
  --cream-dim: #b9b3c4;
  --gold: #cf9f5a;
  --gold-bright: #e6bd7e;
  --violet: #8f7fd9;
  --violet-dim: #6a5fa3;
  --green: #7fbf9e;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0,0,0,0.35);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(143,127,217,0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(207,159,90,0.10), transparent 60%),
    var(--ink);
  color: var(--cream);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

::selection{ background: var(--violet-dim); color: white; }

/* ---------- Layout shell ---------- */
.app-shell{
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar{
  background: var(--ink-2);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand{
  display:flex; flex-direction:column; gap:2px;
}
.brand .mark{
  font-family:'Fraunces', serif;
  font-size: 1.5rem;
  font-weight:600;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
}
.brand .sub{
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.nav-index{ display:flex; flex-direction:column; gap:6px; }
.nav-item{
  display:flex; align-items:center; gap:12px;
  padding: 12px 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s ease;
  color: var(--cream-dim);
}
.nav-item .num{
  font-family:'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--violet);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  min-width: 28px;
  text-align: center;
}
.nav-item .label{ font-size: 0.92rem; font-weight:500; }
.nav-item .flag{ margin-left:auto; font-size:0.9rem; opacity:.7; }
.nav-item:hover{ background: var(--panel); color: var(--cream); }
.nav-item.active{
  background: linear-gradient(135deg, rgba(207,159,90,0.14), rgba(143,127,217,0.14));
  border-color: var(--gold);
  color: var(--cream);
}
.nav-item.active .num{ background: var(--gold); color: var(--ink); border-color: var(--gold); }

.sidebar-foot{
  margin-top: auto;
  font-size: 0.72rem;
  color: var(--cream-dim);
  opacity: .7;
  line-height:1.5;
}

/* ---------- Main ---------- */
.main{
  padding: 40px 56px 100px;
  max-width: 980px;
}
.eyebrow{
  font-family:'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 10px;
}
h1.page-title{
  font-family: 'Fraunces', serif;
  font-size: clamp(2rem, 4vw, 2.9rem);
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--cream);
}
.page-tagline{
  color: var(--cream-dim);
  font-size: 1.02rem;
  margin-bottom: 36px;
  max-width: 640px;
}

/* Dashboard hero */
.hero-rotator{
  font-family:'Fraunces', serif;
  font-style: italic;
  font-size: 1.3rem;
  color: var(--gold-bright);
  min-height: 2.2em;
  margin-bottom: 28px;
}
.dash-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 10px;
}
.dash-card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  cursor:pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.dash-card:hover{ transform: translateY(-3px); border-color: var(--gold); }
.dash-card .num{
  font-family:'JetBrains Mono', monospace;
  color: var(--violet);
  font-size: 0.8rem;
}
.dash-card h3{
  font-family:'Fraunces', serif;
  margin: 8px 0 6px;
  font-size: 1.3rem;
}
.dash-card p{ color: var(--cream-dim); font-size: 0.9rem; margin:0; }

/* Lesson content */
.lesson-section{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-bottom: 22px;
}
.lesson-section h2{
  font-family:'Fraunces', serif;
  color: var(--gold-bright);
  font-size: 1.4rem;
  margin-top:0;
  display:flex; align-items:center; gap:10px;
}
.lesson-section h3{
  color: var(--cream);
  font-size: 1.05rem;
  margin: 22px 0 8px;
}
.lesson-section p{ color: var(--cream-dim); }
.lesson-section table{
  width:100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 0.92rem;
}
.lesson-section th{
  text-align:left;
  color: var(--violet);
  font-weight:600;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing:.04em;
}
.lesson-section td{
  padding: 9px 10px;
  border-bottom: 1px solid rgba(58,51,80,0.5);
  color: var(--cream);
}
.lesson-section td.tr{ color: var(--cream-dim); font-style:italic; }
.lesson-section td.pron{ color: var(--green); font-family:'JetBrains Mono', monospace; font-size:0.82rem; }
.lesson-section code, .lesson-section pre{
  font-family:'JetBrains Mono', monospace;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.lesson-section pre{ padding: 14px; overflow-x:auto; font-size: 0.85rem; line-height:1.5; }
.lesson-section code{ padding: 2px 6px; font-size: 0.88em; }
.callout{
  border-left: 3px solid var(--gold);
  background: rgba(207,159,90,0.08);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 14px 0;
  font-size: 0.92rem;
  color: var(--cream);
}

/* Speak button */
.speak-btn{
  margin-left:auto;
  display:inline-flex; align-items:center; gap:6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--cream-dim);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor:pointer;
  transition: all .15s ease;
}
.speak-btn:hover{ border-color: var(--violet); color: var(--cream); }
.speak-btn.speaking{ border-color: var(--gold); color: var(--gold-bright); }

/* Practice exercise box */
.practice-box{
  background: var(--ink-2);
  border: 1px dashed var(--violet-dim);
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 14px;
}
.practice-box .practice-label{
  font-family:'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--violet);
  text-transform:uppercase;
  letter-spacing:.08em;
}
.practice-box button{
  margin-top:10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  border:none;
  color: var(--ink);
  font-weight:600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor:pointer;
  font-size: 0.85rem;
}

/* ---------- Chatbot ---------- */
.chat-toggle{
  position: fixed;
  bottom: 28px; right: 28px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--gold));
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 1.5rem;
  z-index: 40;
  color: white;
}
.chat-panel{
  position: fixed;
  bottom: 100px; right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
}
.chat-panel.open{ display:flex; }
.chat-head{
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display:flex; align-items:center; gap:10px;
  background: var(--ink-2);
}
.chat-head .dot{ width:8px; height:8px; border-radius:50%; background: var(--green); }
.chat-head .title{ font-family:'Fraunces', serif; font-weight:600; color: var(--gold-bright); }
.chat-head .lang-select{
  margin-left:auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 0.75rem;
  border-radius: 6px;
  padding: 4px 6px;
}
.chat-body{
  flex:1;
  overflow-y:auto;
  padding: 16px 18px;
  display:flex; flex-direction:column; gap:12px;
}
.msg{
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height:1.5;
  white-space: pre-wrap;
}
.msg.bot{ background: var(--ink-2); align-self:flex-start; border: 1px solid var(--line); }
.msg.user{ background: var(--violet-dim); align-self:flex-end; color:white; }
.msg.typing{ color: var(--cream-dim); font-style:italic; }
.chat-input-row{
  display:flex; gap:8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--ink-2);
}
.chat-input-row textarea{
  flex:1;
  resize:none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--cream);
  border-radius: 10px;
  padding: 9px 12px;
  font-family:'Inter', sans-serif;
  font-size: 0.88rem;
  height: 42px;
}
.chat-input-row button{
  background: var(--gold);
  border:none;
  border-radius: 10px;
  padding: 0 16px;
  font-weight:600;
  cursor:pointer;
  color: var(--ink);
}
#mic-btn{
  background: var(--panel-2);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 42px;
  padding: 0;
  font-size: 1.1rem;
  cursor:pointer;
}
#mic-btn.recording{
  background: #c0554f;
  color: white;
  border-color: #c0554f;
  animation: pulse 1s infinite;
}
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(192,85,79,0.5); }
  70%{ box-shadow: 0 0 0 8px rgba(192,85,79,0); }
  100%{ box-shadow: 0 0 0 0 rgba(192,85,79,0); }
}
.chat-head .lang-select{ width: auto; }
.chat-icon-btn{
  margin-left: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--cream);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 0.95rem;
}
.setup-banner{
  background: rgba(207,159,90,0.1);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--cream-dim);
  margin: 10px 14px 0;
}

@media (max-width: 800px){
  .app-shell{ grid-template-columns: 1fr; }
  .sidebar{ position: static; height: auto; flex-direction: row; overflow-x:auto; }
  .nav-index{ flex-direction: row; }
  .nav-item .label{ display:none; }
  .main{ padding: 24px 18px 100px; }
  .dash-grid{ grid-template-columns: 1fr; }
  .chat-panel{ width: calc(100vw - 24px); right: 12px; }
}
