/* ============================================
   LoFi Theme: ☕ Café au Lait
   CSS 變數：顏色、字體、間距系統
   ============================================ */

:root[data-theme="light"] {
  --bg:           #F0E8DC;
  --surface:      #FFFAF4;
  --surface-2:    #F5EFE6;
  --border:       #E2CDB0;
  --text:         #3D2B1F;
  --text-muted:   #A08060;
  --accent:       #C8874A;
  --accent-light: #F5E4D0;
  --danger:       #B85444;
  --danger-light: #F5E0DC;
  --success:      #6A9E6A;
  --success-light:#DCF0DC;
  --warning:      #C49A3A;
  --warning-light:#F5EDCC;
  --shadow:       0 2px 8px rgba(100,60,20,0.10), 0 1px 3px rgba(100,60,20,0.07);
  --shadow-md:    0 4px 16px rgba(100,60,20,0.12), 0 2px 6px rgba(100,60,20,0.08);
  --nav-bg:       #FDF7EE;
  --header-bg:    #FDF7EE;
  --grain:        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  --bg:           #1C1410;
  --surface:      #2A1E16;
  --surface-2:    #231912;
  --border:       #3D2E22;
  --text:         #F0E4D0;
  --text-muted:   #9A7A5A;
  --accent:       #D4956A;
  --accent-light: #3D2416;
  --danger:       #D47060;
  --danger-light: #3D1A14;
  --success:      #7AB87A;
  --success-light:#1A3A1A;
  --warning:      #D4B060;
  --warning-light:#3A2C10;
  --shadow:       0 2px 8px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.20);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.25);
  --nav-bg:       #221810;
  --header-bg:    #221810;
  --grain:        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

/* ============================================
   Reset & 基礎設定
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, 'PingFang TC', 'Noto Sans TC',
               'Microsoft JhengHei', BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* LoFi 紙張質感疊加層 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--grain);
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 1;
}

body > * {
  position: relative;
  z-index: 1;
}

/* ============================================
   Layout：Header / Main / Bottom Nav
   ============================================ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 2px 12px rgba(100,60,20,0.08);
}

.app-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.app-main {
  padding-top: 56px;
  padding-bottom: 72px;
  min-height: 100vh;
  min-height: 100dvh;
}

.page {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   底部導覽列
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 64px;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  box-shadow: 0 -1px 4px rgba(0,0,0,0.06);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
  padding: 8px 0;
  min-height: 44px;
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* ============================================
   懸浮新增按鈕 (FAB)
   ============================================ */

.fab {
  position: fixed;
  right: 20px;
  bottom: 80px;
  z-index: 150;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(180,100,40,0.35), 0 1px 4px rgba(180,100,40,0.2);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 8px rgba(180,100,40,0.25);
}

/* ============================================
   Modal（Bottom Sheet 風格）
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 210;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--border);
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-overflow-scrolling: touch;
}

.modal.active {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 4px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 20px 24px;
}

/* ============================================
   頁面動作列（篩選）
   ============================================ */

.page-actions {
  margin-bottom: 12px;
}

.filter-bar {
  display: flex;
  gap: 8px;
}

.filter-select,
.filter-input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

/* ============================================
   空狀態提示
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 15px;
  line-height: 1.5;
}

/* ============================================
   主題切換按鈕
   ============================================ */

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.15s;
}

.icon-btn:active {
  background: var(--border);
}

/* ============================================
   捲動條美化
   ============================================ */

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
