/* 
 * 溫暖木質調配色系統 (Warm Wood Tone)
 */
:root {
  --primary-color: #5d4037;      /* 深木褐色：主按鈕、標題 */
  --primary-light: #816d66;     /* 淺木褐色：Hover 效果 */
  --secondary-color: #a1887f;    /* 輔助木色：次要元素 */
  --accent-color: #bcaaa4;      /* 灰木色：格線與裝飾 */
  --bg-color: #fcf9f2;          /* 米白色：整體背景 (具有紙質感) */
  --card-bg: #ffffff;           /* 純白：卡片背景 */
  --text-main: #3e2723;         /* 近乎黑的深褐：內文、標題 */
  --text-muted: #795548;        /* 柔和褐：說明、日期 */
  --danger: #d32f2f;            /* 警告紅：刪除、錯誤 */
  
  /* 字體系統 */
  --font-main: 'Inter', 'Noto Sans TC', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 12px;
}

/* 基礎重設 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 650px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* 登入遮罩優化 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(62, 39, 35, 0.85); /* 深褐色透明 */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 20px;
  border: 1px solid var(--accent-color);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 420px;
  text-align: center;
}

.modal h2 { 
  margin-bottom: 10px; 
  color: var(--primary-color);
  font-size: 1.8rem;
}

.auth-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 30px;
}

.auth-switch {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary-color);
  font-weight: 700;
  text-decoration: none;
  margin-left: 5px;
  border-bottom: 1px solid var(--primary-color);
}

.auth-switch a:hover {
  color: var(--primary-light);
  border-color: var(--primary-light);
}

.auth-actions {
  margin-top: 10px;
}
.card {
  background: var(--card-bg);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(62, 39, 35, 0.06);
  border: 1px solid rgba(188, 170, 164, 0.3);
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(62, 39, 35, 0.1);
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 支出顯示區優化 */
.budget-display {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-color);
  text-align: center;
  letter-spacing: -1px;
}

.currency { font-size: 1.2rem; margin-right: 8px; vertical-align: middle; color: var(--text-muted); }

/* 分攤資訊區樣式 */
.share-info {
  margin-top: 25px;
  padding: 24px;
  background: var(--bg-color);
  border-radius: 16px;
  text-align: center;
}

.stepper-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 50px;
  padding: 6px;
  border: 1px solid var(--accent-color);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  margin-bottom: 20px;
}

.step-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-color);
  color: var(--primary-color);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.step-btn:hover { background: var(--primary-color); color: #fff; }

.stepper input {
  width: 60px;
  border: none;
  background: none;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary-color);
  outline: none;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
}

.per-person-card {
  border-top: 1px dashed var(--accent-color);
  padding-top: 15px;
}

.per-person-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 5px; }
.per-person-value { font-size: 1.8rem; font-weight: 800; color: var(--primary-color); }

/* 表單元件高級感 */
.input-group { margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }
.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--accent-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition);
  color: var(--text-main);
}

.input-group input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(93, 64, 55, 0.1);
  outline: none;
}

.button-group { display: flex; gap: 12px; margin-top: 30px; }
button {
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary { background: var(--primary-color); color: #fff; flex: 2; }
.primary:hover { background: var(--primary-light); }
.secondary { background: var(--bg-color); color: var(--primary-color); border: 1px solid var(--primary-color); flex: 1; }
.secondary:hover { background: var(--accent-color); color: #fff; }

.submit-btn {
  width: 100%;
  background: var(--primary-color);
  color: #fff;
  font-size: 1rem;
  margin-top: 10px;
}

/* 列表設計 */
.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid rgba(188, 170, 164, 0.2);
}

.item-info .item-name { font-weight: 600; font-size: 1.1rem; color: var(--text-main); display: block; }
.item-info .item-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

.item-amount { color: var(--primary-color); font-weight: 700; font-size: 1.1rem; margin-right: 15px; }

.del-btn {
  background: #fdf2f2;
  color: #cf6679;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.75rem;
  border: none;
}

.del-btn:hover { background: var(--danger); color: #fff; transform: rotate(90deg); }

/* Header 工具列 */
.header-content { margin-bottom: 30px; text-align: center; }
h1 { font-size: 2rem; color: var(--primary-color); font-weight: 800; margin-bottom: 5px; }
#user-info { display: inline-flex; align-items: center; background: #fff; padding: 6px 15px; border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.text-btn { background: none; color: var(--danger); font-size: 0.85rem; font-weight: 500; }

.hidden { display: none !important; }
/* 📊 究極顯眼圖表佈局 */
.chart-info {
  display: flex;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px 0;
}

.chart-container {
  width: 260px;
  height: 260px;
  position: relative;
}

/* 自訂 HTML 圖例容器 */
.custom-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 140px;
}

/* 回應使用者需求：讓點選項目更明顯 (膠囊按鈕風格) */
.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: white;
  border: 2px solid var(--accent-color);
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-color);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.legend-item:hover {
  transform: scale(1.05) translateX(5px);
  border-color: var(--primary-color);
  box-shadow: 0 8px 15px rgba(62, 39, 35, 0.12);
}

/* 被關閉時的明顯狀態變換 */
.legend-item.hidden-item {
  opacity: 0.4;
  text-decoration: line-through;
  background: #f0f0f0;
  border-color: #ccc;
  box-shadow: none;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 2px rgba(0,0,0,0.1);
}

.empty-msg { text-align: center; color: var(--text-muted); padding: 50px; }

/* 響應式佈局 (Media Queries) */
@media (max-width: 480px) {
  #app { padding: 20px 15px; }
  h1 { font-size: 1.5rem; }
  .budget-display { font-size: 2.2rem; }
  .modal { padding: 30px 20px; }
}
