:root {
  --bg: #0b0f1d;
  --surface: #161d35;
  --text: #f3f4f8;
  --muted: #9aa4c2;
  --gold: #f5b942;
  --gold-hover: #e5a528;
  --gold-soft: rgba(245, 185, 66, 0.14);
  --accent: #7c6cff;
  --accent-soft: rgba(124, 108, 255, 0.16);
  --border: rgba(255, 255, 255, 0.09);
  --success: #34d399;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-size: 1.2rem;
  margin-right: 10px;
}

.sub-tag {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  gap: 22px;
  padding: 28px 20px 60px;
  align-items: start;
}

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

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}

.panel-head,
.chapters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel h1 {
  font-size: 1.3rem;
}

.panel h2 {
  font-size: 1.08rem;
}

.panel-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.story-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.field small {
  font-size: 0.76rem;
  color: var(--muted);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chapter-box {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chapter-title-tag {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gold);
}

.chapter-meta-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.small-btn {
  padding: 6px 11px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--gold);
  color: #14110a;
}

.btn-primary:hover {
  background: var(--gold-hover);
}

.btn-secondary {
  background: var(--accent-soft);
  color: #c8c0ff;
}

.btn-ghost {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-item {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.saved-item strong {
  display: block;
  font-size: 0.92rem;
}

.saved-item span {
  font-size: 0.78rem;
  color: var(--muted);
}

.item-actions {
  display: flex;
  gap: 6px;
}

.export-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.export-box {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg);
  color: var(--text);
}

.status-msg {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(52, 211, 153, 0.14);
  color: var(--success);
  font-size: 0.86rem;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.cover-manager-box {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 640px) {
  .cover-manager-box {
    grid-template-columns: 1fr;
  }
}

.cover-manager-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cover-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cover-upload-row input[type="file"] {
  max-width: 240px;
  font-size: 0.8rem;
  color: var(--muted);
}

.cover-preview-col {
  text-align: center;
}

.cover-preview-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.admin-cover-preview {
  aspect-ratio: 2 / 3;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #10162b;
  position: relative;
}

.admin-cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.admin-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}
