/* நவகிரக மண்டலம் — a night sky with temple gold.
 *
 * Two authentic forms carry the design rather than decoration:
 *   the navagraha shrine layout, Surya centred with the eight around him in
 *   their traditional directions, and the South Indian ராசி கட்டம், a 4x4
 *   grid whose twelve outer cells are fixed rasis with a hollow centre.
 * Graha colours are the traditional ones, not a palette invented for looks.
 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@300;400;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --night:      #090C16;
  --night-2:    #111628;
  --night-3:    #1A2138;
  --gold:       #D4A853;
  --gold-soft:  #E9CE92;
  --gold-dim:   #7A6031;
  --text:       #EDE7DA;
  --text-dim:   #9A93A6;
  --line:       rgba(212,168,83,.22);
  --ok:         #6FBF8B;
  --bad:        #D97066;
  --mid:        #D9B36A;

  /* Traditional navagraha colours */
  --sun:     #D9542B;
  --moon:    #EFE9DC;
  --mars:    #B03A3A;
  --mercury: #3E9E6E;
  --jupiter: #E0A81C;
  --venus:   #DCDCE8;
  --saturn:  #4C5D87;
  --rahu:    #7A7488;
  --ketu:    #9A8468;

  --radius: 14px;
  --shadow: 0 18px 48px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--night);
  color: var(--text);
  font-family: 'Noto Sans Tamil', system-ui, sans-serif;
  font-size: 16px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Star field: three layers of static points, cheap and still */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 18% 22%, rgba(255,255,255,.55), transparent),
    radial-gradient(1.1px 1.1px at 72% 12%, rgba(255,255,255,.40), transparent),
    radial-gradient(1.6px 1.6px at 41% 68%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.1px 1.1px at 88% 54%, rgba(255,255,255,.45), transparent),
    radial-gradient(1.3px 1.3px at 12% 82%, rgba(255,255,255,.30), transparent),
    radial-gradient(1.0px 1.0px at 62% 88%, rgba(255,255,255,.35), transparent),
    radial-gradient(900px 600px at 50% -10%, rgba(80,70,140,.22), transparent 70%),
    radial-gradient(700px 500px at 90% 100%, rgba(140,110,50,.10), transparent 70%);
}

.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 28px 20px 72px; }

/* ---------- Masthead ---------- */
.masthead { text-align: center; padding: 26px 0 10px; }
.masthead h1 {
  font-size: clamp(30px, 6vw, 46px); font-weight: 700; margin: 0 0 6px;
  letter-spacing: .02em;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold) 55%, var(--gold-dim));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.masthead p {
  margin: 0; color: var(--text-dim); font-family: 'Cormorant Garamond', serif;
  font-style: italic; font-size: 17px;
}

/* ---------- Navagraha mandala ---------- */
.mandala { display: grid; place-items: center; margin: 22px auto 30px; }
.mandala svg { width: min(340px, 78vw); height: auto; overflow: visible; }
.orbit { fill: none; stroke: var(--line); stroke-width: 1; }
.orbit-spin { transform-origin: 160px 160px; animation: spin 140s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orbit-spin { animation: none; } }

.graha-dot { cursor: default; }
.graha-dot circle { transition: r .25s ease, filter .25s ease; }
.graha-dot:hover circle { r: 17; filter: brightness(1.35); }
.graha-label { font-size: 10.5px; fill: var(--text-dim); text-anchor: middle; }

/* ---------- Settings gear ---------- */
/* Fixed to the viewport rather than the header: the result screen is long,
 * and the credentials are most often changed after an answer disappoints. */
.gear {
  position: fixed; top: 14px; right: 14px; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 400;
  background: rgba(17,22,40,.86); backdrop-filter: blur(6px);
  border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.gear .cog { font-size: 15px; line-height: 1; transition: transform .45s ease; }
.gear:hover .cog { transform: rotate(120deg); }
.gear .model {
  color: var(--text-dim); font-size: 12.5px; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* On a narrow screen the cog alone is the affordance; the model name would
 * otherwise crowd the masthead. */
@media (max-width: 560px) { .gear .model { display: none; } }

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

/* Model picker: a dropdown when the gateway lists its models, the typed
 * field when it does not. Both occupy the same slot. */
.modelpick { display: flex; gap: 8px; }
.modelpick select, .modelpick input { flex: 1; min-width: 0; }
button.tiny {
  flex: 0 0 auto; padding: 0 13px; font-size: 17px; font-weight: 400;
  line-height: 1; height: 44px;
}
.hint { font-size: 12px; color: var(--text-dim); margin: -4px 0 12px;
        min-height: 15px; line-height: 1.5; }

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(180deg, rgba(26,33,56,.92), rgba(17,22,40,.92));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px;
}
.panel + .panel { margin-top: 20px; }
.panel h2 {
  margin: 0 0 4px; font-size: 21px; font-weight: 600; color: var(--gold-soft);
}
.panel .sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--text-dim); margin: 0 0 6px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 9px;
  background: rgba(9,12,22,.75); color: var(--text);
  border: 1px solid rgba(212,168,83,.18);
  font-family: inherit; font-size: 15px; transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,168,83,.14);
}
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.field { margin-bottom: 14px; position: relative; }

button {
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  padding: 11px 22px; border-radius: 9px; border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, rgba(212,168,83,.22), rgba(212,168,83,.08));
  color: var(--gold-soft); transition: transform .12s, background .18s, box-shadow .18s;
}
button:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(212,168,83,.34), rgba(212,168,83,.14));
  box-shadow: 0 6px 18px rgba(212,168,83,.14);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; border-color: rgba(212,168,83,.25); }

/* ---------- Place autocomplete ---------- */
.suggest {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
  background: var(--night-3); border: 1px solid var(--line);
  border-radius: 0 0 9px 9px; max-height: 230px; overflow-y: auto;
}
.suggest div { padding: 9px 13px; cursor: pointer; font-size: 14px; }
.suggest div:hover, .suggest div.active { background: rgba(212,168,83,.14); }
.suggest .en { color: var(--text-dim); font-size: 12px; margin-left: 6px; }

/* ---------- Mode cards ---------- */
.modes { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.mode {
  text-align: center; padding: 30px 22px; border-radius: var(--radius);
  border: 1px solid var(--line); cursor: pointer;
  background: linear-gradient(180deg, rgba(26,33,56,.85), rgba(17,22,40,.85));
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.mode:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow); }
.mode .glyph { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.mode h3 { margin: 0 0 6px; font-size: 19px; color: var(--gold-soft); font-weight: 600; }
.mode p { margin: 0; font-size: 13.5px; color: var(--text-dim); }

/* ---------- South Indian ராசி கட்டம் ---------- */
.kattam {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr);
  aspect-ratio: 1; max-width: 430px; margin: 0 auto;
  border: 1px solid var(--gold-dim); border-radius: 6px; overflow: hidden;
  background: rgba(9,12,22,.5);
}
.cell {
  border: 1px solid rgba(212,168,83,.16); padding: 5px 6px;
  font-size: 11.5px; min-height: 0; display: flex; flex-direction: column; gap: 2px;
}
.cell .rasi { color: var(--gold-dim); font-size: 10px; letter-spacing: .02em; }
.cell .body { display: flex; flex-wrap: wrap; gap: 3px; }
.cell .g { font-size: 11.5px; font-weight: 600; }
.cell.lagna { background: rgba(212,168,83,.10); box-shadow: inset 0 0 0 1px var(--gold-dim); }
.kattam .centre {
  grid-column: 2 / 4; grid-row: 2 / 4; border: 1px solid rgba(212,168,83,.16);
  display: grid; place-items: center; text-align: center; color: var(--text-dim);
  font-size: 12px; line-height: 1.5;
}
.kattam .centre b { display: block; color: var(--gold-soft); font-size: 15px; font-weight: 600; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; padding-right: 6px; }
.msg { padding: 13px 16px; border-radius: 12px; max-width: 88%; font-size: 15px; }
.msg.user { align-self: flex-end; background: rgba(212,168,83,.14); border: 1px solid var(--line); }
.msg.bot  { align-self: flex-start; background: rgba(26,33,56,.85); border: 1px solid rgba(212,168,83,.14); }
.msg.bot h2, .msg.bot h3 { color: var(--gold-soft); font-size: 16px; margin: 12px 0 6px; }
.msg.bot strong { color: var(--gold-soft); }
.msg .cites { margin-top: 10px; padding-top: 9px; border-top: 1px dashed rgba(212,168,83,.22); font-size: 12px; color: var(--text-dim); }
.msg .cites b { color: var(--gold-dim); }
.msg .cites .tr { opacity: .65; font-style: italic; }

.thinking { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; }
.thinking .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: pulse 1.3s ease-in-out infinite; }
.thinking .dot:nth-child(2) { animation-delay: .18s; }
.thinking .dot:nth-child(3) { animation-delay: .36s; }
@keyframes pulse { 0%,100% { opacity:.25; transform: scale(.8);} 50% { opacity:1; transform: scale(1);} }

/* Grows with the question. A one-line input made anything longer than a
 * sentence invisible as it was typed, which is the opposite of frictionless. */
.composer { display: flex; gap: 10px; margin-top: 16px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; overflow-y: auto; min-height: 46px; max-height: 220px;
  line-height: 1.5; padding: 12px 13px;
}
.composer button { flex: 0 0 auto; height: 46px; padding: 0 22px; }

/* The same button stops the answer it started. */
button.stop {
  border-color: rgba(217,112,102,.45); color: var(--bad);
  background: linear-gradient(180deg, rgba(217,112,102,.20), rgba(217,112,102,.07));
}
button.stop:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(217,112,102,.32), rgba(217,112,102,.12));
  box-shadow: 0 6px 18px rgba(217,112,102,.14);
}
.msg .stopped {
  margin-top: 8px; font-size: 12px; color: var(--text-dim); font-style: italic;
}

/* ---------- Audience toggle ---------- */
/* A segmented control, not a dropdown: both options must be readable at a
 * glance, because the choice changes what the next answer looks like. */
.audience { display: flex; gap: 0; margin-top: 14px;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.aud {
  flex: 1; border: 0; border-radius: 0; background: transparent;
  padding: 9px 10px; font-size: 14px; font-weight: 600; color: var(--text-dim);
  display: flex; flex-direction: column; gap: 2px; line-height: 1.3;
}
.aud span { font-size: 11px; font-weight: 400; opacity: .8; }
.aud + .aud { border-left: 1px solid var(--line); }
.aud:hover:not(.active) { background: rgba(212,168,83,.07); color: var(--text); }
.aud.active {
  color: var(--gold-soft);
  background: linear-gradient(180deg, rgba(212,168,83,.22), rgba(212,168,83,.08));
}

/* ---------- Tables inside an answer ---------- */
/* The Do's and Don'ts table is part of every reading, so it has to render as
 * a table rather than as a row of pipe characters. */
.msg.bot table.md { width: 100%; border-collapse: collapse; margin: 10px 0;
  font-size: 13px; }
.msg.bot table.md th {
  text-align: left; padding: 7px 9px; font-size: 11.5px; font-weight: 600;
  color: var(--gold-dim); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.msg.bot table.md td {
  padding: 8px 9px; vertical-align: top;
  border-bottom: 1px solid rgba(212,168,83,.10);
}
.msg.bot table.md tr:last-child td { border-bottom: 0; }
.msg.bot p { margin: 0 0 7px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot .li { margin: 0 0 5px; padding-left: 4px; }
.msg.bot .gap { height: 7px; }

/* ---------- Porutham table ---------- */
.porutham { width: 100%; border-collapse: collapse; font-size: 14px; }
.porutham th { text-align: left; color: var(--gold-dim); font-weight: 600; font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); }
.porutham td { padding: 10px; border-bottom: 1px solid rgba(212,168,83,.10); vertical-align: top; }
.porutham .pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok  { background: rgba(111,191,139,.16); color: var(--ok); }
.pill.bad { background: rgba(217,112,102,.16); color: var(--bad); }
.pill.mid { background: rgba(217,179,106,.16); color: var(--mid); }
.score { text-align: center; padding: 20px 0 6px; }
.score .big { font-size: 46px; font-weight: 700; color: var(--gold-soft); line-height: 1; }
.score .of  { color: var(--text-dim); font-size: 14px; }

/* ---------- Misc ---------- */
.note { font-size: 12.5px; color: var(--text-dim); margin-top: 12px; line-height: 1.6; }
.err { color: var(--bad); font-size: 13.5px; margin-top: 10px; }
.hidden { display: none !important; }
.center { text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { font-size: 12.5px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(212,168,83,.22); color: var(--text-dim); background: transparent; }
.chip:hover { border-color: var(--gold); color: var(--gold-soft); }
/* Marks the chips as follow-ups to the answer above, not a fresh menu. */
.chiplabel { font-size: 12px; color: var(--gold-dim); align-self: center;
             margin-right: 2px; }
.split { display: grid; gap: 20px; grid-template-columns: minmax(0,1fr); }
@media (min-width: 900px) { .split { grid-template-columns: 430px minmax(0,1fr); } }
