:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #16181a;
  --muted: #5f6368;
  --border: #e2e2dc;
  --accent: #0f7b5f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ed;
  --line: #06c755;
  --danger: #c4372b;
  --danger-soft: #fbe9e7;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111312; --surface: #1a1c1b; --surface-2: #232625; --text: #eceeed; --muted: #a2a7a5;
    --border: #2e3231; --accent: #3fbf94; --accent-ink: #08130f; --accent-soft: #173229;
    --danger: #ff7b6e; --danger-soft: #3a1d1a; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .container { display: flex; align-items: center; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.brand-mark svg { width: 18px; height: 18px; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- buttons & form ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 32px; padding: 0; }
.icon-btn svg, .btn svg { width: 16px; height: 16px; flex: none; }

label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; outline: none; }
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group { display: flex; align-items: stretch; }
.input-group .prefix { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--border); border-right: 0;
  border-radius: 10px 0 0 10px; background: var(--surface-2); color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-group input { border-radius: 0 10px 10px 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 14px; }
.check input { margin-top: 4px; }
.error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 14px; }

.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: 14px;
  height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button svg { width: 16px; height: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-line { background: color-mix(in srgb, var(--line) 15%, transparent); color: color-mix(in srgb, var(--line) 75%, var(--text)); }
.badge-url { background: var(--accent-soft); color: var(--accent); }
.badge-off { background: var(--danger-soft); color: var(--danger); }

/* ---------- toast & modal ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-start;
  justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; padding: 18px 20px 0; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }

.footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 13px; margin-top: 64px; }
.footer .container { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.footer nav { margin-left: auto; display: flex; gap: 16px; }
