:root {
  --bg: #f4f0e8;
  --bg-soft: #f8f6f0;
  --card: #fffefa;
  --ink: #1f2a2f;
  --muted: #5d6b72;
  --primary: #1f8a70;
  --primary-deep: #11624f;
  --accent: #e57b3a;
  --accent-soft: #f0b17e;
  --line: #d7ddd6;
  --danger: #b7362f;
  --ok: #1d7f4f;
  --shadow: 0 18px 30px rgba(31, 42, 47, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #f4f0e8 0%, #eef4ef 45%, #f9efe4 100%);
  min-height: 100vh;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 15%, rgba(229, 123, 58, 0.15), transparent 45%),
    radial-gradient(circle at 90% 20%, rgba(31, 138, 112, 0.14), transparent 40%),
    radial-gradient(circle at 70% 85%, rgba(17, 98, 79, 0.09), transparent 42%);
  z-index: -1;
}

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1rem 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  animation: riseIn 0.8s ease;
}

.eyebrow {
  margin: 0;
  color: var(--primary-deep);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

h1 {
  margin: 0.4rem 0 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 3.8vw, 3rem);
  line-height: 1.05;
}

.hero-sub {
  max-width: 62ch;
  color: var(--muted);
  margin: 0.7rem 0 0;
}

.hero-meta {
  text-align: right;
  color: var(--primary-deep);
  font-weight: 600;
}

.hero-meta p {
  margin: 0;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1rem;
  animation: riseIn 0.55s ease;
}

.card h2 {
  margin-top: 0;
  font-size: 1.12rem;
}

#profileCard,
#teacherConnectCard,
#goalsCard,
#analysisCard,
#timetableCard,
#cbseCard,
#roadmapCard,
#chatCard {
  grid-column: span 12;
}

@media (min-width: 760px) {
  #profileCard,
  #teacherConnectCard,
  #goalsCard,
  #analysisCard {
    grid-column: span 6;
  }

  #timetableCard,
  #cbseCard {
    grid-column: span 6;
  }

  #roadmapCard,
  #chatCard {
    grid-column: span 6;
  }
}

.form-grid {
  display: grid;
  gap: 0.65rem;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.compact .full-width,
.form-grid.compact button,
.form-grid.compact .hint {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-meta {
    text-align: left;
  }
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  font-size: 0.88rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem 0.7rem;
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--bg-soft);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 55%, white);
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: white;
  padding: 0.68rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.1);
}

.btn:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary-deep);
}

.hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.link {
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.goals-list {
  display: grid;
  gap: 0.45rem;
}

.goal-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.58rem;
  align-items: center;
}

.goal-text.done {
  text-decoration: line-through;
  color: #6e7d83;
}

.goal-done-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--primary-deep);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.goal-done-btn.is-done {
  background: #d9f4e3;
  border-color: #9ad1b5;
  color: #13583c;
}

.meter {
  height: 10px;
  border-radius: 999px;
  background: #e8ece8;
  overflow: hidden;
  margin-top: 0.7rem;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
  transition: width 0.35s ease;
}

.status-box {
  margin-top: 0.65rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(130deg, #f8f5eb 0%, #f2f8f3 100%);
  padding: 0.75rem;
  color: var(--ink);
}

.status-pill {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.58rem;
  margin-right: 0.35rem;
}

.pill-ok {
  background: #d9f4e3;
  color: var(--ok);
}

.pill-watch {
  background: #ffe5d5;
  color: #a85015;
}

.inline-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
  margin-top: 0.75rem;
}

@media (max-width: 640px) {
  .inline-tools {
    grid-template-columns: 1fr;
  }
}

.list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem;
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  align-items: center;
  background: #fdfcf8;
}

.item strong {
  display: block;
}

.item small {
  color: var(--muted);
}

.item button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 0.36rem 0.6rem;
  cursor: pointer;
}

.chat-window {
  margin-top: 0.7rem;
  min-height: 230px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.68rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: #f9fbf8;
}

.msg {
  max-width: 85%;
  border-radius: 12px;
  padding: 0.5rem 0.62rem;
  line-height: 1.35;
  font-size: 0.9rem;
}

.msg.user {
  align-self: flex-end;
  background: #dcf4e8;
}

.msg.bot {
  align-self: flex-start;
  background: #fff0e4;
}

.chat-form {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 20;
}

.toast {
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  padding: 0.62rem 0.75rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 230px;
  animation: slideIn 0.25s ease;
}

.toast.warn {
  border-left-color: var(--accent);
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#teacherConnectStatus.connected {
  border-color: #9ad1b5;
  background: linear-gradient(130deg, #eefaf3 0%, #e9f7ef 100%);
}

#teacherConnectStatus.disconnected {
  border-color: #d8dede;
  background: linear-gradient(130deg, #f8f8f3 0%, #f3f6f5 100%);
}

#teacherConnectStatus code {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid #c8d8ef;
  background: #edf4ff;
  font-size: 0.82rem;
}
