:root {
  /* Your DNA Guide GREEN identity for Coach Hazel (validators stay pink #e8006e).
     Swap --hazel / --hazel-deep / --accent to your exact brand green anytime. */
  --bg: #f0f5f2;
  --panel: #ffffff;
  --ink: #1f2a24;
  --ink-soft: #566159;
  --hazel: #126433;
  --hazel-deep: #0c4423;
  --accent: #1e9e57;
  --student: #e4ede7;
  --sidebar: #e9f1ec;
  --line: #d6e3db;
  --radius: 16px;
  --font: "Fraunces", "Georgia", serif;
  --ui: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 18px; line-height: 1.6; }
.hidden { display: none !important; }

.avatar, .welcome-avatar {
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--hazel));
  color: #fff; font-family: var(--font); font-weight: bold;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.avatar img, .welcome-avatar img, .mini-avatar img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 18%;
}

/* ── Login ── */
.login-overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #f4f1ea, #e8dfce);
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 40px 36px; max-width: 440px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(94, 70, 48, 0.15);
}
.login-card .welcome-avatar { width: 64px; height: 64px; font-size: 30px; margin: 0 auto 16px; }
.login-card h1 { font-family: var(--font); color: var(--hazel-deep); margin: 0 0 10px; font-size: 28px; }
.login-card > p { color: var(--ink-soft); font-size: 17px; margin: 0 0 22px; }
.login-card label {
  display: block; text-align: left; font-size: 15px; font-weight: 600;
  color: var(--hazel-deep); margin-bottom: 14px;
}
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 13px 15px;
  font-size: 18px; font-family: var(--ui);
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-error { color: #a33; font-size: 15px; min-height: 18px; margin: 2px 0 8px; }
.primary-btn {
  width: 100%; background: var(--hazel); color: #fff; border: none; border-radius: 12px;
  padding: 15px; font-size: 18px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.primary-btn:hover { background: var(--hazel-deep); }
.login-note { font-size: 13px; color: var(--ink-soft); margin: 16px 0 0; }

/* ── App shell ── */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 288px; flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.sidebar-head .avatar { width: 40px; height: 40px; font-size: 20px; }
.sidebar-title { font-family: var(--font); font-size: 21px; color: var(--hazel-deep); }
.back-to-dash {
  display: block; margin: 0 16px 10px; padding: 4px 2px;
  font-size: 14px; color: var(--ink-soft); text-decoration: none;
}
.back-to-dash:hover { color: var(--hazel-deep); text-decoration: underline; }

.new-convo-btn {
  margin: 4px 16px 12px; padding: 12px; border: 1.5px solid var(--accent); border-radius: 12px;
  background: transparent; color: var(--hazel-deep); font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
}
.new-convo-btn:hover { background: var(--accent); color: #fff; }

.convo-list { flex: 1; overflow-y: auto; padding: 0 10px; display: flex; flex-direction: column; gap: 4px; }
.convo-item {
  display: flex; align-items: center; gap: 8px; text-align: left; width: 100%;
  padding: 11px 12px; border: none; border-radius: 10px; background: transparent;
  color: var(--ink); font-size: 15px; font-family: var(--ui); cursor: pointer;
}
.convo-item:hover { background: #e4dccc; }
.convo-item.active { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.convo-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-badge { color: #4a7c59; font-weight: bold; }

.sidebar-foot {
  border-top: 1px solid var(--line); padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.student-name { font-size: 15px; font-weight: 600; color: var(--hazel-deep); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--ink-soft); font-size: 14px; cursor: pointer; text-decoration: underline; flex-shrink: 0; }

/* ── Chat pane ── */
.chat-pane { flex: 1; display: flex; flex-direction: column; background: var(--panel); min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 22px;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fffdf9, #f9f5ee);
}
.menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--hazel-deep); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 { margin: 0; font-family: var(--font); font-size: 21px; color: var(--hazel-deep); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grounding { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grounding strong { color: var(--hazel); }
.resolve-btn {
  background: var(--panel); color: var(--hazel-deep); border: 1.5px solid var(--accent);
  border-radius: 999px; padding: 10px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s; white-space: nowrap;
}
.resolve-btn:hover { background: var(--accent); color: #fff; }
.resolve-btn:disabled { opacity: .5; cursor: default; }

.chat { flex: 1; overflow-y: auto; padding: 26px 22px 12px; display: flex; flex-direction: column; gap: 20px; }

.welcome { text-align: center; max-width: 560px; margin: 30px auto; color: var(--ink-soft); }
.welcome .welcome-avatar { width: 64px; height: 64px; font-size: 30px; margin: 0 auto 14px; }
.welcome h2 { font-family: var(--font); color: var(--hazel-deep); margin: 0 0 10px; font-size: 26px; }
.welcome p { font-size: 18px; }

.msg { display: flex; gap: 12px; max-width: 100%; }
.msg .bubble { padding: 14px 18px; border-radius: var(--radius); font-size: 18px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.hazel .bubble { background: #fbf8f2; border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.student { flex-direction: row-reverse; }
.msg.student .bubble { background: var(--student); border-top-right-radius: 4px; white-space: pre-wrap; }
.msg .mini-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--hazel));
  color: #fff; font-family: var(--ui); font-weight: 600; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.msg.student .mini-avatar { background: #b9ae99; }

.bubble h2 { font-family: var(--font); font-size: 20px; color: var(--hazel-deep); margin: 18px 0 6px; }
.bubble h2:first-child { margin-top: 0; }
.bubble strong { color: var(--hazel-deep); }
.bubble em { color: var(--ink-soft); }
.bubble p { margin: 0 0 10px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0 10px; padding-left: 22px; } .bubble li { margin: 3px 0; }
.summary .bubble { background: #fffaf0; border: 1.5px solid var(--accent); }
.typing .bubble { color: var(--ink-soft); font-style: italic; }

/* ── Composer ── */
.composer { border-top: 1px solid var(--line); padding: 14px 22px 18px; background: #fbf9f4; }
.composer-inner { display: flex; gap: 10px; align-items: flex-end; max-width: 900px; margin: 0 auto; }
#input {
  flex: 1; resize: none; font-family: var(--ui); font-size: 18px; line-height: 1.5;
  padding: 13px 16px; border: 1.5px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink); max-height: 200px;
}
#input:focus { outline: none; border-color: var(--accent); }
.send-btn {
  background: var(--hazel); color: #fff; border: none; border-radius: 14px;
  padding: 13px 24px; font-size: 17px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.send-btn:hover { background: var(--hazel-deep); }
.send-btn:disabled { opacity: .5; cursor: default; }

/* ── Mobile ── */
@media (max-width: 720px) {
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; z-index: 10; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .resolve-btn { padding: 9px 12px; font-size: 13px; }
}
