﻿:root {
  --bg: #f1f5fb;
  --bg-accent: #e6eef9;
  --card: #ffffff;
  --primary: #2f6fe4;
  --primary-dark: #2557b3;
  --accent: #8eb4ff;
  --text: #1f2a44;
  --muted: #5c6e92;
  --border: #e0e6f2;
  --shadow: 0 18px 45px rgba(32, 52, 96, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Barlow Semi Condensed", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f7f9fe 0%, #eef3fb 45%, #f7f9fe 100%);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Crect width='240' height='240' fill='none'/%3E%3Cg fill='none' stroke='%2392a6d6' stroke-width='2' opacity='0.35'%3E%3Cpath d='M26 28h32l-16 28z'/%3E%3Cpath d='M174 26h34l-17 30z'/%3E%3Cpath d='M48 168h30l-15 26z'/%3E%3C/g%3E%3Ctext x='38' y='108' fill='%2392a6d6' font-size='26' font-family='Arial'%3E%CF%80%3C/text%3E%3Ctext x='150' y='156' fill='%2392a6d6' font-size='24' font-family='Arial'%3E%E2%88%AB%3C/text%3E%3Ctext x='92' y='210' fill='%2392a6d6' font-size='22' font-family='Arial'%3E%E2%88%91%3C/text%3E%3C/svg%3E");
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  display: grid;
  gap: 32px;
}

.hero {
  text-align: center;
  padding: 16px 24px 8px;
}

.hero-title {
  font-family: "ZCOOL XiaoWei", serif;
  font-size: clamp(2.4rem, 3.4vw, 3.4rem);
  color: var(--primary);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 auto 18px;
  max-width: 760px;
}

.hero-strip {
  display: inline-flex;
  gap: 12px;
  background: var(--bg-accent);
  padding: 6px 18px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--primary-dark);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(46, 100, 202, 0.08);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card h2 {
  margin: 0;
  font-size: 1.4rem;
}

.badge {
  background: var(--primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.outline {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid var(--accent);
}

.hint {
  margin: 0 0 18px;
  color: var(--muted);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #f8faff;
  font-family: "Barlow Semi Condensed", "Segoe UI", sans-serif;
  font-size: 1rem;
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(142, 180, 255, 0.3);
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  margin-top: 16px;
}

.select-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
}

select {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8faff;
  color: var(--primary-dark);
  font-family: "Barlow Semi Condensed", "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.example-label {
  color: var(--muted);
  font-weight: 600;
}

.status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #f3f6fd;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

button {
  border: none;
  font-family: "Barlow Semi Condensed", "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

button.primary {
  background: linear-gradient(135deg, #2f6fe4, #3b8af2);
  color: #fff;
  box-shadow: 0 10px 20px rgba(46, 109, 228, 0.25);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(46, 109, 228, 0.3);
}

button.ghost {
  background: #f5f8ff;
  border: 1px solid var(--border);
  color: var(--primary-dark);
}

button.ghost:hover {
  background: #eaf0ff;
}

.output {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.formula-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-radius: 14px;
  background: #f9fbff;
  border: 1px solid rgba(47, 111, 228, 0.12);
}

.formula-line.error {
  border-color: rgba(217, 69, 69, 0.4);
  background: #fff6f6;
}

.line-no {
  font-weight: 700;
  color: var(--primary-dark);
  background: rgba(47, 111, 228, 0.12);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.math {
  overflow-x: auto;
}

.katex-display {
  margin: 0;
}

.empty-state {
  margin-top: 18px;
  padding: 20px;
  border-radius: 14px;
  background: #f3f6fd;
  color: var(--muted);
  border: 1px dashed var(--border);
}

.footer {
  text-align: center;
  padding: 24px 16px 36px;
  color: var(--muted);
  font-size: 0.95rem;
}

.footer-note {
  margin-top: 6px;
}

@media (max-width: 720px) {
  .page {
    padding: 48px 18px 32px;
  }

  .card {
    padding: 22px;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .formula-line {
    grid-template-columns: 1fr;
  }

  .line-no {
    width: fit-content;
  }
}

/* Settings Panel */
.settings-panel {
  margin-top: 16px;
  overflow: hidden;
  max-height: 1200px;
  opacity: 1;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--bg-accent);
  border-radius: 14px;
  border: 1px solid rgba(47, 111, 228, 0.08);
}

.settings-panel.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  border-width: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 20px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-item select,
.setting-item input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
}

/* Ghost Blue Button (for Random) */
.ghost-blue {
    background: rgba(47, 111, 228, 0.1);
    color: var(--primary);
    box-shadow: none;
}
.ghost-blue:hover {
    background: rgba(47, 111, 228, 0.2);
    transform: translateY(-1px);
}

.input-actions {
    justify-content: space-between;
}

.icon-only {
    padding: 10px 14px;
    font-size: 1.2rem;
    line-height: 1;
}

/* Advanced Settings */
.settings-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
    margin: 10px 20px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid rgba(47, 111, 228, 0.1);
    padding-bottom: 6px;
}

.advanced-grid {
    background: rgba(47, 111, 228, 0.03);
}


/* Checkbox alignment */
.checkbox-item {
    flex-direction: row;
    align-items: center;
    padding-top: 24px;
}

.checkbox-item input {
    width: auto;
    margin: 0;
}

.checkbox-item label {
    margin: 0;
    text-transform: none;
    cursor: pointer;
}

/* Button Group for Rules + Settings */
.button-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Rules Tooltip */
.rules-container {
  position: relative;
  display: inline-flex;
}

.rules-tooltip {
  position: absolute;
  top: 100%;
  right: 0; /* Align to right edge */
  margin-top: 12px;
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 
    0 10px 40px -10px rgba(47, 111, 228, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.98);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
  color: var(--text-secondary);
  text-align: left;
  pointer-events: none;
}

.rules-container.active .rules-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.rules-tooltip h3 {
  margin: 0 0 8px 0;
  color: var(--primary);
  font-size: 1.1em;
  font-weight: 700;
}

.rules-tooltip p {
  margin: 0 0 12px 0;
  font-size: 0.9em;
  line-height: 1.5;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(47, 111, 228, 0.05);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.rules-list span {
  font-size: 0.85em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rules-list strong {
  color: var(--primary-dark);
  font-family: inherit;
  width: 80px;
}

.rules-extra {
  font-size: 0.8em !important;
  color: var(--muted);
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 8px;
  margin-bottom: 0 !important;
}

/* Arrow for tooltip */
.rules-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: white;
  transform: rotate(45deg);
  border-left: 1px solid rgba(255,255,255,0.5);
  border-top: 1px solid rgba(255,255,255,0.5);
}
