:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #1c2430;
  --muted: #647084;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #1e40af;
  --danger-dark: #1e3a8a;
  --focus: #93c5fd;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.language-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
}

.language-toggle-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 14px;
  text-decoration: none;
}

.language-toggle-item + .language-toggle-item {
  border-left: 1px solid #bfdbfe;
}

.language-toggle-item:not(.is-active):hover {
  background: #dbeafe;
}

.language-toggle-item.is-active {
  background: var(--primary);
  color: #fff;
  cursor: default;
}

.admin-email {
  color: var(--muted);
  font-size: 14px;
}

.topnav-account {
  margin-left: 12px;
}

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 28px auto 64px;
}

.heading {
  margin-bottom: 18px;
}

.heading h1 {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

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

.heading-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.back-link {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.panel,
.site-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  margin-bottom: 18px;
  padding: 20px;
}

.panel.narrow {
  width: min(420px, 100%);
  margin: 80px auto;
}

.panel h1,
.panel h2 {
  margin: 0 0 14px;
}

.site-list {
  overflow: hidden;
}

.site-list-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.4fr) minmax(130px, 0.7fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 58px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.site-list-row:first-child {
  border-top: 0;
}

.site-list-head {
  min-height: 40px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.site-list-name,
.site-list-status,
.site-list-date,
.site-list-actions {
  min-width: 0;
}

.site-list-name {
  display: grid;
  gap: 3px;
}

.site-list-name span,
.site-list-date {
  color: var(--muted);
}

.site-list-status a {
  overflow-wrap: anywhere;
}

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

@media (max-width: 760px) {
  .site-list-head {
    display: none;
  }

  .site-list-row {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
  }

  .site-list-actions {
    justify-content: flex-start;
  }
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

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

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

.button.secondary {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

.button.danger {
  background: var(--danger);
  color: #fff;
}

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

.button.small {
  min-height: 32px;
}

.button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button svg.stop-icon {
  fill: currentColor;
  stroke: none;
}

.icon-tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #1e40af;
  cursor: pointer;
}

.icon-tool-button:hover {
  background: #dbeafe;
}

.icon-tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-tool-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 140px;
  border: 2px dashed #aeb7c5;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.drop-zone strong {
  color: var(--text);
}

.drop-zone.is-dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.status-line {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
}

.message.error,
.status-line.error {
  color: var(--danger);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.archive-status-progress {
  display: grid;
  grid-template-columns: minmax(140px, 280px) max-content;
  align-items: center;
  gap: 8px;
  width: auto;
  margin-left: auto;
}

.archive-list-shell {
  position: relative;
  min-height: 80px;
}

.archive-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.archive-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  min-height: 100%;
  border-radius: 8px;
  background: rgb(255 255 255 / 78%);
  color: var(--muted);
  font-size: 14px;
}

.archive-loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #bfdbfe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.archive-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.archive-row.is-processing {
  border-color: #93c5fd;
  background: #f8fbff;
}

.archive-row.is-error {
  border-color: #ef4444;
  background: #fff7f7;
}

.archive-meta {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.archive-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.archive-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-detail,
.archive-note {
  color: var(--muted);
  font-size: 13px;
}

.archive-note {
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
  padding-inline: 10px;
  overflow-wrap: anywhere;
  text-align: left;
}

.archive-note.is-empty {
  font-style: italic;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e7f3ff;
  color: #24517d;
  font-size: 12px;
  text-decoration: none;
}

.badge svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.badge:hover {
  background: #dbeafe;
}

.badge.staging {
  background: #dbeafe;
  color: #1e40af;
}

.badge.staging:hover {
  background: #bfdbfe;
}

.archive-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.archive-action-status {
  color: var(--muted);
  font-size: 13px;
}

.archive-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.archive-progress-bar {
  position: relative;
  width: min(280px, 100%);
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}

.archive-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 160ms ease;
}

.archive-progress-bar.is-indeterminate span {
  position: absolute;
  width: 40%;
  animation: archive-progress 1.1s ease-in-out infinite;
}

@keyframes archive-progress {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(260%);
  }
}

.archive-note-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.archive-note-edit input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.archive-note-edit.is-saving input,
.archive-note-edit.is-saving button {
  opacity: 0.55;
}

.archive-note-edit.is-saving .inline-spinner {
  display: inline-block;
}

.inline-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bfdbfe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.inline-spinner[hidden] {
  display: none;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  box-shadow: 0 12px 30px rgb(0 0 0 / 20%);
}

@media (max-width: 720px) {
  .topbar,
  .heading.split,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

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