/* AI龍蝦玄學館 v1.0 - Mobile First 樣式 */
:root {
  --gold: #C8A96A;
  --gold-light: #E8D5A0;
  --gold-dark: #A8883A;
  --bg: #F8F8F8;
  --card: #FFFFFF;
  --text: #222222;
  --text-secondary: #666666;
  --text-light: #999999;
  --border: #E8E8E8;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; max-width: 100vw; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}

/* Header */
.header {
  background: var(--card);
  padding: 20px 16px 14px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-dark);
}
.header-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Form */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #fafafa;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus {
  border-color: var(--gold);
  background: #fff;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.form-row > * {
  flex: 1 1 140px;
  min-width: 0;
}
.form-select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #fafafa;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

/* Button */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  margin: 16px 0 0;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .8; }
.btn-secondary {
  padding: 10px 20px;
  background: var(--card);
  color: var(--gold-dark);
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--gold-light);
  border-radius: 8px;
  cursor: pointer;
}

/* Pillar Grid */
.pillar-section { margin-bottom: 12px; }
.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.pillar-item {
  text-align: center;
  padding: 8px 2px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.pillar-label { font-size: 10px; color: var(--text-light); margin-bottom: 3px; }
.pillar-ganzhi { font-size: 18px; font-weight: 700; color: var(--text); }
.pillar-shishen { font-size: 11px; color: var(--gold-dark); margin-top: 2px; }

/* Hidden Stems */
.hidden-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.hidden-item {
  padding: 6px 2px;
  background: #fafafa;
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--border);
}
.hidden-branch { font-size: 13px; font-weight: 600; color: var(--gold-dark); margin-bottom: 3px; }
.hidden-list { font-size: 11px; color: var(--text-secondary); line-height: 1.6; }
.hidden-ss { font-size: 10px; color: var(--text-light); }

/* Five Elements */
.elements-grid {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.element-item {
  text-align: center;
  flex: 1;
  min-width: 0;
  padding: 6px 0;
}
.element-name { font-size: 12px; font-weight: 700; }
.element-count { font-size: 20px; font-weight: 700; margin: 2px 0; }
.element-bar {
  height: 4px;
  border-radius: 2px;
  margin: 0 auto;
  max-width: 36px;
  transition: width .3s;
}
.element-label { font-size: 9px; color: var(--text-light); margin-top: 2px; }

/* DaYun */
.dayun-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.dayun-scroll { display: flex; gap: 8px; padding-bottom: 8px; }
.dayun-item {
  flex-shrink: 0;
  width: 100px;
  padding: 12px 8px;
  background: linear-gradient(135deg, #fafafa, #f5f0e6);
  border: 1px solid var(--gold-light);
  border-radius: 10px;
  text-align: center;
}
.dayun-age { font-size: 11px; color: var(--text-light); }
.dayun-ganzhi { font-size: 18px; font-weight: 700; color: var(--gold-dark); margin: 4px 0; }
.dayun-range { font-size: 10px; color: var(--text-secondary); }

/* Clients */
.client-list { margin: 0 16px; }
.client-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.client-card:active { opacity: .7; }
.client-name { font-size: 16px; font-weight: 600; }
.client-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.client-actions { display: flex; gap: 6px; }
.btn-sm {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-size: 12px;
  cursor: pointer;
}
.btn-sm-del { border-color: #ffcccc; color: #c92a2a; }

/* Search */
.search-bar {
  margin: 12px 16px;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--card);
}
.search-input:focus { border-color: var(--gold); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 16px; color: var(--text-light); }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1;
  text-align: center;
  padding: 6px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 11px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--gold-dark); font-weight: 600; }
.nav-icon { font-size: 20px; display: block; margin-bottom: 2px; }

/* Info row */
.info-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; gap: 8px; }
.info-row + .info-row { border-top: 1px solid #f5f5f5; }
.info-label { color: var(--text-secondary); flex-shrink: 0; }
.info-value { font-weight: 600; text-align: right; overflow-wrap: break-word; word-break: break-all; min-width: 0; }

/* AI Analysis */
.ai-text {
  font-size: 14px;
  line-height: 1.8;
  color: rgba(255,255,255,0.85);
}

/* 📱 Mobile RWD fixes */
@media (max-width: 400px) {
  .card { margin: 8px 8px; }
  .pillar-item { padding: 6px 1px; }
  .pillar-ganzhi { font-size: 16px; }
  .pillar-shishen { font-size: 10px; }
  .hidden-grid { gap: 3px; }
  .hidden-item { padding: 4px 1px; }
  .hidden-list { font-size: 10px; }
  .element-count { font-size: 17px; }
  .element-name { font-size: 11px; }
  .element-bar { max-width: 28px; }
  .dayun-item { width: 88px; padding: 10px 6px; }
  .dayun-ganzhi { font-size: 16px; }
}

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); font-size: 14px; }

/* Loading */
.loading-spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast-like notice */
.notice {
  margin: 12px 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}
.notice-good { background: #e6f7e6; color: #2b8a3e; }
.notice-bad { background: #fff5f5; color: #c92a2a; }

/* Modal overlay */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions button { flex: 1; padding: 10px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-cancel { background: #eee; color: #555; }
.btn-confirm { background: var(--gold-dark); color: #fff; }

/* Back button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  color: var(--gold-dark);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 8px;
}
