* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 24%),
              radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.10), transparent 28%),
              #eef5fb;
  min-height: 100vh;
  line-height: 1.7;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(180deg, rgba(255,255,255,0.28), transparent 32%);
  opacity: 0.9;
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.container {
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 34px;
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.12);
  padding: clamp(32px, 4vw, 56px);
}

.top-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  color: #2563eb;
  font-weight: 700;
}

.label {
  display: inline-flex;
  padding: 9px 18px;
  border-radius: 999px;
  color: #2563eb;
  background: #dbeafe;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(2.6rem, 4vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0 0 16px;
  font-size: clamp(1.65rem, 2.4vw, 2.3rem);
  line-height: 1.1;
}

p {
  margin: 0 0 18px;
  color: #475569;
}

.lead {
  max-width: 760px;
  color: #475569;
  font-size: 1.12rem;
}

.button-group,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 28px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

button.button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.button,
.button-full {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 170px;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button {
  background: #2563eb;
  color: #fff;
}

.button.secondary {
  background: transparent;
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.24);
}

.button:hover,
.button-full:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.16);
}

.grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 40px 0;
}

.feature,
.card,
.story-step {
  border-radius: 28px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  padding: 28px;
}

.feature h3,
.card h3,
.story-step h3 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1.12rem;
}

.feature p,
.card p,
.story-step p {
  margin-bottom: 0;
  color: #475569;
}

.form-card {
  width: min(520px, 100%);
}

.field {
  margin-bottom: 18px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  font-size: 1rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

select {
  background: #fff;
}

.workspace-section {
  margin-top: 48px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.4fr);
  gap: 24px;
  align-items: start;
}

.top-space {
  margin-top: 36px;
}

.panel-card,
.empty-state {
  padding: 26px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 24px;
  background: #fff;
}

.panel-card h2,
.panel-card h3 {
  margin-top: 0;
}

.chapter-list {
  display: grid;
  gap: 14px;
}

.chapter-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 20px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 22px;
  background: #fff;
}

.chapter-item h3,
.chapter-item p {
  margin: 0 0 6px;
}

.sequence-badge {
  display: flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: #2563eb;
  font-weight: 800;
}

.meta {
  color: #64748b;
  font-size: 0.9rem;
}

.status-badge {
  display: inline-flex;
  margin-right: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 0.86rem;
  font-weight: 700;
}

.button.compact {
  min-width: 0;
  padding: 10px 16px;
}

.editor-container {
  max-width: 1050px;
  margin: 0 auto;
}

.editor-toolbar {
  display: flex;
  gap: 18px;
  align-items: flex-end;
}

.editor-toolbar .grow {
  flex: 1;
}

.status-field {
  width: 210px;
}

.manuscript-editor {
  min-height: 560px;
  padding: 24px;
  line-height: 1.85;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  background: #fffefb;
}

.editor-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
  color: #64748b;
  font-size: 0.9rem;
}

.context-item {
  padding: 22px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 22px;
  background: #fff;
}

.context-item h3,
.context-item p {
  margin-top: 0;
  margin-bottom: 8px;
}

.context-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.context-actions form {
  margin: 0;
}

.text-button {
  display: inline;
  padding: 0;
  border: 0;
  color: #2563eb;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.danger-text {
  color: #b91c1c;
}

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

.ai-history {
  display: grid;
  gap: 16px;
  margin-top: 32px;
}

.ai-response {
  margin-top: 16px;
  padding: 20px;
  border-radius: 18px;
  background: #f8fafc;
  color: #1e293b;
}

.button-full {
  width: 100%;
  border: none;
}

.notice {
  margin-bottom: 18px;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 18px;
  color: #334155;
}

.notice.success {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.danger-zone {
  margin-top: 40px;
  padding: 28px;
  border: 1px solid #fecaca;
  border-radius: 28px;
  background: #fff7f7;
}

.confirmation {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #7f1d1d;
  font-weight: 600;
}

.confirmation input {
  width: auto;
  margin-top: 6px;
}

.button.danger {
  margin-top: 16px;
  background: #b91c1c;
}

.error {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.footer-note {
  margin-top: 32px;
  color: #475569;
}

@media (max-width: 900px) {
  .grid,
  .card-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 24px 0 48px;
  }

  h1 {
    font-size: 2.5rem;
  }

  .chapter-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chapter-item .button {
    grid-column: 1 / -1;
  }

  .editor-toolbar {
    display: block;
  }

  .status-field {
    width: auto;
  }
}
