:root {
  --bg: #f5f3ee;
  --bg-accent: #ece6d8;
  --panel: rgba(255, 253, 250, 0.92);
  --panel-strong: #fffdfa;
  --panel-border: #c8bfae;
  --text: #2f2b24;
  --muted: #706658;
  --accent: #8d5a09;
  --accent-strong: #6f4706;
  --progress-good: #0d5b26;
  --warn: #8a5a16;
  --danger: #983939;
  --shadow: 0 18px 40px rgba(84, 62, 28, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #f6f1e8 0%, #ece6d8 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0.62rem 1rem;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

button:hover:enabled {
  transform: translateY(-1px);
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(141, 90, 9, 0.2);
}

button.primary:hover:enabled {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.hero {
  margin-bottom: 12px;
}

.hero-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1 1 auto;
  min-width: 0;
}

.hero-logo {
  width: 112px;
  height: 112px;
  object-fit: contain;
  flex: 0 0 auto;
}

.hero-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
  padding-bottom: 6px;
}

.hero-title {
  margin: 0;
  font-size: clamp(2.4rem, 5.2vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: #b97809;
}

.version-note {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
}

.hero-actions {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
  margin-left: auto;
  padding-bottom: 6px;
}

.hero-help-btn {
  min-width: 92px;
  padding: 0.62rem 1.45rem;
  border-radius: 16px;
  font-size: 0.98rem;
  background: rgba(255, 253, 250, 0.96);
  box-shadow: 0 8px 18px rgba(84, 62, 28, 0.08);
}

.hero-help-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent-strong);
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.steps {
  position: relative;
  z-index: 2;
  padding: 18px;
}

.steps-grid {
  display: grid;
  gap: 14px;
}

.step-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(198, 180, 144, 0.9);
  border-radius: 12px;
  background: rgba(255, 252, 246, 0.88);
}

.step-index {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eadab8;
  color: #5a4d33;
  font-weight: 700;
}

.step-title {
  margin: 0;
  font-size: 1rem;
}

.step-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.28rem;
}

.step-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 1;
}

.step-help[open] {
  z-index: 3;
}

.step-help-toggle {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-grid;
  place-items: center;
  margin: 0;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.step-help-toggle::-webkit-details-marker {
  display: none;
}

.step-help-card {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  z-index: 5;
  width: min(26rem, calc(100vw - 6rem));
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: #fff9ef;
  box-shadow: var(--shadow);
  color: var(--text);
}

.step-help-card p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

.step-help-card p + p {
  margin-top: 0.65rem;
}

.step-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.step-meta {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.step-value {
  font-size: 0.9rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.step-value.subtle {
  color: var(--muted);
  font-weight: 500;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.status-panel {
  position: relative;
  z-index: 1;
  padding: 10px 12px;
}

.writer-help-card {
  padding: 16px 18px;
}

.writer-help-title {
  margin: 0 0 8px;
  font-size: 1rem;
}

.writer-help-copy {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.5;
}

.writer-help-copy + .writer-help-copy {
  margin-top: 10px;
}

.writer-help-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.return-actions {
  display: flex;
  justify-content: flex-end;
}

.status-label {
  color: var(--muted);
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.status-text {
  color: var(--text);
}

.status-message.warn .status-text {
  color: var(--warn);
}

.status-message.err .status-text {
  color: var(--danger);
}

.status-detail {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.error-detail {
  color: var(--danger);
}

.progress-block {
  margin-top: 8px;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(198, 180, 144, 0.45);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: #d99e4d;
  transition:
    width 160ms ease,
    background-color 160ms ease;
}

.progress-fill.success {
  background: var(--progress-good);
}

.progress-fill.failure {
  background: var(--danger);
}

.progress-label {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.92rem;
}

.loaded-file-name {
  font-weight: 700;
}

.loaded-file-summary {
  font-weight: 400;
}

.fineprint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 640px) {
  .hero-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-brand {
    align-items: center;
  }

  .hero-logo {
    width: 96px;
    height: 96px;
  }

  .hero-title-group {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding-bottom: 0;
  }

  .hero-help-btn {
    min-width: 0;
  }

  .step-card {
    grid-template-columns: auto 1fr;
  }

  .actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .return-actions {
    justify-content: flex-start;
  }

  .step-help-card {
    width: min(24rem, calc(100vw - 5rem));
  }

  .hero-actions {
    padding-bottom: 0;
  }
}
