:root {
  --navy: #173b57;
  --teal: #2f7d7a;
  --teal-dark: #23635f;
  --teal-soft: #e8f4f2;
  --ink: #183044;
  --muted: #64748b;
  --line: #dce7eb;
  --surface: #ffffff;
  --canvas: #f2f7f8;
  --warning: #b45309;
  --warning-soft: #fff7e8;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 16px 42px rgba(23, 59, 87, 0.09);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(61, 139, 114, .11), transparent 27rem),
    var(--canvas);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1420px, calc(100% - 40px));
  margin: 28px auto;
}

.hero {
  min-height: 150px;
  padding: 28px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  border-radius: 26px;
  background: linear-gradient(125deg, var(--navy), #245b65 72%, var(--teal));
  box-shadow: var(--shadow);
}

.eyebrow {
  display: block;
  margin-bottom: 10px;
  color: #bfe0dc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
}

.hero h1 { margin: 0; font-size: clamp(27px, 3vw, 40px); }
.hero p { margin: 12px 0 0; color: #d7ebeb; }

.connection {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  font-size: 14px;
}

.connection-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251,191,36,.18);
}

.connection.online .connection-dot {
  background: #67e8b1;
  box-shadow: 0 0 0 4px rgba(103,232,177,.18);
}

.connection.offline .connection-dot {
  background: #fda29b;
  box-shadow: 0 0 0 4px rgba(253,162,155,.18);
}

.workspace {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: stretch;
}

.chat-panel {
  min-height: 720px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-toolbar {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.chat-toolbar h2 { margin: 0; font-size: 20px; }
.chat-toolbar p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.messages {
  min-height: 0;
  flex: 1;
  padding: 26px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(255,255,255,.92), rgba(255,255,255,.92)),
    radial-gradient(circle at 1px 1px, #d4e4e7 1px, transparent 1px);
  background-size: auto, 22px 22px;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  color: var(--teal);
  border-radius: 18px;
  background: var(--teal-soft);
  font-size: 25px;
}

.empty-state h3 { margin: 0 0 9px; color: var(--ink); }
.empty-state p { margin: 0; }

.message-row {
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  animation: messageIn .22s ease-out;
}

.message-row.user { justify-content: flex-end; }

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  font-size: 13px;
  font-weight: 800;
}

.bubble {
  max-width: min(74%, 680px);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 6px 18px 18px 18px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(23, 59, 87, .06);
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.user .bubble {
  color: #fff;
  border: 0;
  border-radius: 18px 6px 18px 18px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
}

.message-time {
  margin-top: 6px;
  color: #8da0ae;
  font-size: 11px;
}

.user .message-time { color: rgba(255,255,255,.7); }

.quick-replies {
  padding: 0 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #fff;
}

.quick-replies:not(:empty) { padding-top: 14px; }

.quick-button {
  padding: 8px 13px;
  color: var(--teal-dark);
  border: 1px solid #aed3cf;
  border-radius: 999px;
  background: #f4fbfa;
}

.quick-button:hover { border-color: var(--teal); background: var(--teal-soft); }

.composer {
  padding: 18px 22px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  background: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 62px;
  max-height: 160px;
  padding: 13px 15px;
  resize: vertical;
  color: var(--ink);
  border: 1px solid #cddde1;
  border-radius: 14px;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47,125,122,.12);
}

.button {
  padding: 11px 16px;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }

.button-primary { color: #fff; background: var(--teal); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { color: var(--navy); background: #edf4f6; }
.full-width { width: 100%; margin-top: 14px; }
select {
  width: 100%; margin: 7px 0 2px; padding: 11px 12px;
  border: 1px solid rgba(92, 107, 192, .24); border-radius: 12px;
  background: #fff; color: #34405c;
}

.send-button {
  min-width: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.side-panel { display: flex; flex-direction: column; gap: 16px; }

.side-card, .notice-card, .api-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(23,59,87,.055);
}

.side-card-title {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
}

.homework-card strong { display: block; color: var(--navy); line-height: 1.5; }
.homework-card ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.homework-card li { margin: 7px 0; line-height: 1.45; }

.soft-badge {
  padding: 4px 8px;
  color: var(--teal-dark);
  border-radius: 999px;
  background: var(--teal-soft);
  font-size: 11px;
}

.side-card label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.side-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cddde1;
  border-radius: 11px;
  outline: none;
}

.stage-badge {
  padding: 12px;
  color: var(--teal-dark);
  border-radius: 12px;
  background: var(--teal-soft);
  font-weight: 800;
  text-align: center;
}

.status-list { margin: 16px 0 0; }
.status-list div {
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #edf2f4;
}
.status-list div:last-child { border-bottom: 0; }
.status-list dt { color: var(--muted); font-size: 13px; }
.status-list dd { margin: 0; text-align: right; font-size: 13px; font-weight: 700; }

.notice-card {
  color: #75430b;
  border-color: #f5d7a6;
  background: var(--warning-soft);
}
.notice-card p { margin: 8px 0 0; font-size: 13px; line-height: 1.7; }
.notice-card.danger { color: var(--danger); border-color: #f5c2bd; background: var(--danger-soft); }

.api-card { color: var(--muted); font-size: 12px; }
.api-card code { display: block; margin-top: 7px; color: var(--teal-dark); word-break: break-all; }

.mobile-new { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 25px;
  z-index: 20;
  padding: 11px 16px;
  color: #fff;
  border-radius: 999px;
  background: rgba(24,48,68,.94);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.calendar-handle {
  position: fixed; right: 0; top: 48%; z-index: 31; padding: 14px 10px;
  display: grid; gap: 5px; justify-items: center; color: #fff; border: 0;
  border-radius: 16px 0 0 16px; background: linear-gradient(180deg, var(--teal), var(--navy));
  box-shadow: 0 10px 30px rgba(23,59,87,.22); font-size: 12px;
}
.calendar-handle span:first-child { font-size: 21px; }
.drawer-mask { position: fixed; inset: 0; z-index: 39; background: rgba(18,45,61,.28); opacity: 0; visibility: hidden; transition: .25s; }
.drawer-mask.open { opacity: 1; visibility: visible; }
.calendar-drawer {
  position: fixed; top: 0; right: 0; z-index: 40; width: min(430px, 94vw); height: 100vh;
  padding: 26px; overflow-y: auto; background: #f7fbfb; border-left: 1px solid #cce0e2;
  box-shadow: -18px 0 48px rgba(23,59,87,.15); transform: translateX(105%); transition: transform .28s ease;
}
.calendar-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-header h2 { margin: 2px 0 20px; color: var(--navy); }
.drawer-eyebrow { color: var(--teal); }
.icon-button { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 11px; color: var(--navy); background: #e5f1f1; font-size: 25px; }
.exam-date-card { padding: 17px; border-radius: 17px; color: #fff; background: linear-gradient(135deg, var(--navy), var(--teal)); }
.exam-date-card span { display: block; color: #cde4e3; font-size: 12px; }
.exam-date-card strong { display: block; margin-top: 5px; font-size: 18px; }
.date-setting { margin-top: 15px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.date-setting input, .date-setting button { padding: 9px 10px; border: 0; border-radius: 10px; }
.date-setting button { color: var(--teal-dark); background: #fff; font-weight: 800; }
.calendar-tabs { margin: 18px 0 12px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; border-radius: 14px; background: #e5f1f1; }
.calendar-tab { padding: 10px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 800; }
.calendar-tab.active { color: #fff; background: var(--teal); box-shadow: 0 5px 14px rgba(47,125,122,.2); }
.calendar-panel { animation: messageIn .2s ease; }
.calendar-panel[hidden] { display: none; }
.period-heading { margin: 18px 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
.period-heading strong { color: var(--navy); }
.period-heading span { color: var(--muted); font-size: 12px; }
.weekly-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekly-day { min-width: 0; padding: 9px 3px; display: grid; justify-items: center; gap: 3px; border: 1px solid #dbe8e9; border-radius: 13px; background: #fff; }
.weekly-day.today { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.weekly-day span { color: var(--muted); font-size: 10px; }
.weekly-day b { color: var(--navy); font-size: 13px; }
.weekly-day em { min-height: 22px; font-style: normal; font-size: 18px; }
.weekly-day small { min-height: 14px; color: var(--teal-dark); font-size: 9px; white-space: nowrap; }
.compact-summary { margin-top: 14px; }
.weekly-homework { display: grid; gap: 8px; }
.homework-row { padding: 10px; display: flex; align-items: center; gap: 10px; border-radius: 11px; background: #f6f1e9; }
.homework-row.done { background: #eaf4f3; }
.homework-row > span { width: 23px; height: 23px; display: grid; place-items: center; color: var(--teal-dark); border-radius: 50%; background: #fff; font-weight: 900; }
.homework-row div { display: grid; gap: 3px; }
.homework-row strong { color: var(--navy); font-size: 13px; }
.homework-row small { color: var(--muted); font-size: 11px; }
.calendar-toolbar { margin: 24px 0 13px; display: flex; align-items: center; justify-content: space-between; }
.calendar-toolbar strong { color: var(--navy); font-size: 18px; }
.week-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-row { margin-bottom: 7px; color: var(--muted); text-align: center; font-size: 12px; }
.calendar-day { position: relative; min-height: 49px; padding: 7px 5px; border: 1px solid #dbe8e9; border-radius: 12px; background: #fff; text-align: center; font-size: 12px; }
.calendar-day.muted { opacity: .34; }
.calendar-day.today { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.calendar-day.exam { color: #fff; border-color: var(--teal); background: linear-gradient(145deg, #4b948d, #286b69); }
.calendar-day .mood { display: block; margin-top: 2px; font-size: 19px; line-height: 1; }
.calendar-day .score-dot { position: absolute; right: 4px; bottom: 3px; min-width: 16px; color: var(--teal-dark); font-size: 9px; font-weight: 800; }
.mood-legend { margin-top: 14px; padding: 10px; display: flex; justify-content: space-between; border-radius: 12px; background: #eaf4f3; font-size: 11px; }
.mood-legend b { margin-right: 3px; font-size: 16px; }
.calendar-summary { margin-top: 20px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.calendar-summary h3 { margin: 0 0 12px; color: var(--navy); }
.assessment-history { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.history-item { padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; border-radius: 10px; background: #f0f7f6; }
.history-item b { font-size: 20px; }

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

.message-row.streaming .bubble > div:first-child::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: currentColor;
  animation: streamCursor .75s steps(1) infinite;
}

@keyframes streamCursor {
  50% { opacity: 0; }
}

@media (max-width: 900px) {
  .page-shell { width: min(100% - 24px, 720px); margin: 12px auto; }
  .hero { min-height: 130px; padding: 23px; align-items: flex-start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .side-panel { grid-row: 1; display: grid; grid-template-columns: 1fr 1fr; }
  .notice-card, .api-card { display: none; }
  .chat-panel { min-height: 680px; }
}

@media (max-width: 600px) {
  .hero { border-radius: 18px; }
  .hero p { font-size: 13px; }
  .side-panel { display: none; }
  .mobile-new { display: inline-block; }
  .chat-toolbar { padding: 16px; }
  .chat-toolbar p { display: none; }
  .messages { padding: 18px 13px; }
  .bubble { max-width: 86%; }
  .composer { padding: 14px; grid-template-columns: 1fr; }
  .send-button { min-height: 44px; }
  .calendar-handle { top: auto; bottom: 92px; }
}
