
:root {
  --color-bg: linear-gradient(180deg, #e8f9ff 0%, #f9fdff 100%);
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-primary: #2563eb; /* Vibrant royal blue */
  --color-accent: #06b6d4; /* Aqua accent */
  --color-story-text: #0f172a;

  --border-glow: 1px solid rgba(37, 99, 235, 0.25);
  --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.15);
  --shadow-glow-hover: 0 0 25px rgba(6, 182, 212, 0.4);
  --focus-glow: 0 0 10px rgba(6, 182, 212, 0.6);

  --gradient-btn: linear-gradient(90deg, #2563eb, #06b6d4);
  --gradient-btn-hover: linear-gradient(90deg, #1e40af, #0891b2);

  --radius: 1rem;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

  --font-primary: 'Inter', system-ui, sans-serif;
  --font-heading: 'Poppins', system-ui, sans-serif;
}




    .dark {
      --color-bg: linear-gradient(180deg, #0f172a 0%, #020617 100%);
      --color-surface: #111827;
      --color-text: #f1f5f9;
      --color-muted: #94a3b8;
      --color-primary: #06b6d4; /* Electric cyan */
      --color-accent: #a855f7; /* Neon purple */
      --color-story-text: #e2e8f0;
      --border-glow: 1px solid rgba(6, 182, 212, 0.4);
      --shadow-glow: 0 0 20px rgba(168, 85, 247, 0.3);
      --shadow-glow-hover: 0 0 30px rgba(6, 182, 212, 0.6);
      --focus-glow: 0 0 12px rgba(168, 85, 247, 0.7);
      --gradient-btn: linear-gradient(90deg, #06b6d4, #a855f7);
      --gradient-btn-hover: linear-gradient(90deg, #0891b2, #9333ea);
      --shadow: 0 4px 25px rgba(6, 182, 212, 0.25);
    }

    * { box-sizing: border-box; }
    html, body { height: 100%; margin: 0; }
    body {
      background: var(--color-bg);
      color: var(--color-text);
      font-family: var(--font-primary);
      line-height: 1.6;
      font-size: 1rem;
    }

    /* Animations */
    .fade-in {
      animation: fadeIn 0.6s ease-out;
    }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .pulse {
      animation: pulse 2s ease-in-out infinite;
    }
    @keyframes pulse {
      0%, 100% { opacity: 0.7; }
      50% { opacity: 1; }
    }
    .spin {
      animation: spin 1s linear infinite;
    }
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    /* Tooltip */
    .tooltip { position: relative; }
    .tooltip .tooltiptext {
      visibility: hidden;
      width: 140px;
      background-color: #4b5563;
      color: #fff;
      text-align: center;
      border-radius: 6px;
      padding: 6px;
      position: absolute;
      z-index: 10;
      bottom: 130%;
      left: 50%;
      transform: translateX(-50%);
      opacity: 0;
      transition: opacity 0.3s;
    }
    .tooltip:hover .tooltiptext {
      visibility: visible;
      opacity: 1;
    }

    /* Header */
    header {
      background: var(--color-surface);
      box-shadow: var(--shadow);
      position: sticky;
      top: 0;
      z-index: 10;
      padding: 0.75rem 0;
    }
    .header-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      max-width: 1400px;
      margin: 0 auto;
      padding: 0 1rem;
      gap: 1rem;
    }
    .logo {
      font-family: var(--font-heading);
      font-size: 1.75rem;
      font-weight: 700;
      background: var(--gradient-btn);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      transition: transform 0.3s ease;
    }
    .logo:hover { transform: scale(1.05); }
    .headline {
      font-family: var(--font-heading);
      font-weight: 800;
      font-size: 2rem;
      text-align: center;
      letter-spacing: -0.02em;
      margin: 0;
      color: var(--color-primary);
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    .theme-toggle {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    /* Footer */
    footer {
      background: var(--color-surface);
      box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
      padding: 1rem 0;
      margin-top: 2rem;
    }
    .footer-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      max-width: 1400px;
      margin: 0 auto;
      padding: 0.75rem 1rem;
      gap: 1rem;
      font-size: 0.9rem;
    }
    .footer-inner a {
      color: var(--color-primary);
      text-decoration: none;
      font-weight: 500;
      transition: color 0.2s;
    }
    .footer-inner a:hover { color: var(--color-accent); }

    /* Ad Banner */
    .ad {
      border: var(--border-glow);
      border-radius: var(--radius);
      background: rgba(99, 102, 241, 0.1);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding: 0.75rem 1rem;
      margin: 1rem 0;
      font-family: var(--font-primary);
      box-shadow: var(--shadow-glow);
    }
    .ad strong { color: var(--color-accent); }
    .ad .ad-actions { display: flex; gap: 0.5rem; }
    .ad .close {
      border: var(--border-glow);
      background: transparent;
      color: var(--color-text);
      border-radius: var(--radius);
      padding: 0.35rem 0.6rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
    }
    .ad .close:hover { box-shadow: var(--shadow-glow-hover); transform: translateY(-2px); }

    /* Processing Animation */
    .processing {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: var(--color-surface);
      border: var(--border-glow);
      border-radius: var(--radius);
      padding: 2rem;
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 1rem;
      z-index: 100;
      opacity: 0;
      animation: appear 0.3s ease-out forwards;
    }
    @keyframes appear {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    .spinner {
      width: 40px;
      height: 40px;
      border: 4px solid var(--color-muted);
      border-top: 4px solid var(--color-primary);
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
    .processing-text {
      font-family: var(--font-heading);
      color: var(--color-text);
      font-weight: 500;
    }

    /* Main Layout */
    .container { max-width: 1400px; margin: 0 auto; padding: 1rem; }
    .layout {
      display: grid;
      gap: 1.5rem;
      margin: 1rem 0;
    }
    @media (min-width: 1024px) {
      .layout { grid-template-columns: 1fr 2fr; }
      .left { position: sticky; top: 1rem; align-self: start; }
    }
    @media (max-width: 1023px) {
      .layout { grid-template-columns: 1fr; }
    }

    /* Panels */
    .panel {
      background: var(--color-surface);
      border: var(--border-glow);
      border-radius: var(--radius);
      padding: 1.5rem;
      box-shadow: var(--shadow-glow);
    }
    .panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 1rem;
    }

    /* Buttons */
    .btn {
      border: none;
      border-radius: var(--radius);
      padding: 0.75rem 1.25rem;
      background: var(--gradient-btn);
      color: #ffffff;
      font-family: var(--font-primary);
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
    }
    .btn:hover {
      background: var(--gradient-btn-hover);
      box-shadow: var(--shadow-glow-hover);
      transform: translateY(-2px);
    }
    .btn.secondary {
      background: transparent;
      color: var(--color-text);
      border: var(--border-glow);
    }
    .btn.secondary:hover {
      background: rgba(99, 102, 241, 0.1);
      box-shadow: var(--shadow-glow-hover);
    }
    .btn.ghost { background: transparent; color: var(--color-text); border: none; }
    .btn.accent { background: var(--gradient-btn); color: #ffffff; }

    /* Inputs */
    .field { display: grid; gap: 0.4rem; margin-bottom: 0.75rem; }
    .label { font-size: 0.9rem; color: var(--color-muted); font-weight: 500; }
    select, textarea, input[type="text"] {
      width: 100%;
      border: var(--border-glow);
      background: var(--color-surface);
      color: var(--color-text);
      border-radius: var(--radius);
      padding: 0.75rem;
      font-size: 1rem;
      font-family: var(--font-primary);
      transition: all 0.3s ease;
    }
    select:focus, textarea:focus, input[type="text"]:focus {
      border-color: var(--color-primary);
      box-shadow: var(--focus-glow);
      outline: none;
    }
    textarea { min-height: 140px; resize: vertical; }

    /* Grid */
    .grid { display: grid; gap: 1rem; }

    /* Progress */
    .progress {
      height: 12px;
      border-radius: 999px;
      background: rgba(99, 102, 241, 0.3);
      overflow: hidden;
    }
    .progress > span {
      display: block;
      height: 100%;
      background: var(--gradient-btn);
      transition: width 0.2s linear;
    }

    /* Story */
    .story { white-space: pre-wrap; letter-spacing: 0.01em; font-size: 1rem; line-height: 1.7; color: var(--color-story-text); }
    .story h4 { margin: 0 0 0.75rem 0; color: var(--color-primary); font-size: 1.2rem; font-family: var(--font-heading); }

    /* Toggle */
    .switch { display: inline-flex; align-items: center; gap: 0.5rem; }
    .switch input { display: none; }
    .switch .track {
      width: 48px;
      height: 26px;
      border-radius: 999px;
      background: rgba(99, 102, 241, 0.3);
      position: relative;
      transition: background 0.2s;
    }
    .switch .thumb {
      position: absolute;
      top: 3px;
      left: 3px;
      width: 20px;
      height: 20px;
      border-radius: 999px;
      background: #ffffff;
      transition: transform 0.2s;
    }
    .switch input:checked + .track { background: var(--color-primary); }
    .switch input:checked + .track .thumb { transform: translateX(22px); }

    /* Toolbar */
    .toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

    /* Utility */
    .sr-only {
      position: absolute;
      clip: rect(1px, 1px, 1px, 1px);
      width: 1px;
      height: 1px;
      overflow: hidden;
      white-space: nowrap;
    }

    /* Responsive */
    @media (max-width: 640px) {
      .header-inner, .footer-inner {
        flex-direction: column;
        text-align: center;
      }
      .headline { font-size: 1.5rem; }
      .logo { font-size: 1.25rem; }
      .btn { padding: 0.6rem 1rem; }
      .panel { padding: 1rem; }
      .tooltip .tooltiptext { width: 120px; font-size: 0.8rem; }
      .processing { width: 90%; max-width: 300px; }
    }
