:root {
  color-scheme: light dark;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f6f7fb;
  color: #1a1f36;
}

::selection {
  background-color: #4c8eda;
  color: #fff;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  .preview-canvas {
    position: relative;
    flex: 1;
  }

  .diagram-output {
    flex: 1;
    min-height: 320px;
    border: 1px solid #d1d9e6;
    border-radius: 8px;
    background-color: #f9fbff;
    padding: 2.5rem 0.75rem 0.75rem 0.75rem;
    overflow: auto;
  }

  .app {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));

    .export-panel {
      position: absolute;
      top: 0.5rem;
      left: 0.5rem;
      display: inline-flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.45rem 0.6rem;
      border-radius: 8px;
      background-color: rgba(255, 255, 255, 0.92);
      box-shadow: 0 6px 15px rgba(56, 72, 107, 0.16);
      gap: 0.5rem;
      font-weight: 600;
      margin-bottom: 0.5rem;
    }

    .editor,
    .preview {
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
      border-radius: 12px;
      padding: 1rem;
      background-color: #f9fbff;
      box-shadow: 0 10px 30px rgba(56, 72, 107, 0.12);
    }

    .editor-input {
      display: grid;
      grid-template-columns: auto 1fr;
      align-items: stretch;
      margin-bottom: 0.75rem;
    }

    .line-numbers {
      margin: 0;
      padding: 0.75rem 0.75rem 0.75rem 0.5rem;
      font-size: 0.85rem;
      line-height: 1.5;
      font-family: "Fira Code", "Consolas", "Courier New", monospace;
      text-align: right;
      color: #7d8aac;
      background-color: #eef1f8;
      border: 1px solid #d1d9e6;
      border-right: none;
      border-radius: 8px 0 0 8px;
      min-width: 3rem;
      overflow: hidden;
      white-space: pre;
      user-select: none;
    }

    .editor textarea {
      resize: vertical;
      min-height: 320px;
      border: 1px solid #d1d9e6;
      border-left: none;
      border-radius: 0 8px 8px 0;
      padding: 0.75rem;
      font-family: "Fira Code", "Consolas", "Courier New", monospace;
      font-size: 0.95rem;
      line-height: 1.5;
      color: inherit;
      background-color: #f9fbff;
      margin: 0;
    }

    .editor textarea:focus {
      outline: 2px solid #4c8eda;
      outline-offset: 2px;
    }

    .controls {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.75rem;
      flex-wrap: wrap;
    }

    .controls button {
      background-color: #4c8eda;
      color: #ffffff;
      border: none;
      border-radius: 6px;
      padding: 0.6rem 1.2rem;
      font-size: 0.95rem;
      cursor: pointer;
      transition: transform 0.1s ease, box-shadow 0.1s ease;
    }

    .secondary-button {
      background-color: #dde4f5;
      color: #1a1f36;
    }

    .secondary-button:hover,
    .secondary-button:focus {
      box-shadow: 0 6px 14px rgba(29, 78, 216, 0.2);
    }

    .controls button:focus,
    .controls button:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 16px rgba(76, 142, 218, 0.25);
    }

    .controls button:active {
      transform: translateY(0);
      box-shadow: none;
    }

    .checkbox {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      font-size: 0.9rem;
      user-select: none;
    }

    .theme-picker {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
      font-size: 0.8rem;
      color: #4f5d78;
    }

    .theme-picker select {
      min-width: 160px;
      border: 1px solid #d1d9e6;
      border-radius: 6px;
      padding: 0.4rem 0.6rem;
      font-size: 0.9rem;
      background-color: #f9fbff;
      color: inherit;
      cursor: pointer;
    }

    .theme-picker select:focus {
      outline: 2px solid #4c8eda;
      outline-offset: 2px;
    }

    .editor-input:focus-within .line-numbers {
      color: #4c8eda;
    }

    .preview-canvas {
      position: relative;
      flex: 1;
    }

    .diagram-output {
      flex: 1;
      min-height: 320px;
      border: 1px solid #d1d9e6;
      border-radius: 8px;
      background-color: #f9fbff;
      padding: 2.5rem 0.75rem 0.75rem 0.75rem;
      overflow: auto;
    }

    .diagram-output svg {
      max-width: 100%;
    }

    .export-panel {
      position: absolute;
      top: 0.5rem;
      left: 0.5rem;
      display: inline-flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.45rem 0.6rem;
      border-radius: 8px;
      background-color: rgba(255, 255, 255, 0.92);
      box-shadow: 0 6px 15px rgba(56, 72, 107, 0.16);
    }

    .export-title {
      font-weight: 600;
      color: #4f5d78;
    }

    .export-buttons {
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
    }

    @media (prefers-color-scheme: dark) {
      :root {
        background-color: #f6f7fb;
        color: #1a1f36;
      }

      .app-footer,
      .preview {
        background-color: #f9fbff;
        box-shadow: 0 10px 30px rgba(56, 72, 107, 0.12);
      }

      .editor {
        background-color: #f9fbff;
        box-shadow: 0 10px 30px rgba(56, 72, 107, 0.12);
        color: #1a1f36;
      }

      .editor textarea {
        background-color: #f9fbff;
        border-color: #d1d9e6;
        color: #1a1f36;
      }

      .diagram-output {
        background-color: #f9fbff;
        border-color: #d1d9e6;
        color: #1a1f36;
      }

      .line-numbers {
        background-color: #eef1f8;
        border-color: #d1d9e6;
        color: #7d8aac;
      }

      .editor-input:focus-within .line-numbers {
        color: #4c8eda;
      }

      .controls button,
      .app-footer a {
        background-color: #4c8eda;
        color: #ffffff;
      }

      .controls button:hover,
      .controls button:focus {
        box-shadow: 0 6px 14px rgba(29, 78, 216, 0.2);
      }

      .secondary-button {
        background-color: #dde4f5;
        color: #1a1f36;
      }

      .theme-picker {
        color: inherit;
      }

      .theme-picker select {
        background-color: #f9fbff;
        border-color: #d1d9e6;
        color: inherit;
      }

      .export-title {
        color: #4f5d78;
      }
    }
