:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --border: #e5e5e5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --success: #15803d;
  --warning: #a16207;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  --content-max: 42rem;
  --page-pad: 1rem;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0.75rem var(--page-pad);
}

.site-header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.site-brand {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.site-brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.9375rem;
}

.site-main {
  flex: 1;
  padding: 1.5rem var(--page-pad) 3rem;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
}

.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.doc-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  margin-bottom: 1.25rem;
}

.doc-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.doc-section h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.prose {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.prose:last-child {
  margin-bottom: 0;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form input[type="text"],
.form input[type="file"] {
  font: inherit;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 44px;
}

.form input[type="file"] {
  padding: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  text-decoration: none;
}

.error-text {
  margin: 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.error-box {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.error-box p {
  margin: 0 0 0.5rem;
}

.meta-list {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.meta-list > div {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) 1fr;
  gap: 0.5rem 1rem;
  align-items: baseline;
  font-size: 0.9375rem;
}

.meta-list dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.meta-list dd {
  margin: 0;
  word-break: break-word;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--text);
}

.badge-pending,
.badge-queued {
  background: #fef3c7;
  color: var(--warning);
}

.badge-in_progress {
  background: #dbeafe;
  color: var(--accent);
}

.badge-completed {
  background: #dcfce7;
  color: var(--success);
}

.badge-failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.download-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.status-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

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

.build-list li {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
}

.build-list li:first-child {
  border-top: none;
  padding-top: 0;
}

.build-list a {
  font-weight: 500;
}

.build-list .meta-line {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.icon-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.icon-preview img {
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem var(--page-pad);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}

@media (min-width: 768px) {
  :root {
    --page-pad: 1.5rem;
  }

  .page-title {
    font-size: 2rem;
  }

  .doc-section {
    padding: 1.5rem 1.75rem;
  }

  .download-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
