
    :root, [data-theme="crimson"] {
      --bg: #141417;
      --surface: #1c1c21;
      --surface-hover: #25252c;
      --border: #2e2e38;
      --text: #ececf1;
      --text-muted: #8e8e9e;
      --accent: #dc2626;
      --accent-hover: #ef4444;
      --accent-soft: rgba(220, 38, 38, 0.14);
    }

    [data-theme="gruvbox"] {
      --bg: #1d2021;
      --surface: #282828;
      --surface-hover: #3c3836;
      --border: #504945;
      --text: #ebdbb2;
      --text-muted: #a89984;
      --accent: #fb4934;
      --accent-hover: #cc241d;
      --accent-soft: rgba(251, 73, 52, 0.15);
    }

    [data-theme="paper"] {
      --bg: #faf9f6;
      --surface: #f0eee9;
      --surface-hover: #e5e2db;
      --border: #d6d2c9;
      --text: #1c1b18;
      --text-muted: #6e6a61;
      --accent: #b91c1c;
      --accent-hover: #991b1b;
      --accent-soft: rgba(185, 28, 28, 0.1);
    }

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

    html, body {
      height: 100%;
      width: 100%;
      background: var(--bg);
      color: var(--text);
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      overflow: hidden;
    }

    .app {
      display: flex;
      height: 100vh;
      width: 100vw;
      position: relative;
    }

    /* Main Canvas */
    .canvas {
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      min-width: 0;
    }

    textarea#editor {
      flex: 1;
      width: 100%;
      height: 100%;
      background: transparent;
      color: var(--text);
      border: none;
      outline: none;
      resize: none;
      padding: 2rem clamp(1.25rem, 6vw, 4.5rem);
      font-family: inherit;
      font-size: 15px;
      line-height: 1.65;
      caret-color: var(--accent);
    }

    textarea#editor::placeholder {
      color: var(--text-muted);
      opacity: 0.6;
    }

    /* Read-Only View Mode */
    #viewer {
      display: none;
      flex: 1;
      overflow-y: auto;
      padding: 2rem clamp(1.25rem, 6vw, 4.5rem);
      font-size: 15px;
      line-height: 1.65;
      white-space: pre-wrap;
      word-break: break-word;
    }

    #viewer a.bundle-link {
      color: var(--accent-hover);
      text-decoration: underline;
      text-underline-offset: 3px;
    }

    .view-banner {
      display: none;
      align-items: center;
      justify-content: space-between;
      padding: 0.6rem 1.25rem;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      font-size: 12px;
      color: var(--text-muted);
    }

    body.is-view .view-banner { display: flex; }
    body.is-view #viewer { display: block; }
    body.is-view #editor { display: none; }

    /* Edge Toggle Handle */
    .drawer-toggle {
      position: fixed;
      top: 14px;
      right: 14px;
      z-index: 30;
      background: var(--surface);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 6px 10px;
      font-family: inherit;
      font-size: 12px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: border-color 0.15s, background 0.15s;
    }

    .drawer-toggle:hover {
      border-color: var(--accent);
      background: var(--surface-hover);
    }

    /* Slide-Out Utility Drawer */
    .drawer {
      width: 310px;
      height: 100%;
      background: var(--surface);
      border-left: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      transition: transform 0.2s ease, width 0.2s ease;
      z-index: 20;
      overflow-y: auto;
    }

    .drawer.collapsed {
      width: 0;
      border-left: none;
      overflow: hidden;
    }

    .drawer-inner {
      width: 310px;
      padding: 3.25rem 1rem 1rem;
      display: flex;
      flex-direction: column;
      gap: 1.15rem;
      flex: 1;
    }

    .section-label {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      margin-bottom: 0.45rem;
      display: block;
    }

    .btn-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }

    .btn-stack {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    button.tool-btn {
      background: var(--bg);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: 5px;
      padding: 7px 9px;
      font-family: inherit;
      font-size: 12px;
      text-align: left;
      cursor: pointer;
      transition: all 0.15s;
    }

    button.tool-btn:hover {
      border-color: var(--accent);
      background: var(--surface-hover);
    }

    button.tool-btn.primary {
      background: var(--accent-soft);
      border-color: var(--accent);
      color: var(--text);
      font-weight: 600;
    }

    button.tool-btn.primary:hover {
      background: var(--accent);
      color: #fff;
    }

    .theme-row {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
    }

    .theme-btn {
      background: var(--bg);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: 5px;
      padding: 6px;
      font-family: inherit;
      font-size: 11px;
      cursor: pointer;
      text-align: center;
    }

    .theme-btn.active {
      border-color: var(--accent);
      background: var(--accent-soft);
    }

    .drawer-footer {
      margin-top: auto;
      padding-top: 0.75rem;
      border-top: 1px solid var(--border);
      font-size: 11px;
      color: var(--text-muted);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .status-ok { color: #22c55e; }
    .status-warn { color: #f59e0b; }
    .status-crit { color: var(--accent-hover); }
  
/* Responsive drawer and keyboard states supplement the supplied design. */
.drawer.collapsed {display:none}
.drawer {max-width:calc(100vw - 16px);flex-shrink:0}
.drawer-inner {width:100%}
.app {height:100dvh;width:100%}
#editor,#viewer {min-height:0;padding-top:4rem;tab-size:4}
button:focus-visible,summary:focus-visible,a:focus-visible,input:focus-visible,#viewer:focus-visible {outline:2px solid var(--accent-hover);outline-offset:3px}
button:disabled {opacity:.5;cursor:default}
body.is-view [data-tpl],body.is-view [data-tx],body.is-view #text-tools {display:none}
.theme-btn {min-height:34px}
.check-row {display:flex;gap:.5rem;align-items:center;font-size:12px;margin-top:.75rem}
summary {font-size:12px;cursor:pointer;padding:.5rem 0}
.hint {font-size:11px;color:var(--text-muted);line-height:1.5;margin-bottom:.5rem}
.view-banner {padding-right:5rem;gap:.75rem;flex-wrap:wrap}
.drawer-footer {flex-wrap:wrap;gap:.75rem}
.drawer a {color:var(--text);text-underline-offset:3px}
#toast {max-width:100%;overflow-wrap:anywhere}
[data-theme="paper"] .status-ok {color:#166534}
[data-theme="paper"] .status-warn {color:#92400e}
dialog {margin:auto;padding:1.25rem;background:var(--surface);color:var(--text);border:1px solid var(--border);max-width:calc(100vw - 24px);width:560px}
dialog::backdrop {background:#0009}
dialog p {font-size:12px;line-height:1.5;margin:.75rem 0}
dialog textarea {width:100%;height:180px;margin-bottom:1rem;background:var(--bg);color:var(--text);padding:.75rem}
@media(max-width:640px) {.drawer {position:fixed;right:0;top:0;box-shadow:-8px 0 32px #0005}.canvas {width:100%}}
@media print {.drawer,.drawer-toggle,.view-banner,dialog {display:none!important}html,body,.app,.canvas {height:auto;overflow:visible}#editor {display:none!important}#viewer {display:block!important;white-space:pre-wrap;overflow:visible;color:#111;background:white}}
