:root {
  --bg: transparent;
  --card: rgba(255, 255, 255, 0.9);
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-ink: #2563eb;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.65 "Inter", "Outfit", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500;
}

/* ===== 上方列 ===== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #9cd5ff);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.appbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== 版面 ===== */
.container {
  max-width: 1200px;
  margin: 18px auto;
  padding: 0 16px;
}

/* ===== Hero ===== */
.hero {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #fff, #f9fbff);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.hero-text h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 900;
}

.hero-text p {
  margin: 0;
  color: var(--muted);
}

.hero-cta .btn {
  min-width: 120px;
}

/* ===== 區塊標題 ===== */
.section-hd {
  margin: 18px 2px 10px;
}

.section-hd h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.section-hd .muted {
  margin: 0;
  color: var(--muted);
}

/* ===== Form Groups (Unboxed) ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 0 48px 0;
}

.form-group:last-of-type {
  margin-bottom: 0;
}

.group-title {
  font-size: 16px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0; /* Handled by parent gap */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
}

.group-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 16px;
  background: var(--brand, #3b82f6);
  border-radius: 4px;
}

/* ===== 表單 (UX Spacing Improvement) ===== */
.form .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form .field[hidden] {
  display: none !important;
}

.lbl {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0; /* Handled by parent gap */
}

.req::after {
  content: " *";
  color: var(--danger);
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #d6dae6;
  background: #fff;
  color: var(--text);
  outline: none;
  line-height: 1.4;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(59, 130, 246, .65);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .15);
}

.search-select {
  position: relative;
}

.search-select-input {
  padding-right: 48px;
}

.search-select-toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.search-select.is-open .search-select-toggle {
  color: var(--accent-ink);
}

.search-select-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  display: none;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d6dae6;
  border-radius: 14px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
  padding: 8px;
}

.search-select.is-open .search-select-panel {
  display: block;
}

.search-select-option {
  width: 100%;
  display: block;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.search-select-option:hover,
.search-select-option.is-active {
  background: #eff6ff;
  color: var(--accent-ink);
}

.search-select-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

/* grid */
.grid {
  display: grid;
  gap: 24px; /* Reduced from 36px */
}

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

.span-2 {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .g-2 {
    grid-template-columns: 1fr;
  }
}

/* row helpers */
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row.wrap {
  flex-wrap: wrap;
}

.datetime-hint {
  margin: 6px 2px 0;
  font-size: 13px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
}

.choice input {
  width: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
}

/* muted */
.muted {
  color: var(--muted);
}

/* ===== note / preview ===== */
.note {
  background: #fbfcff;
  border: 1px dashed #e2e8f0;
  border-radius: 14px;
  padding: 10px 12px;
}

.preview {
  margin: 10px 0 0;
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
}

.file-list {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.sample-download-wrap {
  margin: 8px 0 0;
}

.sample-download-link {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sample-download-link:hover {
  color: var(--accent);
}

/* ===== actions ===== */
.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-bottom: 18px;
}

.msg {
  margin-top: 8px;
  font-size: 14px;
}

/* ===== Buttons ===== */
.btn {
  border: 1px solid #d6dae6;
  background: #fff;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  transition: transform .05s, border-color .15s, background .15s;
}

.btn:hover {
  border-color: #c1c7d6;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800;
}

.btn.primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

/* ===== 提醒區塊（紅框） ===== */
.important-tip {
  margin: 16px 2px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--danger);
  background: rgba(251, 75, 75, 0.06);
  color: #b91c1c;
  font-weight: 800;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.important-tip::before {
  content: "！";
  display: inline-flex;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid currentColor;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-top: 2px;
}

/* ===== 多選下拉（鏈結領域 & SDGs） ===== */
.multi-select {
  position: relative;
}

.ms-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d6dae6;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.ms-trigger:focus {
  outline: none;
  border-color: rgba(59, 130, 246, .65);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .15);
}

.ms-placeholder {
  color: var(--muted);
}

.ms-value {
  font-weight: 700;
}

.ms-caret {
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #6b7280;
}

.multi-select.is-open .ms-caret {
  transform: rotate(180deg);
}

.ms-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  background: #fff;
  border: 1px solid #d6dae6;
  border-radius: 12px;
  padding: 8px 10px;
  max-height: 240px;
  overflow: auto;
  box-shadow: 0 12px 24px rgba(15, 23, 42, .12);
}

.multi-select.is-open .ms-panel {
  display: block;
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.ms-option:hover {
  background: #f3f5fb;
}

.ms-option input {
  width: auto;
  margin: 0;
}

/* ===== 簽章/備註：平常隱藏，列印才顯示 ===== */
.print-only {
  display: none;
}

@media print {
  .print-only {
    display: block !important;
  }
}

.ai-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.ai-score-title {
  font-weight: 600;
  color: var(--ink);
}

.ai-score-value {
  font-weight: 700;
  background: #eef2ff;
  color: #1f2a44;
  padding: 4px 10px;
  border-radius: 999px;
}

.ai-score-msg {
  font-size: 12px;
  color: var(--muted);
}

/* ===== 活動時段 (Scheme A: Fixed Add Button Layout) ===== */
.time-slot-inline {
  display: flex;
  gap: 30px;
  align-items: flex-start; /* Fix to top */
  justify-content: flex-start;
  margin-top: 8px;
}

.time-slots {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px; /* Reduced from 24px */
}

.time-slot-row {
  display: flex;
  gap: 40px;
  align-items: center;
  background: transparent;
}

.time-slot-date-group {
  flex: 0 0 220px;
}

.time-slot-date-group input[type="date"] {
  width: 100%;
}

.time-slot-time-group {
  flex: 1;
  display: flex;
  gap: 12px;
  align-items: center;
}

.time-slot-time-group input[type="time"] {
  flex: 1;
  min-width: 0;
}

.time-slot-sep {
  color: var(--muted);
  font-weight: 500;
  padding: 0 4px;
}

.time-slot-add {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 22px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 0; /* Align with top row */
}

.time-slot-add:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: var(--accent);
}

.slot-remove {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  color: #94a3b8;
  border: 1px solid transparent;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.slot-remove:hover {
  color: #ef4444;
  background: #fef2f2;
}

@media (max-width: 900px) {
  .time-slot-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .time-slot-row {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
  }
  .time-slot-date-group, 
  .time-slot-time-group {
    flex: 1 1 100%;
  }
}

/* ==== 拖曳上傳區塊 ==== */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.5);
  padding: 30px 20px;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.file-drop-zone:hover,
.file-drop-zone.drag-active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.drop-zone-icon {
  color: var(--accent);
  margin-bottom: 4px;
}

.drop-zone-text {
  font-size: 15px;
}

.file-drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ==== 操作列 ==== */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn-large {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
}

/* --- File Upload Success Styles --- */
.file-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-success-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 500;
  animation: fileFadeIn 0.2s ease-out forwards;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.file-success-item svg {
  flex-shrink: 0;
  color: #10b981;
  width: 16px;
  height: 16px;
}

.file-success-item .file-size {
  color: #94a3b8;
  font-size: 12px;
  margin-left: 2px;
  font-weight: 400;
}

@keyframes fileFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.file-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 4px;
  margin-left: 4px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-remove-btn:hover {
  background: #f1f5f9;
  color: #ef4444;
}

.file-remove-btn svg {
  color: currentColor;
  width: 14px !important;
  height: 14px !important;
}
