:root {
  --ink: #161827; --ink2: #3b3f55; --muted: #6b7088; --line: #e6e7ef; --bg: #f6f6fa; --card: #ffffff;
  --pri: #4338ca; --pri2: #6366f1; --pri-soft: #eef0ff; --acc: #f97316; --acc-soft: #fff1e6;
  --ok: #0f9d63; --ok-soft: #e6f7ef; --warn: #b45309; --warn-soft: #fff6e0; --bad: #d92d20; --bad-soft: #fdecea;
  --r: 12px; --shadow: 0 1px 2px rgba(20,22,40,.05), 0 4px 16px rgba(20,22,40,.04);
  --font: "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; letter-spacing: .01em; }
h1 { font-size: 24px; font-weight: 800; } h2 { font-size: 18px; font-weight: 700; } h3 { font-size: 15.5px; font-weight: 700; }
p { margin: .3em 0 .8em; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: #0f1020; color: #e6e7ff; padding: 12px 14px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* layout */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: #fbfbfe; border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main { min-width: 0; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.8); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.topbar .menu-btn { display: none; margin-right: auto; }
.content { padding: 26px 28px 60px; max-width: 1180px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 900; font-size: 19px; color: var(--ink); padding: 4px 8px 12px; letter-spacing: .02em; }
.logo .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--pri) 0%, var(--pri2) 55%, var(--acc) 100%); display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 900; }
.logo small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav-sec { font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 14px 10px 6px; letter-spacing: .06em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink2); font-weight: 500; margin: 1px 0; }
.nav a:hover { background: #f0f0f7; text-decoration: none; }
.nav a.on { background: var(--pri-soft); color: var(--pri); font-weight: 700; }
.nav a .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: #eceef6; font-size: 12px; flex: none; }
.nav a.on .ic { background: var(--pri); color: #fff; }
.nav a .badge { margin-left: auto; }
.nav .sub { padding-left: 14px; border-left: 2px solid var(--line); margin-left: 20px; }
.nav .sub a { padding: 6px 10px; font-size: 13.5px; }
.brand-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin: 4px 0 6px; }
.brand-card .row { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800; flex: none; }
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; background: #f0f0f6; border-radius: 9px; padding: 3px; margin: 6px 0; }
.mode-toggle button { border: 0; background: transparent; padding: 5px; border-radius: 7px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.mode-toggle button.on { background: #fff; color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.userbox { display: flex; align-items: center; gap: 9px; padding: 12px 8px; border-top: 1px solid var(--line); margin-top: 16px; }
.userbox .avatar { background: var(--pri); border-radius: 50%; }
.userbox .em { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

/* components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flat { box-shadow: none; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 2px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: .12s; }
.btn:hover { border-color: #c9cbe0; background: #fafaff; text-decoration: none; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: #3730a3; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.acc { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger.fill { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #eef0f6; color: var(--ink2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.pri { background: var(--pri-soft); color: var(--pri); } .badge.acc { background: var(--acc-soft); color: #c2410c; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--ink2); }
label.f > em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=time], input[type=search], select, textarea {
  width: 100%; border: 1px solid #d9dbe7; border-radius: 9px; padding: 9px 11px; font: inherit; background: #fff; color: var(--ink); outline: none; transition: .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--pri2); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; min-height: 420px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #cfd2e0; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch i:before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--pri); }
.switch input:checked + i:before { transform: translateX(18px); }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid #f0f1f6; vertical-align: top; }
table.t tr:hover td { background: #fbfbfe; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty b { display: block; color: var(--ink2); font-size: 15px; margin-bottom: 4px; }
.notice { border-radius: var(--r); padding: 14px 16px; background: var(--pri-soft); border: 1px solid #dcdffd; margin-bottom: 16px; }
.notice.acc { background: var(--acc-soft); border-color: #fde0c6; }
.notice.warn { background: var(--warn-soft); border-color: #f7e2b0; }
.notice.bad { background: var(--bad-soft); border-color: #f7cdc8; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 800; }
.stat span { font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--pri); border-bottom-color: var(--pri); }
.steps { counter-reset: s; }
.step { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--pri-soft); color: var(--pri); font-weight: 800; display: grid; place-items: center; flex: none; }
.step.done .n { background: var(--ok); color: #fff; }
.goal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.goal { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; transition: .12s; }
.goal:hover { border-color: #c7cbf6; }
.goal.on { border-color: var(--pri); background: var(--pri-soft); }
.goal b { display: block; margin-bottom: 3px; }
.goal p { font-size: 12.5px; color: var(--ink2); margin: 0 0 4px; }
.goal small { color: var(--muted); font-size: 11.5px; }
.pick { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; }
.pick.on { border-color: var(--pri); background: var(--pri-soft); }
.pick:hover { border-color: #c7cbf6; }

/* inbox */
.inbox { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 58px - 110px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.inbox .list { border-right: 1px solid var(--line); overflow-y: auto; }
.inbox .item { padding: 12px 14px; border-bottom: 1px solid #f0f1f6; cursor: pointer; display: block; color: inherit; }
.inbox .item:hover { background: #fafaff; text-decoration: none; }
.inbox .item.on { background: var(--pri-soft); }
.inbox .item .last { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread .head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thread .msgs { flex: 1; overflow-y: auto; padding: 16px; background: #f8f8fc; }
.thread .composer { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; }
.thread .composer textarea { min-height: 44px; height: 44px; }
.bubble { max-width: 74%; margin: 6px 0; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; position: relative; }
.bubble.in { background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.bubble.out { margin-left: auto; background: var(--pri); color: #fff; border-top-right-radius: 4px; }
.bubble.out.human { background: #1f2937; }
.bubble.out.draft { background: var(--warn-soft); color: var(--ink); border: 1.5px dashed #e7b75a; }
.bubble.out.failed { background: var(--bad-soft); color: var(--bad); }
.meta { font-size: 11px; color: var(--muted); margin: -2px 2px 6px; }
.meta.r { text-align: right; }

/* chat test */
.chatbox { border: 1px solid var(--line); border-radius: var(--r); background: #f8f8fc; height: 460px; display: flex; flex-direction: column; }
.chatbox .msgs { flex: 1; overflow-y: auto; padding: 14px; }
.chatbox form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--r) var(--r); }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,16,32,.45); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal .x { float: right; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; animation: up .16s; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes up { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth .art { background: radial-gradient(900px 500px at 10% 0%, #6366f1 0%, transparent 60%), radial-gradient(700px 500px at 100% 100%, #f97316 0%, transparent 55%), #1e1b4b; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .art h1 { font-size: 34px; line-height: 1.35; }
.auth .form { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.auth .form > div { width: 100%; max-width: 380px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips span { background: rgba(255,255,255,.14); padding: 6px 12px; border-radius: 99px; font-size: 13px; }
.bar { height: 6px; background: #eceef6; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pri); border-radius: 99px; }
.bar.warn i { background: var(--acc); } .bar.bad i { background: var(--bad); }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: 8px; }
.chart .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; }
.chart .c i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: #c7cbf6; min-height: 2px; }
.chart .c i.ai { background: var(--pri); }
.chart .c small { font-size: 10px; color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.media-grid .m { border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #eee; aspect-ratio: 1; position: relative; cursor: pointer; }
.media-grid .m.on { border-color: var(--pri); }
.media-grid .m img, .media-grid .m video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid .m span { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.platform { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 800; color: #fff; background: #64748b; }
.p-line { background: #06c755; } .p-instagram { background: linear-gradient(45deg,#f58529,#dd2a7b,#8134af); } .p-facebook { background: #1877f2; }
.p-threads, .p-x { background: #111; } .p-telegram { background: #229ed9; } .p-whatsapp { background: #25d366; } .p-youtube { background: #ff0000; }
.p-tiktok { background: #010101; } .p-linkedin { background: #0a66c2; } .p-webchat { background: var(--pri); }
.sigpad { border: 1.5px dashed #c9cbe0; border-radius: 10px; background: #fcfcff; touch-action: none; width: 100%; height: 160px; }
.kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; background: #fff; }
.score { font-size: 44px; font-weight: 900; line-height: 1; }
.issue { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 50px; }
  .g2, .g3, .g4, .goal-grid { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox .list { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth { grid-template-columns: 1fr; }
  .auth .art { display: none; }
  .bubble { max-width: 88%; }
  table.t { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.t td, table.t th { white-space: nowrap; }
  table.t td.small, table.t td .small { white-space: normal; min-width: 160px; }
  .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .page-head h1 { font-size: 21px; }
  .card { padding: 14px; }
  .modal { padding: 18px 16px; }
  .tabs button { padding: 9px 10px; }
  textarea.code { min-height: 300px; }
  .topbar { padding: 0 12px; }
}
