/* ═══════════════════════════════════════════════════
   BIBLOMAX – Refined Academic Luxury Design System
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Outfit:wght@300;400;500;600;700&display=swap');

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ── Core Palette ── */
  --navy:        #0D1B2A;
  --navy-mid:    #1B2C3E;
  --navy-light:  #243447;
  --teal:        #0E7C7B;
  --teal-bright: #14A5A4;
  --teal-glow:   #1ECFCE;
  --gold:        #C9A84C;
  --gold-light:  #E2C06A;
  --gold-pale:   #F5E6B8;

  /* ── Neutrals ── */
  --cream:       #F9F6F0;
  --cream-mid:   #F0EBE1;
  --parchment:   #E8E0D0;
  --white:       #FFFFFF;

  /* ── Text ── */
  --text-primary:   #0D1B2A;
  --text-secondary: #3D5166;
  --text-muted:     #6B849A;
  --text-light:     #A8BECF;

  /* ── Semantic ── */
  --primary:       var(--teal);
  --primary-dark:  #0A5E5D;
  --primary-light: var(--teal-bright);
  --accent:        var(--gold);
  --accent-light:  var(--gold-light);

  /* ── Backgrounds ── */
  --bg-main:    var(--cream);
  --bg-card:    var(--white);
  --bg-section: #F4F0EA;

  /* ── Borders ── */
  --border-light:  #DDD8CE;
  --border-medium: #C8C0B2;

  /* ── Status ── */
  --success: #0A7A5A;
  --danger:  #C0392B;
  --warning: var(--gold);

  /* ── Shadows ── */
  --shadow-xs: 0 1px 3px rgba(13,27,42,0.06);
  --shadow-sm: 0 2px 8px rgba(13,27,42,0.08);
  --shadow-md: 0 6px 20px rgba(13,27,42,0.10);
  --shadow-lg: 0 14px 40px rgba(13,27,42,0.14);
  --shadow-xl: 0 24px 64px rgba(13,27,42,0.18);
  --shadow-teal: 0 6px 24px rgba(14,124,123,0.22);
  --shadow-gold: 0 4px 16px rgba(201,168,76,0.25);

  /* ── Radii ── */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* ── Motion ── */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition:  all 0.28s var(--ease-smooth);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--cream-mid); }
::-webkit-scrollbar-thumb { background: var(--teal); border-radius: 99px; }

/* ── Body ── */
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Subtle parchment texture via gradient */
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(14,124,123,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(201,168,76,0.05) 0%, transparent 60%);
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.2rem; }

/* ═══════════════════════════
   HEADER
═══════════════════════════ */
header {
  background: var(--navy);
  color: white;
  padding: 0;
  box-shadow: 0 4px 24px rgba(13,27,42,0.35);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--teal);
  /* Subtle inner shimmer */
  background-image:
    linear-gradient(135deg, var(--navy-light) 0%, var(--navy) 50%, #0A1520 100%);
}

/* Gold accent stripe at very top */
header::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--teal-glow), var(--gold), transparent);
  opacity: 0.8;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-section img {
  height: 52px;
  width: auto;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(201,168,76,0.4), var(--shadow-md);
  transition: var(--transition);
}

.logo-section img:hover {
  box-shadow: 0 0 0 3px var(--gold), var(--shadow-lg);
  transform: scale(1.05);
}

.logo-section h1 {
  color: white;
  font-size: 1.85rem;
  margin-bottom: 0.1rem;
  letter-spacing: 0.01em;
}

/* Gold underline on brand name */
.logo-section h1 span,
.logo-section h1 {
  background: linear-gradient(135deg, #fff 60%, var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-glow);
  opacity: 0.9;
}

/* ── Nav ── */
nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

nav a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  position: relative;
  transition: var(--transition);
  letter-spacing: 0.02em;
}

nav a:hover {
  color: white;
  background: rgba(255,255,255,0.08);
}

nav a.active {
  color: var(--gold-light);
  background: rgba(201,168,76,0.12);
  font-weight: 600;
}

nav a.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 1.1rem;
  right: 1.1rem;
  height: 2px;
  background: var(--gold);
  border-radius: 99px;
}

/* ═══════════════════════════
   MAIN
═══════════════════════════ */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  width: 100%;
}

/* ═══════════════════════════
   HERO SECTION
═══════════════════════════ */
.hero-section {
  text-align: center;
  padding: 4rem 2rem;
  background:
    linear-gradient(160deg, var(--navy) 0%, var(--navy-mid) 60%, #0A2540 100%);
  border-radius: var(--radius-xl);
  margin-bottom: 3rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}

/* Decorative orbs */
.hero-section::before {
  content: '';
  position: absolute;
  top: -60px; left: -60px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(14,124,123,0.25) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -80px; right: -40px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(201,168,76,0.18) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* Gold rule above heading */
.hero-section h2 {
  font-size: 2.75rem;
  color: white;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 1;
}

.hero-section h2::after {
  content: '';
  display: block;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--teal-glow));
  margin: 0.75rem auto 0;
  border-radius: 99px;
}

.hero-section p {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.7);
  max-width: 660px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  font-weight: 300;
  letter-spacing: 0.01em;
}

/* ═══════════════════════════
   GENERATOR CONTAINER
═══════════════════════════ */
.generator-container {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ═══════════════════════════
   CARDS
═══════════════════════════ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: box-shadow 0.3s var(--ease-smooth), transform 0.3s var(--ease-smooth), border-color 0.3s;
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--teal-bright);
}

/* Subtle left accent bar */
.card::before {
  content: '';
  position: absolute;
  top: 20px; bottom: 20px; left: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--teal), var(--gold));
  border-radius: 0 3px 3px 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.card:hover::before {
  opacity: 1;
}

/* ── Step Header ── */
.step-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.step-number {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--shadow-teal);
  flex-shrink: 0;
  font-family: 'Playfair Display', serif;
}

.step-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.35rem;
}

/* ═══════════════════════════
   RADIO CARDS
═══════════════════════════ */
.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.radio-card {
  position: relative;
  cursor: pointer;
  display: block;
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-content {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.35rem 1.5rem;
  background: var(--bg-section);
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.radio-card input:checked + .radio-content {
  background: linear-gradient(135deg, rgba(14,124,123,0.07) 0%, rgba(14,124,123,0.03) 100%);
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,0.15), var(--shadow-sm);
}

.radio-card:hover .radio-content {
  border-color: var(--teal-bright);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.radio-icon {
  font-size: 1.9rem;
  line-height: 1;
}

.radio-content strong {
  display: block;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.radio-content small {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* ═══════════════════════════
   FORM ELEMENTS
═══════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-group label small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0;
}

input[type="text"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.97rem;
  color: var(--text-primary);
  background: var(--white);
  transition: var(--transition);
  font-weight: 400;
}

input[type="text"]:hover,
input[type="email"]:hover,
select:hover,
textarea:hover {
  border-color: var(--teal-bright);
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,0.14);
  background: #FAFFFE;
}

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

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Special styling for reference output */
#finalOutput {
  font-family: 'Times New Roman', Times, serif !important;
}

/* ── Input Group ── */
.input-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.input-group input {
  flex: 1;
}

/* ═══════════════════════════
   BUTTONS
═══════════════════════════ */
button {
  padding: 0.875rem 1.6rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.97rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  color: white;
  box-shadow: var(--shadow-teal);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(14,124,123,0.35);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--teal) 100%);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-success {
  background: linear-gradient(135deg, #0A7A5A, #0EA574);
  color: white;
  box-shadow: 0 4px 14px rgba(10,122,90,0.25);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(10,122,90,0.35);
}

.btn-secondary {
  background: var(--bg-section);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-medium);
}

.btn-secondary:hover {
  background: var(--cream-mid);
  border-color: var(--teal);
  color: var(--teal);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #C0392B, #E74C3C);
  color: white;
  box-shadow: 0 4px 14px rgba(192,57,43,0.2);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(192,57,43,0.3);
}

/* ═══════════════════════════
   MODE PANELS
═══════════════════════════ */
.mode-panel {
  margin-top: 1.5rem;
}

/* ═══════════════════════════
   PREVIEW BOX
═══════════════════════════ */
.preview-box {
  background: linear-gradient(135deg, rgba(14,124,123,0.05) 0%, rgba(14,124,123,0.02) 100%);
  border: 1.5px solid rgba(14,124,123,0.25);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 1.5rem;
  position: relative;
}

.preview-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.preview-box h4 {
  color: var(--teal);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.preview-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.preview-item {
  display: flex;
  flex-direction: column;
}

.preview-item label {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-edit-field {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(14,124,123,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: white;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  transition: var(--transition);
}

.preview-edit-field:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,0.12);
}

.preview-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ── Style Selector ── */
.style-selector {
  margin-top: 1rem;
}

.style-selector select {
  width: 100%;
  max-width: 600px;
  font-size: 1rem;
  padding: 0.9rem 3rem 0.9rem 1.1rem;
}

/* ═══════════════════════════
   SOURCE TYPE GRID
═══════════════════════════ */
.source-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.source-type-card {
  position: relative;
  cursor: pointer;
  display: block;
}

.source-type-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.source-type-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.35rem 0.75rem;
  background: var(--bg-section);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-md);
  transition: var(--transition);
  min-height: 110px;
}

.source-type-card input:checked + .source-type-content {
  background: linear-gradient(135deg, rgba(14,124,123,0.08) 0%, rgba(14,124,123,0.03) 100%);
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,0.15), var(--shadow-sm);
}

.source-type-card:hover .source-type-content {
  border-color: var(--teal-bright);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: white;
}

.source-type-icon {
  font-size: 2.2rem;
  line-height: 1;
  transition: transform 0.2s var(--ease-spring);
}

.source-type-card:hover .source-type-icon {
  transform: scale(1.12);
}

.source-type-content strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ═══════════════════════════
   REFERENCE LIST
═══════════════════════════ */
.reference-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.reference-item {
  position: relative;
  padding: 1.4rem 1.4rem 1.4rem 1.75rem;
  background: var(--bg-section);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: var(--transition);
  border-left: 4px solid var(--teal);
}

.reference-item:hover {
  border-color: var(--teal);
  border-left-color: var(--gold);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
  background: white;
}

.reference-item .ref-type {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  background: var(--teal);
  color: white;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.reference-item strong {
  display: block;
  color: var(--text-primary);
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
  font-family: 'Playfair Display', serif;
}

.reference-item .ref-details {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
  font-weight: 300;
}

.reference-item .ref-url {
  display: block;
  color: var(--teal);
  font-size: 0.83rem;
  word-break: break-all;
  margin-top: 0.4rem;
  opacity: 0.8;
}

.reference-item > button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
}

/* Button row at bottom of each citation card */
.ref-btn-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1.5px solid var(--border-light);
  width: 100%;
}

.ref-btn-row button,
.btn-save-cit,
.btn-remove-cit {
  position: static !important;
  top: auto !important;
  right: auto !important;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1.05rem;
  border-radius: 7px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border: 1.5px solid;
  background: transparent;
  transition: all 0.2s ease;
  line-height: 1;
}

.btn-save-cit {
  border-color: var(--teal);
  color: var(--teal);
}

.btn-save-cit:hover:not(:disabled) {
  background: var(--teal);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(14,124,123,0.28);
}

.btn-save-cit.saved {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  cursor: default;
}

.btn-save-cit:disabled:not(.saved) {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-remove-cit {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-remove-cit:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(192,57,43,0.22);
}

.list-actions {
  display: flex;
  gap: 1rem;
  margin: 2rem 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-light);
}

#outputSection {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-light);
}

#outputSection h4 {
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 1.1rem;
}

#finalOutput {
  width: 100%;
  padding: 1.5rem;
  background: var(--white);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: 'Times New Roman', Times, serif;
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
  box-shadow: inset 0 2px 8px rgba(13,27,42,0.04);
}

#finalOutput em { font-style: italic; }

#finalOutput p.ref-line {
  margin: 0 0 1.1em 0;
  line-height: 1.8;
}

/* Hanging indent */
#finalOutput[data-style="apa6"] p.ref-line,
#finalOutput[data-style="apa7"] p.ref-line,
#finalOutput[data-style="mla8"] p.ref-line,
#finalOutput[data-style="mla9"] p.ref-line,
#finalOutput[data-style="chicago-ad"] p.ref-line,
#finalOutput[data-style="chicago-nb"] p.ref-line,
#finalOutput[data-style="asa"] p.ref-line,
#finalOutput[data-style="apsa"] p.ref-line,
#finalOutput[data-style="mhra"] p.ref-line {
  padding-left: 2em;
  text-indent: -2em;
}

.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  opacity: 0.25;
}

/* ═══════════════════════════
   FOOTER
═══════════════════════════ */
footer {
  background: var(--navy);
  background-image: linear-gradient(160deg, var(--navy-light) 0%, var(--navy) 60%, #07111C 100%);
  color: white;
  padding: 3.5rem 2rem 1.5rem;
  margin-top: 4rem;
  border-top: 3px solid var(--teal);
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--teal-glow), var(--gold), var(--teal));
  opacity: 0.7;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-section h3 {
  color: var(--gold-light);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.footer-section p {
  color: rgba(255,255,255,0.65);
  line-height: 1.75;
  font-size: 0.92rem;
  font-weight: 300;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.65rem;
}

.footer-links a {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.92rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 300;
}

.footer-links a:hover {
  color: var(--teal-glow);
  transform: translateX(4px);
}

.social-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: var(--transition);
  font-size: 1rem;
}

.social-links a:hover {
  background: var(--teal);
  border-color: var(--teal-bright);
  color: white;
  transform: translateY(-3px);
  box-shadow: var(--shadow-teal);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.45);
  font-size: 0.88rem;
  font-weight: 300;
}

/* ═══════════════════════════
   ABOUT PAGE – FEATURE BOXES
═══════════════════════════ */
.feature-box {
  background: var(--bg-section);
  padding: 1.75rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.feature-box::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transform: scaleX(0);
  transition: transform 0.3s var(--ease-smooth);
  transform-origin: left;
}

.feature-box:hover {
  border-color: var(--teal-bright);
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  background: white;
}

.feature-box:hover::after {
  transform: scaleX(1);
}

.feature-icon {
  font-size: 2.4rem;
  margin-bottom: 1rem;
  display: block;
}

.feature-box h4 {
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  font-size: 1.1rem;
}

.feature-box p {
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.65;
  font-weight: 300;
}

/* Benefits List */
.benefits-list {
  list-style: none;
  padding: 0;
  margin-top: 1rem;
}

.benefits-list li {
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.85rem;
  background: var(--bg-section);
  border-left: 4px solid var(--teal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.7;
  transition: var(--transition);
  color: var(--text-secondary);
  font-weight: 300;
  font-size: 0.97rem;
}

.benefits-list li:hover {
  background: white;
  box-shadow: var(--shadow-sm);
  border-left-color: var(--gold);
  transform: translateX(4px);
}

.benefits-list strong {
  color: var(--teal);
  display: block;
  margin-bottom: 0.2rem;
  font-weight: 600;
  font-size: 1rem;
}

/* ═══════════════════════════
   CONTACT PAGE
═══════════════════════════ */
.contact-info-grid {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.contact-info-item {
  display: flex;
  gap: 1.1rem;
  padding: 1.25rem;
  background: var(--bg-section);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  transition: var(--transition);
  align-items: flex-start;
}

.contact-info-item:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-sm);
  background: white;
  transform: translateY(-2px);
}

.contact-icon {
  font-size: 1.9rem;
  line-height: 1;
  flex-shrink: 0;
}

.contact-info-item h4 {
  margin: 0 0 0.25rem 0;
  color: var(--text-primary);
  font-size: 1rem;
}

.contact-info-item p {
  margin: 0.25rem 0;
  color: var(--text-secondary);
  font-size: 0.93rem;
  font-weight: 300;
}

.contact-info-item a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 500;
}

.contact-info-item a:hover {
  color: var(--teal-bright);
  text-decoration: underline;
}

/* FAQ */
.faq-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.faq-item {
  background: var(--bg-section);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.faq-item:hover {
  border-color: var(--teal-bright);
  background: white;
}

.faq-item[open] {
  border-color: var(--teal);
  background: linear-gradient(135deg, rgba(14,124,123,0.04) 0%, rgba(14,124,123,0.01) 100%);
  box-shadow: var(--shadow-sm);
}

.faq-item summary {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::after {
  content: '+';
  font-size: 1.4rem;
  color: var(--teal);
  font-weight: 300;
  line-height: 1;
  transition: transform 0.25s;
}

.faq-item[open] summary::after {
  content: '–';
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item p {
  margin: 1rem 0 0 0;
  color: var(--text-secondary);
  line-height: 1.75;
  font-size: 0.95rem;
  font-weight: 300;
}

.faq-item a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 500;
}

.faq-item a:hover {
  text-decoration: underline;
}

/* Google Form Embed */
.form-embed-container {
  width: 100%;
  max-width: 100%;
  margin-top: 1.5rem;
}

.form-embed-container iframe {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════
   RESPONSIVE
═══════════════════════════ */
/* ═══════════════════════════════════════
   MOBILE — Global overflow prevention
═══════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

img, video, iframe, table, pre, code {
  max-width: 100%;
}

/* ═══════════════════════════════════════
   RESPONSIVE BREAKPOINTS
═══════════════════════════════════════ */

/* ── Tablet & below (≤ 900px) ── */
@media (max-width: 900px) {
  .chat-panel {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  .chat-list {
    max-height: 260px;
    overflow-y: auto;
  }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {

  /* Header */
  .header-content {
    flex-direction: column;
    text-align: center;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .logo-section {
    flex-direction: row;
    justify-content: center;
  }
  nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    width: 100%;
  }
  nav a {
    font-size: 0.82rem;
    padding: 0.35rem 0.55rem;
  }
  .nav-chat-link {
    font-size: 0.82rem;
    padding: 0.38rem 0.7rem;
  }
  .nav-username { display: none; }
  .nav-user-btn { padding: 0.42rem 0.65rem; }
  .nav-dropdown, .signin-dropdown {
    right: 0;
    min-width: 200px;
    max-width: calc(100vw - 1rem);
  }

  /* Main layout */
  main {
    padding: 1rem 0.75rem;
  }
  .card {
    padding: 1.25rem 1rem;
    margin-left: 0;
    margin-right: 0;
  }

  /* Hero */
  .hero-section {
    padding: 2rem 1rem;
  }
  .hero-section h2 {
    font-size: 1.65rem;
  }

  /* Forms & grids */
  .radio-group { grid-template-columns: 1fr; }
  .form-grid   { grid-template-columns: 1fr; }
  .stats-row, .stats-bar {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .input-group  { flex-direction: column; }
  .list-actions { flex-direction: column; }
  .footer-grid  { grid-template-columns: 1fr; }
  .source-type-grid { grid-template-columns: repeat(2, 1fr); }

  /* Reference items */
  .reference-item {
    transform: none !important;
  }
  .ref-btn-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .btn-save-cit, .btn-remove-cit {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 120px;
  }

  /* Chat page */
  .chat-wrap {
    height: calc(100vh - 140px);
    min-height: 360px;
    border-radius: 10px;
  }
  .chat-toolbar { flex-wrap: wrap; gap: 0.35rem; }
  .payment-card { padding: 1rem 0.85rem; }
  .payment-card .amount { font-size: 1.35rem; }
  .upi-id { font-size: 0.78rem; flex-wrap: wrap; gap: 0.3rem; }

  /* Dashboard (My Citations) */
  .cit-card { padding: 1rem; }
  .cit-card-actions { flex-wrap: wrap; gap: 0.4rem; }
  .dash-toolbar { flex-wrap: wrap; gap: 0.5rem; }
  .search-wrap input { width: 130px; }
  .dash-hero { flex-direction: column; gap: 1rem; padding: 1.5rem 1rem; }

  /* Tables — horizontal scroll */
  .tcard, .table-card { overflow-x: auto; }
  table { min-width: 480px; }
  td, th { padding: 0.6rem 0.75rem; font-size: 0.82rem; }

  /* Auth gate modal */
  .auth-gate-card { max-width: 98vw; margin: 0 0.5rem; }
  .auth-gate-body { padding: 1.25rem 1rem 1.5rem; }

  /* Tools page */
  .tools-nav {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem;
  }
  .tool-tab {
    flex: 1 1 calc(50% - 0.4rem);
    min-width: 120px;
    font-size: 0.78rem;
    padding: 0.5rem 0.6rem;
    text-align: center;
  }
  .tool-panel { padding: 1rem 0.75rem; }
  .clock-grid { grid-template-columns: 1fr 1fr !important; }
  .calc-display { font-size: 1.5rem; }
  .calc-btn { padding: 0.6rem 0.3rem; font-size: 0.88rem; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .footer-bottom p { font-size: 0.78rem; }

  /* Modal */
  .modal-box, .modal { max-width: 96vw; padding: 1.5rem 1rem; }
  .modal-btns { flex-direction: column; gap: 0.5rem; }
  .modal-btns button { width: 100%; justify-content: center; }
}

/* ── Small mobile (≤ 480px) ── */
@media (max-width: 480px) {
  .header-content { padding: 0.6rem 0.75rem; }
  nav a { font-size: 0.75rem; padding: 0.3rem 0.45rem; }

  main { padding: 0.75rem 0.5rem; }
  .card { padding: 1rem 0.75rem; border-radius: 10px; }

  .hero-section h2 { font-size: 1.4rem; }
  .hero-section p  { font-size: 0.88rem; }

  .stats-row, .stats-bar {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.6rem;
  }
  .stat-num, .stat-box .num { font-size: 1.6rem; }

  .source-type-grid { grid-template-columns: repeat(2, 1fr); }

  .chat-wrap { height: calc(100vh - 120px); }
  .chat-header { padding: 0.75rem 1rem; }
  .msg { max-width: 92%; }
  .msg-bubble { font-size: 0.84rem; padding: 0.6rem 0.85rem; }

  .tool-tab { flex: 1 1 calc(50% - 0.35rem); font-size: 0.72rem; }

  .btn-save-cit, .btn-remove-cit, .btn { font-size: 0.78rem; padding: 0.42rem 0.75rem; }

  /* Tables stay scrollable */
  .tcard, .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .payment-card { padding: 0.85rem 0.75rem; }
  .upi-id { font-size: 0.73rem; }
}

/* ── Fix overflow globally ── */
.generator-container, .card, main, .tool-panel,
.chat-wrap, .cit-card, .reference-item,
.modal-box, .auth-gate-card {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ═══════════════════════════
   LOADING SPINNER
═══════════════════════════ */
.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════
   ENTRANCE ANIMATIONS
═══════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeUp 0.45s var(--ease-smooth) both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.12s; }
.card:nth-child(3) { animation-delay: 0.19s; }
.card:nth-child(4) { animation-delay: 0.26s; }

/* ═══════════════════════════
   UTILITY
═══════════════════════════ */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ═══════════════════════════
   NEW CITATION HIGHLIGHT
═══════════════════════════ */
@keyframes citationPop {
  0%   { background: linear-gradient(90deg, #6ee7b7 0%, #d1fae5 60%, #f0fdf4 100%); box-shadow: -4px 0 0 #059669; transform: scale(1.013); }
  60%  { background: linear-gradient(90deg, #a7f3d0 0%, #ecfdf5 60%, #f0fdf4 100%); box-shadow: -4px 0 0 #34d399; transform: scale(1); }
  100% { background: linear-gradient(90deg, #d1fae5 0%, #f0fdf4 55%, transparent 100%); box-shadow: -4px 0 0 #6ee7b7; transform: scale(1); }
}

.ref-line--new {
  border-radius: 0 6px 6px 0;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  background: linear-gradient(90deg, #d1fae5 0%, #f0fdf4 55%, transparent 100%);
  box-shadow: -4px 0 0 #6ee7b7;
  animation: citationPop 1.6s ease forwards;
  position: relative;
}


