:root {
  --bg: #f6f3ef;
  --ink: #171717;
  --muted: #5b5b5b;
  --card: #ffffff;
  --accent: #ff6b4a;
  --accent-dark: #d94f2f;
  --outline: rgba(23, 23, 23, 0.12);
  --shadow: 0 18px 40px rgba(23, 23, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Serif 4", serif;
  background: radial-gradient(circle at top, #fff1e8 0%, #f6f3ef 45%, #f0efe9 100%);
  color: var(--ink);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: absolute;
  border-radius: 999px;
  filter: blur(0px);
  opacity: 0.5;
  z-index: 0;
}

.shape-a {
  width: 460px;
  height: 460px;
  top: -120px;
  right: -120px;
  background: radial-gradient(circle at 30% 30%, #ffb6a5, #ff7c5f 55%, #f75c3b 100%);
}

.shape-b {
  width: 520px;
  height: 520px;
  bottom: -200px;
  left: -120px;
  background: radial-gradient(circle at 20% 40%, #ffe6b4, #ffd285 60%, #f7b547 100%);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 64px 12px;
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
  font-family: "Space Grotesk", sans-serif;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 20px;
  letter-spacing: 1px;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.ghost-link {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--outline);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ghost-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr);
  gap: 28px;
  padding: 12px 64px 64px;
  position: relative;
  z-index: 1;
}

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

.panel h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 36px;
  margin: 0 0 12px;
}

.lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 17px;
}

.dropzone {
  border: 2px dashed rgba(23, 23, 23, 0.2);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  background: #fff8f1;
  position: relative;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: #fff1e8;
  transform: translateY(-2px);
}

.dropzone-inner {
  pointer-events: none;
}

.dropzone-icon {
  font-size: 34px;
  font-family: "Space Grotesk", sans-serif;
}

.dropzone-text {
  font-family: "Space Grotesk", sans-serif;
  font-size: 16px;
  margin-top: 6px;
}

.dropzone-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 12px;
}

.btn {
  border: 1px solid var(--outline);
  background: #fff;
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 999px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.status {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.file-list-header,
.file-list {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
}

.file-list-header {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-item {
  display: contents;
}

.file-preview-btn {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-family: "Source Serif 4", serif;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
}

.file-preview-btn:hover {
  background: #fff3ec;
}

.file-preview-btn.is-selected {
  border-color: var(--accent);
  background: #fff1e8;
}

.file-status {
  font-size: 13px;
  color: var(--muted);
}

.file-action button {
  padding: 6px 12px;
  font-size: 12px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-header h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  margin: 0;
}

.preview-label {
  color: var(--muted);
  font-size: 12px;
}

.preview {
  flex: 1;
  border: 1px solid var(--outline);
  border-radius: 18px;
  padding: 20px;
  background: #fff;
  overflow: auto;
  min-height: 320px;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4 {
  font-family: "Space Grotesk", sans-serif;
}

.preview pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 12px;
  overflow-x: auto;
}

.preview code {
  font-family: "Courier New", monospace;
  font-size: 0.9em;
}

.mermaid-diagram {
  margin: 16px 0;
  overflow: auto;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.render-host {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 900px;
}

.pdf-wrapper {
  padding: 24px;
  background: #fff;
  color: #111;
  width: 794px;
}

.pdf-wrapper .mermaid-diagram {
  page-break-inside: avoid;
  break-inside: avoid;
}

.pdf-wrapper svg {
  max-width: 100%;
  height: auto;
}

.pdf-wrapper h1,
.pdf-wrapper h2,
.pdf-wrapper h3,
.pdf-wrapper h4 {
  font-family: "Space Grotesk", sans-serif;
}

@media (max-width: 980px) {
  .site-header {
    padding: 24px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 12px 24px 48px;
  }
}

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

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

  .file-list-header,
  .file-list {
    grid-template-columns: 1fr;
  }
}
