/* 排程秘書 —— 共用樣式（登入 / 連 iCloud / 設定 / 隱私頁）。首頁 index.html 有自己的一大包。 */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #eceff3;
  --ink: #1a212c;
  --ink-soft: #57616f;
  --ink-faint: #8d96a3;
  --line: #d9dee4;
  --line-strong: #c3cad2;
  --blue: #3e6e90;
  --blue-soft: #e2ebf1;
  --teal: #2e8577;
  --amber: #9c6b27;
  --amber-soft: #f3e9da;
  --danger: #a3423a;
  --danger-soft: #f1e0de;
  --on-blue: #ffffff;
  --shadow: 0 1px 2px rgba(26, 33, 44, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --surface: #1b212b;
    --surface-alt: #232a35;
    --ink: #e7eaee;
    --ink-soft: #a8b0bb;
    --ink-faint: #6e7683;
    --line: #313a46;
    --line-strong: #3d4753;
    --blue: #7faac7;
    --blue-soft: #223441;
    --teal: #78c4b2;
    --amber: #d3a35c;
    --amber-soft: #3a2e1c;
    --danger: #e0938c;
    --danger-soft: #37211f;
    --on-blue: #0e1319;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding:
    calc(40px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(64px + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
}

h1 { font-size: 23px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 600; margin: 26px 0 10px; color: var(--ink-soft); }
p { margin: 0 0 14px; }
.muted { color: var(--ink-soft); font-size: 14px; }
.faint { color: var(--ink-faint); font-size: 13px; }
a { color: var(--blue); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  animation: card-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── iOS 風的展開／收合區塊 ── */
.acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}
.acc-head h2 { margin: 0; }
.acc-head .chev {
  flex: none;
  margin-left: 10px;
  color: var(--ink-faint);
  font-size: 13px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.acc-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.acc-inner { padding-top: 14px; }

/* ── iOS 風開關 ── */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--ink-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.toggle input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.toggle .switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background-color 0.25s ease;
}
.toggle .switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toggle input:checked + .switch { background: var(--teal); }
.toggle input:checked + .switch .thumb { transform: translateX(20px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--blue); outline-offset: 2px; }

label { display: block; font-size: 13px; color: var(--ink-soft); margin: 0 0 5px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* iOS 聚焦不放大 */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }

.field { margin-bottom: 14px; }

.weekday-picker { display: flex; gap: 6px; }
.wd-btn {
  flex: 1;
  min-height: 36px;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  cursor: pointer;
}
.wd-btn.active { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

button, .btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.14s ease-out, opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
button:disabled { opacity: 0.5; cursor: default; }
button:not(.btn-link):not(:disabled):active,
.acc-head:active { transform: scale(0.97); }
.btn-primary { background: var(--blue); color: var(--on-blue); width: 100%; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-link { background: none; border: none; color: var(--blue); padding: 0; min-height: 0; text-decoration: underline; font-weight: 500; }

.msg { border-radius: 10px; padding: 11px 13px; font-size: 14px; margin: 12px 0; }
.msg.err { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger); }
.msg.ok { color: var(--teal); background: var(--surface-alt); }
.msg.info { color: var(--ink-soft); background: var(--surface-alt); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row + .row { margin-top: 12px; }

/* 使用統計：管道佔比的堆疊小長條 */
.stats-headline { font-size: 26px; font-weight: 700; color: var(--teal); line-height: 1.3; }
.stats-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.stats-mixbar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 14px 0 8px;
  background: rgba(128, 128, 128, 0.12);
}
.stats-mixbar > span { height: 100%; }
.stats-mixbar .c-web { background: var(--teal); }
.stats-mixbar .c-line { background: #06c755; }
.stats-mixbar .c-email { background: #f0a020; }
.stats-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-soft); }
.stats-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer { margin-top: 30px; text-align: center; font-size: 12px; color: var(--ink-faint); line-height: 1.9; }

ol { padding-left: 20px; }
ol li { margin-bottom: 8px; }
code { background: var(--surface-alt); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

/* ── 步驟式引導（數字圓圈 + 說明），用在比較需要手把手的流程，例如連 iCloud ── */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  padding: 0 0 16px;
  position: relative;
}
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 圓圈之間的連接線，最後一個不用 */
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 26px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.steps .step-body { flex: 1; min-width: 0; padding-top: 3px; font-size: 14.5px; color: var(--ink); }
.steps .step-body strong { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .spinner { animation: none; }
  button, .acc-head, .acc-body, .acc-head .chev,
  .toggle .switch, .toggle .switch .thumb { transition: none !important; }
}
