:root {
  --ara-code-bg: #0b0f17;
  --ara-code-bg-elevated: rgba(255, 255, 255, 0.03);
  --ara-code-bg-elevated-strong: rgba(255, 255, 255, 0.06);
  --ara-code-border: rgba(73, 85, 108, 0.58);
  --ara-code-text: #edf4ff;
  --ara-code-comment: #6b7c98;
  --ara-code-keyword: #68e1fd;
  --ara-code-string: #8df7a6;
  --ara-code-number: #ffb86c;
  --ara-code-function: #ffe66d;
  --ara-code-operator: #ff7aa2;
  --ara-code-property: #b691ff;
  --ara-code-symbol: #7ee7ff;
  --ara-code-selection: rgba(104, 225, 253, 0.26);
  --ara-code-grid-minor: rgba(255, 255, 255, 0.038);
  --ara-code-grid-major: rgba(255, 255, 255, 0.075);
}

.wp-block-code.ara-code-aesthetic,
.wp-block-preformatted.ara-code-aesthetic,
pre.ara-code-aesthetic__surface {
  position: relative;
  overflow-x: auto;
  margin: 1em 0;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--ara-code-border);
  border-radius: 0;
  background:
    linear-gradient(var(--ara-code-grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--ara-code-grid-major) 1px, transparent 1px),
    linear-gradient(var(--ara-code-grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--ara-code-grid-minor) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(255,255,255,0.03), transparent 34%),
    var(--ara-code-bg);
  background-size:
    48px 48px,
    48px 48px,
    12px 12px,
    12px 12px,
    auto,
    auto;
  backdrop-filter: blur(16px) saturate(132%);
  -webkit-backdrop-filter: blur(16px) saturate(132%);
  color: var(--ara-code-text);
  font-family: "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  tab-size: 4;
  white-space: pre;
}

.wp-block-code.ara-code-aesthetic code,
.wp-block-preformatted.ara-code-aesthetic,
code.ara-code-aesthetic__content {
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
}

.wp-block-code.ara-code-aesthetic code {
  white-space: inherit;
}

:where(.wp-block-code.ara-code-aesthetic, .wp-block-preformatted.ara-code-aesthetic, pre.ara-code-aesthetic__surface)::-webkit-scrollbar {
  height: 10px;
}

:where(.wp-block-code.ara-code-aesthetic, .wp-block-preformatted.ara-code-aesthetic, pre.ara-code-aesthetic__surface)::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

:where(.wp-block-code.ara-code-aesthetic, .wp-block-preformatted.ara-code-aesthetic, pre.ara-code-aesthetic__surface)::-webkit-scrollbar-thumb {
  background: rgba(104, 225, 253, 0.22);
  border-radius: 999px;
}

:where(.wp-block-code.ara-code-aesthetic, .wp-block-preformatted.ara-code-aesthetic, pre.ara-code-aesthetic__surface) ::selection {
  background: var(--ara-code-selection);
}

.wp-block-code.ara-code-aesthetic a,
.wp-block-preformatted.ara-code-aesthetic a,
pre.ara-code-aesthetic__surface a,
code.ara-code-aesthetic__content a {
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: var(--ara-code-keyword);
  text-decoration: underline;
  text-underline-offset: 0.12em;
  text-decoration-color: rgba(104, 225, 253, 0.55);
}

/* ── Tablas ───────────────────────────────────────────────────── */
figure.wp-block-table {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  margin: 1em 0;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #ffffff;
}

.ara-table__stage {
  display: block;
  width: 100%;
  transform-origin: top left;
}

.ara-table__stage table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
  background: #ffffff;
  color: #111827;
  font-family: "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.ara-table__stage th,
.ara-table__stage td {
  padding: 0.3rem 0.6rem;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  color: inherit;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.ara-table__stage thead th {
  background: #f3f4f6;
  color: #374151;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(0,0,0,0.13);
  vertical-align: middle;
}

.ara-table__stage tbody tr:nth-child(odd) td  { background: #ffffff; }
.ara-table__stage tbody tr:nth-child(even) td { background: #f9fafb; }
.ara-table__stage tbody tr:last-child td      { border-bottom: none; }
.ara-table__stage tbody tr:hover td           { background: #eff6ff; }
.ara-table__stage strong { color: #000; }
.ara-table__stage a { color: #0284c7; }
.ara-table__stage code {
  display: inline;
  padding: 1px 4px;
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 3px;
  color: #0369a1;
  font: inherit;
  word-break: break-all;
}

/* Botón maximizar (tablas y mermaid) */
.ara-table-maximize,
.ara-mermaid__maximize {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 4px;
  background: rgba(255,255,255,0.88);
  color: #374151;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  transition: background 0.15s;
}
.ara-table-maximize:hover,
.ara-mermaid__maximize:hover { background: #fff; border-color: rgba(0,0,0,0.25); }
.ara-table-maximize svg,
.ara-mermaid__maximize svg { pointer-events: none; }

/* Modal compartido */
.ara-expand-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  padding: 1rem;
  box-sizing: border-box;
}
.ara-expand-modal__inner {
  position: relative;
  background: #ffffff;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.28);
}
.ara-expand-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 4px;
  background: rgba(255,255,255,0.95);
  color: #374151;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 2;
}
.ara-expand-modal__close:hover { background: #f3f4f6; }
.ara-expand-modal__content { padding: 2.5rem 1rem 1rem; }
.ara-expand-modal__content table { width: 100%; font-size: 0.88rem; white-space: normal; }

.ara-token {
  color: var(--ara-code-text);
}

.ara-token-comment {
  color: var(--ara-code-comment);
  font-style: italic;
}

.ara-token-keyword {
  color: var(--ara-code-keyword);
}

.ara-token-string {
  color: var(--ara-code-string);
}

.ara-token-number {
  color: var(--ara-code-number);
}

.ara-token-function {
  color: var(--ara-code-function);
}

.ara-token-operator {
  color: var(--ara-code-operator);
}

.ara-token-property {
  color: var(--ara-code-property);
}

.ara-token-symbol {
  color: var(--ara-code-symbol);
}

.ara-code-aesthetic .token.comment,
.ara-code-aesthetic .token.prolog,
.ara-code-aesthetic .token.doctype,
.ara-code-aesthetic .token.cdata,
.ara-code-aesthetic .hljs-comment,
.ara-code-aesthetic .hljs-quote {
  color: var(--ara-code-comment);
}

.ara-code-aesthetic .token.keyword,
.ara-code-aesthetic .token.selector,
.ara-code-aesthetic .token.atrule,
.ara-code-aesthetic .hljs-keyword,
.ara-code-aesthetic .hljs-selector-tag,
.ara-code-aesthetic .hljs-selector-class {
  color: var(--ara-code-keyword);
}

.ara-code-aesthetic .token.string,
.ara-code-aesthetic .token.attr-value,
.ara-code-aesthetic .token.char,
.ara-code-aesthetic .hljs-string,
.ara-code-aesthetic .hljs-attribute {
  color: var(--ara-code-string);
}

.ara-code-aesthetic .token.number,
.ara-code-aesthetic .token.boolean,
.ara-code-aesthetic .token.constant,
.ara-code-aesthetic .hljs-number,
.ara-code-aesthetic .hljs-literal {
  color: var(--ara-code-number);
}

.ara-code-aesthetic .token.function,
.ara-code-aesthetic .token.class-name,
.ara-code-aesthetic .hljs-title.function_,
.ara-code-aesthetic .hljs-function {
  color: var(--ara-code-function);
}

.ara-code-aesthetic .token.operator,
.ara-code-aesthetic .token.entity,
.ara-code-aesthetic .token.url,
.ara-code-aesthetic .hljs-operator {
  color: var(--ara-code-operator);
}

.ara-code-aesthetic .token.property,
.ara-code-aesthetic .token.tag,
.ara-code-aesthetic .token.attr-name,
.ara-code-aesthetic .hljs-property,
.ara-code-aesthetic .hljs-tag,
.ara-code-aesthetic .hljs-name {
  color: var(--ara-code-property);
}

.block-editor-block-list__layout .wp-block-code.ara-code-aesthetic,
.block-editor-block-list__layout .wp-block-preformatted.ara-code-aesthetic {
  margin-top: 0.45rem;
  margin-bottom: 0.45rem;
}

@media (max-width: 782px) {
  .wp-block-code.ara-code-aesthetic,
  .wp-block-preformatted.ara-code-aesthetic,
  pre.ara-code-aesthetic__surface {
    border-radius: 0;
    padding: 1rem 1.05rem;
    font-size: 0.9rem;
    line-height: 1.62;
  }

  figure.wp-block-table { margin: 0.9rem 0; }
}
