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

      /* ========================================
         CSS Variables - Light Theme (Default)
         ======================================== */
      :root {
        /* Backgrounds */
        --bg-primary: #ffffff;
        --bg-secondary: #f5f5f5;
        --bg-toolbar: #2c3e50;
        --bg-editor: #ffffff;
        --bg-editor-focus: #fafafa;
        --bg-format-bar: #ffffff;
        --bg-code-block: #f4f4f4;

        /* Text Colors */
        --text-primary: #333333;
        --text-secondary: #666666;
        --text-heading: #2c3e50;
        --text-heading-secondary: #34495e;
        --text-toolbar: #ffffff;

        /* Borders */
        --border-primary: #e0e0e0;
        --border-secondary: #d0d0d0;
        --border-heading: #eeeeee;
        --border-blockquote: #3498db;
        --border-table: #ddd;

        /* Accents */
        --accent-blue: #3498db;
        --accent-blue-hover: #2980b9;

        /* Shadows */
        --shadow-light: rgba(0, 0, 0, 0.1);
        --shadow-medium: rgba(0, 0, 0, 0.15);

        /* Transitions */
        --transition-speed: 250ms;
      }

      /* ========================================
         CSS Variables - Dark Theme
         ======================================== */
      [data-theme="dark"] {
        /* Backgrounds */
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-toolbar: #0f1419;
        --bg-editor: #1a1a1a;
        --bg-editor-focus: #222222;
        --bg-format-bar: #2d2d2d;
        --bg-code-block: #2a2a2a;

        /* Text Colors */
        --text-primary: #e0e0e0;
        --text-secondary: #a0a0a0;
        --text-heading: #f0f0f0;
        --text-heading-secondary: #e8e8e8;
        --text-toolbar: #e0e0e0;

        /* Borders */
        --border-primary: #404040;
        --border-secondary: #4a4a4a;
        --border-heading: #333333;
        --border-blockquote: #66b3ff;
        --border-table: #505050;

        /* Accents */
        --accent-blue: #66b3ff;
        --accent-blue-hover: #52a3ff;

        /* Shadows */
        --shadow-light: rgba(0, 0, 0, 0.3);
        --shadow-medium: rgba(0, 0, 0, 0.4);
      }

      /* ========================================
         Smooth Transitions
         ======================================== */
      * {
        transition: background-color var(--transition-speed) ease,
          color var(--transition-speed) ease,
          border-color var(--transition-speed) ease;
      }

      body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
        background: var(--bg-secondary);
        color: var(--text-primary);
        line-height: 1.6;
      }

      .container {
        max-width: 100%;
        margin: 0 auto;
        background: var(--bg-primary);
        min-height: 100vh;
        box-shadow: 0 0 20px var(--shadow-light);
      }

      .toolbar {
        position: sticky;
        top: 0;
        background: var(--bg-toolbar);
        color: var(--text-toolbar);
        padding: 1rem 2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 2px 5px var(--shadow-light);
        z-index: 100;
      }

      .toolbar h1 {
        font-size: 1.5rem;
        font-weight: 500;
      }

      .buttons {
        display: flex;
        gap: 0.5rem;
      }

      button {
        background: var(--accent-blue);
        color: var(--text-toolbar);
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 4px;
        cursor: pointer;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
      }

      button:hover {
        background: var(--accent-blue-hover);
      }

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

      /* PDF Button Styles */
      #pdfBtn:disabled {
        background: #95a5a6;
        cursor: not-allowed;
        opacity: 0.6;
      }

      #pdfBtn:hover:not(:disabled) {
        background: #2980b9;
      }

      .loading-indicator {
        font-size: 1.2rem;
        animation: spin 1s linear infinite;
      }

      @keyframes spin {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }

      #githubBtn {
        background: transparent;
        color: white;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        transition: opacity 0.2s;
      }

      #githubBtn svg {
        fill: white;
      }

      #githubBtn:hover {
        opacity: 0.8;
      }

      .theme-toggle-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
      }

      .theme-toggle {
        position: relative;
        width: 40px;
        height: 20px;
        background: var(--border-primary);
        border-radius: 10px;
        cursor: pointer;
        transition: background-color 0.25s ease;
        border: 1px solid var(--border-secondary);
      }

      .theme-toggle:hover {
        background: var(--border-secondary);
      }

      .theme-toggle-slider {
        position: absolute;
        top: 2px;
        left: 2px;
        width: 14px;
        height: 14px;
        background: white;
        border-radius: 50%;
        transition: transform 0.25s ease;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
      }

      .theme-toggle[data-theme="dark"] {
        background: var(--accent-blue);
      }

      .theme-toggle[data-theme="dark"] .theme-toggle-slider {
        transform: translateX(20px);
      }

      #editor {
        padding: 2rem;
        min-height: calc(100vh - 80px);
        outline: none;
        border: 1px solid var(--border-primary);
        border-radius: 4px;
        margin: 1rem;
        background: var(--bg-editor);
        color: var(--text-primary);
      }

      #editor:focus {
        background: var(--bg-editor-focus);
        border-color: var(--border-secondary);
      }

      #editor h1 {
        font-size: 2rem;
        margin: 1.5rem 0 1rem;
        color: var(--text-heading);
        border-bottom: 2px solid var(--border-heading);
        padding-bottom: 0.5rem;
      }

      #editor h1:first-child {
        margin-top: 0;
      }

      #editor h2 {
        font-size: 1.5rem;
        margin: 1.5rem 0 1rem;
        color: var(--text-heading-secondary);
      }

      #editor h3 {
        font-size: 1.25rem;
        margin: 1.25rem 0 0.75rem;
        color: var(--text-heading-secondary);
      }

      #editor p {
        margin: 1rem 0;
      }

      #editor ul,
      #editor ol {
        margin: 1rem 0;
        padding-left: 2rem;
      }

      #editor li {
        margin: 0.5rem 0;
      }

      #editor blockquote {
        border-left: 4px solid var(--border-blockquote);
        padding-left: 1rem;
        margin: 1rem 0;
        color: var(--text-secondary);
        font-style: italic;
      }

      #editor code {
        background: var(--bg-code-block);
        padding: 0.2rem 0.4rem;
        border-radius: 3px;
        font-family: "Courier New", monospace;
        font-size: 0.9em;
        color: var(--text-primary);
      }

      #editor pre {
        background: var(--bg-code-block);
        padding: 1rem;
        border-radius: 4px;
        overflow-x: auto;
        margin: 1rem 0;
      }

      #editor pre code {
        background: none;
        padding: 0;
      }

      #editor a {
        color: var(--accent-blue);
        text-decoration: none;
      }

      #editor a:hover {
        text-decoration: underline;
      }

      #editor img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 1rem 0;
      }

      #editor hr {
        border: none;
        border-top: 2px solid var(--border-heading);
        margin: 2rem 0;
      }

      #editor table {
        border-collapse: collapse;
        width: 100%;
        margin: 1rem 0;
      }

      #editor th,
      #editor td {
        border: 1px solid var(--border-table);
        padding: 0.75rem;
        text-align: left;
      }

      #editor th {
        background: var(--bg-code-block);
        font-weight: 600;
      }

      #editor tr:nth-child(even) {
        background: var(--bg-editor-focus);
      }

      /* Mermaid Diagram Styles */
      .mermaid-wrapper {
        margin: 1rem 0;
        padding: 1rem;
        background: var(--bg-code-block);
        border-radius: 8px;
        border: 1px solid var(--border-primary);
        overflow-x: auto;
        text-align: center;
      }

      .mermaid-wrapper svg {
        max-width: 100%;
        height: auto;
      }

      .mermaid-wrapper .mermaid-error {
        color: #e74c3c;
        padding: 1rem;
        font-family: monospace;
        white-space: pre-wrap;
        text-align: left;
      }

      .mermaid-source {
        display: none;
      }

      /* Dark mode adjustments for Mermaid */
      [data-theme="dark"] .mermaid-wrapper {
        background: var(--bg-code-block);
      }

      .format-bar {
        position: absolute;
        background: var(--bg-format-bar);
        border: 1px solid var(--border-table);
        border-radius: 6px;
        padding: 0.5rem;
        display: none;
        gap: 0.25rem;
        box-shadow: 0 4px 12px var(--shadow-medium);
        z-index: 1000;
        align-items: center;
      }

      .format-bar.visible {
        display: flex;
      }

      .format-btn {
        background: var(--bg-format-bar);
        color: var(--text-primary);
        border: 1px solid var(--border-table);
        padding: 0.4rem 0.6rem;
        border-radius: 4px;
        cursor: pointer;
        font-size: 0.85rem;
        font-weight: 600;
        min-width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .format-btn:hover {
        background: var(--bg-editor-focus);
        border-color: var(--border-secondary);
      }

      .format-btn:active {
        background: var(--bg-secondary);
        transform: translateY(0);
      }

      .format-btn.active {
        background: var(--accent-blue);
        color: var(--text-toolbar);
        border-color: var(--accent-blue);
      }

      .separator {
        width: 1px;
        height: 24px;
        background: var(--border-table);
        margin: 0 0.25rem;
      }

      @media (max-width: 768px) {
        .container {
          max-width: 100%;
          box-shadow: none;
        }

        .toolbar {
          padding: 0.75rem 1rem;
          flex-direction: column;
          gap: 0.75rem;
          align-items: stretch;
        }

        .toolbar h1 {
          font-size: 1.25rem;
          text-align: center;
        }

        .buttons {
          flex-wrap: wrap;
          justify-content: center;
          gap: 0.4rem;
        }

        button {
          padding: 0.4rem 0.6rem;
          font-size: 0.85rem;
          gap: 0.3rem;
          flex: 1 1 auto;
          min-width: fit-content;
          max-width: 120px;
        }

        button svg {
          width: 16px;
          height: 16px;
        }

        #clearBtn {
          height: 32px;
        }

        .theme-toggle-container {
          flex-direction: row;
          gap: 0.5rem;
          align-items: center;
        }

        #githubBtn {
          padding: 0.4rem;
        }

        #githubBtn svg {
          width: 24px;
          height: 24px;
        }

        #editor {
          padding: 1rem;
          min-height: calc(100vh - 120px);
          font-size: 0.95rem;
        }

        #editor h1 {
          font-size: 1.5rem;
        }

        #editor h2 {
          font-size: 1.25rem;
        }

        #editor h3 {
          font-size: 1.1rem;
        }

        .format-bar {
          flex-wrap: wrap;
          max-width: 90vw;
        }

        .format-btn {
          min-width: 28px;
          height: 28px;
          padding: 0.3rem 0.5rem;
        }
      }

      @media (max-width: 480px) {
        .toolbar h1 {
          font-size: 1.1rem;
        }

        button {
          font-size: 0;
          padding: 0.5rem;
          min-width: 40px;
          max-width: 50px;
          justify-content: center;
        }

        button svg {
          width: 18px;
          height: 18px;
          margin: 0;
        }

        #editor {
          padding: 0.75rem;
          font-size: 0.9rem;
        }

        #editor h1 {
          font-size: 1.35rem;
        }

        #editor h2 {
          font-size: 1.15rem;
        }

        #editor h3 {
          font-size: 1rem;
        }
      }

      /* ========================================
         Print/PDF Export Styles
         Force light mode and clean layout
         ======================================== */
      @media print {
        body {
          background: #ffffff !important;
          color: #333333 !important;
        }

        #editor {
          background: #ffffff !important;
          color: #333333 !important;
          border: none !important;
          margin: 0 !important;
          padding: 2rem !important;
          min-height: auto !important;
        }

        #editor h1 {
          color: #2c3e50 !important;
          border-bottom-color: #eeeeee !important;
        }

        #editor h2,
        #editor h3 {
          color: #34495e !important;
        }

        #editor blockquote {
          border-left-color: #3498db !important;
        }

        #editor code {
          background: #f4f4f4 !important;
          color: #c7254e !important;
        }

        #editor pre {
          background: #f4f4f4 !important;
        }

        #editor pre code {
          color: #333333 !important;
        }

        #editor a {
          color: #3498db !important;
        }

        #editor table {
          border-color: #ddd !important;
        }

        #editor th,
        #editor td {
          border-color: #ddd !important;
        }

        #editor th {
          background: #f5f5f5 !important;
        }
      }
