/* © 2026 Sergio Santiago Bendaña Quesada. All rights reserved: no use, copy or reuse without written permission,
   and no use by AI or automated tools (training, datasets, retrieval, code generation, scraping). See LICENSE. bsketch-7f3a9c2e */
:root {
  --bg: #ffffff;
  --text: #1b1b1f;
  --muted: #5c5f66;
  --border: #e3e4e8;
  --accent: #3451b2;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

/* Dark: the system's, unless the menu forces light; or forced from the menu (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181b;
    --text: #ececf1;
    --muted: #a1a1aa;
    --border: #2e2e35;
    --accent: #9db2ff;
  }
}

:root[data-theme="dark"] {
  --bg: #18181b;
  --text: #ececf1;
  --muted: #a1a1aa;
  --border: #2e2e35;
  --accent: #9db2ff;
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 1.05rem;
}

.menu-button,
.drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.menu-button:hover,
.drawer-close:hover {
  border-color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The side menu: a modal <dialog> on the left (Escape and the backdrop close it). */
.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(20rem, 100vw - 3rem);
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 0.75rem 1rem 1.5rem;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
}

.drawer::backdrop {
  background: rgba(0, 0, 0, 0.3);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0.75rem 0;
  border: 0;
  border-top: 1px solid var(--border);
  min-width: 0;
}

.drawer-section h3,
.drawer-section legend {
  margin: 0 0 0.15rem;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* A legend does not take part in the fieldset's flex layout: give it room above the options. */
fieldset.drawer-section legend {
  float: left;
  width: 100%;
  margin-bottom: 0.5rem;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.drawer-item:hover {
  border-color: var(--border);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.drawer-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 12rem;
  overflow-y: auto;
}

.drawing-item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawing-item[aria-current="true"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-weight: 600;
}

.drawer-row {
  display: flex;
  gap: 0.35rem;
}

.drawer-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.drawer-item kbd,
.drawer-check kbd {
  margin-left: auto;
  padding: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
}

.drawer-seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.drawer-seg label {
  flex: 1;
  position: relative;
  padding: 0.45rem 0.25rem;
  text-align: center;
  font-size: 0.9rem;
  cursor: pointer;
}

.drawer-seg label + label {
  border-left: 1px solid var(--border);
}

.drawer-seg input,
.drawer-swatches input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.drawer-seg label:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  font-weight: 600;
}

.drawer-seg label:has(input:focus-visible),
.drawer-swatches label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.drawer-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.drawer-swatches label {
  position: relative;
  display: block;
  cursor: pointer;
}

.drawer-swatch {
  display: block;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.drawer-swatches label:has(input:checked) .drawer-swatch {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.drawer-note {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.board {
  position: relative;
  flex: 1;
  min-height: 0;
}

.status {
  position: fixed;
  left: 50%;
  bottom: 4.5rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  max-width: calc(100vw - 2rem);
}

@media (max-width: 640px) {
  .status {
    top: 6rem;
    bottom: auto;
  }
}

.status:empty {
  display: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Text to diagram: a centred dialog with the text, examples and the direction. */
.td-dialog {
  width: min(36rem, 100vw - 2rem);
  max-height: calc(100vh - 2rem);
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.td-dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
}

.td-dialog h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.td-help {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.td-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.td-example {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.td-example:hover {
  border-color: var(--accent);
}

#td-text {
  box-sizing: border-box;
  width: 100%;
  min-height: 12rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 0.9rem/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  resize: vertical;
}

.td-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.9rem;
}

.td-row select {
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#td-count {
  margin-left: auto;
  color: var(--muted);
}

.td-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.td-actions .drawer-item {
  width: auto;
  justify-content: center;
}

.td-insert {
  background: var(--accent);
  color: var(--bg);
}

.td-insert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Templates in the menu: small buttons that wrap. */
.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.drawer-chips .drawer-item {
  width: auto;
  padding: 0.35rem 0.7rem;
  border-color: var(--border);
  border-radius: 999px;
}

/* Help: the guide and the shortcuts, in the same kind of dialog as text to diagram. */
.help-dialog {
  width: min(40rem, 100vw - 2rem);
  overflow: auto;
}

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.help-dialog h3 {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
}

.help-guide {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.help-guide li + li {
  margin-top: 0.3rem;
}

.help-keys {
  width: 100%;
  margin-bottom: 0.6rem;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.help-keys caption {
  padding: 0.3rem 0;
  font-weight: 600;
  text-align: left;
  color: var(--muted);
}

.help-keys td {
  padding: 0.25rem 0;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.help-keys td + td {
  padding-left: 0.75rem;
  text-align: right;
  white-space: nowrap;
}

.help-keys kbd {
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.82rem;
}

@media (max-width: 30rem) {
  .help-keys td + td {
    white-space: normal;
  }
}
