:root {
  --bg: #f5f5f7;
  --bg-soft: #fbfbfd;
  --card: rgba(255, 255, 255, 0.88);
  --card-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.16);
  --text-main: #1d1d1f;
  --text-soft: #6e6e73;
  --brand: #0071e3;
  --brand-hover: #0062c3;
  --ok-bg: #eaf7ef;
  --ok-fg: #1f6f46;
  --error-bg: #fff0f0;
  --error-fg: #b21d1d;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family:
    "SF Pro Display",
    "SF Pro Text",
    -apple-system,
    BlinkMacSystemFont,
    "PingFang SC",
    "Helvetica Neue",
    "Noto Sans CJK SC",
    sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 50% -20%, rgba(0, 113, 227, 0.1), transparent 45%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 70%, #f1f1f3 100%);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line-strong);
  text-decoration: none;
  z-index: 30;
}

.skip-link:focus {
  top: 10px;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 18px 44px;
}

.hero {
  margin-bottom: 18px;
  padding: 34px 30px 30px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88)),
    linear-gradient(120deg, rgba(0, 113, 227, 0.06), rgba(255, 255, 255, 0));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.hero-kicker {
  margin: 0;
  color: #8a8a8f;
  font-size: 12px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-weight: 600;
}

.hero h1 {
  margin: 10px 0 10px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.03;
  letter-spacing: -0.028em;
  font-weight: 700;
}

.hero-subtitle {
  margin: 0;
  max-width: 760px;
  color: var(--text-soft);
  font-size: 19px;
  line-height: 1.6;
}

.mode-switch {
  display: inline-flex;
  gap: 10px;
  margin-top: 20px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.mode-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: transparent;
  color: #526173;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.mode-button:hover {
  color: var(--text-main);
  transform: translateY(-1px);
}

.mode-button.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 20px rgba(0, 113, 227, 0.18);
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 18px;
}

.mode-panel {
  display: none;
}

.mode-panel.is-active {
  display: grid;
}

.control-stack {
  display: grid;
  gap: 18px;
  align-content: start;
}

.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
  padding: 22px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 25px;
  letter-spacing: -0.015em;
}

.upload-card {
  padding-bottom: 16px;
}

.upload {
  display: block;
  padding: 21px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(0, 113, 227, 0.32);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.upload:hover {
  border-color: rgba(0, 113, 227, 0.56);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 113, 227, 0.12);
}

.upload input {
  display: none;
}

.upload-title {
  display: block;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.upload-desc {
  display: block;
  margin-top: 7px;
  color: var(--text-soft);
  font-size: 14px;
}

.status {
  margin-top: 12px;
  border-radius: var(--radius-md);
  padding: 12px 13px;
  border: 1px solid rgba(31, 111, 70, 0.26);
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.status.error {
  border-color: rgba(178, 29, 29, 0.24);
  background: var(--error-bg);
  color: var(--error-fg);
}

.field-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.field-row label {
  color: #4a4a4f;
  font-size: 14px;
  font-weight: 600;
}

.field-row input,
.field-row select {
  width: 100%;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card-strong);
  color: #2c2c2f;
  padding: 10px 11px;
  font-size: 14px;
}

.field-row input:focus,
.field-row select:focus,
.preview-editor:focus {
  outline: none;
  border-color: rgba(0, 113, 227, 0.46);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.primary {
  width: 100%;
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 20px rgba(0, 113, 227, 0.25);
}

.primary-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 20px;
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.primary.is-loading .button-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: button-spin 0.8s linear infinite;
}

.primary.is-success {
  background: #1f8f5f;
  box-shadow: 0 10px 20px rgba(31, 143, 95, 0.24);
}

.primary.is-success .button-icon::before {
  content: "✓";
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
}

.primary:disabled,
.field-row select:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary {
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(0, 113, 227, 0.22);
  background: rgba(0, 113, 227, 0.06);
  color: #215b97;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.secondary:hover {
  background: rgba(0, 113, 227, 0.1);
  border-color: rgba(0, 113, 227, 0.34);
  transform: translateY(-1px);
}

.secondary:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.tips {
  margin: 12px 0 0;
  color: #7a7a7f;
  font-size: 13px;
  line-height: 1.55;
}

.preview-stage {
  display: flex;
  flex-direction: column;
  min-height: 730px;
}

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

.preview-head h2 {
  margin: 0;
}

.preview-chip {
  border-radius: 999px;
  border: 1px solid rgba(0, 113, 227, 0.24);
  color: #3f6186;
  background: rgba(0, 113, 227, 0.08);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.preview-editor {
  width: 100%;
  min-height: 620px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #ffffff, #fbfbfd);
  color: #1f2937;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  resize: vertical;
}

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

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

  .hero {
    padding: 28px 24px;
  }

  .hero-subtitle {
    font-size: 17px;
  }

  .mode-switch {
    display: flex;
    width: 100%;
  }

  .mode-button {
    flex: 1;
    text-align: center;
  }

  .preview-stage {
    min-height: auto;
  }

  .preview-editor {
    min-height: 460px;
  }
}

/* Static deployment: ensure the HTML hidden attribute always wins over the active layout rule. */
.mode-panel[hidden] {
  display: none !important;
}
