/* ===== Global Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #F8F8FA;
  color: #333;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Navigation Bar ===== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #F8F8FA;
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 48px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.nav-bar-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: #000;
}

.nav-bar-back {
  width: 32px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-bar-back svg {
  width: 12px;
  height: 24px;
  fill: rgba(0,0,0,0.9);
}

.nav-bar-placeholder {
  width: 32px;
}

/* ===== Page Container ===== */
.page {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.page.active {
  display: flex;
}

.page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 40px;
}

/* ===== Section ===== */
.section {
  margin-bottom: 8px;
  padding: 0 12px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #2C3E6B;
  margin: 10px 0 6px;
  padding-left: 4px;
}

/* ===== Config Card ===== */
.config-card {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #F0F0F5;
}

.config-row:last-child {
  border-bottom: none;
}

.config-label-wrap {
  display: flex;
  align-items: center;
}

.config-icon {
  font-size: 12px;
  color: #4A90D9;
  margin-right: 6px;
  font-weight: 600;
}

.config-label {
  font-size: 14px;
  color: #333;
}

/* ===== Picker Button ===== */
.picker-btn {
  display: flex;
  align-items: center;
  background: #EEF3FA;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.picker-btn select {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.picker-symbol {
  font-size: 12px;
  margin-right: 4px;
}

.picker-text {
  font-size: 13px;
  color: #2C3E6B;
  font-weight: 500;
}

.picker-btn-small {
  background: #EEF3FA;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  color: #2C3E6B;
  font-weight: 500;
  position: relative;
}

.picker-btn-small select {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.picker-btn-planet {
  display: flex;
  align-items: center;
  background: #F0F0F5;
  border-radius: 4px;
  padding: 3px 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.picker-btn-planet select {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.picker-symbol-small {
  font-size: 10px;
  margin-right: 2px;
}

.picker-text-small {
  font-size: 12px;
  color: #555;
}

/* ===== Switch ===== */
.switch-wrap {
  display: flex;
  align-items: center;
}

.switch-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: #E0E0E0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.switch-toggle.active {
  background: #4A90D9;
}

.switch-toggle.active.transit {
  background: #E6A23C;
}

.switch-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #FFF;
  border-radius: 10px;
  transition: transform 0.3s;
}

.switch-toggle.active::after {
  transform: translateX(20px);
}

.switch-toggle.retro {
  width: 36px;
  height: 20px;
  border-radius: 10px;
}

.switch-toggle.retro::after {
  width: 16px;
  height: 16px;
  border-radius: 8px;
  top: 2px;
  left: 2px;
}

.switch-toggle.retro.active::after {
  transform: translateX(16px);
}

.switch-toggle.retro.active {
  background: #E6A23C;
}

.switch-text {
  font-size: 12px;
  color: #888;
  margin-left: 6px;
}

/* ===== Ruler Info ===== */
.ruler-info {
  background: #F5F0E8;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 4px 0 2px;
}

.ruler-row {
  display: flex;
  align-items: center;
  padding: 3px 0;
}

.ruler-label {
  font-size: 12px;
  color: #8B7355;
  margin-right: 8px;
  font-weight: 500;
}

.ruler-value {
  font-size: 13px;
  color: #2C3E6B;
  font-weight: 600;
}

/* ===== Planet Card ===== */
.planet-card {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.planet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.planet-name-wrap {
  display: flex;
  align-items: center;
}

.planet-symbol {
  font-size: 16px;
  margin-right: 5px;
}

.planet-name {
  font-size: 15px;
  font-weight: 600;
  color: #2C3E6B;
}

.planet-meta {
  display: flex;
  align-items: center;
}

.planet-category {
  font-size: 11px;
  color: #888;
  margin-right: 6px;
  background: #F0F0F5;
  padding: 2px 5px;
  border-radius: 3px;
}

.dignity-tag {
  font-size: 12px;
  font-weight: 600;
  background: #F0F0F5;
  padding: 2px 5px;
  border-radius: 3px;
}

.planet-detail {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #F0F0F5;
}

.planet-energy-info {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.energy-label {
  font-size: 11px;
  color: #4A90D9;
  font-weight: 600;
  margin-right: 4px;
}

.energy-value {
  font-size: 13px;
  color: #333;
  font-weight: 600;
  margin-right: 6px;
}

.energy-detail {
  font-size: 10px;
  color: #999;
}

.planet-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

.control-item {
  display: flex;
  align-items: center;
}

.control-label {
  font-size: 12px;
  color: #666;
  margin-right: 4px;
}

.degree-input {
  width: 50px;
  height: 25px;
  font-size: 12px;
  text-align: center;
  background: #F0F0F5;
  border-radius: 4px;
  border: none;
  padding: 0 4px;
  outline: none;
}

.degree-input:focus {
  background: #EEF3FA;
}

/* ===== Calc Button ===== */
.action-bar {
  padding: 15px 12px;
}

.calc-btn {
  background: #2C3E6B;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  padding: 12px 0;
  text-align: center;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.calc-btn:hover {
  background: #3A5080;
}

/* ===== Help Section ===== */
.help-section {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 12px;
}

.help-title {
  font-size: 14px;
  font-weight: 600;
  color: #2C3E6B;
  margin-bottom: 6px;
}

.help-text {
  font-size: 12px;
  color: #666;
  line-height: 20px;
  display: block;
  margin-bottom: 4px;
}

.help-toggle {
  text-align: center;
  padding: 10px;
  font-size: 12px;
  color: #4A90D9;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Result Page ===== */

/* Mode tag */
.mode-tag {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.mode-text {
  font-size: 12px;
  color: #888;
  background: #F0F0F5;
  padding: 3px 10px;
  border-radius: 4px;
}

/* Summary card */
.summary-card {
  margin: 8px 12px;
  border-radius: 10px;
  padding: 16px 14px;
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.summary-card.positive {
  border-top: 3px solid #27AE60;
}

.summary-card.negative {
  border-top: 3px solid #C0392B;
}

.summary-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.summary-label {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.summary-value {
  font-size: 24px;
  font-weight: 700;
  color: #2C3E6B;
}

.summary-card.positive .summary-value {
  color: #27AE60;
}

.summary-card.negative .summary-value {
  color: #C0392B;
}

.summary-sub {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-top: 8px;
  border-top: 1px solid #F0F0F5;
}

.sub-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sub-label {
  font-size: 11px;
  color: #999;
  margin-bottom: 3px;
}

.sub-value {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.support .sub-value {
  color: #27AE60;
}

.stress .sub-value {
  color: #C0392B;
}

.sub-detail {
  font-size: 10px;
  color: #999;
}

.sub-divider {
  width: 1px;
  height: 30px;
  background: #F0F0F5;
}

/* Planet energy list */
.planet-energy-list {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.pe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #F5F5F7;
}

.pe-row:last-child {
  border-bottom: none;
}

.pe-left {
  display: flex;
  align-items: center;
  flex: 1;
}

.pe-symbol {
  font-size: 14px;
  margin-right: 4px;
}

.pe-name {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.pe-center {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.pe-dignity {
  font-size: 12px;
  font-weight: 500;
}

.pe-bonus {
  font-size: 11px;
  color: #4A90D9;
  margin-left: 4px;
}

.pe-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.pe-energy {
  font-size: 13px;
  font-weight: 600;
  color: #2C3E6B;
}

/* Tab bar */
.tab-bar {
  display: flex;
  background: #FFFFFF;
  border-radius: 6px;
  margin-bottom: 6px;
  padding: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  font-size: 13px;
  color: #888;
  border-radius: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-item.active {
  background: #2C3E6B;
  color: #FFFFFF;
  font-weight: 600;
}

/* Aspect list */
.aspect-list {
  margin-bottom: 8px;
}

.aspect-group-label {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
}

.benefic-label {
  background: #E8F5E9;
  color: #27AE60;
}

.malefic-label {
  background: #FFEBEE;
  color: #C0392B;
}

.aspect-card {
  background: #FFFFFF;
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.aspect-card.benefic {
  border-left: 3px solid #27AE60;
}

.aspect-card.malefic {
  border-left: 3px solid #C0392B;
}

.aspect-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aspect-pair {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.ap-symbol {
  font-size: 12px;
  margin-right: 2px;
}

.ap-name {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  margin-right: 4px;
}

.ap-dignity-small {
  font-size: 10px;
  margin-right: 4px;
}

.aspect-type {
  font-size: 13px;
  color: #2C3E6B;
  font-weight: 600;
  margin-right: 4px;
}

.aspect-score {
  font-size: 16px;
  font-weight: 700;
}

.positive-score {
  color: #27AE60;
}

.negative-score {
  color: #C0392B;
}

.aspect-detail {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #F0F0F5;
}

.detail-item {
  font-size: 11px;
  color: #888;
  line-height: 18px;
  display: block;
}

.ruler-tag {
  color: #4A90D9;
  font-weight: 500;
}

.empty-tip {
  text-align: center;
  padding: 15px;
  font-size: 13px;
  color: #999;
}

/* Bottom bar */
.bottom-bar {
  padding: 12px 12px 20px;
}

.back-btn {
  background: #FFFFFF;
  color: #2C3E6B;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  padding: 10px 0;
  border: 1px solid #2C3E6B;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  text-align: center;
}

/* ===== Responsive fine-tuning ===== */
@media (min-width: 480px) {
  .section { padding: 0 16px; }
  .config-card { padding: 12px 16px; }
  .planet-card { padding: 10px 14px; }
  .summary-card { padding: 18px 16px; }
  .calc-btn { font-size: 17px; }
}

@media (min-width: 768px) {
  html { font-size: 18px; }
  .page-scroll { max-width: 600px; margin: 0 auto; }
}
