*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0b14;
  --surface:  #12101c;
  --border:   #2a2540;
  --accent:   #9b59b6;
  --accent2:  #e040fb;
  --gold:     #d4af5a;
  --text:     #e8e0f5;
  --muted:    #7a70a0;
  --danger:   #e05252;
  --success:  #52c97a;
  --radius:   14px;
  --glow:     0 0 24px rgba(155,89,182,.25);
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Lato', sans-serif;
  font-weight: 300;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 4rem;
  overflow-x: hidden;
}

.bg-layer {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 15% 25%, rgba(100,50,200,.1) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 75%, rgba(180,50,220,.08) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(60,30,120,.06) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
body > * { position: relative; z-index: 1; }

header {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  max-width: 720px; width: 100%;
}

.star-line {
  color: var(--accent);
  font-size: .8rem; letter-spacing: .2rem; opacity: .4; margin: .6rem 0;
}

header h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold) 0%, var(--accent) 50%, var(--accent2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  line-height: 1.2; margin: .4rem 0;
}

.subtitle { color: var(--muted); font-size: .95rem; line-height: 1.5; }

main { width: 100%; max-width: 720px; margin-top: 2rem; }

/* ── Tabs ── */
.tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.tab {
  flex: 1; padding: .75rem .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted);
  font-family: 'Cinzel', serif; font-size: .8rem; cursor: pointer; transition: all .2s;
}
.tab:hover { border-color: var(--accent); color: var(--text); }
.tab.active { border-color: var(--accent); color: var(--accent); background: rgba(155,89,182,.1); box-shadow: var(--glow); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Card ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  box-shadow: 0 4px 32px rgba(0,0,0,.4);
}
.card h2 { font-family: 'Cinzel', serif; font-size: 1.25rem; font-weight: 600; color: var(--gold); margin-bottom: .35rem; }
.card-desc { color: var(--muted); font-size: .9rem; margin-bottom: 1.75rem; line-height: 1.5; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.4rem; }
label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1rem; color: var(--muted); }
.optional { font-weight: 300; text-transform: none; letter-spacing: 0; font-size: .75rem; opacity: .7; }

.cat-buttons { display: flex; flex-wrap: wrap; gap: .45rem; }
.cat-btn, .gen-cat-btn {
  padding: .4rem .85rem;
  background: transparent; border: 1px solid var(--border);
  border-radius: 20px; color: var(--muted);
  font-family: 'Lato', sans-serif; font-size: .82rem; cursor: pointer; transition: all .2s;
}
.cat-btn:hover, .gen-cat-btn:hover { border-color: var(--accent); color: var(--text); }
.cat-btn.active, .gen-cat-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(155,89,182,.12); }

textarea {
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-family: 'Lato', sans-serif; font-size: .95rem; line-height: 1.6;
  padding: .85rem 1rem; resize: vertical; transition: border-color .2s; width: 100%;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155,89,182,.15); }
textarea::placeholder { color: var(--muted); opacity: .6; }

/* ── Button ── */
.btn-primary {
  display: block; width: 100%; padding: .9rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), #6a1b9a);
  border: none; border-radius: 10px; color: #fff;
  font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 600; letter-spacing: .05rem;
  cursor: pointer; transition: all .25s;
  box-shadow: 0 4px 20px rgba(155,89,182,.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(155,89,182,.5); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Results ── */
.results { margin-top: 1.75rem; }

/* Random headcanon card */
.headcanon-card {
  background: rgba(155,89,182,.07);
  border: 1px solid rgba(155,89,182,.25);
  border-radius: 12px; padding: 1.2rem 1.4rem;
  animation: fadeSlide .35s ease both;
  margin-bottom: .75rem;
}
.headcanon-card .hc-category {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12rem; color: var(--accent); margin-bottom: .5rem;
}
.headcanon-card .hc-text {
  font-size: 1rem; line-height: 1.7; color: var(--text);
  cursor: pointer; transition: color .2s;
}
.headcanon-card .hc-text:hover { color: #fff; }
.headcanon-card .copy-hint {
  font-size: .72rem; color: var(--muted); margin-top: .5rem; opacity: 0; transition: opacity .2s;
}
.headcanon-card:hover .copy-hint { opacity: 1; }

/* AI result card */
.ai-result {
  background: rgba(224,64,251,.06);
  border: 1px solid rgba(224,64,251,.2);
  border-radius: 12px; padding: 1.4rem;
  animation: fadeSlide .35s ease both;
}
.ai-result .ai-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12rem; color: var(--accent2); margin-bottom: .6rem;
  display: flex; align-items: center; gap: .5rem;
}
.ai-result .ai-text {
  font-size: 1rem; line-height: 1.75; color: var(--text);
  cursor: pointer;
}
.ai-result .copy-hint {
  font-size: .72rem; color: var(--muted); margin-top: .6rem; opacity: 0; transition: opacity .2s;
}
.ai-result:hover .copy-hint { opacity: 1; }

/* Relationship dynamic badge */
.dynamic-badge {
  display: inline-block;
  padding: .2rem .7rem;
  background: rgba(155,89,182,.15);
  border: 1px solid rgba(155,89,182,.3);
  border-radius: 20px; font-size: .75rem;
  color: var(--accent); margin-left: .5rem;
  text-transform: capitalize;
}

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

.spinner {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; padding: 1.5rem; color: var(--muted); font-size: .9rem;
}
.spinner::before {
  content: ''; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: rgba(224,82,82,.1); border: 1px solid rgba(224,82,82,.3);
  border-radius: 10px; padding: .9rem 1.1rem; color: var(--danger); font-size: .9rem;
}

footer { margin-top: 3rem; }

@media (max-width: 500px) {
  .card { padding: 1.25rem; }
  .tabs { flex-direction: column; }
}

header h1::before {
  content: '◆';
  display: inline-block;
  margin-right: .5rem;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  font-size: 70%;
  vertical-align: middle;
}

/* About / GEO section */
.about-section {
  margin-top: 2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem 2rem;
  font-size: .9rem; line-height: 1.75; color: var(--muted);
}
.about-section h2 {
  font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 600;
  color: var(--gold); margin-bottom: .75rem;
}
.about-section p { margin-bottom: .75rem; }
.about-section p:last-of-type { margin-bottom: 1rem; }
.about-section strong { color: var(--text); }
.about-section em { color: var(--accent); font-style: normal; }
.about-section details { margin-top: .5rem; }
.about-section summary {
  cursor: pointer; color: var(--accent); font-size: .85rem;
  font-weight: 700; letter-spacing: .05rem; text-transform: uppercase;
  padding: .5rem 0; list-style: none; outline: none;
}
.about-section summary::-webkit-details-marker { display: none; }
.about-section summary::before { content: '+ '; }
details[open] summary::before { content: '- '; }
.about-section dl { margin-top: .75rem; }
.about-section dt { color: var(--text); font-weight: 700; margin-top: .75rem; }
.about-section dd { margin: .2rem 0 0 1rem; }
