/* BaZi Module Styles - Modern & Polished */

/* ============================================
   Form Card
   ============================================ */
.bazi-form-card {
  background: linear-gradient(145deg, rgba(30, 35, 45, 0.95), rgba(20, 24, 32, 0.98));
  border: 1px solid rgba(91, 141, 239, 0.15);
  border-radius: 20px;
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  overflow: visible; /* Changed from hidden to allow location dropdown to show */
}

.bazi-form-card .card-body {
  padding: 28px;
}

/* ============================================
   Form Grid Layout
   ============================================ */
.bazi-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.bazi-field-location {
  grid-column: 1 / -1;
}

.bazi-options {
  grid-column: 1 / -1;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bazi-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  padding-top: 16px;
}

@media (max-width: 600px) {
  .bazi-form-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .bazi-form-card .card-body {
    padding: 20px;
  }
}

/* ============================================
   Field Labels
   ============================================ */
.bazi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 10px;
}

.bazi-icon {
  width: 18px;
  height: 18px;
  color: var(--primary, #5b8def);
  flex-shrink: 0;
}

/* ============================================
   Inputs - Modern Style
   ============================================ */
.bazi-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.bazi-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.bazi-input:hover {
  border-color: rgba(91, 141, 239, 0.3);
  background: rgba(0, 0, 0, 0.35);
}

.bazi-input:focus {
  border-color: var(--primary, #5b8def);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.15);
}

/* Flatpickr wrapper - ensure full clickability */
.bazi-field .flatpickr-wrapper {
  width: 100%;
}
.bazi-field .flatpickr-wrapper input.flatpickr-input {
  cursor: pointer;
}

/* Time row with unknown checkbox */
.bazi-time-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.bazi-time-row .bazi-input {
  flex: 1;
}

/* Checkbox styling */
.bazi-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  transition: color 0.2s;
}

.bazi-checkbox-label:hover {
  color: rgba(255, 255, 255, 0.85);
}

.bazi-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary, #5b8def);
  cursor: pointer;
}

.bazi-checkbox-text {
  user-select: none;
}

/* ============================================
   Select Dropdowns
   ============================================ */
.bazi-select-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bazi-select-label .small {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.bazi-select {
  padding: 10px 32px 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: all 0.2s ease;
}

.bazi-select:hover {
  border-color: rgba(91, 141, 239, 0.3);
}

.bazi-select:focus {
  border-color: var(--primary, #5b8def);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.15);
}

.bazi-select option {
  background: #1a1e28;
  color: #fff;
}

/* ============================================
   Location Autocomplete
   ============================================ */
.location-input-wrap {
  position: relative;
}

.location-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #252a36, #1e222c);
  border: 1px solid rgba(91, 141, 239, 0.2);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
}

.location-suggestions.hidden {
  display: none;
}

.location-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.location-suggestion:last-child {
  border-bottom: none;
}

.location-suggestion:hover,
.location-suggestion.active {
  background: rgba(91, 141, 239, 0.12);
}

.location-suggestion-icon {
  width: 20px;
  height: 20px;
  color: var(--primary, #5b8def);
  flex-shrink: 0;
  opacity: 0.7;
}

.location-suggestion-text {
  flex: 1;
}

.location-suggestion-name {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.location-suggestion-tz {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}

/* ============================================
   Action Buttons
   ============================================ */
.bazi-btn-compute {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  background: linear-gradient(135deg, #5b8def 0%, #4a7de0 100%);
  box-shadow: 0 4px 16px rgba(91, 141, 239, 0.3);
  transition: all 0.2s ease;
}

.bazi-btn-compute:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(91, 141, 239, 0.4);
}

.bazi-btn-compute:active {
  transform: translateY(0);
}

.bazi-btn-icon {
  width: 18px;
  height: 18px;
}

/* ============================================
   Expert View
   ============================================ */
.bazi-expert {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  overflow: auto;
  max-height: 60vh;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

/* ============================================
   History Sidebar (matching Oracle sidebar styles)
   ============================================ */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--fg);
}

.history-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0 10px;
}

.history-search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 10px 0;
  font-size: 14px;
  font-family: inherit;
}

.history-search input:focus {
  outline: none;
}

.history-search input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.history-scroll {
  flex: 1;
  border: none;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
}

.history-row {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.history-row__heading {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.history-row__question {
  font-weight: 500;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-row__owner {
  font-size: 11px;
  color: var(--accent);
  border: 1px solid rgba(91, 141, 239, 0.3);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: auto;
  background: rgba(91, 141, 239, 0.12);
}

.history-row__meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.history-row__meta-info {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  flex: 1;
}

.history-row__turns {
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--muted);
  min-width: 56px;
  text-align: center;
  white-space: nowrap;
}

.history-row:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.history-row.active {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.25);
  box-shadow: 
    inset 0 0 0 1px rgba(91, 141, 239, 0.5),
    0 0 0 2px rgba(91, 141, 239, 0.3),
    0 8px 24px rgba(3, 12, 38, 0.45);
}

.history-row.active .history-row__question {
  color: #fff;
  font-weight: 600;
}

.history-row--new {
  border: 1px dashed rgba(91, 141, 239, 0.6);
  border-radius: 16px;
  margin: 0;
  padding: 14px;
  background: rgba(91, 141, 239, 0.12);
  box-shadow: inset 0 0 0 1px rgba(91, 141, 239, 0.3);
}

.history-row-title {
  font-weight: 500;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.history-row-sub {
  opacity: 0.6;
  font-size: 12px;
  margin-top: 2px;
}

/* API-based history items (new format) */
.history-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--fg);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}

.history-item:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.history-item.active {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.25);
  box-shadow: 
    inset 0 0 0 1px rgba(91, 141, 239, 0.5),
    0 0 0 2px rgba(91, 141, 239, 0.3),
    0 8px 24px rgba(3, 12, 38, 0.45);
}

.history-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item-question {
  font-weight: 500;
  font-size: 14px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-item-birth {
  font-size: 12px;
  opacity: 0.7;
  font-family: 'Courier New', monospace;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  opacity: 0.6;
}

.history-item-timestamp {
  white-space: nowrap;
}

.history-user-badge {
  padding: 2px 6px;
  background: rgba(91, 141, 239, 0.2);
  border: 1px solid rgba(91, 141, 239, 0.3);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
}

.history-item-delete {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: all 0.15s ease;
  opacity: 0;
}

.history-item:hover .history-item-delete {
  opacity: 1;
}

.history-item-delete:hover {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
}

.history-end {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  opacity: 0.5;
}

.history-end.loading {
  opacity: 0.7;
  font-style: italic;
}

.history-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   Flatpickr Customizations
   ============================================ */
.flatpickr-calendar {
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
  border: 1px solid rgba(91, 141, 239, 0.2) !important;
}

.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after {
  display: none;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary, #5b8def) !important;
  border-color: var(--primary, #5b8def) !important;
}

.flatpickr-day:hover {
  background: rgba(91, 141, 239, 0.2) !important;
  border-color: transparent !important;
}

.flatpickr-current-month {
  font-size: 14px !important;
}

.flatpickr-monthDropdown-months,
.numInputWrapper input {
  font-size: 14px !important;
}

/* Time picker specific */
.flatpickr-time {
  border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.flatpickr-time input {
  font-size: 16px !important;
}

/* ============================================
   Enhanced Time & Date Picker Controls
   ============================================ */

/* Time quick pick buttons */
.time-quick-picks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.time-quick-btn {
  padding: 8px 6px;
  font-size: 12px;
  background: rgba(91, 141, 239, 0.1);
  border: 1px solid rgba(91, 141, 239, 0.3);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-weight: 500;
}

.time-quick-btn:hover {
  background: rgba(91, 141, 239, 0.25);
  border-color: rgba(91, 141, 239, 0.5);
  transform: translateY(-1px);
}

.time-quick-btn:active {
  transform: translateY(0);
}

/* Year jump input in date picker */
.year-jump-container {
  width: 100%;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.year-jump-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  transition: all 0.2s ease;
}

.year-jump-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

.year-jump-input:focus {
  outline: none;
  border-color: var(--primary, #5b8def);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.1);
}

.year-jump-input:hover:not(:focus) {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.07);
}

/* Make the month/year navigation more prominent */
.flatpickr-current-month {
  padding: 14px 0 !important;
  font-size: 15px !important;
}

.flatpickr-monthDropdown-months {
  font-weight: 600 !important;
  font-size: 15px !important;
}

.numInputWrapper input {
  font-weight: 600 !important;
}

/* Improve calendar day hover states */
.flatpickr-day {
  transition: all 0.15s ease !important;
}

.flatpickr-day:hover:not(.flatpickr-disabled) {
  transform: scale(1.05);
}

/* Mobile responsiveness for quick picks */
@media (max-width: 480px) {
  .time-quick-picks {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
  }
  
  .time-quick-btn {
    padding: 10px 8px;
    font-size: 13px;
  }
  
  .year-jump-input {
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* Expert-Only Options */
.bazi-expert-only {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.bazi-expert-only.hidden {
  display: none !important;
}

/* ============================================
   User Menu Profile Section
   ============================================ */
.user-menu-section .bazi-datepicker,
.user-menu-section .bazi-timepicker {
  padding: 10px 12px;
  font-size: 14px;
}

.user-menu .location-suggestions {
  max-height: 200px;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 480px) {
  .bazi-time-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  .bazi-checkbox-label {
    justify-content: flex-start;
    padding: 8px 0;
  }
  
  .bazi-actions {
    flex-direction: column;
  }
  
  .bazi-btn-compute {
    justify-content: center;
  }
  
  .bazi-options {
    flex-direction: column;
    gap: 12px;
  }
  
  .bazi-select-label {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  
  .bazi-select-label .small {
    min-width: 80px;
  }
  
  .bazi-select {
    flex: 1;
  }
}

/* ============================================
   Layout & Scrollable Content
   ============================================ */
.bazi-main-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;
}

.bazi-scrollable-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-bottom: 100px; /* Space for pinned composer (accounts for composer height ~84px + margin) */
}

/* ============================================
   Form Header & Lock Hint
   ============================================ */
.bazi-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bazi-lock-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  opacity: 0.7;
}

.bazi-lock-hint.hidden {
  display: none;
}

.bazi-lock-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================
   Chat Composer (Bottom Pinned) - Reuse Oracle styles
   ============================================ */
.bazi-chat-composer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w, 0);
  right: 0;
  background: var(--bg, #1a1d24);
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  z-index: 1000;
  padding: 12px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.bazi-chat-composer.hidden {
  display: none;
}

/* Reuse Oracle chat-pod styles */
.bazi-chat-composer .chat-pod {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 8px 12px;
  margin: 0;
  box-sizing: border-box;
  transition: border-color 0.2s ease, background 0.2s ease;
  max-width: 1200px;
  margin: 0 auto;
}

.bazi-chat-composer .chat-pod:focus-within {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.bazi-chat-composer .pod-buttons-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bazi-chat-composer .pod-input-wrapper {
  width: 100%;
  position: relative;
  min-width: 0;
}

.bazi-chat-composer .pod-input {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  background: transparent;
  color: var(--fg, #fff);
  border: 0;
  resize: none;
  overflow-y: auto;
  outline: none;
  padding: 20px 10px 0px 10px;
  font-size: 15px;
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.5;
  box-sizing: border-box;
}

.bazi-chat-composer .pod-buttons-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bazi-chat-composer .pod-buttons-right .circle-btn.success {
  order: 2;
}

.bazi-chat-composer .circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: var(--accent, #5b8def);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.bazi-chat-composer .circle-btn:hover {
  transform: scale(1.05);
}

.bazi-chat-composer .circle-btn:active {
  transform: scale(0.95);
}

.bazi-chat-composer .circle-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--border, rgba(255, 255, 255, 0.1)) !important;
  color: var(--muted, rgba(255, 255, 255, 0.6)) !important;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1)) !important;
}

.bazi-chat-composer .circle-btn.hidden {
  display: none !important;
}

.bazi-chat-composer .circle-btn.success {
  background: var(--ok, #4caf50);
  color: #fff;
  border: 0;
}

.bazi-chat-composer .circle-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg, #fff);
}

.bazi-chat-composer .circle-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.bazi-chat-composer .circle-btn svg {
  width: 20px;
  height: 20px;
}

.bazi-chat-composer .pod-char-count {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 10px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.bazi-chat-composer .pod-input:focus ~ .pod-char-count {
  opacity: 0.6;
}

.bazi-chat-composer .pod-char-count.warn {
  color: var(--warn, #ff9800);
  opacity: 1 !important;
}

.bazi-chat-composer .voice-status {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 53, 69, 0.95);
  color: white;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 10001;
  transition: opacity 0.2s ease;
}

.bazi-chat-composer .voice-status.hidden {
  display: none;
}

.bazi-chat-composer .voice-status.processing {
  background: rgba(91, 141, 239, 0.95);
}

.bazi-chat-composer .voice-status.error {
  background: rgba(220, 53, 69, 0.95);
}

.bazi-chat-composer .voice-status-text {
  font-weight: 500;
}

/* Mobile adjustments for BaZi voice status */
@media (max-width: 480px) {
  .bazi-chat-composer .voice-status {
    font-size: 12px;
    padding: 4px 10px;
    bottom: 110px;
  }
}

.bazi-chat-composer .voice-icon {
  width: 20px;
  height: 20px;
}

.bazi-chat-composer .circle-btn.recording {
  background: var(--error, #f44336) !important;
  animation: baziVoicePulse 1.5s ease-in-out infinite;
}

.bazi-chat-composer .circle-btn.success {
  background: var(--ok, #4caf50) !important;
}

@keyframes baziVoicePulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* ============================================
   Sticky Bottom Thinking Bar
   ============================================ */
.bazi-sticky-thinking-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w, 0);
  right: 0;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px 20px;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  opacity: 0;
}

.bazi-sticky-thinking-bar.visible {
  transform: translateY(0);
  opacity: 1;
}

.bazi-sticky-thinking-bar .sticky-bar-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1200px;
  margin: 0 auto;
  color: var(--muted, rgba(255, 255, 255, 0.7));
  font-size: 15px;
}

.bazi-sticky-thinking-bar .thinking-label {
  margin-right: 8px;
}

.bazi-sticky-thinking-bar .typing-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.bazi-sticky-thinking-bar .typing-dots i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted, rgba(255, 255, 255, 0.6));
  opacity: 0.35;
  animation: orclTyping 1s infinite ease-in-out;
}

.bazi-sticky-thinking-bar .typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.bazi-sticky-thinking-bar .typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

/* Mobile optimization */
@media (max-width: 768px) {
  .bazi-sticky-thinking-bar {
    padding: 12px 16px;
    left: 0;
  }
  
  .bazi-sticky-thinking-bar .sticky-bar-content {
    font-size: 14px;
  }
}

/* ============================================
   Conversation Thread
   ============================================ */
#baziConversation {
  margin-top: 24px;
}

#baziConversation.hidden {
  display: none;
}

#baziChatLog {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bazi-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 15px;
  word-wrap: break-word;
}

.bazi-msg.user {
  align-self: flex-end;
  background: rgba(91, 141, 239, 0.15);
  border: 1px solid rgba(91, 141, 239, 0.35);
  color: var(--fg, #fff);
  white-space: pre-wrap;
}

.bazi-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fg, #fff);
}

/* Structured content in conversation thread */
.bazi-msg.bot .bazi-human-view {
  margin: 0;
}

.bazi-msg.bot .bazi-section-title {
  font-size: 12px;
}

.bazi-msg.bot .bazi-guidance-card {
  margin-bottom: 12px;
}

.bazi-msg.bot .bazi-guidance-card:last-child {
  margin-bottom: 0;
}

/* Reuse Oracle chat paragraph styles for formatted text */
.bazi-msg.bot .chat-paragraph {
  margin: 0 0 8px 0;
  line-height: 1.6;
  font-size: inherit;
  color: inherit;
}

.bazi-msg.bot .chat-paragraph:last-child {
  margin-bottom: 0;
}

.bazi-guidance-value .chat-paragraph {
  margin: 0;
  display: inline;
}

.bazi-snapshot-line .chat-paragraph {
  margin: 0;
  display: inline;
}

.bazi-msg.bot.thinking {
  color: var(--muted, rgba(255, 255, 255, 0.6));
}

.bazi-msg.bot.thinking .typing-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.bazi-msg.bot.thinking .typing-dots i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted, rgba(255, 255, 255, 0.6));
  opacity: 0.35;
  animation: orclTyping 1s infinite ease-in-out;
}

.bazi-msg.bot.thinking .typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.bazi-msg.bot.thinking .typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes orclTyping {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.bazi-msg.system {
  align-self: center;
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid rgba(255, 152, 0, 0.3);
  color: var(--warn, #ff9800);
  font-size: 14px;
  text-align: center;
  max-width: 90%;
}

.bazi-msg.system .retry-btn {
  margin-left: 8px;
  padding: 4px 12px;
  font-size: 13px;
  background: rgba(255, 152, 0, 0.2);
  border: 1px solid rgba(255, 152, 0, 0.4);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bazi-msg.system .retry-btn:hover {
  background: rgba(255, 152, 0, 0.3);
}

/* ============================================
   Lock Overlay (Hard Lock During Processing)
   ============================================ */
.bazi-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 9999;
  pointer-events: all;
  cursor: wait;
}

.bazi-lock-overlay.hidden {
  display: none;
}

/* ============================================
   Form Locked State
   ============================================ */
.bazi-form-card.locked .bazi-input,
.bazi-form-card.locked .bazi-select,
.bazi-form-card.locked .bazi-checkbox,
.bazi-form-card.locked button:not(.bazi-send-btn) {
  opacity: 0.6;
  pointer-events: none;
  cursor: not-allowed;
}

/* ============================================
   AI Explanation Container
   ============================================ */
#baziExplanation {
  margin-top: 24px;
}

#baziExplanation.hidden {
  display: none;
}

.bazi-explanation-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bazi-explanation-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--fg, #fff);
}

.bazi-human-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Snapshot Line */
.bazi-snapshot-line {
  margin: 0 0 20px 0;
  padding: 16px;
  background: rgba(91, 141, 239, 0.05);
  border: 1px solid rgba(91, 141, 239, 0.2);
  border-radius: 8px;
  line-height: 1.6;
  font-size: 15px;
  color: var(--fg, #fff);
}

.bazi-section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--accent, #5b8def);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Guidance Section */
.bazi-guidance-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bazi-guidance-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bazi-guidance-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
}

.bazi-guidance-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.bazi-guidance-card .card-body {
  padding: 20px;
}

.bazi-guidance-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--fg, #fff);
}

.bazi-guidance-row {
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg, #fff);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bazi-guidance-row:first-child {
  margin-top: 0;
}

.bazi-guidance-label {
  color: var(--accent, #5b8def);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bazi-guidance-label strong {
  color: var(--accent, #5b8def);
  font-weight: 600;
}

.bazi-guidance-value {
  color: var(--fg, #fff);
  flex: 1;
}

.bazi-guidance-value .chat-paragraph {
  margin: 0;
  display: inline;
}

/* Overlay Note */
.bazi-overlay-note {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-style: italic;
  opacity: 0.7;
}

.bazi-overlay-note.chat-paragraph {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Evidence Panel */
.bazi-evidence-panel {
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 16px;
}

.bazi-evidence-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bazi-evidence-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg, #fff);
}

.bazi-toggle-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.bazi-evidence-content {
  margin-top: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bazi-evidence-content.hidden {
  display: none;
}

.bazi-evidence-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bazi-evidence-item {
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bazi-evidence-signal {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--fg, #fff);
}

.bazi-evidence-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
}

.bazi-evidence-scope,
.bazi-evidence-confidence,
.bazi-evidence-source {
  display: inline-block;
}

/* Claim Map */
.bazi-claim-map-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bazi-subsection-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--muted, rgba(255, 255, 255, 0.7));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Uncertainty Notes */
.bazi-uncertainty-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bazi-uncertainty-list {
  margin: 8px 0;
  padding-left: 20px;
  list-style: disc;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  font-size: 13px;
}

.bazi-uncertainty-list li {
  margin: 6px 0;
  line-height: 1.5;
}

.bazi-claim-map-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bazi-claim-map-item {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  color: var(--muted, rgba(255, 255, 255, 0.6));
}

.bazi-claim-sentence {
  color: var(--fg, #fff);
  font-weight: 500;
}

.bazi-claim-evidence {
  margin-left: 8px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
}

/* Error State */
.bazi-explanation-error {
  padding: 20px;
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 8px;
  color: var(--warn, #ff9800);
}

.retry-btn-inline {
  margin-left: 8px;
  padding: 4px 12px;
  font-size: 13px;
  background: rgba(255, 152, 0, 0.2);
  border: 1px solid rgba(255, 152, 0, 0.4);
  border-radius: 6px;
  color: var(--warn, #ff9800);
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn-inline:hover {
  background: rgba(255, 152, 0, 0.3);
}

/* ============================================
   BaZi Visuals Section
   ============================================ */
.bazi-visuals {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.bazi-visuals.fade-in {
  animation: fadeIn 0.6s ease-in-out forwards;
}

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

.bazi-visual-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--fg, #fff);
}

/* Chart Card */
.bazi-chart-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bazi-chart-table-wrapper {
  overflow-x: auto;
  margin: -8px;
  padding: 8px;
}

.bazi-chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bazi-chart-table th,
.bazi-chart-table td {
  padding: 12px 8px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: top;
}

.bazi-chart-table th {
  background: rgba(0, 0, 0, 0.2);
  font-weight: 600;
  color: var(--fg, #fff);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bazi-table-row-label {
  background: rgba(0, 0, 0, 0.2);
  font-weight: 600;
  color: var(--muted, rgba(255, 255, 255, 0.7));
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  width: 40px;
  min-width: 40px;
  padding: 8px 4px;
}

.bazi-table-pillar-header {
  background: rgba(0, 0, 0, 0.3);
}

.bazi-table-cell {
  background: rgba(0, 0, 0, 0.15);
  min-width: 100px;
  position: relative;
}

.bazi-table-cell.bazi-table-day-cell {
  background: rgba(91, 141, 239, 0.1);
  border-color: rgba(91, 141, 239, 0.4);
  box-shadow: inset 0 0 0 2px rgba(91, 141, 239, 0.2);
}

.bazi-table-cell.bazi-table-empty {
  opacity: 0.4;
  color: var(--muted, rgba(255, 255, 255, 0.4));
}

.bazi-table-main-char {
  font-size: 28px;
  font-weight: 600;
  color: var(--fg, #fff);
  line-height: 1.2;
  margin-bottom: 4px;
}

.bazi-table-pinyin {
  font-size: 11px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  margin-bottom: 2px;
  text-transform: capitalize;
}

.bazi-table-element {
  font-size: 10px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  margin-bottom: 4px;
}

.bazi-table-ten-god {
  font-size: 10px;
  color: var(--accent, #5b8def);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bazi-table-hidden-cell {
  padding: 8px 4px;
}

.bazi-table-hidden-stem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.bazi-table-hidden-stem:last-child {
  margin-bottom: 0;
}

.bazi-table-hidden-char {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg, #fff);
}

.bazi-table-hidden-pinyin {
  font-size: 9px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  text-transform: capitalize;
}

.bazi-table-hidden-element {
  font-size: 9px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
}

.bazi-table-hidden-ten-god {
  font-size: 9px;
  color: var(--accent, #5b8def);
  margin-top: 2px;
}

.bazi-table-animal {
  font-size: 9px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  margin-top: 2px;
}

.bazi-day-master-note {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
  color: var(--fg, #fff);
  text-align: center;
}

.bazi-day-master-note strong {
  color: var(--accent, #5b8def);
}

/* Computed Indicator (subtle superscript) */
.computed-indicator {
  font-size: 0.7em;
  opacity: 0.6;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  margin-left: 2px;
  vertical-align: super;
  cursor: help;
  line-height: 1;
}

@media (max-width: 768px) {
  .bazi-chart-table {
    font-size: 11px;
  }

  .bazi-table-main-char {
    font-size: 22px;
  }

  .bazi-table-cell {
    min-width: 80px;
    padding: 8px 4px;
  }

  .bazi-table-row-label {
    width: 30px;
    min-width: 30px;
    font-size: 10px;
    padding: 4px 2px;
  }

  .bazi-table-hidden-char {
    font-size: 16px;
  }
}

/* Element Bar */
.bazi-element-bar-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bazi-element-bar {
  display: flex;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bazi-element-segment {
  position: relative;
  min-width: 0;
  transition: opacity 0.2s ease;
}

.bazi-element-segment:hover {
  opacity: 0.85;
}

.bazi-element-dominant {
  filter: saturate(100%);
}

.bazi-element-subdued {
  filter: saturate(50%) brightness(0.9);
}

.bazi-element-legend {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  font-size: 12px;
}

.bazi-element-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.bazi-element-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bazi-element-label {
  color: var(--fg, #fff);
}

.bazi-element-count {
  color: var(--muted, rgba(255, 255, 255, 0.6));
  font-weight: 600;
}

/* Interaction Map */
.bazi-interaction-map-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bazi-interaction-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bazi-interaction-signal {
  padding: 10px 12px;
  padding-left: 16px;
  background: rgba(0, 0, 0, 0.15);
  border-left: 3px solid;
  border-radius: 4px;
  transition: all 0.2s ease;
  position: relative;
}

.bazi-interaction-signal:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Severity indicators via left border */
.bazi-interaction-signal.bazi-severity-low {
  border-left-color: #4caf50;
}

.bazi-interaction-signal.bazi-severity-medium {
  border-left-color: #ff9800;
}

.bazi-interaction-signal.bazi-severity-high {
  border-left-color: #f44336;
}

.bazi-interaction-primary {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg, #fff);
  line-height: 1.4;
  margin-bottom: 4px;
}

.bazi-interaction-secondary {
  font-size: 11px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  line-height: 1.3;
  margin-bottom: 4px;
}

.bazi-interaction-type-label {
  font-size: 10px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.bazi-interaction-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  font-size: 14px;
}

  .bazi-interaction-more {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  font-size: 12px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
}

/* ============================================
   History Action Buttons
   ============================================ */
.history-recalculate-btn,
.history-delete-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}

.history-recalculate-btn {
  background: rgba(91, 141, 239, 0.1);
  border: 1px solid rgba(91, 141, 239, 0.3);
}

.history-delete-btn {
  background: rgba(239, 83, 80, 0.1);
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.history-row:hover .history-recalculate-btn,
.history-row:hover .history-delete-btn {
  display: flex;
}

.history-recalculate-btn:hover {
  background: rgba(91, 141, 239, 0.25);
  border-color: rgba(91, 141, 239, 0.6);
  transform: scale(1.1);
}

.history-recalculate-btn:active {
  transform: scale(0.95);
}

.history-delete-btn:hover {
  background: rgba(239, 83, 80, 0.25);
  border-color: rgba(239, 83, 80, 0.6);
  transform: scale(1.1);
}

.history-delete-btn:active {
  transform: scale(0.95);
}

/* Update history-row to support click events as div */
.history-row {
  cursor: pointer;
}

/* Update history-row-meta to support the delete button */
.history-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.history-row-meta > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row__delete {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.history-row:hover .history-row__delete {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.history-row__delete:hover {
  color: #f44336;
  background: rgba(244, 67, 54, 0.15);
}

.history-loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-skeleton {
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  animation: shimmer 1.4s infinite ease-out;
}

/* ============================================
   Mobile Adjustments
   ============================================ */
@media (max-width: 768px) {
  /* CRITICAL FIX: iOS Safari nested scroll context issue
     On mobile, the parent .main .container has overflow:auto, and
     .bazi-scrollable-content also has overflow:auto. This causes
     iOS Safari to fail to render scrolled content (like #baziExplanation).
     Solution: Let the parent .main .container handle all scrolling */
  .bazi-main-container {
    height: auto;
    min-height: 0;
    overflow: visible;
    /* Force GPU layer to fix iOS rendering */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  .bazi-scrollable-content {
    overflow: visible;
    height: auto;
    flex: none;
    padding-bottom: 120px;
    /* iOS Safari scroll fix */
    -webkit-overflow-scrolling: touch;
  }
  
  /* Ensure explanation renders properly on mobile */
  #baziExplanation {
    overflow: visible;
    min-height: 0;
    /* Force repaint on iOS Safari */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  #baziExplanation:not(.hidden) {
    display: block !important;
    visibility: visible !important;
    opacity: 1;
  }
  
  /* Storybook container visibility fix */
  .bazi-explanation-container {
    display: block;
    visibility: visible;
    opacity: 1;
  }
  
  .bazi-chat-composer {
    left: 0;
  }
  
  .bazi-msg {
    max-width: 90%;
  }

  .bazi-pillars-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bazi-element-legend {
    gap: 12px;
    font-size: 11px;
  }

  .bazi-interaction-signal {
    padding: 8px 10px;
    padding-left: 14px;
  }

  .bazi-interaction-primary {
    font-size: 12px;
  }

  .bazi-interaction-secondary {
    font-size: 10px;
  }
}

/* ============================================
   Inline Evidence Components (v2)
   Visual proof integrated directly into narrative
   ============================================ */

.inline-evidence {
  margin: 16px 0;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  font-size: 13px;
}

/* Star Presence Indicator */
.star-presence {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.star-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 140px;
}

.star-label {
  font-weight: 500;
  color: var(--fg, #fff);
  white-space: nowrap;
  font-size: 12px;
}

.star-dots-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.star-pillars {
  display: flex;
  gap: 6px;
}

.pillar-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
}

.pillar-dot.active {
  background: var(--accent, #5b8def);
  border-color: var(--accent, #5b8def);
  box-shadow: 0 0 8px rgba(91, 141, 239, 0.4);
}

.pillar-labels {
  display: flex;
  gap: 6px;
}

.pillar-label-mini {
  width: 14px;
  text-align: center;
  font-size: 9px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  font-weight: 500;
}

/* Element Balance Mini */
.element-balance-mini {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.element-bar-mini {
  display: flex;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.element-segment {
  min-width: 2px;
  transition: opacity 0.2s ease;
}

.element-segment:hover {
  opacity: 0.85;
}

.element-segment.element-wood {
  background: linear-gradient(180deg, #4caf50, #388e3c);
}

.element-segment.element-fire {
  background: linear-gradient(180deg, #ff5722, #d84315);
}

.element-segment.element-earth {
  background: linear-gradient(180deg, #ff9800, #ef6c00);
}

.element-segment.element-metal {
  background: linear-gradient(180deg, #9e9e9e, #757575);
}

.element-segment.element-water {
  background: linear-gradient(180deg, #2196f3, #1565c0);
}

.element-legend-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted, rgba(255, 255, 255, 0.7));
}

.legend-item.dominant {
  color: var(--fg, #fff);
  font-weight: 600;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.element-wood { background: #4caf50; }
.legend-dot.element-fire { background: #ff5722; }
.legend-dot.element-earth { background: #ff9800; }
.legend-dot.element-metal { background: #9e9e9e; }
.legend-dot.element-water { background: #2196f3; }

.legend-count {
  opacity: 0.7;
  font-weight: 500;
}

/* Direction Compass Mini */
.direction-compass-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.compass-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  width: 140px;
  height: 140px;
}

.compass-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.compass-cell.favorable {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.4);
}

.compass-cell.favorable .compass-indicator {
  color: #4caf50;
  font-size: 16px;
}

.compass-cell.unfavorable {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.compass-cell.unfavorable .compass-indicator {
  color: rgba(244, 67, 54, 0.8);
  font-size: 16px;
}

.compass-cell.neutral {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.compass-cell.neutral .compass-indicator {
  color: rgba(255, 255, 255, 0.3);
  font-size: 14px;
}

.compass-center {
  background: rgba(91, 141, 239, 0.1);
  border: 1px solid rgba(91, 141, 239, 0.3);
  color: var(--accent, #5b8def);
  font-size: 18px;
}

.compass-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted, rgba(255, 255, 255, 0.6));
  margin-top: 2px;
}

.compass-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--muted, rgba(255, 255, 255, 0.6));
}

.favorable-legend {
  color: #4caf50;
}

.unfavorable-legend {
  color: rgba(244, 67, 54, 0.8);
}

/* Growth Phase Radar Chart (ApexCharts) */
.growth-phase-radar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
}

.radar-chart-wrapper {
  width: 100%;
  max-width: 240px;
  min-height: 200px;
}

/* ApexCharts dark theme overrides */
.growth-phase-radar .apexcharts-canvas {
  background: transparent !important;
}

.growth-phase-radar .apexcharts-radar-series polygon {
  stroke-linejoin: round;
}

.growth-phase-radar .apexcharts-tooltip {
  background: rgba(20, 24, 32, 0.95) !important;
  border: 1px solid rgba(91, 141, 239, 0.3) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

.growth-phase-radar .apexcharts-tooltip-title {
  background: rgba(91, 141, 239, 0.1) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.radar-empty {
  color: var(--muted, rgba(255, 255, 255, 0.5));
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
}

.radar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 8px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  width: 100%;
}

.legend-phase {
  font-size: 10px;
  color: var(--muted, rgba(255, 255, 255, 0.7));
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.legend-phase:hover {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.1);
}

.legend-phase strong {
  color: var(--fg, rgba(255, 255, 255, 0.95));
  font-weight: 600;
}

.legend-phase-strong {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.legend-phase-strong strong {
  color: #10b981;
}

.legend-phase-weak {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
}

.legend-phase-weak strong {
  color: #ef4444;
}

.legend-phase-neutral,
.legend-phase-moderate {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
}

.legend-phase-neutral strong,
.legend-phase-moderate strong {
  color: #f59e0b;
}

/* Interaction Diagram */
.interaction-diagram {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.interaction-empty {
  color: var(--muted, rgba(255, 255, 255, 0.5));
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.interaction-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
}

.interaction-item:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.12);
}

.interaction-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.interaction-entity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.interaction-entity .entity-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--fg, #fff);
}

.interaction-entity .entity-pillar {
  font-size: 10px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  text-transform: capitalize;
}

.interaction-arrow {
  font-size: 14px;
  color: var(--muted, rgba(255, 255, 255, 0.4));
  margin: 0 4px;
}

.interaction-type {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.interaction-severity-high {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.interaction-severity-medium {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.25);
}

.interaction-severity-low {
  background: rgba(76, 175, 80, 0.1);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.25);
}

.interaction-affected {
  width: 100%;
  font-size: 11px;
  color: var(--muted, rgba(255, 255, 255, 0.5));
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Element Distribution (visual) */
.element-distribution {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.element-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.element-label {
  width: 50px;
  font-size: 12px;
  color: var(--muted, rgba(255, 255, 255, 0.7));
  text-align: right;
}

.element-bar {
  flex: 1;
  height: 18px;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.element-bar-fire { background: linear-gradient(90deg, #ff5722, #d84315); }
.element-bar-water { background: linear-gradient(90deg, #2196f3, #1565c0); }
.element-bar-wood { background: linear-gradient(90deg, #4caf50, #388e3c); }
.element-bar-metal { background: linear-gradient(90deg, #9e9e9e, #757575); }
.element-bar-earth { background: linear-gradient(90deg, #ff9800, #ef6c00); }

.element-count {
  width: 24px;
  font-size: 12px;
  color: var(--fg, #fff);
  font-weight: 600;
}

/* Mobile adjustments for inline evidence */
@media (max-width: 480px) {
  .inline-evidence {
    padding: 12px 14px;
    margin: 12px 0;
  }
  
  .star-presence {
    gap: 12px;
  }
  
  .star-indicator {
    min-width: 120px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .compass-grid {
    width: 120px;
    height: 120px;
  }
  
  /* Growth phase radar mobile */
  .growth-phase-radar {
    padding: 6px 2px;
    gap: 6px;
  }
  
  .radar-chart-wrapper {
    max-width: 200px;
    min-height: 160px;
  }
  
  .radar-legend {
    gap: 4px;
    padding-top: 8px;
  }
  
  .legend-phase {
    font-size: 9px;
    padding: 3px 6px;
  }
  
  /* Interaction diagram mobile */
  .interaction-item {
    padding: 10px 12px;
  }
  
  .interaction-entity .entity-value {
    font-size: 18px;
  }
  
  .interaction-type {
    font-size: 9px;
    padding: 3px 8px;
  }
}
