/* index.css — Chart Calculator */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: #1a1a2e;
  color: white;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-title h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-title p {
  font-size: 0.78rem;
  opacity: 0.55;
  margin-top: 0.25rem;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  font-size: 0.82rem;
}

.header-auth-email {
  color: rgba(255,255,255,0.7);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-auth a, .header-auth button {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.header-auth a:hover, .header-auth button:hover {
  background: rgba(255,255,255,0.22);
}

#subBtn {
  background: #e49836;
  border-color: #e49836;
  color: white;
  font-weight: 600;
}
#subBtn:hover { background: #c8821e; }

#unsubBtn {
  background: rgba(255,255,255,0.06);
  font-size: 0.72rem;
  opacity: 0.7;
}

/* ── Layout ── */
main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Card ── */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 8px rgba(0, 0, 0, 0.04);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

/* ── Form ── */
.form-row {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row-main {
  grid-template-columns: 180px 140px 1fr;
}

.form-row-optional {
  grid-template-columns: 1fr 1fr 2fr;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #444;
  margin-bottom: 0.35rem;
}

.field label .tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 400;
  color: #aaa;
  background: #f2f2f2;
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  margin-left: 0.35rem;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}

input[type="date"],
input[type="time"],
input[type="number"],
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  font-size: 0.9rem;
  color: #1a1a1a;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

/* Restore native date/time picker arrows */
input[type="date"],
input[type="time"] {
  appearance: auto;
  -webkit-appearance: auto;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.14);
}

input::placeholder {
  color: #bbb;
}

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

button[type="submit"] {
  background: #1a1a2e;
  color: white;
  border: none;
  padding: 0.65rem 1.75rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  letter-spacing: 0.01em;
}

button[type="submit"]:hover:not(:disabled) {
  background: #2d2d50;
}

button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Save chart button ── */
#saveChartBtn {
  background: #2e7d32;
  color: white;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.01em;
  display: none;
}

#saveChartBtn:hover {
  background: #1b5e20;
}

#saveChartBtn.guest {
  background: #bdbdbd;
  color: #fff;
  cursor: pointer;
}

#saveChartBtn.guest:hover {
  background: #9e9e9e;
}

/* ── City autocomplete ── */
.city-autocomplete {
  position: relative;
}

.city-autocomplete input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  font-size: 0.9rem;
  color: #1a1a1a;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.city-autocomplete input[type="text"]:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.14);
}

#cityDropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d5d5d5;
  border-top: none;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

#cityDropdown .city-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

#cityDropdown .city-item:last-child {
  border-bottom: none;
}

#cityDropdown .city-item:hover,
#cityDropdown .city-item.active {
  background: #f0f4fa;
}

#cityDropdown .city-main {
  font-size: 0.88rem;
  font-weight: 500;
  color: #1a1a1a;
}

#cityDropdown .city-sub {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.1rem;
}

#cityInfo {
  font-size: 0.75rem;
  color: #4a6fa5;
  margin-top: 0.3rem;
  min-height: 1em;
}

/* ── Topocentric checkbox ── */
#topoRow {
  display: none;
  margin-bottom: 0.75rem;
}

.topo-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #888;
  cursor: pointer;
  user-select: none;
}

.topo-label input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: none;
  cursor: pointer;
  accent-color: #4a6fa5;
}

.topo-warning {
  display: inline;
  font-size: 0.72rem;
  color: #b56a00;
  margin-left: 0.25rem;
}

/* ── Language selector in form ── */
.lang-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.lang-wrap label {
  font-size: 0.78rem;
  color: #666;
  white-space: nowrap;
}

.lang-wrap select {
  width: auto;
  padding: 0.55rem 2rem 0.55rem 0.65rem;
  font-size: 0.85rem;
}

/* ── Status messages ── */
#status {
  display: none;
  font-size: 0.84rem;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
}

#status.loading {
  color: #555;
}

#status.error {
  color: #a52020;
  background: #fff3f3;
  border: 1px solid #f0c0c0;
}

/* ── Date locked ── */
#birthdate[readonly] {
  background: #f5f5f5;
  color: #555;
  cursor: not-allowed;
}

#dateResetLink {
  float: right;
  font-size: 0.7rem;
  font-weight: 400;
  color: #4a6fa5;
  text-decoration: none;
}

#dateResetLink:hover { text-decoration: underline; }

/* ── Login modal ── */
#loginModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

#loginModal.open, #upgradeModal.open { display: flex; }
#upgradeModal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }

.modal-box {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  padding: 2rem 2rem 1.5rem;
  max-width: 320px;
  width: 90%;
  text-align: center;
}

.modal-box h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 0.55rem;
}

.modal-box p {
  font-size: 0.84rem;
  color: #666;
  margin-bottom: 1.4rem;
  line-height: 1.5;
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.modal-btns a {
  display: block;
  padding: 0.6rem 1.25rem;
  border-radius: 5px;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}

.modal-btn-primary   { background: #1a1a2e; color: white; }
.modal-btn-primary:hover   { background: #2d2d50; }
.modal-btn-secondary { background: #e8eaf0; color: #1a1a2e; }
.modal-btn-secondary:hover { background: #d5d8e8; }

.modal-close {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: #aaa;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.modal-close:hover { color: #666; }

/* ── Results ── */
#results {
  display: none;
}

.results-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.toggle-btn {
  background: none;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  color: #666;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.toggle-btn:hover {
  border-color: #4a6fa5;
  color: #4a6fa5;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 280px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* ── Collapsible detail columns ── */
.col-extra {
  display: none;
}

.details-open .col-extra {
  display: table-cell;
}

/* ── Chart card ── */
.chart-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.chart-card-header {
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.chart-card-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  letter-spacing: 0.01em;
}

.chart-card-header .julday {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  font-family: monospace;
}

.personality-header { background: #1a1a2e; }
.design-header      { background: #7d1c1c; }

/* ── Planet table ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead th {
  text-align: left;
  padding: 0.45rem 0.85rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #888;
  background: #f8f9fa;
  border-bottom: 1px solid #ececec;
}

thead th:not(:first-child) {
  text-align: center;
}

tbody tr {
  border-bottom: 1px solid #f2f2f2;
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: #fafbfc;
}

tbody td {
  padding: 0.5rem 0.85rem;
  vertical-align: middle;
}

tbody td:not(:first-child) {
  text-align: center;
}

/* Planet cell */
.planet-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.planet-symbol {
  font-size: 1rem;
  width: 1.3rem;
  text-align: center;
  color: #666;
  flex-shrink: 0;
}

.planet-name {
  font-weight: 500;
  white-space: nowrap;
}

.planet-link {
  cursor: pointer;
}
.planet-link:hover .planet-symbol,
.planet-link:hover .planet-name {
  color: var(--accent);
  text-decoration: underline;
}

.retro {
  font-size: 0.68rem;
  color: #b03030;
  font-weight: 600;
  background: #fff0ee;
  border: 1px solid #f5c8c8;
  border-radius: 3px;
  padding: 0.05rem 0.28rem;
  letter-spacing: 0;
}

/* Gate cell */
.gate-num {
  font-weight: 700;
  font-size: 0.95rem;
}

.gate-dot {
  color: #ccc;
  font-weight: 300;
  margin: 0 0.05rem;
}

.gate-line {
  font-weight: 400;
  color: #888;
}

.gate-link {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0;
  border-radius: 3px;
  padding: 0.1rem 0.25rem;
  transition: background 0.12s;
}

.gate-link:hover {
  background: #eef2fa;
}

/* Color · Tone · Base cell */
.ctb {
  font-family: monospace;
  font-size: 0.8rem;
  color: #666;
  letter-spacing: 0.05em;
}

/* Longitude cell */
.lon-cell {
  font-family: monospace;
  font-size: 0.76rem;
  color: #bbb;
}

/* ── Chart summary ── */
.chart-summary {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 8px rgba(0,0,0,0.04);
  padding: 0.9rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0 2rem;
  align-items: baseline;
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.25rem 0;
}

.summary-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
  flex-shrink: 0;
}

.summary-value {
  font-weight: 500;
  color: #1a1a1a;
  font-size: 0.85rem;
}

.detail-link {
  cursor: pointer;
  border-radius: 3px;
  padding: 0.05rem 0.2rem;
  transition: background 0.12s, color 0.12s;
}

.detail-link:hover {
  background: #eef2fa;
  color: #4a6fa5;
}

.channel-chip {
  display: inline-block;
  cursor: pointer;
  border-radius: 3px;
  padding: 0.05rem 0.2rem;
  font-size: 0.82rem;
  font-weight: 400;
  color: #666;
  transition: background 0.12s, color 0.12s;
}

.channel-chip:hover {
  background: #eef2fa;
  color: #4a6fa5;
}

.channel-sep {
  color: #ccc;
  margin: 0 0.1rem;
}

/* ── Bodygraph ── */
#bodygraph-container svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Responsive ── */
@media (max-width: 960px) {
  .form-row-main,
  .form-row-optional {
    grid-template-columns: 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  #bodygraph-container {
    max-width: 280px;
    margin: 0 auto;
  }
}

@media (max-width: 820px) {
  header { padding: 0.9rem 1.25rem; }
  .header-auth-email { display: none; }
}

@media (max-width: 480px) {
  header { padding: 0.7rem 1rem; }
  main { padding: 1.25rem 1rem; }
  .card { padding: 1.25rem; }
  table { font-size: 0.78rem; }
  thead th, tbody td { padding: 0.35rem 0.5rem; }
  .chart-summary { padding: 0.75rem 1rem; }
}
