:root {
  color-scheme: light;
  --page: #edf7fb;
  --paper: #ffffff;
  --paper-soft: #f8fcfe;
  --blue: #2589c8;
  --blue-dark: #186ca5;
  --blue-soft: #d9f0fb;
  --line: #cfe4ee;
  --text: #1f3340;
  --muted: #687d88;
  --warning: #e15f45;
  --warning-bg: #fff7f3;
  --shadow: 0 18px 48px rgba(41, 108, 147, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 8%, rgba(255, 255, 255, 0.9) 0 14%, transparent 30%),
    linear-gradient(180deg, #e5f5fb 0%, #f7fbfd 48%, #edf7fb 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 44px;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 198px;
  padding: 26px 22px 32px;
  color: #ffffff;
  border: 1px solid rgba(99, 174, 214, 0.42);
  border-radius: 24px;
  background-image: url("./assets/card-header.png?v=water-original-2");
  background-position: center top;
  background-size: cover;
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, rgba(0, 78, 126, 0.1) 0%, rgba(0, 78, 126, 0.22) 100%);
}

.hero-brand {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 1px 2px rgba(0, 74, 116, 0.28);
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 30px 0 8px;
  font-size: clamp(38px, 9vw, 64px);
  line-height: 1;
  letter-spacing: 0;
  color: #ffffff;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-weight: 900;
  text-shadow: 0 2px 5px rgba(0, 74, 116, 0.18);
}

.hero p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  line-height: 1.7;
  text-shadow: 0 1px 2px rgba(0, 74, 116, 0.22);
}

.privacy-note {
  margin: 16px 0;
  padding: 14px 16px;
  color: #285061;
  border: 1px solid #c7e6f1;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  line-height: 1.7;
  box-shadow: 0 10px 28px rgba(41, 108, 147, 0.08);
}

.card-form,
.preview-area {
  display: grid;
  gap: 14px;
}

.form-section,
.preview-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 32px rgba(41, 108, 147, 0.08);
}

.form-section h2,
.preview-heading h2,
.panel-topline h3 {
  margin: 0;
  letter-spacing: 0;
}

.form-section h2 {
  color: #174d70;
  font-size: 18px;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
}

.section-heading strong {
  color: var(--warning);
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.form-grid.stacked {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 8px;
}

label > span {
  color: #365b6d;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  border: 1px solid #cddde5;
  border-radius: 14px;
  background: #fbfdfe;
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input,
select {
  min-height: 48px;
  padding: 0 13px;
}

textarea {
  min-height: 106px;
  padding: 12px 13px;
  line-height: 1.65;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #67b8df;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(103, 184, 223, 0.16);
}

.warning-section {
  border-color: #f1d2c6;
  background: linear-gradient(180deg, #fffdfb 0%, #ffffff 100%);
}

.action-bar {
  position: sticky;
  z-index: 4;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 18px -14px 22px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(180, 214, 229, 0.8);
  background: rgba(237, 247, 251, 0.92);
  backdrop-filter: blur(12px);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, #197cbc 0%, #32a2d8 100%);
  box-shadow: 0 14px 28px rgba(25, 124, 188, 0.22);
}

.secondary-button {
  color: #17608e;
  border: 1px solid #a8d7ed;
  background: #ffffff;
}

.text-button {
  min-height: 38px;
  padding: 0 14px;
  color: #17608e;
  border: 1px solid #b9ddec;
  background: #f6fbfe;
  font-size: 14px;
}

.preview-heading {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.preview-heading h2 {
  color: #174d70;
  font-size: 22px;
}

.preview-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel-topline {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-topline h3 {
  color: #174d70;
  font-size: 18px;
}

.preview-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 430px);
  aspect-ratio: 1414 / 2000;
  margin: 0 auto;
  border: 1px solid #e0edf3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(31, 91, 128, 0.12);
}

.preview-panel.has-generated-image .preview-card {
  display: none;
}

.preview-card-header {
  position: relative;
  height: 18%;
  color: #ffffff;
  background-image: url("./assets/card-header.png?v=water-original-1");
  background-position: center top;
  background-size: cover;
}

.preview-card-header::before {
  position: absolute;
  top: 5.2%;
  left: 2.8%;
  content: "©不止挚友律师团队2026";
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.preview-card-header::after {
  position: absolute;
  top: 34%;
  left: 0;
  width: 100%;
  content: "医疗信息卡";
  color: #ffffff;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.preview-card-body {
  position: relative;
  z-index: 1;
  color: #000000;
}

.paper-border {
  position: absolute;
  inset: 18% 4.6% 4.8%;
  border-right: 1px solid #d9eef8;
  border-bottom: 1px solid #d9eef8;
  border-left: 1px solid #d9eef8;
  border-radius: 0 0 2.8% 2.8%;
}

.paper-border .preview-card-body {
  display: grid;
  gap: 1.55%;
  height: 100%;
  padding: 2.2% 4.1% 2.4%;
}

.paper-section h4 {
  margin: 0 0 1.5%;
  color: #1f7fb6;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
}

.paper-fields {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3% 3.3%;
}

.paper-fields p {
  display: flex;
  align-items: center;
  grid-column: span 2;
  min-height: 24px;
  margin: 0;
  padding: 0 2.6%;
  border: 1px solid #d8e9f1;
  border-radius: 8px;
  background: #fbfeff;
  color: #243a49;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.paper-fields .date-field {
  grid-column: span 3;
}

.paper-fields .age-field {
  grid-column: span 3;
}

.paper-fields .full-field {
  grid-column: 1 / -1;
}

.contact-preview .paper-fields {
  grid-template-columns: repeat(6, 1fr);
}

.contact-preview .paper-fields p {
  grid-column: span 2;
}

.contact-preview .paper-fields .phone-field {
  grid-column: span 4;
}

.paper-fields b,
.paper-bullet b,
.paper-note-box b,
.back-note-box b {
  min-width: 0;
  color: #1677aa;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.paper-fields b:empty::after,
.paper-bullet b:empty::after,
.paper-note-box b:empty::after,
.back-note-box b:empty::after {
  display: inline-block;
  min-width: 2.4em;
  content: "";
}

.paper-bullet {
  position: relative;
  margin: 0 0 2.8% 4.5%;
  color: #334b5c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.paper-bullet::before {
  position: absolute;
  left: -3%;
  content: "•";
}

.paper-note-box {
  display: grid;
  gap: 4%;
  min-height: 10.4%;
  margin-top: 1.2%;
  padding: 2.5% 3%;
  border: 1px solid #d8e9f1;
  border-radius: 2.1%;
  background: #fbfeff;
}

.paper-note-box p {
  margin: 0;
  color: #334b5c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.back-body {
  height: 82%;
  padding: 2.2% 4% 5%;
}

.back-note-section h4 {
  margin: 0 0 1.3%;
  color: #1f7fb6;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}

.back-subtitle {
  margin: 0 0 3.4%;
  color: #8b9aa5;
  font-size: 15px;
  font-weight: 700;
}

.back-note-box {
  min-height: 73%;
  padding: 3.2%;
  border: 1px solid #d9eef8;
  border-radius: 2.8%;
  color: #223746;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.preview-card footer {
  position: absolute;
  right: 0;
  bottom: 1.8%;
  left: 0;
  z-index: 1;
  color: #666666;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.generated-image-frame {
  width: min(100%, 430px);
  margin: 14px auto 0;
  padding: 8px;
  border: 1px solid #bfe1ee;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(31, 91, 128, 0.12);
}

.generated-image-frame[hidden] {
  display: none;
}

.generated-image-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  -webkit-touch-callout: default;
  user-select: auto;
}

@media (min-width: 720px) {
  .page-shell {
    padding: 28px 24px 60px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-bar {
    grid-template-columns: 1fr 1fr;
    margin-right: 0;
    margin-left: 0;
    border: 1px solid rgba(180, 214, 229, 0.8);
    border-radius: 22px;
  }
}

@media (min-width: 980px) {
  .preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    min-height: 230px;
    padding: 32px 42px;
  }
}
