:root {
  --bg: #eef2f7;
  --paper: #ffffff;
  --paper-soft: #f8fafc;
  --line: #dbe3ef;
  --text: #172033;
  --muted: #5f6f86;
  --accent: #2563eb;
  --accent-deep: #1d4ed8;
  --accent-soft: #dbeafe;
  --success: #2563eb;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    linear-gradient(180deg, #f3f6fb 0%, #edf2f7 100%);
  min-height: 100vh;
}

.shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.hero {
  margin-bottom: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--accent-deep);
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4.2vw, 46px);
  line-height: 1.04;
  max-width: none;
  letter-spacing: -0.03em;
}

.lede {
  max-width: none;
  font-size: 16px;
  line-height: 1.75;
  color: var(--muted);
  margin-top: 14px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.upload-form {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr auto;
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 14px;
  color: var(--muted);
}

input[type="file"],
select,
button {
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font-size: 15px;
}

input[type="file"],
select {
  background: var(--paper-soft);
  color: var(--text);
}

button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
  box-shadow: none;
}

.ghost-btn {
  background: white;
  color: var(--accent-deep);
  border: 1px solid var(--line);
  box-shadow: none;
}

.message {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.job-card {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

#current-pause-btn {
  margin-top: 14px !important;
}

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

.estimate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.estimate-box {
  padding: 16px;
  border-radius: 20px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
}

.meta-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.meta-value {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.meta-value.small {
  font-size: 14px;
  line-height: 1.6;
  font-weight: 500;
}

.progress-wrap {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: #e5edf9;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
  transition: width 260ms ease;
}

.progress-text,
.queue-note {
  margin: 10px 0 0;
  color: var(--muted);
}

.downloads {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.download-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  color: white;
  background: var(--success);
}

.download-link.subtle {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.logs {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: #0f172a;
}

.logs-head {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#logs-output {
  margin: 0;
  padding: 14px 16px 18px;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.history {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-head h2 {
  margin: 0;
  font-size: 20px;
}

.history-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr) auto;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-soft);
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.history-title {
  margin: 0 0 4px;
  font-weight: 600;
}

.history-sub,
.history-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.history-item.clickable {
  cursor: pointer;
}

.history-item.clickable:hover {
  border-color: #bfd3f8;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.small-btn {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 999px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
}

.modal-panel {
  position: relative;
  width: min(960px, calc(100% - 24px));
  max-height: calc(100vh - 40px);
  margin: 20px auto;
  padding: 20px;
  border-radius: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: auto;
}

.panel,
.hero,
.modal-panel {
  backdrop-filter: blur(6px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  font-size: 24px;
}

.segment-list {
  display: grid;
  gap: 12px;
}

.segment-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
}

.segment-title {
  margin: 0 0 4px;
  font-weight: 600;
}

.segment-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.segment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hidden {
  display: none;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 960px);
    padding-top: 24px;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .upload-form,
  .job-meta,
  .estimate-grid,
  .history-item,
  .segment-item {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
  }
}
