/* ---------------------------------------------------------------- tokens
   Paleta anclada en el índigo histórico de php.net (#4F5B93 / #8892BF):
   es el color propio del tema, no un acento decorativo.                    */
:root {
  --side-w: 340px;

  --chrome:      #f4f4f8;
  --chrome-2:    #ebebf3;
  --paper:       #ffffff;
  --ink:         #1a1a22;
  --ink-2:       #5f5f70;
  --rule:        #dcdce6;
  --accent:      #4f5b93;
  --accent-soft: #e7e9f4;
  --accent-ink:  #ffffff;
  --shadow:      0 1px 2px rgb(26 26 34 / .06);

  --ui:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --chrome:      #16161d;
  --chrome-2:    #1f1f28;
  --paper:       #0f0f14;
  --ink:         #e7e7ef;
  --ink-2:       #9a9aad;
  --rule:        #2c2c38;
  --accent:      #8892bf;
  --accent-soft: #262633;
  --accent-ink:  #14141a;
  --shadow:      none;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--chrome);
  color: var(--ink);
  font: 13px/1.5 var(--ui);
  overflow: hidden;
}

/* ---------------------------------------------------------------- barra */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 10px;
  border-bottom: 1px solid var(--rule);
  background: var(--chrome);
}

.bar__nav { display: flex; gap: 2px; }

.bar__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

.icon:hover:not(:disabled) { background: var(--chrome-2); color: var(--ink); }
.icon:disabled             { opacity: .35; cursor: default; }

.icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------- shell */
.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side-w) 5px 1fr;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--chrome);
}

/* -------------------------------------------------------------- solapas */
.tabs {
  display: flex;
  padding: 0 6px;
  border-bottom: 1px solid var(--rule);
}

.tab {
  flex: 1;
  padding: 9px 4px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.tab:hover                   { color: var(--ink); }
.tab[aria-selected="true"]   { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel[hidden] { display: none; }

.panel__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px 0 14px;
}

/* --------------------------------------------------------------- campos */
.field { padding: 8px 10px; border-bottom: 1px solid var(--rule); }

.field input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder { color: var(--ink-2); }

/* ---------------------------------------------------------------- árbol */
.row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 0;
  border-left: 2px solid transparent;
  cursor: default;
  user-select: none;
}

.row:hover { background: var(--chrome-2); }

.row[aria-current="page"] {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.row__twist {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--ink-2);
  transition: transform .12s ease;
}

.row__twist svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.row[aria-expanded="true"] .row__twist { transform: rotate(90deg); }
.row__twist--leaf { visibility: hidden; }

.row__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kids[hidden] { display: none; }

/* -------------------------------------------------- índice y resultados
   Las entradas del índice son en su mayoría símbolos de código, así que
   se componen en monoespaciada; la prosa mantiene la tipografía de la UI. */
.hit {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 12px;
  border-left: 2px solid transparent;
  cursor: default;
}

.hit:hover                 { background: var(--chrome-2); }
.hit[aria-current="page"]  { background: var(--accent-soft); border-left-color: var(--accent); }

.hit__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit__name--sym { font-family: var(--mono); font-size: 12px; }
.hit__name mark { background: none; color: var(--accent); font-weight: 700; }

.hit__kind {
  flex: none;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--chrome-2);
  color: var(--ink-2);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.hit__kind--sym { background: var(--accent-soft); color: var(--accent); }

.note {
  padding: 10px 12px;
  color: var(--ink-2);
  font-size: 12px;
}

/* ------------------------------------------------------------ pie panel */
.side__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 12px;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 11px;
}

.side__foot #stat {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang {
  flex: none;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  cursor: pointer;
}

.lang:hover { border-color: var(--rule); color: var(--ink); }
.lang[hidden] { display: none; }

/* ---------------------------------------------------------------- grip */
.grip {
  background: var(--rule);
  cursor: col-resize;
}

.grip:hover, .grip:focus-visible { background: var(--accent); outline: none; }

/* ------------------------------------------------------------ contenido */
.doc {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
}

#doc {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.seq {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-top: 1px solid var(--rule);
  background: var(--chrome);
}

.seq__btn {
  padding: 3px 10px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.seq__btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.seq__btn:disabled             { opacity: .4; cursor: default; }

.seq__where {
  flex: 1;
  min-width: 0;
  color: var(--ink-2);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

body.dragging { cursor: col-resize; user-select: none; }
body.dragging #doc { pointer-events: none; }

/* ------------------------------------------------------------ pantallas */
@media (max-width: 720px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 5px 1fr;
  }
  .grip { cursor: row-resize; }
}

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