:root {
  --glass-bg: rgba(20, 26, 40, 0.58);
  --glass-border: rgba(255, 255, 255, 0.13);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --green: #4ade80;
  --amber: #fbbf24;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang HK", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--text-main);
  background-color: #060911;
  user-select: none;
  display: flex;
  flex-direction: column;
}

/* 夜間模式遮罩 */
body.night-dim::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: none;
  z-index: 999;
}

#bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  transition: background 0.8s ease;
  background-size: cover;
  background-position: center;
}
.bg-theme-1 { background: radial-gradient(circle at 15% 20%, #1e3a8a, #0f172a 60%, #020617); }
.bg-theme-2 { background: radial-gradient(circle at 80% 25%, #312e81, #1e1b4b 55%, #090d16); }
.bg-theme-3 { background: linear-gradient(135deg, #0f2027, #203a43, #2c5364); }

/* 三欄式 Full Set iPad 橫向佈局 */
.dashboard-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 16px;
  padding: 18px 20px 10px 20px;
  height: calc(100vh - 38px);
  transition: transform 2s ease-in-out;
}

.col-left, .col-mid, .col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 16px 20px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sub-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* 1. 主時鐘 + 世界時鐘 */
.clock-card { flex: 1.45; justify-content: space-between; }
.top-bar { display: flex; justify-content: space-between; align-items: center; }
.date-row { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 500; }
.mode-pills { display: flex; gap: 6px; }

.pill-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
}
.pill-btn.active { background: rgba(56, 189, 248, 0.22); border-color: var(--accent); color: var(--accent); }

.time-display {
  font-size: 6.4rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  margin: 4px 0;
}
.colon { animation: blink 1s infinite; margin: 0 2px; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.seconds-sub { font-size: 2rem; color: var(--text-muted); margin-left: 10px; }

.world-clock-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.wc-item { display: flex; flex-direction: column; }
.wc-item span { font-size: 0.72rem; color: var(--text-muted); }
.wc-item strong { font-size: 0.98rem; font-variant-numeric: tabular-nums; }

/* 2. 相簿與金句 */
.photo-quote-card {
  flex: 1.15;
  padding: 0;
  overflow: hidden;
  position: relative;
}
.photo-box {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(56,189,248,0.18), rgba(168,85,247,0.18));
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  transition: background-image 1s ease-in-out;
}
.photo-overlay {
  width: 100%;
  padding: 14px 18px;
  background: linear-gradient(to top, rgba(0,0,0,0.82), transparent);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
}
#daily-quote { font-size: 0.9rem; line-height: 1.4; color: #f1f5f9; font-style: italic; flex: 1; }
.upload-photo-label {
  background: rgba(255,255,255,0.18);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

/* 3. 紀念日 / 出入境 */
.countdown-card { flex: 0.75; justify-content: center; }
.countdown-content { display: flex; justify-content: space-between; align-items: center; }
.cd-title { font-size: 1.15rem; font-weight: 600; display: block; margin-bottom: 2px; }
.countdown-days { font-size: 2.3rem; font-weight: 700; color: var(--accent); }
.countdown-days small { font-size: 0.95rem; color: var(--text-muted); }

/* 4. 天氣與空氣質素 */
.weather-card { flex: 1; justify-content: space-between; }
.weather-main { display: flex; align-items: center; gap: 16px; }
.temp-box { font-size: 3.1rem; font-weight: 700; line-height: 1; }
.temp-box .unit { font-size: 1.3rem; color: var(--accent); }
.weather-details p { font-size: 0.88rem; margin-bottom: 3px; color: var(--text-muted); }
.weather-details strong { color: var(--text-main); }
.aqi-badge strong { color: var(--green); }
.warning-text { color: var(--amber); font-size: 0.82rem; margin-top: 4px; }

/* 5. 公共交通與路面 */
.transport-card { flex: 1.25; justify-content: space-between; }
.bus-list { display: flex; flex-direction: column; gap: 8px; }
.bus-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.05);
  padding: 7px 12px;
  border-radius: 12px;
}
.bus-num {
  background: #ef4444;
  color: white;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  min-width: 44px;
  text-align: center;
}
.bus-dest { font-size: 0.88rem; flex: 1; margin-left: 10px; }
.bus-eta { font-size: 0.88rem; font-weight: 600; color: var(--accent); }
.traffic-status {
  font-size: 0.82rem;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.ok-text { color: var(--green); font-weight: 500; }

/* 6. 投資市場看板 */
.invest-card { flex: 0.95; justify-content: space-between; }
.market-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mkt-item {
  background: rgba(0,0,0,0.22);
  padding: 8px 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}
.mkt-name { font-size: 0.75rem; color: var(--text-muted); }
.mkt-price { font-size: 1.05rem; color: var(--green); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* 7. 計時器 & 白噪音 */
.timer-sound-card { flex: 1.05; justify-content: space-between; }
.pomo-body { display: flex; justify-content: space-between; align-items: center; }
.pomo-time { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pomo-actions { display: flex; gap: 6px; }
.action-btn, .icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn { padding: 3px 10px; font-size: 0.78rem; }
.action-btn.primary { background: var(--accent); color: #060911; border: none; }

.sound-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.sound-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 6px 4px;
  border-radius: 10px;
  font-size: 0.75rem;
  cursor: pointer;
}
.sound-btn.playing { background: rgba(74, 222, 128, 0.22); border-color: var(--green); color: var(--green); }
.sound-btn.stop { color: #f87171; }

/* 8. 服藥提醒 & 清單 */
.todo-card { flex: 1.3; min-height: 0; }
.med-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  background: rgba(56, 189, 248, 0.1);
  padding: 6px 10px;
  border-radius: 10px;
}
.med-check { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; cursor: pointer; }
.todo-input-group { display: flex; gap: 6px; margin-bottom: 8px; }
#todo-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 7px 10px;
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
}
.todo-list { list-style: none; overflow-y: auto; flex: 1; }
.todo-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}
.todo-list li.done span { text-decoration: line-through; color: var(--text-muted); }
.del-btn { color: #f87171; background: none; border: none; font-size: 0.95rem; cursor: pointer; }

/* 9. 家居快捷控制 */
.home-card { flex: 0.85; justify-content: space-between; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.home-btn {
  text-decoration: none;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  display: block;
}
.home-btn:active { background: rgba(56, 189, 248, 0.25); }

/* 底部滾動新聞跑馬燈 */
.news-ticker {
  height: 36px;
  background: rgba(10, 15, 28, 0.85);
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
}
.ticker-tag {
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.ticker-wrap { flex: 1; overflow: hidden; white-space: nowrap; }
.ticker-move {
  display: inline-block;
  padding-left: 100%;
  animation: ticker 38s linear infinite;
  font-size: 0.88rem;
  color: #e2e8f0;
}
@keyframes ticker {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}
