:root {
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  
  /* Light Mode - Premium Slate Palette */
  --bg-primary: #f1f5f9;
  --bg-secondary: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.75);
  --card-border: rgba(226, 232, 240, 0.8);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-light: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.15);
  --accent: #06b6d4;
  --accent-hover: #0891b2;
  --accent-glow: rgba(6, 182, 212, 0.15);
  --border-color: #cbd5e1;
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-focus-border: #4f46e5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(79, 70, 229, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 20px 40px -15px rgba(15, 23, 42, 0.08);
  
  --btn-grad: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  --btn-grad-hover: linear-gradient(135deg, #4338ca 0%, #0891b2 100%);
}

[data-theme="dark"] {
  /* Dark Mode - Premium Cosmic & Neon Palette */
  --bg-primary: #05070c;
  --bg-secondary: #0b0f19;
  --card-bg: rgba(11, 15, 25, 0.65);
  --card-border: rgba(99, 102, 241, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-light: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --accent-glow: rgba(34, 211, 238, 0.25);
  --border-color: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(17, 24, 39, 0.8);
  --input-focus-border: #6366f1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px -5px rgba(99, 102, 241, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px -5px rgba(99, 102, 241, 0.05);
  
  --btn-grad: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
  --btn-grad-hover: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: radial-gradient(circle at top right, var(--primary-glow) 0%, transparent 40%),
              radial-gradient(circle at bottom left, var(--accent-glow) 0%, transparent 40%),
              var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  transition: background 0.4s ease, color 0.4s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* ========== Cam Küre Efektleri (Aura) ========== */
body::before, body::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.5;
  pointer-events: none;
}
body::before {
  top: 15%;
  left: 10%;
  background: var(--primary);
}
body::after {
  bottom: 15%;
  right: 10%;
  background: var(--accent);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  flex: 1;
}

header {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
}

h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  background: var(--btn-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 10px rgba(99, 102, 241, 0.15));
}

header small {
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: block;
}

/* ========== Devrimsel Glassmorphic Form Kartı ========== */
.form-stil {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 30px;
  margin: 25px 0;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              border-color 0.4s ease;
  position: relative;
  overflow: hidden;
}

.form-stil::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--btn-grad);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.form-stil:hover {
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1), 0 0 40px -10px var(--primary-glow);
  border-color: rgba(99, 102, 241, 0.25);
}

.form-stil:hover::before {
  opacity: 1;
}

.caption {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 25px;
}

.caption h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
  display: flex;
  align-items: center;
  width: 100%;
  flex: 1;
  line-height: 1;
}

.caption svg {
  color: var(--primary);
  transition: transform 0.3s ease;
}

.caption svg:hover {
  transform: rotate(45deg) scale(1.1);
}

/* ========== Dikey Ortalama & Türkçe Suffix Ekleri ========== */
.vertical-center {
  display: inline-block;
  vertical-align: middle;
  line-height: normal;
}

span.attachment {
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}

.width-calc-20 {
  width: calc(100% - 20px) !important;
}

.width-calc-30 {
  width: calc(100% - 30px) !important;
}

/* ========== Neon İnput Kutuları ========== */
input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 12px 16px;
  background-color: var(--input-bg);
  color: var(--text-primary);
  transition: border-color 0.25s, box-shadow 0.25s, background-color 0.3s;
  box-shadow: var(--shadow-sm);
  outline: none;
}

input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 4px var(--primary-glow), 0 0 15px -3px var(--primary);
  background-color: var(--bg-secondary);
}

input[readonly] {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: var(--card-border);
  color: var(--primary);
  font-weight: 700;
  cursor: default;
  box-shadow: none;
}

[data-theme="dark"] input[readonly] {
  background-color: rgba(255, 255, 255, 0.03);
}

input.input-error {
  background-color: rgba(239, 68, 68, 0.08) !important;
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15), 0 0 10px -2px #ef4444 !important;
}

/* ========== Devrimsel Gradual Neon Buton ========== */
button {
  border: none;
  background: var(--btn-grad);
  padding: 12px 24px;
  color: #ffffff;
  cursor: pointer;
  border-radius: 12px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: var(--shadow-md), 0 4px 20px -2px var(--primary-glow);
  transition: background 0.3s, transform 0.2s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--btn-grad-hover);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
}

button:hover {
  box-shadow: var(--shadow-lg), 0 0 25px 0 var(--primary-glow);
  transform: translateY(-1px);
}

button:hover::before {
  opacity: 1;
}

button:active {
  transform: translateY(1px);
}

/* ========== Reset for Icon Buttons ========== */
button[style*="background:transparent"],
button[style*="background:none"],
button[style*="background: transparent"],
button[style*="background: none"] {
  box-shadow: none !important;
  border-radius: 0 !important;
  overflow: visible !important;
  min-width: auto !important;
  padding: 0 !important;
}

button[style*="background:transparent"]::before,
button[style*="background:none"]::before,
button[style*="background: transparent"]::before,
button[style*="background: none"]::before {
  display: none !important;
}

button[style*="background:transparent"]:hover,
button[style*="background:none"]:hover,
button[style*="background: transparent"]:hover,
button[style*="background: none"]:hover {
  box-shadow: none !important;
  transform: none !important;
}

/* ========== Sonuç Paneli ========== */
.result {
  min-height: 24px;
  visibility: hidden;
  margin-top: 20px;
  padding: 15px;
  background: rgba(99, 102, 241, 0.06);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: fadeIn 0.4s ease forwards;
}

.result span {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.result div {
  display: flex;
  align-items: center;
}

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

.result-border {
  display: block;
  width: 100%;
  border-top: 1px dashed var(--border-color);
  margin: 20px 0;
}

/* ========== SVG Progress Circle & Visuals ========== */
.progress-visual, .progress-info { display: none !important; }

/* ========== Modern Tooltip Tasarımı & Kopyalama İkonları ========== */
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tooltip svg {
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease;
}

.tooltip svg:hover {
  transform: scale(1.15);
  color: var(--primary);
}

.tooltip .tooltiptext {
  visibility: hidden;
  position: absolute;
  z-index: 9999;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--text-primary);
  color: var(--bg-secondary);
  text-align: center;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none; /* Metin kutusu fareyi engellemesin */
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--text-primary) transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Tooltip ile dikey ortalama sınıfı çakışması çözümü */
.tooltip.vertical-center {
  display: inline-flex;
  cursor: pointer;
}

/* ========== Tema Değiştirici (Theme Switcher) ========== */
.header-controls {
  position: absolute;
  top: 30px;
  right: 30px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 15px;
}

.theme-switch-wrapper {
  display: flex;
  align-items: center;
}

.lang-switch-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.lang-flag {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  opacity: 0.4;
}

.lang-flag.active {
  opacity: 1;
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.lang-flag:hover {
  opacity: 1;
  transform: scale(1.1);
}

.flag-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.theme-switch {
  display: inline-block;
  height: 38px;
  position: relative;
  width: 68px;
}

.theme-switch input {
  display: none !important;
}

.slider {
  background-color: var(--border-color);
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.slider svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  z-index: 2;
  transition: .4s ease;
  cursor: pointer;
}

.slider.round::before {
  background-color: var(--bg-secondary);
  bottom: 3px;
  content: "";
  height: 30px;
  left: 4px;
  position: absolute;
  transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 30px;
  border-radius: 50%;
  z-index: 1;
  box-shadow: var(--shadow-md);
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

input:checked + .slider.round::before {
  transform: translateX(28px);
  background-color: #ffffff;
}

input:checked + .slider svg.sun {
  color: rgba(255, 255, 255, 0.3);
  transform: scale(0.8) rotate(-45deg);
}

input:checked + .slider svg.moon {
  color: #ffffff;
  transform: scale(1) rotate(0);
}

/* ========== Footer Stilleri ========== */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
  padding: 30px 40px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  border-radius: 24px 24px 0 0;
  margin-top: 60px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

footer div {
  width: auto;
}

footer ul {
  list-style: none;
  display: flex;
  gap: 20px;
}

footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s, text-shadow 0.2s;
}

footer a:hover {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

/* ========== Eklerin Hizalanması (Gramer) ========== */
span.attachment {
  font-weight: 800;
  color: var(--primary);
  margin-left: 2px;
}

/* ========== SEO & SSS Akordeon Tasarımı (Devrimsel) ========== */
.seo-section {
  margin-top: 60px;
  background: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 35px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}

.seo-section h3 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 25px;
  letter-spacing: -0.03em;
  background: var(--btn-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.accordion-item {
  border-bottom: 1px solid var(--border-color);
  padding: 15px 0;
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-header {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: color 0.2s;
}

.accordion-header:hover {
  color: var(--primary);
}

.accordion-header::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 400;
  transition: transform 0.3s ease;
}

.accordion-item.active .accordion-header::after {
  transform: rotate(45deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.7;
}

.accordion-item.active .accordion-content {
  max-height: 1000px;
  padding-top: 15px;
  transition: max-height 0.5s cubic-bezier(1, 0, 1, 0);
}

/* ========== Responsive Grid (Bootstrap Benzeri) ========== */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -8px;
  margin-left: -8px;
  align-items: center;
}

.form-stil .row > div {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
}

.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12,
.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
  position: relative;
  width: 100%;
  padding-right: 8px;
  padding-left: 8px;
}

.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-10 { flex: 0 0 83.333%; max-width: 83.333%; }
.col-2  { flex: 0 0 16.666%; max-width: 16.666%; }

@media (min-width: 768px) {
  .form-stil.row {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 15px !important;
  }

  /* Başlık, kesikli çizgiler ve sonuç/grafik alanları tüm satırı kaplasın */
  .form-stil.row > .caption,
  .form-stil.row > .result-border,
  .form-stil.row > .result,
  .form-stil.row > .progress-visual {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Geri kalan input ve buton kolonları yan yana dursun */
  .form-stil.row > div:not(.caption):not(.result):not(.progress-visual) {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    white-space: nowrap !important;
  }

  /* Türkçe gramer eki taşıyan kolonları masaüstünde 160px'e sabitle, sarsıntıyı tamamen önle! */
  .form-stil.row > div:has(.attachment) {
    width: 160px !important;
    flex: 0 0 160px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }

  .form-stil.row > div:has(.attachment) input {
    width: 120px !important;
    flex: 0 0 120px !important;
  }

  .form-stil.row > div:has(.attachment) span.attachment {
    width: 30px !important;
    flex: 0 0 30px !important;
    margin-left: 8px !important;
    display: inline-block !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    text-align: left !important;
  }

  .form-stil input:not([readonly]) {
    width: 120px !important;
  }

  .form-stil input[readonly] {
    width: 140px !important;
  }

  .form-stil span:not(.tooltiptext):not(.attachment) {
    white-space: nowrap !important;
  }

  /* Butonlar, inputlar ve spanlar üzerindeki tüm bozucu absolute konumlandırma ve kaymaları sıfırla */
  .form-stil button, .form-stil input, .form-stil span:not(.tooltiptext) {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
  }

  .col-md-1 { flex: 0 0 8.333%; max-width: 8.333%; }
  .col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
  .col-md-3 { flex: 0 0 25%; max-width: 25%; }
  .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; }
  .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
  .col-md-9 { flex: 0 0 75%; max-width: 75%; }
  .col-md-10 { flex: 0 0 83.333%; max-width: 83.333%; }
  .col-md-11 { flex: 0 0 91.666%; max-width: 91.666%; }
  .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (min-width: 992px) {
  .col-lg-1 { flex: 0 0 8.333%; max-width: 8.333%; }
  .col-lg-2 { flex: 0 0 16.666%; max-width: 16.666%; }
  .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
  .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-lg-5 { flex: 0 0 41.666%; max-width: 41.666%; }
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
  .col-lg-7 { flex: 0 0 58.333%; max-width: 58.333%; }
  .col-lg-8 { flex: 0 0 66.666%; max-width: 66.666%; }
  .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
  .col-lg-10 { flex: 0 0 83.333%; max-width: 83.333%; }
  .col-lg-11 { flex: 0 0 91.666%; max-width: 91.666%; }
  .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (max-width: 767px) {
  .container {
    padding-top: 15px;
  }
  .header-controls {
    position: relative;
    top: 0;
    right: 0;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 0;
    width: 100%;
  }
  h1 { font-size: 2.2rem; }
  .form-stil { padding: 20px; }
  .form-stil.row > div {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }
  .form-stil.row > div:last-child {
    margin-bottom: 0;
  }
  footer { flex-direction: column; gap: 20px; text-align: center; }
  footer ul { justify-content: center; }
}

/* ========== History Panel ========== */
.history-toggle-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.history-toggle-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.history-toggle-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.history-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 100%;
  max-width: 400px;
  height: 100vh;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--card-border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  z-index: 1001;
  transition: right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.history-panel.open {
  right: 0;
}

.history-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

.history-overlay.open {
  opacity: 1;
  visibility: visible;
}

.history-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-header h4 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.history-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.history-close-btn:hover {
  color: var(--accent);
}

.history-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.history-item {
  background: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.history-item strong {
  color: var(--primary);
}

.history-time {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: right;
}

.history-empty {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 40px;
  font-size: 0.95rem;
}

.history-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
}

.history-clear-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.history-clear-btn:hover {
  background: #ef4444;
  color: #fff;
}

/* Responsive */
@media (max-width: 576px) {
  .history-toggle-btn {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
  }
}


/* ========== Table of Contents Accordion ========== */
html {
  scroll-behavior: smooth;
}

.toc-accordion {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin: 15px 0 25px 0;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.15);
  overflow: hidden;
  transition: all 0.3s ease;
}

.toc-accordion[open] {
  box-shadow: 0 12px 20px rgba(99, 102, 241, 0.25);
}

.toc-summary {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
  list-style: none; /* Remove default triangle in FF/Safari */
  user-select: none;
  transition: all 0.2s ease;
}

.toc-summary:hover {
  background: rgba(99, 102, 241, 0.15);
  transform: scale(1.005);
}

.toc-summary:active {
  transform: scale(0.995);
}

/* Remove default triangle in Chrome */
.toc-summary::-webkit-details-marker {
  display: none;
}

.toc-icon {
  color: var(--primary);
  transition: transform 0.3s ease;
}

.toc-accordion[open] .toc-icon {
  transform: rotate(180deg);
}

.toc-nav {
  padding: 15px 20px 20px;
  border-top: 1px solid var(--border-color);
}

.toc-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.toc-item {
  margin: 0;
  padding: 0;
}

.toc-link {
  display: block;
  padding: 10px 15px;
  background: rgba(99, 102, 241, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-color);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
}

.toc-link:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

.dark-mode .toc-link:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ========== Micro-Animations ========== */
@keyframes pulse-success {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    background-color: rgba(99, 102, 241, 0.1);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    background-color: var(--bg-input);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    background-color: var(--bg-input);
  }
}

.animate-pulse {
  animation: pulse-success 0.6s ease-out;
}

/* INP & CLS Optimization */
.result, .progress-visual {
  contain: layout style paint;
}


.caption > div {
  display: flex;
  align-items: center;
  height: 100%;
}
.caption > div > a {
  display: flex;
  align-items: center;
  line-height: 1;
}
.caption h2 button {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 8px;
  margin-left: 15px !important;
  line-height: 1;
  border-radius: 8px;
  transition: all 0.2s ease;
  background: transparent;
}
.caption h2 button:hover {
  background: rgba(99, 102, 241, 0.1) !important;
  transform: scale(1.05);
}


/* SEO Article Styling */
.seo-article {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}
.seo-article h2 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: var(--text-primary);
  font-weight: 700;
}
.seo-article h3 {
  font-size: 1.25rem;
  margin-top: 20px;
  margin-bottom: 10px;
  color: var(--text-primary);
  font-weight: 600;
}
.seo-article p {
  margin-bottom: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.seo-article .article-list {
  margin-bottom: 15px;
  margin-left: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
  list-style-type: disc;
}
.seo-article .article-list li {
  margin-bottom: 5px;
}
.seo-article strong {
  color: var(--text-primary);
  font-weight: 600;
}


.seo-article h3 a.article-heading-link {
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
}
.seo-article h3 a.article-heading-link:hover {
  border-bottom-color: var(--primary-color);
  color: var(--primary-color);
}


/* SEO LLM-Friendly Table */
.seo-formula-table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}
.seo-formula-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
}
.seo-formula-table th, .seo-formula-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.seo-formula-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}
.seo-formula-table tr:last-child td {
  border-bottom: none;
}
.seo-formula-table td:first-child {
  font-weight: 500;
  color: var(--text-primary);
}
.seo-formula-table td:last-child {
  font-family: monospace;
  color: var(--primary);
  font-size: 1.1em;
  background: var(--bg-secondary);
}
