/* ===== Theme: Light + Soft Purple ===== */
:root{
  --bg: #f5f3ff;
  --panel: #ffffff;
  --panel-alt: #faf8ff;
  --text: #1e1b4b;
  --muted: #6b7280;
  --line: #e5e1f5;
  --primary: #7c3aed;
  --primary-light: #ede9fe;
  --primary-glow: rgba(124, 58, 237, 0.12);
  --accent: #8b5cf6;
  --accent2: #a78bfa;
  --accent3: #6366f1;
  --danger: #ef4444;
  --shadow: 0 2px 12px rgba(124, 58, 237, 0.08);
  --shadow-lg: 0 8px 30px rgba(124, 58, 237, 0.12);
  --radius: 16px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  background: linear-gradient(160deg, #f5f3ff 0%, #ede9fe 30%, #e0e7ff 70%, #f5f3ff 100%);
  color: var(--text);
  overflow-x: hidden;
}

.bg{
  position:fixed;
  inset:0;
  pointer-events:none;
  overflow:hidden;
}
.bg::before{
  content:"";
  position:absolute;
  width:500px;
  height:500px;
  border-radius:50%;
  background: radial-gradient(circle, rgba(139,92,246,.12) 0%, transparent 70%);
  top:-100px;
  right:-100px;
}
.bg::after{
  content:"";
  position:absolute;
  width:400px;
  height:400px;
  border-radius:50%;
  background: radial-gradient(circle, rgba(99,102,241,.10) 0%, transparent 70%);
  bottom:-80px;
  left:-80px;
}

.wrap{
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  position: relative;
  z-index: 1;
}

/* Hero header */
.hero{
  padding: 8px 0 12px;
}
.brand{
  display:inline-flex;
  align-items:center;
  gap:10px;
  font-weight:700;
  letter-spacing:.5px;
  color: var(--primary);
  font-size: 13px;
}
.brand::before{
  content:"";
  width:10px;
  height:10px;
  border-radius:99px;
  background: linear-gradient(135deg, var(--primary), var(--accent3));
  box-shadow: 0 0 0 5px rgba(124,58,237,.12);
}
.heroTop{
  display:flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.hero h1{
  margin: 8px 0 6px;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--accent3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub{
  margin:0;
  color: var(--muted);
  line-height:1.5;
  font-size: 13px;
}

/* Layout */
.layout{
  display:grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 14px;
  margin-top: 12px;
}

/* Panels */
.panel{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.panelHead{
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-alt), #fff);
}
.panelTitle{ font-weight:700; font-size:14px; }
.panelSub{ color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Cards */
.card{
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card:last-child{ border-bottom:0; }
.soft{
  background: var(--panel-alt);
}
.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}
h2{
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--primary);
}
.muted{ color: var(--muted); font-size: 12px; }

/* Form */
.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field{
  display:flex;
  flex-direction:column;
  gap: 4px;
  margin: 8px 0;
}
.field span{
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea{
  width:100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  outline:none;
  font-size: 13px;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
textarea{ resize: vertical; min-height: 78px; }
input::placeholder, textarea::placeholder{ color: #c4b5fd; }
input:focus, select:focus, textarea:focus{
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(139,92,246,.12);
}

.inline{
  display:flex;
  align-items:center;
  gap:8px;
}
.pill{
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  min-width: 42px;
  text-align: center;
}
.sep{
  color: var(--muted);
  padding: 0 2px;
  font-weight: 600;
}

/* Subject grid */
.subjectGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.subjectBlock{
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px;
}
.subjectTitle{
  font-weight: 650;
  margin-bottom: 8px;
  font-size: 13px;
}
.subjectInputs{
  display:flex;
  align-items:center;
  gap: 8px;
}
.subjectInputs input{ padding: 8px 10px; }
.subjectInputs .pill{ margin-left:auto; }

.otherSubjectsRow{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.miniField{
  display:flex;
  flex-direction:column;
  gap: 4px;
  margin: 0;
}
.miniField span{
  font-size: 10px;
  color: var(--muted);
}
.miniField input{ padding: 7px 9px; }

/* Buttons */
.btn{
  appearance:none;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor:pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .2s ease;
  font-family: inherit;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }

.btn.ai{
  background: linear-gradient(135deg, var(--primary), var(--accent3));
  color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,.3);
}
.btn.ai:hover{
  box-shadow: 0 6px 20px rgba(124,58,237,.4);
}
.btn.ai.policy{
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 4px 14px rgba(245,158,11,.3);
}
.btn.ai.policy:hover{
  box-shadow: 0 6px 20px rgba(245,158,11,.4);
}
.btn.pdf{
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line);
}
.btn.pdf:hover{
  border-color: var(--accent2);
  background: var(--primary-light);
}
.btn.img{
  background: #fff;
  color: var(--accent3);
  border: 1px solid var(--line);
}
.btn.img:hover{
  border-color: var(--accent2);
  background: var(--primary-light);
}
.btn.help{
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.btn.help:hover{
  border-color: var(--accent2);
  color: var(--primary);
  background: var(--primary-light);
}
.btn:disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none !important;
}

@keyframes aiPulse{
  0%,100%{ box-shadow: 0 4px 14px rgba(124,58,237,.3); }
  50%{ box-shadow: 0 6px 24px rgba(124,58,237,.5); }
}
.btn.ai.loading{
  animation: aiPulse 1.2s ease infinite;
}

.hint{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}
.hint.bad{ color: var(--danger); }

/* Report preview */
.reportPreview{
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow:hidden;
  background: var(--panel-alt);
  min-height: 620px;
}
.reportFrame{
  width:100%;
  min-height: 620px;
  border:0;
  background: #fff;
}

.foot{
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  padding: 0 16px;
}

.hide{ display:none !important; }

/* Modal */
.modalOverlay{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 24px 16px;
  background: rgba(30,27,75,.40);
  backdrop-filter: blur(8px);
}
.modalCard{
  width: min(600px, 100%);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(124,58,237,.15);
  overflow:hidden;
}
.modalHead{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modalTitle{ font-weight: 800; font-size: 15px; }
.modalClose{
  appearance:none;
  border: none;
  background: var(--panel-alt);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor:pointer;
  font-size: 18px;
  line-height: 0;
  transition: all .2s;
}
.modalClose:hover{ background: #fee2e2; color: var(--danger); }
.modalBody{ padding: 14px 16px 2px; }
.modalList{ margin: 0; padding-left: 18px; line-height: 1.75; color: var(--muted); font-size: 14px; }
.modalFoot{
  padding: 12px 16px 16px;
  display:flex;
  justify-content:flex-end;
}
.modalFoot .btn{
  background: linear-gradient(135deg, var(--primary), var(--accent3));
  color: #fff;
  padding: 8px 20px;
}

@media print{
  .modalOverlay{ display:none !important; }
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .reportPreview, .reportFrame{ min-height: 520px; }
  .otherSubjectsRow{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
