:root {
  --ink: #0D1321;
  --panel: #161F2F;
  --panel-border: #26314A;
  --amber: #E8A33D;
  --amber-soft: #3A2E1A;
  --up: #4FA37D;
  --down: #C1553D;
  --text: #EDEEF0;
  --text-body: #C9CEDA;
  --muted: #8B93A3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

h1, h2, .brand, .card-title, .lora {
  font-family: 'Lora', serif;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #16223A 0%, var(--ink) 60%);
}
.login-box { max-width: 420px; width: 100%; text-align: center; }
.login-eyebrow { font-family: 'Lora'; font-weight: 600; font-size: 14px; color: var(--amber); margin-bottom: 14px; }
.login-title { font-family: 'Lora'; font-weight: 700; font-size: 40px; margin: 0 0 14px; line-height: 1.15; }
.login-sub { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0 0 34px; }
.google-btn {
  width: 100%; background: var(--text); color: #151515; border: none; border-radius: 10px;
  padding: 13px 20px; font-size: 14.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.google-dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  background: conic-gradient(from 90deg, #4285F4, #34A853, #FBBC05, #EA4335, #4285F4); }
.login-terms { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13,19,33,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--panel-border);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.brand { font-weight: 700; font-size: 18px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--amber-soft); color: var(--amber);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.logout-btn { background: transparent; border: none; color: var(--muted); font-size: 13px; }
.back-btn { background: transparent; border: none; color: var(--muted); display: flex; }

/* ---------- Dashboard ---------- */
.dash-main { max-width: 1040px; margin: 0 auto; padding: 32px 24px 100px; }
.continue-card {
  background: linear-gradient(120deg, #1B2740 0%, var(--panel) 100%);
  border: 1px solid var(--panel-border); border-radius: 10px; padding: 22px 24px; margin-bottom: 30px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.continue-label { font-size: 12px; color: var(--amber); font-weight: 600; margin-bottom: 6px; }
.continue-title { font-family: 'Lora'; font-size: 19px; font-weight: 600; }
.resume-btn { background: var(--amber); border: none; border-radius: 8px; padding: 10px 18px; color: #241A08; font-weight: 600; font-size: 13.5px; }

.section-label { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; letter-spacing: .3px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.module-card {
  text-align: left; background: var(--panel); border: 1px solid var(--panel-border);
  border-left: 3px solid var(--mc, var(--amber)); border-radius: 8px; padding: 18px 18px 16px;
  display: flex; flex-direction: column; gap: 10px; transition: border-color .15s ease;
}
.module-card:hover { border-color: var(--mc, var(--amber)); }
.module-tag { font-size: 11px; color: var(--mc, var(--amber)); font-weight: 600; letter-spacing: .3px; }
.module-title { font-family: 'Lora'; font-weight: 600; font-size: 17.5px; line-height: 1.3; }
.module-blurb { font-size: 13px; color: var(--muted); line-height: 1.5; }
.progress-track { height: 4px; background: #1E2740; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--mc, var(--amber)); }
.progress-text { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ---------- Reader ---------- */
.reader-header-title { font-family: 'Lora'; font-size: 16px; font-weight: 600; }
.reader-body { max-width: 1040px; margin: 0 auto; padding: 28px 24px 100px; display: grid; grid-template-columns: 230px 1fr; gap: 28px; }
.topic-nav { display: flex; flex-direction: column; gap: 8px; }
.topic-btn { text-align: left; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 9px 11px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.topic-btn.active { background: #1F2A3D; color: var(--text); }
.topic-content h2 { font-family: 'Lora'; font-weight: 700; font-size: 26px; margin: 0 0 18px; line-height: 1.25; }
.topic-content p { color: var(--text-body); font-size: 15px; line-height: 1.75; margin: 0 0 16px; max-width: 640px; }
.ask-assistant-btn {
  margin-top: 8px; background: transparent; border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 9px 14px; color: var(--amber); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
}

@media (max-width: 720px) {
  .reader-body { grid-template-columns: 1fr; }
}

/* ---------- Chat ---------- */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; width: 54px; height: 54px; border-radius: 50%;
  background: var(--amber); border: none; color: #241A08; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35); z-index: 40;
}
.chat-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5,7,12,0.55); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.chat-overlay.open { opacity: 1; pointer-events: auto; }
.chat-drawer {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(420px, 100%);
  background: var(--panel); border-left: 1px solid var(--panel-border);
  transform: translateX(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.chat-overlay.open .chat-drawer { transform: translateX(0); }
.chat-head { padding: 18px 20px; border-bottom: 1px solid var(--panel-border); display: flex; align-items: center; justify-content: space-between; }
.chat-head-title { font-family: 'Lora'; font-size: 17px; font-weight: 600; }
.chat-head-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chat-close { background: transparent; border: none; color: var(--muted); padding: 6px; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 85%; border-radius: 10px; padding: 10px 13px; font-size: 13.5px; line-height: 1.5; border: 1px solid var(--panel-border); }
.chat-msg.user { align-self: flex-end; background: var(--amber-soft); border-color: #5A431F; }
.chat-msg.assistant { align-self: flex-start; background: #1F2A3D; }
.chat-foot { padding: 16px; border-top: 1px solid var(--panel-border); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input { flex: 1; background: var(--ink); border: 1px solid var(--panel-border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 13.5px; }
.chat-send { background: var(--amber); border: none; border-radius: 8px; padding: 0 16px; color: #241A08; font-weight: 600; font-size: 13.5px; }
.chat-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }
