:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --border: #d7dde8;
  --border-strong: #bac5d6;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger-bg: #fff1f2;
  --danger-text: #be123c;
  --info-bg: #eff6ff;
  --info-text: #1d4ed8;
  --success-bg: #ecfdf5;
  --success-text: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px;
}

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

.host {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.back-link {
  flex: 0 0 auto;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px;
}

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

.page-heading {
  margin-bottom: 20px;
}

.page-heading h1,
.panel-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.tool-card {
  display: block;
  min-height: 148px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
}

.tool-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.tool-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tool-card h2 {
  margin: 16px 0 8px;
  font-size: 19px;
  line-height: 1.3;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.panel-heading {
  padding: 20px 20px 0;
}

.upload-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.upload-field {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.upload-field span {
  font-size: 14px;
  font-weight: 700;
}

.upload-field input {
  width: 100%;
  color: var(--text);
  font-size: 14px;
}

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

button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

button:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status {
  display: none;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
}

.status-info,
.status-error,
.status-success {
  display: block;
}

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

.status-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

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

.status p {
  margin: 0 0 8px;
}

.status ul {
  margin: 0;
  padding-left: 20px;
}

.progress-panel {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
}

.progress-panel[hidden] {
  display: none;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.download-link {
  color: var(--success-text);
  font-weight: 700;
}

@media (max-width: 640px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .page {
    padding: 24px 16px;
  }

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

  .actions {
    justify-content: stretch;
  }

  button {
    width: 100%;
  }
}
