:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #fff;
  --text: #172018;
  --muted: #68736b;
  --line: #dfe5de;
  --line-strong: #c8d2c8;
  --primary: #246b4b;
  --primary-soft: #e7f2ec;
  --danger: #b94136;
  --shadow: 0 16px 38px rgba(35, 48, 38, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif; }
button, input, select { font: inherit; }
button { border: 0; border-radius: 11px; padding: 10px 15px; cursor: pointer; font-weight: 700; }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary { background: var(--primary); color: white; }
.secondary { background: var(--primary-soft); color: var(--primary); border: 1px solid #cfe4d8; }
.danger { background: var(--danger); color: white; }
.ghost { background: white; color: var(--text); border: 1px solid var(--line); }
.small { padding: 7px 10px; font-size: 13px; }
.full { width: 100%; }
.text-button { background: transparent; color: var(--muted); padding: 0; }
input, select { width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: 11px; background: white; color: var(--text); padding: 0 12px; }
label { display: grid; gap: 7px; color: #344038; font-size: 14px; font-weight: 700; }

.workspace { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 64px; }
.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.page-head h1 { margin: 4px 0 8px; font-size: clamp(34px, 5vw, 56px); line-height: 1; }
.page-head p, .hint { margin: 0; color: var(--muted); line-height: 1.5; }
.kicker, .step-label { color: var(--primary); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.status-pill { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 8px 12px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.workflow { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.source-summary { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; align-items: center; margin-bottom: 16px; }
.source-summary h2 { margin: 4px 0 0; font-size: 20px; }
.workflow-step { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 18px; align-items: start; }
.workflow-step > .step-label { padding-top: 28px; }
.step-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.step-actions { display: flex; align-items: end; }
.check-row { grid-column: 2 / -1; display: grid; grid-template-columns: 18px 1fr; align-items: start; color: var(--muted); font-weight: 600; line-height: 1.45; }
.check-row input { width: 18px; height: 18px; margin-top: 2px; }

.preview-step, .run-step { display: grid; gap: 14px; }
.preview-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.preview-head h2, .run-step h2 { margin: 4px 0 0; font-size: 22px; }
.list-tools, .run-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.counter { color: var(--muted); font-weight: 800; font-size: 13px; }
.event-meta { color: var(--muted); font-size: 13px; }
.calendar-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 8px; }
.calendar-preview-grid h3 { margin: 0 0 8px; font-size: 16px; }
.mini-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); min-height: auto; padding: 0; text-align: left; }
.mini-calendar.empty-state { display: grid; grid-template-columns: 1fr; place-items: center; min-height: 180px; background: white; padding: 20px; }
.cal-head, .cal-day { background: white; min-width: 0; }
.cal-head { padding: 8px 6px; color: var(--muted); font-size: 11px; font-weight: 800; text-align: center; }
.cal-day { min-height: 86px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-day.outside { background: #f8faf7; color: #a5ada6; }
.cal-date { font-size: 12px; font-weight: 800; }
.cal-event { border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 3px 5px; font-size: 11px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event.continues::before { content: "↔ "; opacity: .65; }
.cal-event.selectable { cursor: pointer; outline: 1px solid transparent; }
.cal-event.selectable:hover { outline-color: rgba(36, 107, 75, .28); }
.cal-event.unselected { opacity: .35; filter: grayscale(.35); text-decoration: line-through; }
.label-preview { grid-column: 2 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.label-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted); font-size: 13px; background: white; }
.label-dot { width: 12px; height: 12px; border-radius: 999px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); min-height: 120px; display: grid; place-items: center; text-align: center; padding: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-title span { font-weight: 800; }
.section-title small { color: var(--muted); }
.result-box { display: grid; gap: 8px; }
pre { margin: 0; min-height: 220px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: #101713; color: #eaf5ed; border-radius: 14px; padding: 14px; font-size: 12px; line-height: 1.45; }

.modal { border: 0; padding: 0; background: transparent; width: min(560px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(13, 20, 15, .42); backdrop-filter: blur(2px); }
.modal-card { background: white; border-radius: 20px; padding: 22px; box-shadow: 0 28px 80px rgba(13, 20, 15, .24); display: grid; gap: 16px; }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.modal-head h2 { margin: 4px 0 0; }
.modal-status { color: var(--muted); font-size: 13px; min-height: 18px; }
.modal-status.error { color: var(--danger); }
.modal-status.success { color: var(--primary); }
.detail-body { display: grid; gap: 10px; color: var(--muted); }
.detail-row { display: grid; grid-template-columns: 88px 1fr; gap: 10px; }
.detail-row strong { color: var(--text); }
.form-stack { display: grid; gap: 13px; }
.account-list { display: flex; flex-wrap: wrap; gap: 10px; }
.account-item { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.account-item strong { display: block; margin-bottom: 2px; }
.account-item small { color: var(--muted); overflow-wrap: anywhere; }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 0; }

@media (max-width: 900px) {
  .page-head, .preview-head { flex-direction: column; }
  .head-actions { justify-content: flex-start; }
  .source-summary { grid-template-columns: 1fr; }
  .calendar-preview-grid { grid-template-columns: 1fr; }
  .workflow-step { grid-template-columns: 1fr; align-items: stretch; }
  .step-body { grid-template-columns: 1fr; }
  .check-row { grid-column: auto; }
  .step-actions, .list-tools, .run-actions { justify-content: flex-start; }
}
