/* ============================================
   PUNCH v2 - Base
   淺色系 · Modern Editorial
   ============================================ */

:root {
  /* 主色票 - 米黃溫潤色系 */
  --bg: #faf7f0;
  --bg-elev: #ffffff;
  --bg-soft: #f3ede0;
  --bg-card: #ffffff;

  /* 文字 */
  --text: #2a2622;
  --text-soft: #5a5048;
  --text-mute: #948a7e;
  --text-dim: #c8bfb2;

  /* 線條 */
  --line: #e8e1d2;
  --line-soft: #f0eadc;
  --line-strong: #d4cab5;

  /* 強調色 */
  --accent: #c8893a;        /* 主品牌色 - 焦糖 */
  --accent-soft: #f5e8d0;
  --accent-deep: #8f5e1f;

  /* 語意色 */
  --success: #5a9968;        /* 出勤 - 綠 */
  --success-soft: #d8ead5;
  --warning: #d4a843;        /* 加班 - 金 */
  --warning-soft: #f5ebcc;
  --danger: #c75450;         /* 補休/警示 - 紅 */
  --danger-soft: #f3d8d6;
  --info: #5a89a8;           /* 補休/特殊 - 藍 */
  --info-soft: #d8e4ee;
  --neutral: #8a8576;
  --neutral-soft: #ede9dd;

  /* 公司預設色票(可被覆蓋) */
  --company-1: #c8893a;
  --company-2: #5a89a8;
  --company-3: #7a9a5e;
  --company-4: #b06a8a;
  --company-5: #8a6db0;
  --company-6: #c87a4a;

  /* 字型 */
  --font-display: "Fraunces", "Noto Serif TC", Georgia, serif;
  --font-body: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* 圓角 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* 陰影 */
  --shadow-sm: 0 1px 2px rgba(60, 50, 35, 0.04);
  --shadow-md: 0 2px 8px rgba(60, 50, 35, 0.06);
  --shadow-lg: 0 8px 24px rgba(60, 50, 35, 0.10);
  --shadow-card: 0 1px 3px rgba(60, 50, 35, 0.05), 0 4px 12px rgba(60, 50, 35, 0.04);

  /* Safe area */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Tabbar 高度 */
  --tabbar-h: 64px;

  /* 半透明玻璃背景(header/tabbar)與 hero 漸層 */
  --glass-header: rgba(250, 247, 240, 0.88);
  --glass-tabbar: rgba(255, 255, 255, 0.92);
  --hero-grad: linear-gradient(135deg, #ffffff 0%, #faf2e0 100%);
  --bg-glow: #fdfaf3;

  /* 休假專屬色(草綠 125°,與所有公司色相至少差 33°,不撞色) */
  --leave-color: #37be42;

  /* Toast 背景(固定深色,深淺色模式都用深底白字) */
  --toast-bg: #3a322a;
}

/* ===== 深色模式(深棕褐底 + 暖調,維持焦糖色調)===== */
[data-theme="dark"] {
  /* 背景:深棕褐,帶暖調 */
  --bg: #1c1814;
  --bg-elev: #262019;
  --bg-soft: #2e2620;
  --bg-card: #262019;

  /* 文字:暖白到暖灰 */
  --text: #f0e8dc;
  --text-soft: #c8bcac;
  --text-mute: #9a8e7e;
  --text-dim: #6a6052;

  /* 線條:暖調深線 */
  --line: #3a3128;
  --line-soft: #2e2620;
  --line-strong: #4a3f32;

  /* 強調色:焦糖在暗底要提亮一點 */
  --accent: #e0a456;
  --accent-soft: #3d3122;
  --accent-deep: #f0b870;

  /* 語意色:暗底略提亮 */
  --success: #6fae7d;
  --success-soft: #2a3a2c;
  --warning: #e0b85a;
  --warning-soft: #3a3320;
  --danger: #d96f6b;
  --danger-soft: #3a2625;
  --info: #6fa0c0;
  --info-soft: #243038;
  --neutral: #9a9486;
  --neutral-soft: #2e2a22;

  /* 陰影:暗底用更深的陰影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.2);

  /* 半透明玻璃背景與 hero 漸層(深色) */
  --glass-header: rgba(28, 24, 20, 0.88);
  --glass-tabbar: rgba(38, 32, 25, 0.92);
  --hero-grad: linear-gradient(135deg, #2e2620 0%, #3a2f22 100%);
  --bg-glow: #241e18;
  --leave-color: #57c760;
  --toast-bg: #0f0c09;
}

/* Reset */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  background:
    radial-gradient(ellipse 100% 60% at 50% 0%, var(--bg-glow) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: transparent;
}

input:focus, select:focus, textarea:focus {
  outline: none;
}

ul, ol {
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* 文字工具 */
.muted { color: var(--text-mute); }
.soft  { color: var(--text-soft); }
.dim   { color: var(--text-dim); }
.tabular { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
.display-bold { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }

/* ===== 更新提示橫幅(頂部,卡片式) ===== */
#update-banner {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 9999;
  width: calc(100% - 28px);
  max-width: 420px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.18);
  padding: 12px 14px;
  animation: update-banner-in 0.25s ease;
}
@keyframes update-banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.upd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.upd-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #333);
}
.upd-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.upd-x {
  background: var(--bg-soft, #eee);
  border: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 13px;
  color: var(--text-mute, #888);
  cursor: pointer;
  flex: 0 0 auto;
}
.upd-x:active { transform: scale(0.92); }
.upd-details { margin-top: 8px; }
.upd-details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--accent-deep);
  font-weight: 600;
  padding: 4px 0;
}
.upd-details > summary::-webkit-details-marker { display: none; }
.upd-details .upd-chevron { transition: transform 0.2s; }
.upd-details[open] .upd-chevron { transform: rotate(180deg); }
.upd-changelog {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.upd-change-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-soft, #555);
}
.upd-tag {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  margin-top: 1px;
}
.upd-tag.feat { background: #e3f0e0; color: #3b6d11; }
.upd-tag.change { background: #e6eef6; color: #185fa5; }
.upd-tag.fix { background: #f6e6e6; color: #a32d2d; }
.upd-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.upd-btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.upd-btn-primary:active { transform: scale(0.98); }
.upd-btn-ghost {
  flex: 0 0 auto;
  background: transparent;
  color: var(--text-mute, #888);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.upd-btn-ghost:active { transform: scale(0.98); }

/* 檢查更新彈窗 */
.upd-modal-ver { font-size: 14px; color: var(--text-soft); margin-bottom: 6px; }
.upd-modal-ver strong { color: var(--accent-deep); }
.upd-modal-title { font-size: 15px; font-weight: 700; margin: 4px 0 10px; color: var(--text); }

/* 設定頁:更新設定(可展開) */
.update-settings > summary {
  list-style: none;
  cursor: pointer;
}
.update-settings > summary::-webkit-details-marker { display: none; }
.update-settings > summary .chevron { transition: transform 0.2s; }
.update-settings[open] > summary .chevron { transform: rotate(180deg); }
.update-settings-body .sub-item {
  padding-left: 28px;
  background: var(--bg-soft, rgba(0,0,0,0.02));
}
.mini-select {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-card, #fff);
  color: var(--text, #333);
}

/* 更新遮罩:半透明全屏 + UPDATE + 假進度條,期間禁止操作 */
#update-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(20, 16, 12, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  /* 攔截所有操作 */
  pointer-events: all;
  touch-action: none;
  animation: upd-ov-in 0.2s ease;
}
@keyframes upd-ov-in { from { opacity: 0; } to { opacity: 1; } }
.upd-ov-inner {
  width: min(80vw, 320px);
  text-align: center;
  color: #fff;
}
.upd-ov-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.18em;
  font-family: var(--font-display, inherit);
}
.upd-ov-sub {
  font-size: 13px;
  opacity: 0.75;
  margin: 10px 0 20px;
}
.upd-ov-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.upd-ov-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d6a55a, #c8893a);
  transition: width 0.18s ease;
}
.upd-ov-pct {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
