:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-soft: #eef5f4;
  --line: #d7e3ea;
  --text: #22313f;
  --muted: #607384;
  --accent: #2d7c7a;
  --accent-soft: #dff1ef;
  --science: #e2f4ee;
  --math: #fff3dd;
  --english: #e9efff;
  --shadow: 0 12px 30px rgba(35, 58, 78, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #f8fbfd 0%, #f1f7fb 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: Consolas, "Courier New", monospace;
}

.container {
  width: min(1180px, calc(100% - 1.5rem));
  margin: 0 auto;
}

.site-header {
  padding: 1.4rem 0 0.9rem;
}

.compact-header {
  padding-bottom: 0.7rem;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.eyebrow,
.section-label,
.subject-tag,
.stat-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 2.6vw, 2.45rem);
}

h2 {
  margin-bottom: 0.55rem;
  font-size: clamp(1.15rem, 1.7vw, 1.55rem);
}

h3 {
  margin-bottom: 0.35rem;
  font-size: 1.03rem;
}

.date-chip,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.main-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(244, 248, 251, 0.9);
  border-top: 1px solid rgba(215, 227, 234, 0.65);
  border-bottom: 1px solid rgba(215, 227, 234, 0.65);
}

.nav-links {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding: 0.55rem 0;
}

.nav-links a {
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--surface);
  color: var(--text);
}

.page-shell {
  padding: 1rem 0 2rem;
  display: grid;
  gap: 0.8rem;
}

.hero-grid,
.summary-grid,
.subject-grid,
.card-grid,
.quick-links,
.filters {
  display: grid;
  gap: 0.8rem;
}

.hero-grid {
  grid-template-columns: 1.4fr 1fr;
}

.summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.review-hero {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.subject-card,
.group-card,
.mistake-card,
.topic-card,
.review-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel,
.group-card,
.mistake-card,
.topic-card,
.review-card {
  padding: 0.9rem;
}

.welcome-panel {
  background: linear-gradient(135deg, #effaf8 0%, #ffffff 70%);
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 104px;
}

.stat-value {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.large-note {
  font-size: 0.98rem;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.group-list,
.topic-stack {
  display: grid;
  gap: 0.65rem;
}

.task-switcher {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.task-switch {
  border: 1px solid var(--line);
  background: #f7fbfd;
  color: var(--muted);
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.task-switch.active {
  background: var(--accent-soft);
  color: #1f5f5d;
  border-color: #bdded9;
}

.task-panel {
  display: none;
}

.task-panel.active {
  display: block;
}

.panel-header-line {
  margin-bottom: 0.5rem;
}

.task-list {
  display: grid;
  gap: 0.6rem;
}

.task-item {
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid #e2eceb;
}

.task-item-complete {
  opacity: 0.7;
  background: linear-gradient(180deg, #f7fbfa 0%, #fdfefe 100%);
}

.task-item-complete h3,
.task-item-complete .chip {
  opacity: 0.72;
}

.task-item-complete .task-copy h3 {
  font-weight: 600;
}

.task-item-complete .task-details {
  display: none;
}

.keydate-highlight {
  background: linear-gradient(180deg, #fff4df 0%, #fffaf1 100%);
  border-color: #f0d39a;
}

.keydate-chip-highlight {
  background: #ffe2a8;
  color: #744d0a;
}

.task-topline,
.mistake-topline,
.review-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
}

.task-main {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  min-width: 0;
}

.task-copy {
  min-width: 0;
}

.task-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  margin-top: 0.1rem;
  flex: 0 0 auto;
}

.task-complete-toggle {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.task-check-mark {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  border: 2px solid #9fb9c5;
  background: #ffffff;
  box-shadow: inset 0 0 0 2px #ffffff;
  transition: all 120ms ease;
}

.task-complete-toggle:checked + .task-check-mark {
  background: var(--accent);
  border-color: var(--accent);
}

.task-complete-toggle:checked + .task-check-mark::after {
  content: "";
  display: block;
  width: 0.32rem;
  height: 0.62rem;
  margin: 0.16rem 0 0 0.38rem;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.task-meta,
.chip-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  background: var(--accent-soft);
  color: #1f5f5d;
}

.chip-sync {
  background: #dfeafd;
  color: #294f91;
}

.priority-high {
  background: #ffe1db;
  color: #8f3b28;
}

.priority-medium {
  background: #fff1d6;
  color: #7b5a14;
}

.priority-low {
  background: #e8f4e3;
  color: #3d6d30;
}

.subject-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.subject-card {
  padding: 0.85rem;
  min-height: 128px;
}

.subject-science {
  background: linear-gradient(180deg, var(--science) 0%, #ffffff 80%);
}

.subject-math {
  background: linear-gradient(180deg, var(--math) 0%, #ffffff 80%);
}

.subject-english {
  background: linear-gradient(180deg, var(--english) 0%, #ffffff 80%);
}

.quick-links {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quick-link {
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-weight: 600;
}

.task-link {
  display: inline-block;
  margin-top: 0.25rem;
  color: var(--accent);
  font-weight: 600;
}

.task-link:hover {
  text-decoration: underline;
}

.note-box {
  background: #f6fbfa;
  border: 1px dashed #bdd6d3;
  border-radius: 12px;
  padding: 0.8rem;
}

.filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filters label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 600;
}

.filters select {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mistake-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

.mistake-detail {
  margin: 0.42rem 0;
  line-height: 1.42;
}

.mistake-detail strong {
  color: var(--text);
}

.status-review-now,
.status-retry-today {
  background: #ffe5de;
  color: #8f3d2a;
}

.status-retry-soon,
.status-partial {
  background: #fff1d8;
  color: #805d1e;
}

.status-mastered {
  background: #e4f4df;
  color: #3a6b32;
}

.topic-card {
  display: grid;
  gap: 0.8rem;
}

.topic-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.topic-details {
  display: block;
}

.topic-card-collapsed .topic-details {
  display: none;
}

.topic-card-collapsed {
  gap: 0.4rem;
}

.topic-answer-box {
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: #eef7f4;
  border: 1px solid #c9e3db;
}

.topic-answer-label {
  margin: 0 0 0.22rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2b5d59;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topic-answer-text {
  margin: 0;
  font-weight: 700;
  line-height: 1.45;
}

.topic-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.topic-section {
  padding: 0.8rem;
  border-radius: 12px;
  background: #f8fbfd;
  border: 1px solid var(--line);
}

.topic-section ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}

.empty-state {
  padding: 0.8rem;
  border-radius: 12px;
  background: #f8fbfd;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.updates-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.updates-stat-card {
  min-height: 96px;
}

.updates-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.5rem;
}

.floating-chat {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: grid;
  justify-items: end;
  gap: 0.7rem;
}

.floating-timeline {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 35;
  display: grid;
  justify-items: start;
  gap: 0.7rem;
}

.floating-timeline-toggle {
  min-width: 196px;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(24, 63, 77, 0.12);
  border-radius: 18px;
  background: linear-gradient(135deg, #f0f8ff 0%, #e6f6ef 100%);
  color: var(--text);
  box-shadow: 0 18px 40px rgba(27, 57, 73, 0.18);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.floating-timeline-toggle-title,
.floating-timeline-toggle-mode {
  display: block;
}

.floating-timeline-toggle-title {
  font-weight: 700;
}

.floating-timeline-toggle-mode {
  margin-top: 0.18rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.floating-timeline-panel {
  width: min(380px, calc(100vw - 1.5rem));
  max-height: min(72vh, 720px);
  overflow: hidden;
  border: 1px solid rgba(24, 63, 77, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, #fcfeff 0%, #f7fbfd 100%);
  box-shadow: 0 22px 56px rgba(27, 57, 73, 0.18);
  display: none;
}

.floating-timeline.is-open .floating-timeline-panel {
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr);
}

.floating-timeline-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem 1rem 0 1rem;
}

.floating-timeline-note {
  margin: 0;
  padding: 0 1rem 0.85rem 1rem;
}

.timeline-list {
  overflow-y: auto;
  padding: 0 1rem 1rem 1rem;
  display: grid;
  gap: 0.65rem;
}

.timeline-item {
  padding: 0.75rem 0.8rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.timeline-date {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.timeline-date-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #32556f;
}

.timeline-date-chip {
  padding: 0.26rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  background: #edf6f2;
  color: #2c6b67;
}

.timeline-body h3 {
  margin-bottom: 0.25rem;
}

.floating-chat-toggle {
  min-width: 180px;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(24, 63, 77, 0.12);
  border-radius: 18px;
  background: linear-gradient(135deg, #1d6a69 0%, #244d6f 100%);
  color: #ffffff;
  box-shadow: 0 18px 40px rgba(27, 57, 73, 0.24);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.floating-chat-toggle-title,
.floating-chat-toggle-mode {
  display: block;
}

.floating-chat-toggle-title {
  font-weight: 700;
}

.floating-chat-toggle-mode {
  margin-top: 0.18rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.82);
}

.floating-chat-panel {
  width: min(460px, calc(100vw - 1.5rem));
  max-height: min(82vh, 820px);
  overflow: hidden;
  border: 1px solid rgba(24, 63, 77, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, #fcfeff 0%, #f4fafc 100%);
  box-shadow: 0 26px 60px rgba(27, 57, 73, 0.24);
  display: none;
}

.floating-chat.is-open .floating-chat-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(120px, 1fr) auto;
}

.floating-chat-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem 1rem 0 1rem;
}

.floating-chat-note {
  margin: 0;
  padding: 0 1rem 0.9rem 1rem;
}

.chat-example-box {
  margin: 0 1rem 0.95rem 1rem;
  padding: 0.55rem 0.72rem;
  border-radius: 14px;
  background: #f5faf8;
  border: 1px solid #d8e8e2;
}

.chat-example-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chat-example-button {
  border: 1px solid #cddfd8;
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  padding: 0.42rem 0.72rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-example-button:hover {
  background: #edf7f3;
}

.chat-example-line {
  margin: 0.22rem 0 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.88rem;
}

.chat-thread {
  min-height: 120px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 0 1rem 1rem 1rem;
  display: grid;
  gap: 0.7rem;
}

.chat-controls {
  border-top: 1px solid rgba(215, 227, 234, 0.9);
  background: rgba(255, 255, 255, 0.78);
  padding: 0.9rem 1rem 1rem 1rem;
  display: grid;
  gap: 0.7rem;
}

.chat-toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.upload-button,
.ghost-button,
.send-button,
.attachment-remove {
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.upload-button,
.ghost-button,
.send-button {
  padding: 0.62rem 0.95rem;
  font-weight: 600;
}

.upload-button,
.ghost-button {
  background: var(--surface);
  color: var(--text);
}

.send-button {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

.send-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.chat-attachments {
  display: grid;
  gap: 0.45rem;
  max-height: 92px;
  overflow-y: auto;
}

.attachment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  background: #f8fbfd;
  border: 1px solid var(--line);
}

.attachment-remove {
  padding: 0.3rem 0.6rem;
  background: #ffffff;
  color: var(--muted);
}

.chat-form {
  display: grid;
  gap: 0.6rem;
  align-items: end;
}

.chat-form textarea {
  width: 100%;
  min-height: 112px;
  max-height: 180px;
  resize: vertical;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

.chat-form .send-button {
  position: sticky;
  bottom: 0;
}

.chat-message {
  max-width: min(92%, 720px);
  padding: 0.85rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(35, 58, 78, 0.06);
}

.chat-message-user {
  margin-left: auto;
  background: linear-gradient(180deg, #dff1ef 0%, #edf8f7 100%);
  border-color: #b8dad4;
}

.chat-message-assistant {
  margin-right: auto;
  background: #ffffff;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.message-role {
  font-weight: 700;
  color: var(--text);
}

.message-text {
  margin-bottom: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-answer-box {
  margin-bottom: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: #eef7f4;
  border: 1px solid #c9e3db;
}

.message-answer-label {
  margin: 0 0 0.2rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #2b5d59;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-answer-text {
  margin: 0;
  font-weight: 700;
  line-height: 1.45;
}

.message-files {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.message-file-chip {
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #eef4ff;
  color: #2f4c82;
  font-size: 0.78rem;
}

.pending-note {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .hero-grid,
  .summary-grid,
  .subject-grid,
  .quick-links,
  .filters,
  .review-hero,
  .card-grid,
  .topic-section-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .section-heading,
  .topic-card-header,
  .task-topline,
  .mistake-topline,
  .review-topline {
    flex-direction: column;
  }

  .page-shell {
    padding-top: 1rem;
  }

  .task-switcher {
    gap: 0.5rem;
  }

  .floating-chat {
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
  }

  .floating-timeline {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 5.75rem;
  }

  .floating-chat-toggle,
  .floating-chat-panel,
  .floating-timeline-toggle,
  .floating-timeline-panel {
    width: 100%;
  }

  .floating-chat.is-open .floating-chat-panel,
  .floating-timeline.is-open .floating-timeline-panel {
    max-height: 72vh;
  }

  .floating-chat-header,
  .floating-timeline-header,
  .message-meta,
  .attachment-chip {
    flex-direction: column;
    align-items: flex-start;
  }

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