* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #fef3c7 0%, #fdf2f8 40%, #eef2ff 100%);
  color: #1f2937;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 18px 20px;
  border-radius: 18px;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.header::before {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, rgba(99, 102, 241, 0) 70%);
}

.header::after {
  content: "";
  position: absolute;
  left: -30px;
  bottom: -30px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.16) 0%, rgba(16, 185, 129, 0) 70%);
}

.header-badge {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f97316, #ec4899);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 20px rgba(236, 72, 153, 0.25);
}

.header-text h1 {
  margin: 0 0 6px;
  font-size: 28px;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.header-text p {
  margin: 0;
  color: #475569;
}

.header-stars {
  display: flex;
  gap: 4px;
  font-size: 20px;
}

.panel {
  background: #ffffff;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  margin-top: 20px;
}

.panel.hero {
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  color: #ffffff;
  border: none;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
}

.hero-sub {
  font-size: 15px;
  opacity: 0.95;
}

.hero-steps {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.step-item {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

label {
  font-weight: 600;
}

input[type="text"],
input[type="password"],
select,
textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  font-size: 15px;
  background: #f8fafc;
}

textarea {
  resize: vertical;
}

.mode label {
  display: inline-block;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #111827;
}

textarea {
  font-size: 16px;
  line-height: 1.6;
}

.field-tip {
  margin-top: 8px;
  font-size: 14px;
  color: #6b7280;
}

.action-tip {
  margin-top: 10px;
  background: #ecfeff;
  border: 1px dashed #67e8f9;
  color: #0f766e;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  text-align: center;
}

.mode-text textarea,
.mode-voice textarea {
  min-height: 160px;
}

.mode-photo textarea {
  min-height: 110px;
}

.photo-target {
  margin-top: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.tab {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tab.active {
  background: linear-gradient(135deg, #2563eb, #22c55e);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 12px 20px rgba(37, 99, 235, 0.2);
  transform: translateY(-2px);
}

.tab-title {
  font-size: 18px;
  font-weight: 800;
}

.tab-sub {
  font-size: 13px;
  color: inherit;
  opacity: 0.7;
}

.mode-hint {
  margin-bottom: 16px;
  color: #1f2937;
  font-weight: 700;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
  border: 1px solid #eef2ff;
  font-size: 15px;
}

.mode {
  display: none;
  margin-bottom: 16px;
  background: #ffffff;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #eef2ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.mode.active {
  display: block;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

button {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

button.primary {
  background: linear-gradient(135deg, #2563eb, #22c55e);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

.cta {
  font-size: 18px;
  padding: 14px 20px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.preview {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #d1d5db;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
}

.preview img {
  max-width: 100%;
  border-radius: 10px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.result-body {
  display: grid;
  gap: 16px;
}

.result-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.06);
}

.result-empty {
  background: #fff7ed;
  border: 1px dashed #fdba74;
  color: #9a3412;
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
}

.status {
  margin-top: 6px;
  font-weight: 600;
  color: #6b7280;
}

.status-hint {
  margin-top: 6px;
  font-size: 14px;
  color: #64748b;
}

.status[data-state="loading"] {
  color: #2563eb;
}

.status[data-state="success"] {
  color: #059669;
}

.status[data-state="error"] {
  color: #dc2626;
}

.status[data-state="loading"] + .status-hint {
  color: #2563eb;
}

.status[data-state="success"] + .status-hint {
  color: #059669;
}

.status[data-state="error"] + .status-hint {
  color: #dc2626;
}

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

.result-actions button {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 10px 14px;
}

.answer-block {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px;
  min-height: 54px;
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.6;
}

.answer-main {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-weight: 800;
  font-size: 18px;
}

.answer-steps {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

.step-section {
  display: grid;
  gap: 8px;
}

.step-title {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #1f2937;
  background: #ffffff;
  border: 1px dashed #cbd5f5;
  border-radius: 999px;
  padding: 6px 10px;
  width: fit-content;
}

.step-text {
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
}

.step-section[data-type="formula"] .step-title {
  background: #fef3c7;
  border-color: #facc15;
  color: #92400e;
}

.step-section[data-type="formula"] .step-text,
.step-section[data-type="formula"] .step-list li {
  background: #fff7ed;
  border-color: #fed7aa;
}

.step-group {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #ffffff;
}

.step-group-title {
  font-weight: 800;
  color: #0f172a;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 6px 10px;
}

.answer-list {
  display: grid;
  gap: 8px;
}

.answer-list-item {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
}

.step-list {
  margin: 0;
  padding-left: 22px;
  list-style-position: inside;
  display: grid;
  gap: 8px;
}

.step-list li {
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
}

.answer-raw {
  background: #111827;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 80px;
}

.practice-list {
  display: grid;
  gap: 10px;
}

.practice-item {
  border: 1px dashed #cbd5f5;
  background: #eef2ff;
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.practice-question {
  font-weight: 700;
  color: #1f2937;
}

.practice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.practice-actions button {
  border-radius: 999px;
  border: 1px solid #c7d2fe;
  background: #ffffff;
  padding: 6px 12px;
  font-weight: 600;
}

.practice-answer {
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  display: none;
}

.practice-item.show-answer .practice-answer {
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-dialog {
  width: min(720px, 100%);
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
  display: grid;
  gap: 12px;
  max-height: 80vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.modal-close {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px 12px;
  font-weight: 600;
}

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

.notebook-item {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
}

.notebook-item-title {
  font-weight: 800;
  color: #0f172a;
}

.notebook-meta {
  font-size: 12px;
  color: #64748b;
}

.notebook-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notebook-item-actions button {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px 12px;
}

.details {
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  overflow: visible;
}

.details summary {
  cursor: pointer;
  font-weight: 700;
  color: #111827;
  list-style: none;
}

.details summary::-webkit-details-marker {
  display: none;
}

.hint {
  margin-top: 8px;
  color: #6b7280;
}

@media (max-width: 600px) {
  .app {
    padding: 12px;
  }
  .header {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 12px 14px;
    gap: 10px;
  }
  .header-badge {
    margin: 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 16px;
  }
  .header-text h1 {
    font-size: 20px;
  }
  .header-text p {
    font-size: 13px;
  }
  .header-stars {
    display: none;
  }
  .panel {
    padding: 14px;
    margin-top: 12px;
  }
  .panel.hero {
    padding: 12px 14px;
  }
  .hero-title {
    font-size: 18px;
  }
  .hero-sub {
    font-size: 13px;
  }
  .hero-steps {
    display: none;
  }
  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .tab {
    padding: 10px 12px;
    min-height: 56px;
    border-radius: 12px;
  }
  .tab-title {
    font-size: 15px;
  }
  .tab-sub {
    font-size: 11px;
  }
  .mode-hint {
    margin-bottom: 10px;
    padding: 10px 12px;
    font-size: 13px;
  }
  .mode {
    padding: 10px;
    margin-bottom: 12px;
  }
  .mode label {
    font-size: 15px;
  }
  .field-tip {
    font-size: 12px;
  }
  .action-tip {
    display: none;
  }
  .mode-text textarea,
  .mode-voice textarea {
    min-height: 110px;
  }
  .mode-photo textarea {
    min-height: 90px;
  }
  .preview {
    min-height: 80px;
  }
  button {
    width: 100%;
    padding: 10px 14px;
    min-height: 40px;
  }
  .action-row {
    grid-template-columns: 1fr;
  }
  .result-actions {
    width: 100%;
  }
  .result-header {
    gap: 8px;
  }
  .status-hint {
    font-size: 12px;
  }
  .result-body {
    gap: 12px;
  }
  .result-card {
    padding: 10px;
  }
  .answer-block {
    padding: 10px;
    min-height: 44px;
    font-size: 15px;
  }
  .answer-main {
    font-size: 16px;
  }
  .step-list {
    gap: 6px;
  }
  .step-list li {
    padding: 6px 8px;
  }
  .details {
    padding: 8px 10px;
  }
}
