/* ==========================================================================
   tool.hktv.my — 工具站樣式
   前綴 th-（hub/版面）、tl-（工具卡）、lv-（即時數據卡）、ph-（電話表）
   全部獨立於 Tailwind；深色模式跟隨 html.dark（主題與主站共用 Cookie）
   ========================================================================== */

:root{
  --th-bg:#f5f7fb;
  --th-card:#ffffff;
  --th-line:#e5e9f0;
  --th-ink:#0f172a;
  --th-mut:#64748b;
  --th-brand:#2563eb;
  --th-brand-soft:#eef4ff;
  --th-shadow:0 1px 2px rgba(16,24,40,.04),0 10px 26px -16px rgba(16,24,40,.28);
  --th-shadow-h:0 2px 4px rgba(16,24,40,.05),0 18px 38px -18px rgba(16,24,40,.34);
  --th-radius:16px;
}
html.dark{
  --th-bg:#080e18;
  --th-card:#101a28;
  --th-line:#1e2b3c;
  --th-ink:#e7edf5;
  --th-mut:#93a3b8;
  --th-brand:#60a5fa;
  --th-brand-soft:rgba(37,99,235,.16);
  --th-shadow:0 1px 2px rgba(0,0,0,.4);
  --th-shadow-h:0 14px 30px -16px rgba(0,0,0,.7);
}

*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;background:var(--th-bg);color:var(--th-ink);
  font-family:Inter,"Noto Sans TC","PingFang TC","Microsoft JhengHei",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:15px;line-height:1.6;
  -webkit-font-smoothing:antialiased;
  transition:background-color .2s,color .2s;
}
a{color:inherit}
img{max-width:100%}

/* ---------- 版面容器 ---------- */
.tw{max-width:74rem;margin:0 auto;padding:1.35rem 1rem 0}
@media(min-width:640px){.tw{padding:1.75rem 1.5rem 0}}
@media(min-width:1024px){.tw{padding:2rem 2rem 0}}

/* ---------- 首屏 ---------- */
.th-hero{
  position:relative;overflow:hidden;border-radius:20px;
  padding:1.6rem 1.25rem 1.5rem;
  background:
    radial-gradient(1100px 320px at 12% -30%,rgba(37,99,235,.55),transparent 62%),
    radial-gradient(760px 300px at 92% -10%,rgba(14,165,164,.38),transparent 60%),
    linear-gradient(160deg,#0d1b30 0%,#0a1322 58%,#0a1322 100%);
  color:#fff;
  box-shadow:0 20px 42px -26px rgba(10,20,40,.65);
}
.th-hero::after{
  content:"";position:absolute;inset:0;pointer-events:none;
  background-image:linear-gradient(rgba(255,255,255,.045) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.045) 1px,transparent 1px);
  background-size:44px 44px;mask-image:linear-gradient(180deg,rgba(0,0,0,.9),transparent 78%);
}
.th-hero>*{position:relative;z-index:1}
html.dark .th-hero{border:1px solid rgba(255,255,255,.07)}
.th-hero-tag{
  display:inline-flex;align-items:center;gap:.4rem;
  padding:.28rem .6rem;border-radius:999px;
  background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.16);
  font-size:.7rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:#cfe0ff;
}
.th-hero h1{
  margin:.7rem 0 0;font-size:1.6rem;line-height:1.28;font-weight:800;letter-spacing:-.01em;
}
@media(min-width:640px){.th-hero h1{font-size:2rem}}
@media(min-width:1024px){.th-hero{padding:2.1rem 2rem 1.9rem}.th-hero h1{font-size:2.25rem}}
.th-hero p{margin:.55rem 0 0;font-size:.9rem;line-height:1.8;color:#b9c9e0;max-width:44rem}
.th-hero-stats{display:flex;flex-wrap:wrap;gap:.45rem;margin-top:1rem}
.th-hero-stats span{
  display:inline-flex;align-items:center;gap:.35rem;padding:.3rem .62rem;border-radius:999px;
  background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.12);
  font-size:.74rem;font-weight:600;color:#dbe6f6;
}
.th-hero-stats i{font-size:.72rem;color:#7fb0ff}

/* 首頁搜尋 */
.th-search{position:relative;margin-top:1.15rem;max-width:32rem}
.th-search input{
  width:100%;padding:.78rem 2.6rem .78rem 2.55rem;border-radius:12px;
  border:1px solid rgba(255,255,255,.2);background:rgba(255,255,255,.1);color:#fff;
  font-size:.9rem;outline:none;transition:.15s;
}
.th-search input::placeholder{color:#9fb3cd}
.th-search input:focus{background:rgba(255,255,255,.16);border-color:#7fb0ff;box-shadow:0 0 0 3px rgba(37,99,235,.28)}
.th-search .fa-magnifying-glass{position:absolute;left:.95rem;top:50%;transform:translateY(-50%);color:#9fb3cd;font-size:.85rem}
.th-search .th-search-clear{
  position:absolute;right:.55rem;top:50%;transform:translateY(-50%);
  border:0;background:rgba(255,255,255,.16);color:#dbe6f6;width:1.6rem;height:1.6rem;border-radius:50%;
  cursor:pointer;display:none;align-items:center;justify-content:center;font-size:.72rem;
}
.th-search.has-val .th-search-clear{display:flex}

/* ---------- 分區標題 ---------- */
.th-sec{margin-top:1.9rem}
.th-sec-h{display:flex;align-items:center;gap:.6rem;margin-bottom:.85rem}
.th-sec-h h2{margin:0;font-size:1.02rem;font-weight:800;letter-spacing:-.005em;display:flex;align-items:center;gap:.5rem}
.th-sec-h h2 .th-sec-ico{
  width:1.55rem;height:1.55rem;border-radius:.5rem;display:inline-flex;align-items:center;justify-content:center;
  background:var(--th-brand-soft);color:var(--th-brand);font-size:.78rem;
}
.th-sec-h span.th-sec-sub{font-size:.76rem;color:var(--th-mut)}
.th-sec-h .th-sec-more{margin-left:auto;font-size:.78rem;font-weight:700;color:var(--th-brand);text-decoration:none;white-space:nowrap}
.th-sec-h .th-sec-more:hover{text-decoration:underline}

/* ---------- 即時數據卡 ---------- */
.lv-grid{display:grid;grid-template-columns:1fr;gap:.85rem}
@media(min-width:720px){.lv-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
.lv-card{
  display:flex;flex-direction:column;min-height:9.6rem;
  background:var(--th-card);border:1px solid var(--th-line);border-radius:var(--th-radius);
  padding:1rem 1rem .9rem;box-shadow:var(--th-shadow);
  text-decoration:none;transition:transform .16s,box-shadow .16s,border-color .16s;
}
.lv-card:hover{transform:translateY(-2px);box-shadow:var(--th-shadow-h);border-color:#c9d8f0}
html.dark .lv-card:hover{border-color:#2d4560}
.lv-top{display:flex;align-items:center;gap:.55rem;margin-bottom:.6rem}
.lv-top .lv-ico{
  width:1.85rem;height:1.85rem;border-radius:.6rem;display:inline-flex;align-items:center;justify-content:center;
  color:#fff;font-size:.85rem;flex:0 0 auto;
}
.lv-top b{font-size:.86rem;font-weight:800}
.lv-top .lv-live{
  margin-left:auto;display:inline-flex;align-items:center;gap:.28rem;font-size:.62rem;font-weight:800;
  letter-spacing:.06em;color:#0f9d58;text-transform:uppercase;
}
.lv-top .lv-live i{width:.4rem;height:.4rem;border-radius:50%;background:#10b981;animation:lvpulse 2s infinite}
@keyframes lvpulse{0%,100%{opacity:1}50%{opacity:.35}}
.lv-body{margin-top:.15rem}
.lv-big{font-size:1.5rem;font-weight:800;letter-spacing:-.02em;line-height:1.25;font-variant-numeric:tabular-nums}
.lv-big small{font-size:.72rem;font-weight:700;color:var(--th-mut);margin-left:.2rem}
.lv-sub{margin-top:.2rem;font-size:.76rem;color:var(--th-mut);line-height:1.6}
.lv-row{display:flex;align-items:baseline;gap:.4rem;flex-wrap:wrap}
.lv-up{color:#e11d48}
.lv-down{color:#059669}
.lv-foot{margin-top:auto;padding-top:.55rem;font-size:.68rem;color:var(--th-mut);display:flex;align-items:center;gap:.3rem}
.lv-skel{height:.8rem;border-radius:.4rem;background:linear-gradient(90deg,var(--th-line),rgba(148,163,184,.18),var(--th-line));background-size:200% 100%;animation:lvskel 1.3s linear infinite}
.lv-skel.w60{width:60%}.lv-skel.w40{width:40%}.lv-skel.w80{width:80%}
@keyframes lvskel{0%{background-position:200% 0}100%{background-position:-200% 0}}

/* ---------- 工具卡 ---------- */
.tl-grid{display:grid;grid-template-columns:1fr;gap:.85rem}
@media(min-width:560px){.tl-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(min-width:1024px){.tl-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
/* 只有兩張卡的分區：兩欄橫向鋪滿 */
.tl-grid--two{grid-template-columns:1fr}
@media(min-width:560px){.tl-grid--two{grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}}
.tl-grid--two .tl-card{padding:1.15rem}
.tl-grid--two .tl-ico{width:3rem;height:3rem;flex-basis:3rem;font-size:1.2rem;border-radius:.9rem}
.tl-grid--two .tl-body b{font-size:1.02rem}
.tl-arrow{margin-left:auto;align-self:center;color:var(--th-mut);font-size:.8rem;opacity:.45;transition:.16s;flex:0 0 auto}
.tl-card:hover .tl-arrow{opacity:1;transform:translateX(2px);color:var(--th-brand)}
.tl-card{
  position:relative;display:flex;gap:.85rem;align-items:flex-start;
  background:var(--th-card);border:1px solid var(--th-line);border-radius:var(--th-radius);
  padding:1rem;box-shadow:var(--th-shadow);text-decoration:none;color:inherit;
  transition:transform .16s,box-shadow .16s,border-color .16s;
  overflow:hidden;
}
.tl-card::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--tl-c,var(--th-brand));
  opacity:0;transition:opacity .16s;
}
.tl-card:hover{transform:translateY(-2px);box-shadow:var(--th-shadow-h);border-color:#c9d8f0}
.tl-card:hover::before{opacity:1}
html.dark .tl-card:hover{border-color:#2d4560}
.tl-ico{
  width:2.6rem;height:2.6rem;flex:0 0 2.6rem;border-radius:.8rem;
  display:inline-flex;align-items:center;justify-content:center;color:#fff;font-size:1.05rem;
  background:var(--tl-c,var(--th-brand));
  box-shadow:0 6px 14px -8px var(--tl-c,rgba(37,99,235,.8));
}
.tl-body{min-width:0;flex:1}
.tl-body b{display:block;font-size:.95rem;font-weight:800;letter-spacing:-.005em}
.tl-body span{display:block;margin-top:.22rem;font-size:.78rem;line-height:1.6;color:var(--th-mut)}

/* 搜尋過濾時的隱藏 */
.th-hidden{display:none!important}
.th-empty{
  display:none;padding:2.4rem 1rem;text-align:center;border:1px dashed var(--th-line);border-radius:var(--th-radius);
  color:var(--th-mut);font-size:.86rem;background:var(--th-card);
}
.th-empty.on{display:block}

/* ---------- 常用電話 ---------- */
.ph-wrap{
  background:var(--th-card);border:1px solid var(--th-line);border-radius:var(--th-radius);
  box-shadow:var(--th-shadow);overflow:hidden;
}
.ph-tbl{width:100%;border-collapse:collapse;font-size:.84rem}
.ph-tbl th,.ph-tbl td{padding:.7rem .9rem;text-align:left;border-bottom:1px solid var(--th-line);vertical-align:middle}
.ph-tbl thead th{font-size:.7rem;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--th-mut);background:rgba(148,163,184,.07)}
.ph-tbl tbody tr:last-child td{border-bottom:0}
.ph-tbl tbody tr:hover{background:rgba(37,99,235,.04)}
.ph-tbl .ph-num{font-weight:800;color:var(--th-brand);font-variant-numeric:tabular-nums;white-space:nowrap}
.ph-tbl .ph-note{color:var(--th-mut);font-size:.78rem}
.ph-tbl a{text-decoration:none}
@media(max-width:559px){
  .ph-tbl thead{display:none}
  .ph-tbl,.ph-tbl tbody,.ph-tbl tr,.ph-tbl td{display:block;width:100%}
  .ph-tbl tr{padding:.6rem .9rem;border-bottom:1px solid var(--th-line)}
  .ph-tbl td{border:0;padding:.12rem 0}
  .ph-tbl td:first-child{font-weight:700;font-size:.86rem}
}
.th-fine{margin:.9rem 0 0;font-size:.72rem;line-height:1.75;color:var(--th-mut)}

/* ---------- 內頁：麵包屑 + 工具切換 ---------- */
.th-crumb{display:flex;align-items:center;gap:.4rem;font-size:.76rem;color:var(--th-mut);margin-bottom:.7rem;flex-wrap:wrap}
.th-crumb a{text-decoration:none;font-weight:600;color:var(--th-mut)}
.th-crumb a:hover{color:var(--th-brand)}
.th-crumb .th-crumb-sep{opacity:.45}
.th-crumb b{font-weight:700;color:var(--th-ink)}
.th-switch{display:flex;gap:.4rem;overflow-x:auto;padding:.15rem 0 .6rem;margin-bottom:.4rem;scrollbar-width:none}
.th-switch::-webkit-scrollbar{display:none}
.th-switch a{
  flex:0 0 auto;display:inline-flex;align-items:center;gap:.4rem;
  padding:.42rem .75rem;border-radius:999px;border:1px solid var(--th-line);background:var(--th-card);
  font-size:.78rem;font-weight:700;color:var(--th-mut);text-decoration:none;transition:.15s;white-space:nowrap;
}
.th-switch a i{font-size:.72rem}
.th-switch a:hover{color:var(--th-brand);border-color:#c9d8f0}
.th-switch a.on{background:var(--th-brand);border-color:var(--th-brand);color:#fff;box-shadow:0 8px 16px -12px rgba(37,99,235,.9)}
.th-switch a.on i{color:#fff}

/* 內頁底部：回到工具首頁 */
.th-back{
  display:inline-flex;align-items:center;gap:.45rem;margin:1.4rem 0 0;
  padding:.55rem .9rem;border-radius:.7rem;border:1px solid var(--th-line);background:var(--th-card);
  font-size:.8rem;font-weight:700;color:var(--th-ink);text-decoration:none;transition:.15s;
}
.th-back:hover{border-color:var(--th-brand);color:var(--th-brand)}

/* 內頁裡 pages.css 的 .tpw 不需要自己置中（.tw 已處理） */
.tw .tpw{max-width:none;margin:0}

/* ---------- 頁尾間距 ---------- */
.th-spacer{height:2.2rem}

@media(prefers-reduced-motion:reduce){
  .lv-card,.tl-card,.lv-skel,.lv-top .lv-live i{animation:none!important;transition:none!important}
}
