*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a4a72;
  --primary-light: #2563a0;
  --accent: #16a34a;
  --accent-light: #dcfce7;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #d1dbe8;
  --text: #1e293b;
  --text-muted: #64748b;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, "Helvetica Neue", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-name { font-size: 1.1rem; font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: .75rem; opacity: .7; }
.stage-badge {
  font-size: .72rem;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Layout ── */
main {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  gap: 20px;
  align-items: start;
}

/* ── Form Panel ── */
.form-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky;
  top: 76px;
}

.form-section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-section-label:first-child { margin-top: 0; }

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.optional { font-weight: 400; color: var(--text-muted); font-size: .75rem; }
.required { color: var(--danger); }

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  -webkit-appearance: none;
}
select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
select:focus, textarea:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,160,.15); }
textarea { resize: vertical; line-height: 1.5; }

.radio-group { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
.radio-label { display: flex; align-items: center; gap: 5px; font-size: .83rem; cursor: pointer; }
.radio-label input { accent-color: var(--primary); cursor: pointer; }

.cp-meta {
  margin-top: 6px;
  padding: 8px 10px;
  background: #f0f7ff;
  border-radius: 6px;
  font-size: .78rem;
  color: var(--primary);
  line-height: 1.6;
}

button[type="submit"] {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
button[type="submit"]:hover { background: var(--primary-light); }
button[type="submit"]:active { transform: scale(.98); }
button[type="submit"]:disabled { opacity: .6; cursor: not-allowed; }

/* ── Result Panel ── */
.result-panel { min-height: 400px; }

.placeholder {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
  color: var(--text-muted);
}
.placeholder-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}
.placeholder p { font-size: .9rem; margin-bottom: 28px; line-height: 1.6; }
.placeholder-tips { text-align: left; display: inline-block; }
.tip {
  font-size: .82rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
  color: var(--text);
}
.tip:last-child { border-bottom: none; }
.tip strong { color: var(--primary); }

/* ── Result Header ── */
.result-header {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.result-title { font-size: 1.05rem; font-weight: 700; color: var(--text); flex: 1; }
.result-mode {
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Meta row ── */
.meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.meta-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-size: .82rem;
  flex: 1;
  min-width: 200px;
}
.meta-card .meta-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.hashtags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.hashtag {
  background: #e0eaf6;
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.compliance-card { border-left: 3px solid var(--danger); background: var(--danger-bg); }
.compliance-card .meta-label { color: var(--danger); }
.data-tip-card { border-left: 3px solid var(--warning); background: var(--warning-bg); }
.data-tip-card .meta-label { color: var(--warning); }

/* ── Section Cards ── */
.section-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.section-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.copy-btn {
  font-size: .73rem;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.copy-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.copy-btn.copied { background: var(--accent); color: #fff; border-color: var(--accent); }

/* text kind */
.section-text {
  padding: 16px;
  white-space: pre-wrap;
  font-size: .88rem;
  line-height: 1.75;
}

/* storyboard kind */
.storyboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.storyboard-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.storyboard-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}
.storyboard-table tr:last-child td { border-bottom: none; }
.storyboard-table td:first-child { font-weight: 600; color: var(--primary); white-space: nowrap; width: 90px; }

/* card kind */
.card-content { padding: 20px; }
.card-main {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 6px;
  position: relative;
  display: inline-block;
}
.card-main::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 100%; height: 6px;
  background: #fde68a;
  z-index: -1;
  border-radius: 2px;
}
.card-sub {
  font-size: .88rem;
  color: var(--text-muted);
  margin: 10px 0 14px;
}
.card-points { list-style: none; }
.card-points li {
  display: flex;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  line-height: 1.5;
}
.card-points li:last-child { border-bottom: none; }
.card-points li::before {
  content: counter(item);
  counter-increment: item;
  font-size: .72rem;
  font-weight: 700;
  width: 20px; height: 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.card-points { counter-reset: item; }

/* list kind */
.list-content { padding: 16px; }
.list-content ol {
  padding-left: 20px;
  font-size: .88rem;
  line-height: 2;
}

/* picks kind */
.picks-content { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.pick-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.pick-title { font-weight: 700; font-size: .92rem; margin-bottom: 5px; }
.pick-reason { font-size: .83rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; }
.pick-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.pick-tag {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: #e0eaf6;
  color: var(--primary);
  font-weight: 600;
}

/* week kind */
.week-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.week-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.week-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.week-table tr:last-child td { border-bottom: none; }
.week-table td:first-child { font-weight: 700; color: var(--primary); white-space: nowrap; }
.week-table td:nth-child(3) { color: var(--text-muted); font-size: .78rem; }

/* ── Responsive ── */
@media (max-width: 840px) {
  main { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .form-panel { position: static; }
  .brand-sub { display: none; }
  .form-row.two-col { grid-template-columns: 1fr; gap: 0; }
  .week-table { display: block; overflow-x: auto; }
  .storyboard-table { display: block; overflow-x: auto; }
}

/* ── Loading skeleton ── */
.loading-msg {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
  box-shadow: var(--shadow);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-msg {
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 16px 20px;
  color: var(--danger);
  font-size: .88rem;
  line-height: 1.6;
}
