/* chatmany UI — ManyChat-inspired. Blue #2d7ff9 accent, white cards on light-gray canvas,
   generous rounded corners, sentence case, no emoji in chrome. */

/* The `hidden` attribute must win over any class that sets display (e.g. .st-form is a grid). */
[hidden] { display: none !important; }

:root {
  --blue: #2d7ff9;
  --blue-dark: #1f6ae0;
  --blue-soft: #eaf2ff;
  --canvas: #f3f5f9;
  --card: #ffffff;
  --ink: #1c2434;
  --ink-soft: #5b6472;
  --ink-faint: #8b93a3;
  --line: #e7eaf0;
  --line-strong: #d6dbe4;
  --green: #24b47e;
  --amber: #e0a11b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 30, 55, 0.06), 0 4px 16px rgba(20, 30, 55, 0.05);
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.main-wrap { max-width: 1120px; margin: 0 auto; }

/* ---------- brand + nav ---------- */
.brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 20px; }
.brand .spark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--blue);
  display: grid; place-items: center; color: #fff;
}
.brand .spark svg { width: 15px; height: 15px; }
.brand .name { font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 550; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; font-size: 14px;
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.85; }
.nav-item:hover { background: #f5f7fb; color: var(--ink); }
.nav-item.active { background: var(--blue-soft); color: var(--blue-dark); }
.nav-item.active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.profile { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.profile .avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--line); }
.profile .who { min-width: 0; }
.profile .handle { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; font-size: 11px; color: var(--ink-faint); }
.gh-link { display: flex; align-items: center; gap: 7px; margin-top: 8px; padding: 7px 8px; color: var(--ink-soft); font-size: 13px; border-radius: var(--radius-sm); }
.gh-link:hover { background: #f5f7fb; }
.gh-link svg { width: 16px; height: 16px; }
.legal-links { display: flex; gap: 6px; padding: 4px 8px 0; font-size: 11.5px; color: var(--ink-faint); }
.legal-links a { color: var(--ink-faint); }
.legal-links a:hover { color: var(--ink-soft); text-decoration: underline; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; letter-spacing: -0.3px; }
.page-sub { color: var(--ink-soft); margin-top: 3px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px;
}
.card h3 { font-size: 15px; margin-bottom: 3px; }
.card .hint { color: var(--ink-soft); font-size: 13px; margin-bottom: 14px; }
.section-num { color: var(--ink-faint); font-weight: 700; margin-right: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; background: #eef1f6; color: var(--ink);
}
.btn:hover { background: #e6eaf1; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { background: #f5f7fb; }
.btn.danger { background: transparent; color: #d1435b; border-color: #f0c9d1; }
.btn.danger:hover { background: #fdeef1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { padding: 6px 12px; font-size: 13px; }

/* ---------- form controls ---------- */
label.field { display: block; margin-bottom: 14px; }
.field .label { font-weight: 600; margin-bottom: 6px; display: block; }
input[type="text"], input[type="url"], input[type="password"], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; color: var(--ink); background: #fff; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { resize: vertical; min-height: 66px; }

.radio-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; margin-bottom: 8px; }
.radio-row.selected { border-color: var(--blue); background: var(--blue-soft); }
.radio-row.disabled { opacity: 0.55; cursor: not-allowed; }
.radio-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); flex: 0 0 auto; margin-top: 1px; }
.radio-row.selected .radio-dot { border-color: var(--blue); background: radial-gradient(circle at center, var(--blue) 0 5px, #fff 6px); }
.radio-row .rr-title { font-weight: 600; }
.radio-row .rr-sub { color: var(--ink-soft); font-size: 13px; }

/* toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row:first-child { border-top: 0; }
.toggle-row .tr-title { font-weight: 600; }
.toggle-row .tr-sub { color: var(--ink-soft); font-size: 13px; }
.toggle-row.disabled { opacity: 0.55; }
.toggle-row.disabled .switch { cursor: not-allowed; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cdd4df; border-radius: 999px; transition: 0.15s; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip { padding: 5px 11px; border-radius: 999px; background: #eef1f6; color: var(--ink-soft); font-size: 12px; cursor: pointer; border: 1px solid transparent; }
.chip:hover { background: var(--blue-soft); color: var(--blue-dark); }

/* media picker */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 6px; }
.media-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer; border: 2px solid transparent; background: var(--line); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb.selected { border-color: var(--blue); }
.media-thumb.selected::after { content: "✓"; position: absolute; top: 4px; right: 6px; color: #fff; background: var(--blue); border-radius: 50%; width: 18px; height: 18px; display: grid; place-items: center; font-size: 12px; }

/* ---------- builder + preview split ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.preview-col { position: sticky; top: 26px; }
@media (max-width: 940px) { .builder { grid-template-columns: 1fr; } .preview-col { position: static; } }

.builder-topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.builder-topbar input.name { max-width: 320px; font-weight: 600; }
.status-pill { padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.status-pill.live { background: #e4f7ee; color: var(--green); }
.status-pill.stopped { background: #eef1f6; color: var(--ink-soft); }

/* ---------- phone preview ---------- */
.phone { width: 300px; background: #000; border-radius: 34px; padding: 10px; box-shadow: var(--shadow); margin: 0 auto; }
.phone-screen { background: #000; border-radius: 26px; overflow: hidden; color: #fff; }
.seg { display: flex; background: #111; border-radius: 10px; padding: 3px; margin: 10px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; color: #9aa0aa; font: inherit; font-size: 12px; font-weight: 600; padding: 6px; border-radius: 8px; cursor: pointer; }
.seg button.active { background: #2a2c31; color: #fff; }
.ig { padding: 0 12px 16px; min-height: 430px; }
.ig-top { display: flex; align-items: center; gap: 8px; padding: 8px 2px; }
.ig-top img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.ig-top .u { font-weight: 600; font-size: 13px; }
.ig-media { width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; background: #222; display: block; }
.ig-actions { display: flex; gap: 14px; padding: 9px 2px; color: #fff; }
.ig-actions .heart.liked { color: #ed4956; }
.ig-caption { font-size: 12.5px; color: #eee; padding: 0 2px; }
.ig-caption .u { font-weight: 600; margin-right: 5px; }

.cmt { display: flex; gap: 8px; padding: 8px 2px; }
.cmt .av { width: 26px; height: 26px; border-radius: 50%; background: #444; flex: 0 0 auto; display: grid; place-items: center; font-size: 11px; color: #ccc; }
.cmt .body { font-size: 12.5px; }
.cmt .body .u { font-weight: 600; margin-right: 5px; }
.cmt .body .meta { color: #8a8f98; font-size: 11px; margin-top: 2px; }
.cmt.reply { margin-left: 30px; }

.dm { display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 12.5px; }
.bubble.in { background: #262930; color: #fff; align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.out { background: var(--blue); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.dm-btn { align-self: flex-start; max-width: 82%; border: 1px solid #3a3d44; color: #6cb0ff; background: #1a1c20; border-radius: 16px; padding: 9px 12px; font-size: 12.5px; font-weight: 600; text-align: center; }
.qr { align-self: flex-end; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.qr .pill { border: 1px solid var(--blue); color: #6cb0ff; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; }
.dm-note { color: #8a8f98; font-size: 11px; text-align: center; padding: 2px; }

/* ---------- dashboard ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.metric .m-val { font-size: 27px; font-weight: 700; letter-spacing: -0.5px; }
.metric .m-label { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.metric .m-sub { color: var(--ink-faint); font-size: 12px; margin-top: 4px; }

.funnel-bar { margin: 10px 0; }
.funnel-bar .fb-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.funnel-bar .fb-track { background: #eef1f6; border-radius: 8px; height: 26px; overflow: hidden; }
.funnel-bar .fb-fill { height: 100%; background: linear-gradient(90deg, var(--blue), #5aa0ff); border-radius: 8px; min-width: 2px; transition: width 0.3s; }

/* ---------- contacts ---------- */
.contact-row { display: grid; grid-template-columns: 1fr 130px 90px 110px; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--card); }
.contact-row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.contact-row .av { width: 30px; height: 30px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 12px; color: var(--ink-soft); flex: 0 0 auto; }
.contact-row .uname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-block; white-space: nowrap; }
.pill.done { background: #e4f7ee; color: var(--green); }
.pill.wait { background: #fdf3dd; color: var(--amber); }
.pill.open { background: var(--blue-soft); color: var(--blue-dark); }
.muted { color: var(--ink-faint); }
.dash { color: var(--line-strong); }
@media (max-width: 720px) { .contact-row { grid-template-columns: 1fr 100px; } .contact-row .col-hide { display: none; } }

/* ---------- misc ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; }
.empty svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 10px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); text-align: center; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 550; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: #d1435b; }
.banner { background: #fdf3dd; border: 1px solid #f0dca6; color: #7a5b12; padding: 11px 15px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; }
.banner a { color: #7a5b12; text-decoration: underline; font-weight: 600; }
.select-inline { display: inline-flex; align-items: center; gap: 8px; }
.select-inline select { width: auto; }

/* ---------- automations list ---------- */
.automations-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.automations-toolbar select { width: auto; }
.folder-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px;
  border: 1.5px dashed var(--line-strong); color: var(--blue); font-weight: 600; font-size: 13px;
  background: transparent; cursor: pointer;
}
.folder-btn:hover { background: var(--blue-soft); }
.auto-list-head {
  display: grid; grid-template-columns: 26px 1fr 90px 70px 110px; gap: 12px; align-items: center;
  padding: 0 16px 8px; color: var(--ink-faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
.auto-row {
  display: grid; grid-template-columns: 26px 1fr 90px 70px 110px; gap: 12px; align-items: center;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
  background: var(--card); cursor: pointer; transition: border-color 0.1s;
}
.auto-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.auto-row input[type="checkbox"] { width: 16px; height: 16px; }
.auto-row .auto-name-cell { min-width: 0; }
.auto-row .auto-name-line { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.auto-row .auto-name { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-row .auto-trigger { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 12.5px; }
.auto-row .auto-trigger img { width: 18px; height: 18px; border-radius: 4px; object-fit: cover; flex: 0 0 auto; }
.auto-row .auto-trigger .kw-pill { background: var(--blue-soft); color: var(--blue-dark); padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.auto-row .num { font-weight: 600; }
.auto-row .num-sub { color: var(--ink-faint); font-size: 11px; }
.auto-row.selected { border-color: var(--blue); background: var(--blue-soft); }

/* Archive tab: same row shape as Automations, but the middle stat columns are replaced with a
   wider actions slot (Restore/Delete need more room than the Runs/CTR numbers they stand in for). */
#archlist .auto-list-head, .archived-row { grid-template-columns: 26px 1fr 0 170px 110px; }
.archive-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* search box with a leading icon */
.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 340px; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--ink-faint); pointer-events: none; }
.search-wrap input.search { padding-left: 36px; max-width: none; }

/* row 2: New folder (left) + Trash (right); row 3: View as grid (right) */
.automations-row2 { display: flex; align-items: center; margin-bottom: 6px; }
.automations-row3 { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.trash-link, .grid-link {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 7px 10px;
  color: var(--ink-soft); font-size: 13px; font-weight: 600; background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.trash-link svg, .grid-link svg { width: 15px; height: 15px; }
.trash-link:hover, .grid-link:hover { background: #f5f7fb; color: var(--ink); }

/* bulk selection bar */
.bulk-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin-bottom: 8px;
  background: var(--blue-soft); border: 1px solid var(--blue); border-radius: 12px; font-weight: 600; font-size: 13px; color: var(--blue-dark);
}
.bulk-bar .btn.danger { background: #fdeef1; border-color: #f0c9d1; }
.bulk-bar .btn svg { width: 14px; height: 14px; }

/* ---------- phone: iOS status bar ---------- */
.ios-status { display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 2px; font-size: 13px; font-weight: 600; color: #fff; }
.ios-status .time { min-width: 40px; }
.ios-status .icons { display: flex; align-items: center; gap: 4px; }
.ios-status .bars { display: flex; align-items: flex-end; gap: 1.5px; height: 9px; }
.ios-status .bars span { width: 2.5px; background: #fff; border-radius: 1px; }
.ios-status .bars span:nth-child(1) { height: 40%; }
.ios-status .bars span:nth-child(2) { height: 60%; }
.ios-status .bars span:nth-child(3) { height: 80%; }
.ios-status .bars span:nth-child(4) { height: 100%; }
.ios-status .battery { width: 22px; height: 11px; border: 1.3px solid #fff; border-radius: 3px; position: relative; margin-left: 2px; }
.ios-status .battery::after { content: ""; position: absolute; right: -3px; top: 3px; width: 2px; height: 5px; background: #fff; border-radius: 0 1px 1px 0; }
.ios-status .battery::before { content: ""; position: absolute; inset: 1.5px; background: #fff; border-radius: 1px; width: 80%; }

/* ---------- phone: post tab stats + caption toggle ---------- */
.ig-stats { font-size: 12.5px; font-weight: 600; color: #fff; padding: 2px 2px 4px; }
.ig-caption-toggle { color: #8a8f98; font-weight: 600; cursor: pointer; }
.ig-caption-toggle:hover { color: #fff; }

/* ---------- phone: comments sheet ---------- */
.sheet { background: #1c1e22; border-radius: 18px 18px 0 0; margin-top: -6px; padding-top: 8px; min-height: 380px; display: flex; flex-direction: column; }
.sheet-handle { width: 36px; height: 4px; background: #4a4d54; border-radius: 999px; margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 14px 10px; border-bottom: 1px solid #2a2c31; font-weight: 700; font-size: 13.5px; }
.sheet-body { flex: 1; padding: 4px 14px; }
.sheet-emojis { display: flex; justify-content: space-between; padding: 8px 14px; font-size: 17px; }
.sheet-input-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px 14px; }
.sheet-input-row .av { width: 24px; height: 24px; border-radius: 50%; background: #444; flex: 0 0 auto; object-fit: cover; }
.sheet-input-row .fake-input { flex: 1; background: #2a2c31; color: #6b7078; border-radius: 999px; padding: 8px 14px; font-size: 12.5px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 28px; }
.login-card .brand { justify-content: center; padding-bottom: 8px; }
.login-card h2 { text-align: center; margin-bottom: 4px; }
.login-card p { text-align: center; color: var(--ink-soft); margin: 0 0 20px; }
.connect-box { text-align: center; padding: 8px 0 4px; }
.connect-box .ig-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px; display: block; background: var(--line); }

/* 紀錄 (activity log) */
.contact-row.clickable { cursor: pointer; }
.contact-row.clickable:hover { border-color: var(--blue-soft); }
.log-row { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue-soft); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.log-row.in { border-left-color: #f3d58f; }
.log-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.log-who { font-weight: 600; color: var(--ink); text-decoration: none; }
.log-who:hover { text-decoration: underline; }
.log-text { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }

/* multi-user: sign-in, 開通步驟, setup checklist, admin */
.ig-login { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 14px 0 6px; padding: 11px 14px; border-radius: 12px; color: #fff !important; font-weight: 700; text-decoration: none; background: linear-gradient(45deg, #f09433, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888); border: 0; }
.ig-login svg { width: 20px; height: 20px; }
.login-first { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.lf-title { font-weight: 700; }
.lf-sub { color: var(--ink-soft); font-size: 13px; margin: 2px 0 10px; }
.login-admin { margin-top: 16px; color: var(--ink-soft); font-size: 13px; }
.login-admin summary { cursor: pointer; }
.login-admin .field { margin-top: 10px; }
.onboard-wrap { min-height: 100vh; display: flex; justify-content: center; padding: 32px 16px; background: var(--bg, #f5f7fb); }
.onboard { width: 100%; max-width: 620px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; }
.onboard h2 { margin: 16px 0 4px; }
.steps { counter-reset: st; list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 16px; }
.steps > li { counter-increment: st; position: relative; padding: 14px 16px 14px 52px; border: 1px solid var(--line); border-radius: 12px; }
.steps > li::before { content: counter(st); position: absolute; left: 14px; top: 14px; width: 26px; height: 26px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.st-title { font-weight: 700; margin-bottom: 4px; }
.st-body { font-size: 14px; line-height: 1.6; }
.st-form { margin-top: 12px; display: grid; gap: 4px; }
.st-done { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #e4f7ee; color: var(--green); font-weight: 600; }
.faq { margin: 8px 0 14px; font-size: 14px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq ul { margin: 8px 0 0; padding-left: 20px; line-height: 1.7; }
.logout { width: 100%; margin-top: 10px; }
.viewas-bar { background: #fdf3dd; color: #7a5200; padding: 10px 16px; font-size: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.setup-card { border: 2px solid var(--blue-soft); margin-bottom: 18px; }
.checklist { list-style: none; padding: 0; margin: 14px 0 6px; display: grid; gap: 12px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; }
.checklist .ck { flex: 0 0 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.checklist li.done .ck { background: var(--green); border-color: var(--green); color: #fff; }
.checklist li.done .ck-title { color: var(--ink-soft); text-decoration: line-through; }
.ck-title { font-weight: 700; }
.ck-body { font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.admin-row:first-child { border-top: 0; }
.ar-main { flex: 1 1 260px; min-width: 0; }
.ar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { flex: 1; min-width: 0; }

/* 我的團隊 */
.team-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.team-stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.ts-num { font-size: 24px; font-weight: 700; }
.ts-label { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
@media (max-width: 640px) { .team-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.profile-edit { flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px; margin-top: 4px; background: var(--canvas); border-radius: 10px; }
.profile-edit .field { margin: 0; }
.profile-edit select, .profile-edit input { width: 100%; }
.profile-edit .pe-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
@media (max-width: 640px) { .profile-edit { grid-template-columns: 1fr; } }
.field .hint { display: block; color: var(--ink-soft); font-size: 12.5px; margin: 4px 0 0; }
.profile-edit[hidden] { display: none; }

/* ---------- editor top bar stays in view while scrolling ---------- */
.builder-topbar { position: sticky; top: 0; z-index: 20; background: var(--canvas); padding: 10px 0; margin-top: -10px; }
.builder-topbar .btn svg { width: 15px; height: 15px; }
.automations-toolbar .trash-link { margin-left: auto; }
.auto-mobile-stats { display: none; color: var(--ink-faint); font-size: 12.5px; margin-top: 5px; }

/* ---------- phones: bottom tab bar, sidebar becomes a drawer ---------- */
.tabbar, .drawer-backdrop { display: none; }
@media (max-width: 760px) {
  body { font-size: 15px; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100%; width: 280px; max-width: 85vw;
    z-index: 70; transform: translateX(-102%); transition: transform 0.2s ease; overflow-y: auto;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .layout.drawer-open .sidebar { transform: none; box-shadow: 0 10px 40px rgba(20, 30, 55, 0.25); }
  .layout.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 30, 55, 0.35); z-index: 65; }
  .main { padding: 18px 16px calc(86px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none;
    color: var(--ink-faint); font: inherit; font-size: 11.5px; font-weight: 600; padding: 5px 0; cursor: pointer;
  }
  .tab-item svg { width: 22px; height: 22px; }
  .tab-item.active { color: var(--blue); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* bigger tap targets; 16px inputs so iPhone doesn't zoom in on tap */
  .btn { min-height: 42px; }
  .btn.sm { min-height: 38px; padding: 7px 12px; }
  /* the four request buttons share one row instead of dropping 拒絕 onto a line of its own */
  #reqlist .ar-actions { width: 100%; flex-wrap: nowrap; }
  #reqlist .ar-actions .btn { flex: 1 1 auto; padding: 7px 6px; white-space: nowrap; }
  input[type="text"], input[type="url"], input[type="password"], textarea, select { font-size: 16px; }

  .page-head { margin-bottom: 14px; }
  .page-title { font-size: 20px; }
  .page-head .toolbar { width: 100%; }
  .select-inline { flex: 1 1 auto; }
  .select-inline select { flex: 1; width: 100%; }
  .card { padding: 16px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { padding: 14px; }
  .metric .m-val { font-size: 23px; }

  /* automation rows: stats move under the name */
  .auto-list-head { display: none; }
  .auto-row { grid-template-columns: 22px minmax(0, 1fr); padding: 12px 14px; }
  .auto-row > .stat-col { display: none; }
  .auto-mobile-stats { display: block; }
  .auto-row.archived-row { grid-template-columns: minmax(0, 1fr); }
  .auto-row.archived-row > span:first-child, .auto-row.archived-row > div:nth-child(3) { display: none; }
  .archive-actions { justify-content: flex-start; }
  .search-wrap { max-width: none; flex: 1 1 100%; }

  /* editor */
  .builder-topbar { gap: 8px; }
  .builder-topbar input.name { order: 5; flex: 1 1 100%; max-width: none; }
  .hide-sm { display: none; }
  .phone { width: 100%; max-width: 300px; }
  .onboard { padding: 22px 16px; }
  .steps > li { padding: 14px 14px 14px 48px; }
}
.file-btn { cursor: pointer; margin: 2px 0 6px; }
.field .file-btn + .hint { margin-top: 2px; }
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* 申請開通 waiting: red count on 管理, dot on 更多 */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #e5484d; color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.nav-badge[hidden], .tab-dot[hidden] { display: none; }
.tab-item { position: relative; }
.tab-dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: #e5484d; border: 2px solid var(--card); }
@media (max-width: 359px) { #reqlist .ar-actions { flex-wrap: wrap; } } /* too narrow for four buttons in a row */

/* ---------- 歡迎訊息 ---------- */
.wm-stats { margin: -6px 0 14px; }
.wm-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-top: 12px; }
.wm-box-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 8px; }
.wm-box .field:last-child { margin-bottom: 0; }
.wm-q-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.wm-q-row .field { flex: 1 1 180px; margin: 0; }
.wm-q-row select { width: 100%; }
.wm-add { margin-top: 12px; }
.wm-note { margin: 10px 0 0; }
.wm-pick { cursor: pointer; }
