:root {
  --bg-top: #eff8f1;
  --bg-bottom: #dcefe3;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.97);
  --border: rgba(76, 126, 112, 0.15);
  --primary: #4c9d8f;
  --primary-deep: #2f7165;
  --accent: #d7ad63;
  --text: #1d3b35;
  --muted: #5b756f;
  --danger: #ba6157;
  --shadow: 0 28px 60px rgba(55, 102, 87, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Source Han Serif SC", "Noto Serif SC", "Microsoft YaHei", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(101, 180, 160, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(215, 173, 99, 0.2), transparent 26%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.4) 0%, transparent 42%),
    linear-gradient(300deg, rgba(255, 255, 255, 0.18) 0%, transparent 45%);
  opacity: 0.8;
}

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

.app-shell {
  position: relative;
  max-width: 1560px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.notice {
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(76, 157, 143, 0.14);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 30px rgba(76, 157, 143, 0.08);
}

.notice.notice-hidden {
  display: none;
}

.notice.notice-error {
  border-color: rgba(186, 97, 87, 0.24);
  color: #7e3d35;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}

.summary-card {
  padding: 18px 20px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 18px 42px rgba(53, 104, 93, 0.08);
}

.summary-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  font-size: 28px;
  line-height: 1;
}

.summary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 14px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  box-shadow: 0 14px 32px rgba(53, 104, 93, 0.06);
}

.summary-actions-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.topic-column {
  display: grid;
  gap: 20px;
}

#site-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

#site-panel::-webkit-scrollbar {
  width: 8px;
}

#site-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(76, 157, 143, 0.24);
}

#site-panel::-webkit-scrollbar-track {
  background: transparent;
}

.panel {
  padding: 24px;
  border-radius: 28px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel h2,
.panel h3,
.panel h4 {
  margin: 0;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-title p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.field-grid.single-column {
  grid-template-columns: 1fr;
}

.field-group {
  display: grid;
  gap: 8px;
}

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

.field-group input,
.field-group textarea,
.field-group select,
.mono-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(76, 126, 112, 0.18);
  background: rgba(248, 251, 249, 0.96);
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.field-group textarea {
  min-height: 124px;
  resize: vertical;
  line-height: 1.7;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus,
.mono-input:focus {
  border-color: rgba(76, 157, 143, 0.52);
  box-shadow: 0 0 0 4px rgba(76, 157, 143, 0.12);
  transform: translateY(-1px);
}

.mono-input {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.image-field {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(245, 250, 247, 0.96), rgba(235, 246, 241, 0.92));
  border: 1px solid rgba(76, 126, 112, 0.14);
}

.image-field strong {
  font-size: 15px;
}

.image-preview {
  position: relative;
  min-height: 160px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px dashed rgba(76, 126, 112, 0.18);
  background:
    linear-gradient(135deg, rgba(76, 157, 143, 0.08), rgba(215, 173, 99, 0.08)),
    #ffffff;
}

.image-preview img {
  width: 100%;
  height: 100%;
  min-height: 160px;
  object-fit: cover;
  display: block;
}

.audio-preview {
  min-height: 92px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-player-shell {
  width: 100%;
}

.audio-player-shell audio {
  width: 100%;
  display: block;
}

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.audio-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #f6faf8;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  width: fit-content;
  box-shadow: 0 12px 28px rgba(51, 110, 96, 0.18);
}

.upload-button input {
  display: none;
}

.button-row,
.topic-tab-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.button,
.danger-button,
.ghost-button {
  border: 0;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.button:hover,
.danger-button:hover,
.ghost-button:hover,
.topic-tab:hover {
  transform: translateY(-1px);
}

.button {
  color: #f7fbf8;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  box-shadow: 0 12px 28px rgba(51, 110, 96, 0.18);
}

.danger-button {
  color: #fff8f7;
  background: linear-gradient(135deg, #d87a6e, var(--danger));
  box-shadow: 0 12px 28px rgba(186, 97, 87, 0.18);
}

.ghost-button {
  background: rgba(76, 157, 143, 0.08);
  color: var(--primary-deep);
}

.button:disabled,
.danger-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.topic-tabs-panel {
  padding-bottom: 18px;
  position: static;
  top: auto;
  z-index: auto;
}

.topic-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(76, 126, 112, 0.14);
  background: rgba(241, 248, 244, 0.92);
  color: var(--primary-deep);
  cursor: pointer;
}

.topic-tab.active {
  background: linear-gradient(135deg, rgba(76, 157, 143, 0.18), rgba(76, 157, 143, 0.08));
  border-color: rgba(76, 157, 143, 0.32);
  box-shadow: inset 0 0 0 1px rgba(76, 157, 143, 0.16);
}

.topic-switch-header {
  align-items: center;
}

.topic-switch-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.topic-switch-count {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(76, 157, 143, 0.08);
  color: var(--primary-deep);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.topic-current-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(76, 126, 112, 0.12);
  background: linear-gradient(135deg, rgba(244, 250, 247, 0.98), rgba(236, 246, 242, 0.94));
}

.topic-current-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topic-current-name {
  color: var(--primary-deep);
  font-size: 16px;
  line-height: 1.4;
}

.topic-tab-row-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.topic-tab-row-scroll::-webkit-scrollbar {
  height: 8px;
}

.topic-tab-row-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(76, 157, 143, 0.26);
}

.topic-tab-row-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.topic-tab-row-scroll .topic-tab {
  flex-shrink: 0;
  white-space: nowrap;
}

.topic-tab-add {
  border-style: dashed;
  background: rgba(76, 157, 143, 0.06);
}

.stack {
  display: grid;
  gap: 18px;
}

.editor-flow {
  display: grid;
  gap: 18px;
}

.site-panel-stack {
  display: grid;
  gap: 16px;
}

.topic-context-card,
.editor-layer-panel {
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(248, 251, 249, 0.98), rgba(239, 247, 243, 0.92));
  border: 1px solid rgba(76, 126, 112, 0.14);
}

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

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

.context-pill {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(76, 126, 112, 0.1);
}

.context-pill strong {
  color: var(--primary-deep);
  line-height: 1.45;
}

.context-pill-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-context-note {
  color: var(--muted);
  line-height: 1.7;
  font-size: 13px;
}

.site-layer-grid {
  display: grid;
  gap: 10px;
}

.site-layer-step {
  border: 1px solid rgba(76, 126, 112, 0.14);
  padding: 16px;
  border-radius: 20px;
  background: rgba(245, 250, 247, 0.92);
  color: var(--primary-deep);
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.site-layer-step:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(53, 104, 93, 0.08);
}

.site-layer-step.active {
  background: linear-gradient(135deg, rgba(76, 157, 143, 0.18), rgba(76, 157, 143, 0.06));
  border-color: rgba(76, 157, 143, 0.34);
  box-shadow: inset 0 0 0 1px rgba(76, 157, 143, 0.14);
}

.site-layer-step strong {
  font-size: 15px;
}

.site-layer-step > span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.site-editor-layer {
  padding: 16px;
}

.layer-step-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.layer-step {
  border: 1px solid rgba(76, 126, 112, 0.14);
  padding: 18px 16px;
  border-radius: 22px;
  background: rgba(245, 250, 247, 0.92);
  color: var(--primary-deep);
  cursor: pointer;
  text-align: left;
  display: grid;
  gap: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.layer-step:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(53, 104, 93, 0.08);
}

.layer-step.active {
  background: linear-gradient(135deg, rgba(76, 157, 143, 0.18), rgba(76, 157, 143, 0.06));
  border-color: rgba(76, 157, 143, 0.34);
  box-shadow: inset 0 0 0 1px rgba(76, 157, 143, 0.14);
}

.layer-step strong {
  font-size: 15px;
}

.layer-step > span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.layer-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(76, 157, 143, 0.12);
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 700;
}

.topic-block,
.section-card,
.entry-card {
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(248, 251, 249, 0.98), rgba(239, 247, 243, 0.92));
  border: 1px solid rgba(76, 126, 112, 0.14);
}

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

.subsection-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.entry-card {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(241, 249, 245, 0.94));
}

.entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.entry-grid.full {
  grid-template-columns: 1fr;
}

.helper {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.empty-state {
  padding: 36px 18px;
  border-radius: 24px;
  text-align: center;
  color: var(--muted);
  background:
    linear-gradient(180deg, rgba(248, 251, 249, 0.92), rgba(236, 246, 242, 0.88));
  border: 1px dashed rgba(76, 126, 112, 0.18);
}

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

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #site-panel {
    position: static;
    top: auto;
    max-height: none;
    overflow-y: visible;
  }

  .layer-step-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-actions {
    flex-wrap: wrap;
  }

}

@media (max-width: 720px) {
  .app-shell {
    padding: 20px 14px 36px;
  }

  .summary-grid,
  .field-grid,
  .image-grid,
  .entry-grid,
  .context-pills,
  .layer-step-grid {
    grid-template-columns: 1fr;
  }

  .summary-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }
}
