:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f4;
  --fg: #0a0a0a;
  --fg-2: #525252;
  --fg-3: #a1a1a1;
  --line: #ececec;
  --line-2: #dcdcdc;
  --danger: #b42318;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--fg-2);
}

.faint {
  color: var(--fg-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout */

.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(40px, 12vh, 120px) 16px 64px;
}

.page-wide {
  max-width: 760px;
}

.eyebrow {
  font-size: 13px;
  color: var(--fg-3);
  margin-bottom: 6px;
}

.title {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
  margin-bottom: 4px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--bg);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:hover {
  background: var(--surface);
  border-color: #cfcfcf;
}

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

.btn-primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.btn-primary:hover {
  background: #262626;
  border-color: #262626;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 48px;
  font-size: 15px;
  border-radius: 10px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: default;
  transform: none;
}

.btn-secondary:disabled {
  background: var(--surface);
  border-color: var(--line);
  color: var(--fg-3);
}

.btn-primary:disabled {
  background: #3a3a3a;
  border-color: #3a3a3a;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Spinner */

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  flex: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Tags */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
}

.tag-solid {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.tag-danger {
  color: var(--danger);
  border-color: #efc7c3;
}

.tag-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s var(--ease) infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* Home */

.hero {
  margin-bottom: 28px;
}

.generate {
  margin-bottom: 48px;
}

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

.history-item {
  border-top: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 1px solid var(--line);
}

.history-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 16px;
  padding: 14px 10px;
  margin: 0 -10px;
  border-radius: var(--radius);
  transition: background-color 0.15s var(--ease);
}

.history-link:hover {
  background: var(--surface);
}

.history-link:hover .history-arrow {
  color: var(--fg);
  transform: translateX(2px);
}

.history-main {
  min-width: 0;
}

.history-date {
  font-weight: 500;
}

.history-meta {
  display: block;
  color: var(--fg-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-arrow {
  width: 16px;
  height: 16px;
  color: var(--fg-3);
  transition: transform 0.15s var(--ease), color 0.15s var(--ease);
}

.empty {
  padding: 32px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--fg-3);
  text-align: center;
}

.notice {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg-2);
  font-size: 13px;
}

.notice-danger {
  color: var(--danger);
  border-color: #f1d3d0;
  background: #fdf6f5;
}

.notice a {
  color: var(--fg);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Skeleton */

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 0%, #fbfbfb 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Dialog */

.dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.04);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.dialog[open] {
  animation: dialog-in 0.2s var(--ease);
}

.dialog::backdrop {
  background: rgba(10, 10, 10, 0.28);
  backdrop-filter: blur(2px);
  animation: fade-in 0.2s var(--ease);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.dialog-subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: var(--fg-3);
}

.dialog-head .icon-btn {
  margin: -6px -8px 0 0;
}

/* Export */

.export {
  border: 1px solid var(--line);
  border-radius: 10px;
}

.export-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 12px 14px;
}

.export-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.export-date {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.export-count {
  font-size: 13px;
  color: var(--fg-3);
}

.export-toggle svg {
  transition: transform 0.2s var(--ease);
}

.export-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.export-files {
  list-style: none;
  margin: 0 14px;
  padding: 10px 0 12px;
  max-height: 184px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  color: var(--fg-2);
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.export-files[hidden] {
  display: none;
}

.export-skeleton {
  height: 66px;
  border-radius: 10px;
}

.hint {
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.45;
}

/* Switch */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.switch-text {
  display: flex;
  flex-direction: column;
}

.switch-caption {
  font-size: 13px;
  color: var(--fg-3);
}

.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-2);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s var(--ease);
}

.switch:checked {
  background: var(--fg);
}

.switch:checked::after {
  transform: translateX(16px);
}

/* Report */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  color: var(--fg-3);
  font-size: 13px;
  transition: color 0.15s var(--ease);
}

.back:hover {
  color: var(--fg);
}

.back svg {
  width: 14px;
  height: 14px;
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.report-subtitle {
  margin-top: 6px;
  color: var(--fg-3);
}

.report-head .tag {
  margin-top: 8px;
}

.report-error {
  margin-bottom: 24px;
}

.stages {
  list-style: none;
  margin: 0 0 32px;
  padding: 4px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.stage {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
  padding: 10px 16px;
  color: var(--fg-3);
  transition: color 0.2s var(--ease);
}

.stage[data-status="active"],
.stage[data-status="failed"] {
  color: var(--fg);
  font-weight: 500;
}

.stage[data-status="done"] {
  color: var(--fg-2);
}

.stage-marker {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
}

.stage-marker svg {
  width: 12px;
  height: 12px;
}

.stage[data-status="done"] .stage-marker {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.stage[data-status="active"] .stage-marker {
  border-color: var(--fg);
  border-right-color: transparent;
  animation: spin 0.9s linear infinite;
}

.stage[data-status="failed"] .stage-marker {
  border-color: var(--danger);
  color: var(--danger);
}

.stage-count {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.stage-bar {
  grid-column: 2 / -1;
  height: 3px;
  margin-top: 10px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.stage-bar[hidden] {
  display: none;
}

.stage-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--fg);
  transition: width 0.3s var(--ease);
}

.stage-bar[data-indeterminate] .stage-bar-fill {
  width: 30%;
  animation: indeterminate 1.2s var(--ease) infinite;
}

@keyframes indeterminate {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.files {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.file {
  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s var(--ease);
}

.file[data-ready="true"] {
  border-color: var(--line-2);
}

.file-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.file-description {
  flex: 1;
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.45;
}

.file-count {
  min-height: 20px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.file .btn {
  width: 100%;
  height: 36px;
}

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

  .report-head {
    flex-direction: column;
    gap: 0;
  }

  .report-head .tag {
    margin-top: 12px;
  }

  .title {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
