/* transits.css */
*, *::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-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-btn {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { color: white; }

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

.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); }

/* ── Layout ── */
main {
  max-width: 900px;
  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: auto 1fr; }
.form-row-optional { grid-template-columns: 1fr 1fr; }

/* ── Date/Time Spinner ── */
.dt-spinner {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.spinner-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid #d5d5d5;
  border-radius: 5px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.spin-btn {
  background: #f5f7fa;
  border: none;
  width: 100%;
  padding: 0.18rem 0.55rem;
  font-size: 0.55rem;
  color: #888;
  cursor: pointer;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.spin-btn:hover  { background: #e8ecf4; color: #333; }
.spin-btn:active { background: #d6ddf0; }

.spin-val {
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1a1a1a;
  padding: 0.22rem 0.5rem;
  background: white;
  min-width: 2ch;
  text-align: center;
  line-height: 1.3;
}
.spinner-field[data-spin="year"] .spin-val { min-width: 4ch; }

.spin-sep {
  color: #bbb;
  font-size: 0.85rem;
  padding: 0 0.05rem;
  flex-shrink: 0;
  align-self: center;
}
.spin-time-sep {
  margin: 0 0.3rem;
  color: #ddd;
}

.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;
}

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: auto;
  -webkit-appearance: auto;
}

select {
  appearance: none;
  -webkit-appearance: none;
  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: 0.75rem;
  flex-wrap: wrap;
}

#nowBtn {
  background: #e49836;
  color: white;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#nowBtn:hover { background: #c8821e; }

#calcBtn {
  background: #1a1a2e;
  color: white;
  border: none;
  padding: 0.55rem 1.5rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
#calcBtn:hover:not(:disabled) { background: #2d2d50; }
#calcBtn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── 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;
}

/* ── Status ── */
#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; }

/* ── Lang ── */
.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; }

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

.results-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  grid-column: 1 / -1;
}

.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 (2-column) ── */
.results-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
}

/* ── Collapsible extra columns ── */
.col-extra { display: none; }
.details-open .col-extra { display: table-cell; }
.details-open .chart-card thead th,
.details-open .chart-card tbody td { padding-left: 0.3rem; padding-right: 0.3rem; }
.details-open .chart-card table { font-size: 0.78rem; }

/* ── 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; }

/* ── 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 { display: flex; align-items: center; gap: 0.55rem; }
.planet-symbol { width: 1.3rem; height: 1.3rem; color: #666; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.planet-symbol svg { display: block; }
.planet-name   { font-weight: 500; white-space: nowrap; }
.planet-link   { cursor: pointer; }
.planet-link:hover .planet-symbol,
.planet-link:hover .planet-name { color: #4a6fa5; 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;
}

.mark-exalted   { font-size: 0.62rem; color: #1a8c1a; line-height: 1; vertical-align: middle; }
.mark-detriment { font-size: 0.62rem; color: #cc2222; line-height: 1; vertical-align: middle; }
.mark-cell { width: 1rem; padding-left: 0 !important; padding-right: 0.2rem !important; text-align: center; }

.gate-cell { display: flex; align-items: center; justify-content: center; gap: 0.2rem; }
.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; }

.ctb { font-family: monospace; font-size: 0.8rem; color: #666; letter-spacing: 0.05em; }
.lon-cell { font-family: monospace; font-size: 0.76rem; color: #bbb; }

/* ── Topo checkbox ── */
.topo-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #555;
  cursor: pointer;
}
.topo-label input[type="checkbox"] { margin: 0; cursor: pointer; }
.topo-warning { color: #999; font-size: 0.75rem; }

/* ── Channels ── */
.channels-card { padding: 1.25rem 1.75rem; }

.channel-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  border-radius: 3px;
  padding: 0.05rem 0.2rem;
  font-size: 0.82rem;
  color: #666;
  transition: background 0.12s, color 0.12s;
}
.channel-chip:hover { background: #eef2fa; color: #4a6fa5; }
.channel-sep { color: #ccc; margin: 0 0.1rem; }

.center-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Bodygraph ── */
#bodygraph-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
#bodygraph-container svg { width: 100%; height: auto; display: block; }

/* ── Responsive ── */
@media (max-width: 820px) {
  header { padding: 0.9rem 1.25rem; }
  .header-auth-email { display: none; }
  .form-row-main { grid-template-columns: 1fr 1fr; }
  .form-row-main .field:last-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
  #bodygraph-container {
    max-width: 260px;
    margin: 0 auto;
    order: -1;
  }
  .form-row-main { grid-template-columns: 1fr; }
  .planet-name, .retro { display: none; }
  .planet-cell { justify-content: center; }
  tbody td:first-child, thead th:first-child { width: 1.8rem; padding-left: 0.3rem; padding-right: 0.3rem; }
  .julday { display: none !important; }
}

@media (max-width: 480px) {
  header { padding: 0.7rem 1rem; }
  main { padding: 1.25rem 1rem; }
  .card { padding: 1.25rem; }
}
