:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --text: #172433;
  --muted: #5c6b7a;
  --line: #d7e0ea;
  --blue: #2b5f8a;
  --blue-bright: #3a7bd5;
  --blue-dark: #1d4565;
  --orange: #e8a87c;
  --orange-soft: #fff4ec;
  --blue-soft: #edf4fb;
  --success: #1f7a4d;
  --danger: #b3452e;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(23, 52, 79, 0.10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(58, 123, 213, 0.55);
  outline-offset: 2px;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.hero {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-bright) 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  margin-bottom: 18px;
  padding: 26px 22px;
}

.hero-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--orange);
  color: #4a2c17;
  font-size: 13px;
  font-weight: 700;
}

.hero h1 {
  margin: 12px 0 4px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  font-size: 15px;
  opacity: 0.92;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.landing-panel {
  text-align: center;
}

.landing-head h2 {
  margin: 0;
  font-size: 24px;
}

.mode-actions {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 78px;
  text-align: left;
  padding: 16px 18px;
  border-radius: 16px;
  cursor: pointer;
}

.mode-general {
  background: var(--blue-soft);
  border: 2px solid var(--blue-bright);
  color: var(--blue-dark);
}

.mode-workbook {
  background: var(--orange-soft);
  border: 2px solid var(--orange);
  color: #4a2c17;
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
}

.mode-general .mode-icon {
  background: var(--blue-bright);
  color: #fff;
}

.mode-workbook .mode-icon {
  background: var(--orange);
  color: #4a2c17;
}

.mode-text {
  display: grid;
  gap: 4px;
}

.mode-text strong {
  font-size: 18px;
  line-height: 1.3;
}

.mode-text small {
  font-size: 13px;
  opacity: 0.82;
}

.mode-head-panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.back-btn {
  width: auto;
  min-height: 42px;
  padding: 8px 14px;
  background: #eef1f5;
  color: var(--blue-dark);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.back-btn:hover:not(:disabled) {
  background: var(--blue-soft);
}

.mode-head-info {
  min-width: 0;
}

.mode-head-info h2 {
  margin: 0;
  font-size: 22px;
}

.generic-panel,
.contact-panel {
  border-top: 5px solid var(--blue-bright);
}

.book-panel,
.summary-panel {
  border-top: 5px solid var(--orange);
  background: linear-gradient(180deg, #fffdfb 0%, var(--panel) 70%);
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

.step-blue {
  background: var(--blue-bright);
}

.step-orange {
  background: var(--orange);
  color: #4a2c17;
}

.field + .field {
  margin-top: 20px;
}

label {
  display: block;
  margin-bottom: 9px;
  font-size: 15px;
  font-weight: 700;
  color: var(--blue-dark);
}

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

.chip {
  min-height: 46px;
  padding: 11px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #2d3d4d;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--blue-bright);
  background: var(--blue-soft);
}

.chip.active {
  background: var(--blue-soft);
  border-color: var(--blue-bright);
  color: var(--blue-dark);
  font-weight: 700;
}

input,
textarea,
select,
button {
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue-bright);
  box-shadow: 0 0 0 3px rgba(58, 123, 213, 0.16);
}

textarea {
  resize: vertical;
  margin-top: 12px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) {
  background: var(--blue-bright);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  background: #a9b7c6;
  cursor: not-allowed;
}

#submit {
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.email-field {
  padding: 16px;
  background: var(--blue-soft);
  border: 2px solid var(--blue-bright);
  border-radius: 14px;
}

.email-field label {
  color: var(--blue-dark);
}

.email-row {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 8px;
}

.email-row input,
.email-row select {
  min-height: 50px;
  font-size: 16px;
  border-radius: 12px;
}

.email-row input {
  border-color: var(--blue-bright);
}

.book-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px 2px 8px;
  margin-top: 12px;
}

.text-book {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 54px;
  text-align: left;
  padding: 13px 15px;
  background: var(--blue-soft);
  border: 1.5px solid var(--blue-bright);
  border-radius: 12px;
  color: var(--blue-dark);
  cursor: pointer;
}

.text-book:hover {
  border-color: var(--blue);
  background: #e2eefb;
}

.text-book.active {
  background: var(--orange-soft);
  border-color: var(--orange);
  color: #4a2c17;
  box-shadow: 0 0 0 3px rgba(232, 168, 124, 0.22);
}

.text-book-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.text-book-meta {
  font-size: 13px;
  color: inherit;
  font-weight: 500;
  opacity: 0.88;
}

.cover-card {
  flex: 0 0 132px;
  width: 132px;
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 10px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  scroll-snap-align: start;
}

.cover-card:hover {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.cover-card.active {
  background: var(--orange-soft);
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232, 168, 124, 0.18);
}

.cover-image-wrap {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f5f0;
  border-radius: 10px;
  overflow: hidden;
}

.cover-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cover-fallback {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-bright) 100%);
  color: #fff;
  font-size: 34px;
  font-weight: 700;
}

.cover-info {
  display: grid;
  gap: 4px;
}

.cover-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-meta {
  font-size: 11px;
  color: var(--muted);
}

.empty-book {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  font-size: 14px;
}

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

.summary-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: 12px;
}

.summary-main {
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.summary-workbook {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.remove-item {
  min-height: 38px;
  padding: 7px 13px;
  background: #eef1f5;
  color: var(--danger);
  border: 1px solid var(--line);
  font-size: 13px;
}

.remove-item:hover:not(:disabled) {
  background: #fbe9e5;
}

.empty-summary {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  font-size: 15px;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  border-radius: 12px;
  background: #1f2933;
  color: #fff;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.toast.show {
  opacity: 1;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

@media (min-width: 640px) {
  .app {
    padding: 22px 18px 56px;
  }

  .hero {
    padding: 32px 28px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .panel {
    padding: 24px;
  }

  .email-row {
    grid-template-columns: 1fr 150px;
  }
}
