:root {
  --bg-deep: #0c0e12;
  --bg-panel: #14181f;
  --bg-elevated: #1c222c;
  --border: #2a3344;
  --text: #e6e2db;
  --text-muted: #8b93a4;
  --gold: #c9a962;
  --gold-dim: #8a7344;
  --accent: #6b9bd1;
  --danger: #e07070;
  --radius: 12px;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-deep);
  line-height: 1.55;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.site-header,
.layout,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(201, 169, 98, 0.06), transparent);
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--bg-deep);
  background: linear-gradient(145deg, var(--gold), var(--gold-dim));
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(201, 169, 98, 0.25);
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 36rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 1.25rem;
  padding: 1.25rem clamp(1rem, 3vw, 2rem) 3rem;
  align-items: start;
}

.config-panel.collapsed {
  display: none;
}

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

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
}

.panel-title {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
  line-height: 1.45;
}

.hint code {
  font-size: 0.78rem;
  background: var(--bg-elevated);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.field > span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="password"],
.field input[type="number"],
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.field input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(201, 169, 98, 0.15);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field.compact {
  margin-bottom: 0.75rem;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  cursor: pointer;
}

.check input {
  margin-top: 0.2rem;
  accent-color: var(--gold);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(145deg, var(--gold), #a88b42);
  color: var(--bg-deep);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn.secondary:hover {
  border-color: var(--gold-dim);
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn.ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.main-panel textarea {
  resize: vertical;
  min-height: 120px;
}

.main-actions {
  align-items: center;
}

.status {
  font-size: 0.85rem;
  color: var(--accent);
}

.progress-section {
  margin-top: 1.25rem;
  padding: 1rem 0 1.25rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.35s ease;
}

.progress-meta {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.88rem;
  color: var(--accent);
}

.progress-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.progress-log .log-line {
  margin: 0.2rem 0;
  border-left: 2px solid var(--gold-dim);
  padding-left: 0.5rem;
}

.progress-log .log-line time {
  color: var(--gold-dim);
  margin-right: 0.35rem;
}

.output-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.error-banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(224, 112, 112, 0.12);
  border: 1px solid rgba(224, 112, 112, 0.35);
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.error-banner.hidden {
  display: none;
}

.markdown-body {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-family: var(--font-serif);
  color: var(--gold);
  margin-top: 1.4em;
  margin-bottom: 0.5em;
}

.markdown-body h1 {
  font-size: 1.35rem;
}

.markdown-body h2 {
  font-size: 1.15rem;
}

.markdown-body h3 {
  font-size: 1.05rem;
}

.markdown-body p {
  margin: 0.65em 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.35rem;
}

.markdown-body code {
  font-family: ui-monospace, monospace;
  font-size: 0.86em;
  background: var(--bg-elevated);
  padding: 0.12em 0.35em;
  border-radius: 4px;
}

.markdown-body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
}

.markdown-body pre code {
  background: none;
  padding: 0;
}

.markdown-body blockquote {
  margin: 1em 0;
  padding: 0.4em 0 0.4em 1em;
  border-left: 3px solid var(--gold-dim);
  color: var(--text-muted);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.markdown-body a {
  color: var(--accent);
}

.site-footer {
  padding: 1rem clamp(1rem, 3vw, 2rem) 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
  max-width: 42rem;
  margin-inline: auto;
}
