/* line.kwanxin.com — 共用設計 tokens 與元件 */
:root {
  --ink: #07120d;
  --ink-2: #0d1f17;
  --ink-3: #15301f;
  --ink-line: rgba(220, 255, 232, .1);
  --ink-text: #e7f3ec;
  --ink-muted: #9db5a7;
  --green: #06C755;
  --green-600: #05a847;
  --green-700: #047a34;
  --green-050: #e8f8ee;
  --green-100: #cdeedb;
  --paper: #f7faf8;
  --card: #ffffff;
  --text: #0c1a12;
  --muted: #4d6156;
  --faint: #6f8278;
  --line: #dde7e1;
  --line-strong: #c6d4cb;
  --amber: #9a5b00;
  --amber-bg: #fff3dc;
  --red: #b42323;
  --red-bg: #fdeceb;
  --blue: #1f5fae;
  --blue-bg: #e8f0fb;
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --shadow: 0 1px 2px rgba(7, 18, 13, .06), 0 8px 24px rgba(7, 18, 13, .06);
  --font: "Plus Jakarta Sans", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --gutter: clamp(16px, 4vw, 40px);
  --max: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--text); background: var(--paper); overflow-x: hidden; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--green-700); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.005em; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }
.nb { display: inline-block; white-space: nowrap; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, .mono { font-family: var(--mono); font-feature-settings: "calt" 0; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.nowrap { white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-s { width: 16px; height: 16px; }

/* 品牌 */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 800; font-size: 16px; white-space: nowrap; }
.brand-domain { font-family: var(--mono); font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.on-ink .brand-domain { color: var(--ink-muted); }

/* 按鈕 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; font-size: 15px; line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--green); color: #04140b; }
.btn-primary:hover { background: #10d862; }
.btn-primary:active { background: var(--green-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--text); }
.btn-ghost-ink { background: transparent; color: var(--ink-text); border-color: rgba(231, 243, 236, .28); }
.btn-ghost-ink:hover { border-color: var(--ink-text); }
.btn-danger { background: var(--card); color: var(--red); border-color: #e7b8b5; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: 16px; border-radius: 12px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--green-700); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* 表單 */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label, .field-label { font-size: 14px; font-weight: 600; color: var(--text); }
.field small { color: var(--faint); font-size: 13px; }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); color: var(--text); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(6, 199, 85, .22); }
.input[aria-invalid="true"] { border-color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-error { min-height: 0; color: var(--red); font-size: 14px; font-weight: 600; }
.form-error:empty { display: none; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; line-height: 1.5; white-space: nowrap; background: #eef2ef; color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge-plain::before { display: none; }
.badge-ok { background: var(--green-050); color: var(--green-700); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-bad { background: var(--red-bg); color: var(--red); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.chip-mono { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: #eef3f0; border: 1px solid var(--line); font-family: var(--mono); font-size: 13px; color: var(--text); white-space: nowrap; }

/* 提示 */
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); pointer-events: auto; animation: toast-in .2s ease-out; }
.toast::before { content: ""; flex: none; width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--green); }
.toast.is-error::before { background: #ff6b5f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* 對話框 */
dialog.sheet { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius-l); background: var(--card); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .35); overflow: auto; }
dialog.sheet::backdrop { background: rgba(7, 18, 13, .62); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 0; }
.sheet-body { padding: 16px 24px 24px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: var(--text); flex: none; }
.icon-btn:hover { border-color: var(--text); }

/* 分頁 */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; padding: 16px 0 4px; font-size: 14px; color: var(--muted); }
.pager span { white-space: nowrap; }

/* 細膠囊捲軸 */
* { scrollbar-width: thin; scrollbar-color: #b9c9bf transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #b9c9bf; border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  dialog.sheet { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .sheet-head { padding: 16px 16px 0; }
  .sheet-body { padding: 12px 16px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
