:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e1e8;
  --paper: #f7fafc;
  --panel: #ffffff;
  --teal: #087f8c;
  --teal-dark: #075f6c;
  --coral: #d94841;
  --yellow: #f4b942;
  --green: #1f8f58;
  --shadow: 0 18px 48px rgba(29, 45, 57, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(8, 127, 140, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(8, 127, 140, 0.06) 1px, transparent 1px),
    #eef5f6;
  background-size: 28px 28px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 24px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  font-size: 28px;
  background: linear-gradient(135deg, var(--teal), var(--coral));
  box-shadow: 0 12px 28px rgba(8, 127, 140, 0.22);
}

.brand h1,
.workspace h2,
.workspace h3,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  letter-spacing: 0;
}

.brand p,
.eyebrow,
.search-box label {
  color: var(--muted);
  font-size: 13px;
}

.search-box {
  display: grid;
  gap: 8px;
}

.api-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(8, 127, 140, 0.22);
  border-radius: 8px;
  background: #f0fbfc;
}

.api-box label {
  color: var(--muted);
  font-size: 13px;
}

.api-box input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: white;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.search-row svg {
  width: 19px;
  color: var(--teal);
}

.search-row input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.subject-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subject-chip {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: white;
}

.subject-chip.active {
  color: white;
  border-color: var(--teal);
  background: var(--teal);
}

.quick-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.icon-button,
.primary-button,
.ghost-button,
.round-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 700;
}

.icon-button svg,
.primary-button svg,
.ghost-button svg,
.round-button svg {
  width: 18px;
  height: 18px;
}

.primary-button {
  border-color: var(--teal);
  color: white;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button {
  color: var(--teal);
  border-color: rgba(8, 127, 140, 0.28);
}

.round-button {
  width: 42px;
  padding: 0;
}

.round-button.active {
  color: white;
  border-color: var(--yellow);
  background: var(--yellow);
}

.result-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.result-item {
  display: grid;
  gap: 7px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.result-item:hover,
.result-item.active {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(29, 45, 57, 0.1);
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.result-title {
  font-weight: 800;
  font-size: 16px;
}

.workspace {
  display: grid;
  gap: 20px;
  padding: 28px;
  min-width: 0;
}

.topbar,
.builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar h2 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.answer-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.05fr) minmax(300px, 0.95fr);
  gap: 18px;
}

.panel,
.study-builder {
  padding: 20px;
  border: 1px solid rgba(217, 225, 232, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-title svg {
  width: 20px;
  color: var(--coral);
}

.explain-panel p {
  margin: 0;
  line-height: 1.85;
  color: #344054;
}

.formula-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.formula {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(8, 127, 140, 0.2);
  background: #e9f7f8;
  font-weight: 800;
}

.visual-stage {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  overflow: hidden;
}

.visual-stage svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 260px;
}

.points-panel ul {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.points-panel li {
  position: relative;
  padding-left: 28px;
  line-height: 1.6;
}

.points-panel li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--green);
  box-shadow: inset 0 0 0 3px white;
}

.question-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.question-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.question-count svg {
  width: 18px;
  color: var(--teal);
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.question-item p {
  margin: 0;
  line-height: 1.75;
  color: #344054;
}

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.question-tag {
  padding: 4px 9px;
  border-radius: 999px;
  color: white;
  background: var(--coral);
  font-size: 12px;
  font-weight: 800;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.analysis-box {
  padding: 14px;
  line-height: 1.7;
  border: 1px solid rgba(244, 185, 66, 0.45);
  border-radius: 8px;
  background: #fff8e6;
}

.hidden {
  display: none;
}

.study-builder {
  display: grid;
  gap: 16px;
}

.builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.builder-head h3 {
  font-size: 22px;
}

.study-plan {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.plan-step {
  min-height: 116px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfdfe;
}

.plan-step strong {
  display: block;
  margin-bottom: 8px;
}

.plan-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.ai-result {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(8, 127, 140, 0.22);
  background: #f7feff;
  line-height: 1.75;
}

.ai-result h4 {
  margin: 0;
  font-size: 18px;
}

.ai-result pre {
  white-space: pre-wrap;
  margin: 0;
  font-family: inherit;
}

.ai-result p,
.ai-result ul {
  margin: 0;
}

.ai-result ul {
  display: grid;
  gap: 8px;
  padding-left: 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .result-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 320px;
  }

  .answer-grid,
  .study-plan {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .sidebar,
  .workspace {
    padding: 18px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .quick-tools,
  .result-list {
    grid-template-columns: 1fr;
  }

  .topbar,
  .builder-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .builder-actions,
  .top-actions {
    width: 100%;
  }

  .builder-actions button {
    flex: 1;
  }
}
