:root {
  --bg: #f3f0ea;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(21, 25, 31, 0.1);
  --line-strong: rgba(21, 25, 31, 0.18);
  --text: #12161b;
  --muted: #626b75;
  --accent: #11161d;
  --accent-soft: rgba(17, 22, 29, 0.06);
  --accent-warm: #9a7658;
  --error: #b53d2d;
  --shadow: 0 24px 60px rgba(17, 22, 29, 0.08);
  --shadow-soft: 0 12px 32px rgba(17, 22, 29, 0.06);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Aptos", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(188, 166, 146, 0.18), transparent 28%),
    linear-gradient(180deg, #f7f4ef 0%, #f3f0ea 44%, #efebe4 100%);
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.88fr);
  gap: 24px;
  align-items: start;
}

.main-stack {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
  padding: 8px 0 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  border: 1px solid rgba(17, 22, 29, 0.08);
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 3.1rem;
  font-weight: 700;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.45)),
    linear-gradient(160deg, rgba(154, 118, 88, 0.18), rgba(17, 22, 29, 0.04));
  box-shadow: var(--shadow-soft);
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}

h1 {
  margin: 0;
  max-width: 10ch;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(2.9rem, 6vw, 5.4rem);
  line-height: 0.93;
  letter-spacing: -0.04em;
}

.hero-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-meta span,
.section-tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(17, 22, 29, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.45rem;
  line-height: 1.1;
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.uploader {
  padding: 28px;
}

.toc-panel {
  padding: 28px;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.compact-form {
  align-content: start;
}

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

.dropzone {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 280px;
  padding: 30px 22px;
  border: 1px dashed rgba(17, 22, 29, 0.18);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 246, 242, 0.92));
  text-align: center;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  min-width: 0;
}

.dropzone-compact {
  min-height: 210px;
  padding: 24px 18px;
}

.dropzone:hover,
.dropzone.is-dragging {
  transform: translateY(-2px);
  border-color: rgba(17, 22, 29, 0.28);
  box-shadow: var(--shadow-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 246, 242, 0.98));
}

.dropzone input {
  display: none;
}

.dropzone-glyph {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(17, 22, 29, 0.08);
  background: rgba(17, 22, 29, 0.04);
  color: var(--accent);
  font-size: 1.55rem;
  line-height: 1;
}

.dropzone-title {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.5rem, 2.2vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.dropzone-text,
.dropzone-name {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dropzone-text {
  max-width: 26ch;
  line-height: 1.4;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.dropzone-name {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(17, 22, 29, 0.05);
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.slot-head {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.slot-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.08rem;
}

.slot-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.slot-link-block {
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid rgba(17, 22, 29, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  min-width: 0;
}

.slot-link-block a {
  display: inline-block;
  word-break: break-all;
  color: var(--accent);
  text-decoration: none;
}

.slot-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

button {
  font: inherit;
}

button,
.secondary-button {
  min-height: 52px;
  border: 0;
  border-radius: 15px;
  max-width: 100%;
}

button {
  padding: 0 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: white;
  background: linear-gradient(180deg, #1b222b, #10151c);
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(17, 22, 29, 0.16);
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 28px rgba(17, 22, 29, 0.2);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.status-card,
.result-card,
.error-card {
  margin-top: 14px;
  padding: 18px;
  border-radius: 20px;
  min-width: 0;
}

.status-card,
.result-card {
  background: var(--panel-strong);
  border: 1px solid rgba(17, 22, 29, 0.08);
}

.status-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-weight: 700;
}

.progress {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(17, 22, 29, 0.08);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #11161d, #5b6671, #9a7658);
  transition: width 120ms linear;
}

.status-message,
.result-title,
.result-actions {
  margin: 12px 0 0;
}

.result-head,
.history-head,
.result-item-head,
.result-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-count,
.file-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.result-list,
.history-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  min-width: 0;
}

.result-item,
.history-item {
  padding: 14px 16px;
  border: 1px solid rgba(17, 22, 29, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.result-item {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.history-item {
  display: grid;
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.file-name {
  font-weight: 700;
  word-break: break-word;
}

.result-card a,
.history-list a {
  display: inline-block;
  word-break: break-all;
  color: var(--accent);
  text-decoration-thickness: 1px;
}

.secondary-button {
  min-width: 0;
  padding: 0 18px;
  color: var(--text);
  background: rgba(17, 22, 29, 0.06);
  box-shadow: none;
}

.secondary-button-small {
  min-width: auto;
  min-height: 42px;
  padding: 0 14px;
}

.copy-link-button {
  min-width: auto;
  min-height: 42px;
  padding: 0 14px;
}

.history-panel {
  padding: 28px;
  position: sticky;
  top: 24px;
}

.history-head h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.4rem;
}

.history-empty {
  margin-top: 12px;
  color: var(--muted);
}

.error-card {
  color: white;
  background: linear-gradient(135deg, #d65b44, var(--error));
}

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

  .history-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 20px, 960px);
    padding-top: 20px;
    padding-bottom: 32px;
  }

  .toc-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .brand-mark {
    width: 76px;
    height: 76px;
    font-size: 2.7rem;
  }

  .uploader {
    padding: 18px;
  }

  .toc-panel {
    padding: 18px;
  }

  .history-panel {
    padding: 18px;
  }

  .dropzone {
    min-height: 220px;
  }

  .result-head,
  .history-head,
  .result-item-head,
  .result-item-actions,
  .slot-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  button,
  .secondary-button {
    width: 100%;
  }
}
