/* 中文備註：整體背景與字體 */
:root{
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #e6edf5;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 10px 30px rgba(15,23,42,0.08);
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* =========================
   Header：手機縮高度 + 固定頂部
   ========================= */

/* 中文備註：上方標題列 */
.topbar{
  max-width: 1080px;
  margin: 18px auto 0;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-direction: column;
}

/* 中文備註：手機上把 header 變成黏住，減少佔位 */
@media (max-width: 520px){
  .topbar{
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(244,247,251,0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px 12px;
    margin: 0 auto;
    gap: 10px;
  }
}

.topTitle{
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.title{
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.ver{
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

/* 中文備註：手機縮小字體，讓首屏更乾淨 */
@media (max-width: 520px){
  .title{ font-size: 22px; }
  .ver{ font-size: 12px; }
}

/* 中文備註：主按鈕 */
.primaryBtn{
  border: none;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #1f2937, #0b1220);
  box-shadow: 0 10px 25px rgba(15,23,42,0.18);
  font-weight: 800;
}

/* 中文備註：手機按鈕更扁一點 */
@media (max-width: 520px){
  .primaryBtn{
    width: 100%;
    max-width: 360px;
    padding: 11px 18px;
    border-radius: 14px;
  }
}

.primaryBtn:disabled{
  opacity: .6;
  cursor: not-allowed;
}

/* =========================
   Layout
   ========================= */

/* 中文備註：內容包裹 */
.wrap{
  max-width: 1080px;
  margin: 18px auto 48px;
  padding: 0 18px;
}

@media (max-width: 520px){
  .wrap{
    padding: 0 14px;
    margin: 14px auto 40px;
  }
}

/* 中文備註：單欄內容 */
.content{
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (max-width: 520px){
  .content{ gap: 14px; }
}

/* 中文備註：卡片 */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

@media (max-width: 520px){
  .card{
    padding: 14px;
    border-radius: 18px;
  }
}

.cardHeader{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap; /* 中文備註：手機避免擠爆 */
}

.cardTitle{
  font-size: 16px;
  font-weight: 800;
}
.cardHint{
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

/* =========================
   規則區：手機改成一欄大卡（好讀）
   ========================= */

/* 中文備註：6格規則區（桌機 3 欄） */
.grid6{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* 中文備註：平板 2 欄 */
@media (max-width: 860px){
  .grid6{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ✅ 中文備註：手機 1 欄（最乾淨、最好讀） */
@media (max-width: 520px){
  .grid6{
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.ruleBox{
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
}

@media (max-width: 520px){
  .ruleBox{
    padding: 12px 12px;
    border-radius: 16px;
  }
}

/* 中文備註：標籤改成一行，避免「均線（短/中/長）」被硬拆 */
.ruleLabel{
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 中文備註：手機上放寬一點，可換行但不會擠 */
@media (max-width: 520px){
  .ruleLabel{
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    margin-bottom: 6px;
  }
}

.ruleInput{
  width: 100%;
  border: 0;
  outline: none;
  font-size: 18px;
  font-weight: 900;
  background: transparent;
  color: var(--text);
}

/* 中文備註：手機輸入數字更清楚 */
@media (max-width: 520px){
  .ruleInput{
    font-size: 20px;
    padding: 4px 0;
  }
}

/* =========================
   摘要框：手機縮內距、提升可讀性
   ========================= */

.summaryBox{
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #ffffff;
}

@media (max-width: 520px){
  .summaryBox{
    padding: 12px;
    border-radius: 16px;
  }
}

.summaryTitle{
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 8px;
}
.summaryList{
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}
.summaryList li{
  margin: 6px 0;
  color: var(--text);
  font-weight: 650;
  line-height: 1.45;
}

/* =========================
   狀態顯示：避免手機擠在同一行
   ========================= */

.pillStatus{
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  border: 1px solid var(--line);
}
.pillStatus.neutral{ background: #f1f5f9; color: #334155; }
.pillStatus.ok{ background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.pillStatus.err{ background: #fee2e2; border-color: #fecaca; color: #991b1b; }

.statusText{
  font-size: 13px;
  font-weight: 800;
  margin: 2px 0 10px;
  line-height: 1.4;
}
.statusText.muted{ color: var(--muted); }

/* =========================
   結果區 + 表格：手機好滑 + 第一欄固定
   ========================= */

.resultArea{
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #ffffff;
}

@media (max-width: 520px){
  .resultArea{
    padding: 10px;
    border-radius: 16px;
  }
}

.mutedRow{
  color: var(--muted);
  font-weight: 800;
}

/* 中文備註：表格 */
.tableWrap{
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 中文備註：手機上給一點滑動提示感 */
@media (max-width: 520px){
  .tableWrap{
    border-radius: 14px;
  }
}

table{
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th, td{
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap; /* 中文備註：避免表格亂換行變高 */
}

th{
  color: #334155;
  font-weight: 900;
  background: #fbfdff;
  position: sticky;
  top: 0; /* 中文備註：表頭固定 */
  z-index: 2;
}
td{
  color: #0f172a;
}

/* ✅ 中文備註：第一欄（代碼）固定，手機滑表格不會迷路 */
table th:first-child,
table td:first-child{
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 3;
  border-right: 1px solid var(--line);
}

table th:first-child{
  background: #fbfdff;
}

/* 中文備註：代碼膠囊 */
.codePill{
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #dbeafe;
  font-weight: 900;
}
