/* Bloc compartido: una bitácora de proyecto.
   Idea visual: cada nota, archivo o acción es una línea de cuaderno con su fecha en el margen. */

:root {
  --paper: #f2f4f6;
  --surface: #ffffff;
  --ink: #1b2430;
  --muted: #5a6675;
  --rule: #d3d9e0;
  --accent: #234b8f;
  --accent-ink: #ffffff;
  --danger: #a12d2a;
  --focus: #234b8f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171d;
    --surface: #1a212a;
    --ink: #e6eaf0;
    --muted: #9aa6b5;
    --rule: #2c3643;
    --accent: #8db0f2;
    --accent-ink: #0e1520;
    --danger: #f19590;
    --focus: #8db0f2;
  }
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 0.5rem; font-weight: 600; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
.sub { margin-top: 2rem; color: var(--muted); font-family: var(--sans); font-size: 0.95rem; font-weight: 600; }
p { margin: 0 0 1rem; max-width: 68ch; }
.muted { color: var(--muted); }
.lead { font-family: var(--serif); font-size: 1.15rem; max-width: 62ch; }

/* Estructura */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.brand { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.account { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.95rem; }
.account form { margin: 0; }

.page { max-width: 60rem; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem) 4rem; }
.narrow { max-width: 26rem; margin: 2rem auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin: 0; }
.page-head form { margin: 0; }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row form { margin: 0; }
.stack { display: grid; gap: 1rem; }
.stack > div { margin: 0; }

/* Mensajes */
.flash { padding: 0.7rem 1rem; border-left: 4px solid var(--accent); background: var(--surface); max-width: none; }
.flash.error { border-left-color: var(--danger); }
.empty { padding: 1.25rem 0; color: var(--muted); }

/* Formularios */
label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.95rem; }
label small { font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%; padding: 0.6rem 0.7rem; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 4px;
}
input[type="file"] { font: inherit; font-weight: 400; }
textarea { resize: vertical; line-height: 1.6; }
.editor { min-height: 22rem; font-size: 1.02rem; }

.btn, button.link {
  font: inherit; cursor: pointer;
}
.btn {
  display: inline-block; padding: 0.55rem 1rem; border-radius: 4px;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 0.18em; }
.danger-text { color: var(--danger); }

/* Proyectos */
.project-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.project-list li { padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.project-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.project-list p { margin: 0.25rem 0 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.facts { display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; margin-top: 0.5rem; }

.project-head { margin-bottom: 1.5rem; }
.project-head h1 { margin-bottom: 0.4rem; }
.edit-desc { margin: 0 0 1rem; }
.edit-desc summary { cursor: pointer; color: var(--accent); font-size: 0.95rem; width: max-content; }
.edit-desc form { margin-top: 0.75rem; max-width: 40rem; }
.tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--rule); margin-top: 1rem; }
.tabs a { padding: 0.6rem 0.1rem; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* La bitácora: fecha en el margen, contenido a la derecha */
.journal { list-style: none; margin: 0 0 1.5rem; padding: 0; border-top: 1px solid var(--rule); }
.journal li {
  display: grid; grid-template-columns: 9.5rem 1fr auto; gap: 1.25rem; align-items: baseline;
  padding: 0.8rem 0; border-bottom: 1px solid var(--rule);
}
.gutter { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.entry { display: grid; gap: 0.1rem; min-width: 0; overflow-wrap: anywhere; }
.entry > a { font-weight: 600; }
.meta { color: var(--muted); font-size: 0.88rem; }
.quoted { font-family: var(--serif); }
.journal form { margin: 0; }
.drafts li { border-left: 3px dashed var(--muted); padding-left: 0.75rem; }
.members li { grid-template-columns: 9.5rem 1fr; }
.files li { grid-template-columns: 9.5rem 1fr auto; }

/* Notas */
.note h2 { font-size: 1.8rem; }
.byline { color: var(--muted); }
.note-body { white-space: pre-wrap; max-width: 68ch; font-family: var(--serif); font-size: 1.08rem; line-height: 1.7; padding: 1rem 0 1.5rem; }

/* Archivos */
.crumbs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 1rem; color: var(--muted); }
.upload { display: grid; gap: 0.9rem; padding: 1rem 0 1.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--rule); }

/* Integrantes */
.invite { background: var(--surface); border-left: 4px solid var(--accent); padding: 1rem; margin-bottom: 1rem; }
.invite p { margin-bottom: 0.6rem; }
.invite input[type="text"] { flex: 1 1 18rem; }
.danger-zone { max-width: 26rem; }

@media (max-width: 40rem) {
  .journal li, .members li, .files li { grid-template-columns: 1fr; gap: 0.15rem; }
  .tabs { gap: 1rem; overflow-x: auto; }
  h1 { font-size: 1.6rem; }
}

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

/* Árbol de archivos, al estilo del explorador de VS Code */
:root {
  --k-folder: #4b6fa8; --k-code: #2b6cb0; --k-data: #2f855a; --k-doc: #5a6675;
  --k-image: #7b4bb3; --k-archive: #b7791f; --k-config: #2c7a7b; --k-other: #5a6675;
  --hover: #e9edf2; --selected: #dbe6f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --k-folder: #8fb0e0; --k-code: #79b0f2; --k-data: #6ccf9b; --k-doc: #9aa6b5;
    --k-image: #b99af0; --k-archive: #e0b255; --k-config: #62c7c8; --k-other: #9aa6b5;
    --hover: #212a35; --selected: #26364f;
  }
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.t-folder { color: var(--k-folder); }
.t-code { color: var(--k-code); } .t-data { color: var(--k-data); } .t-doc { color: var(--k-doc); }
.t-image { color: var(--k-image); } .t-archive { color: var(--k-archive); }
.t-config { color: var(--k-config); } .t-other { color: var(--k-other); }

.target { margin: 0; }
.tree { border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); padding: 0.35rem 0; font-size: 0.95rem; }
.node { display: flex; align-items: center; gap: 0.5rem; min-height: 2rem; padding: 0.15rem 0.75rem 0.15rem 0.5rem; }
.node:hover { background: var(--hover); }
.node.selected { background: var(--selected); }
summary.node, .node.root { cursor: pointer; }
summary.node { list-style: none; }
summary.node::-webkit-details-marker { display: none; }
.chev { color: var(--muted); transition: transform 0.12s; }
.chev.open, details[open] > summary .chev { transform: rotate(90deg); }
.chev-gap { width: 1rem; flex: none; }
.node .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node.file .name { color: var(--ink); text-decoration: none; }
.node.file .name:hover { text-decoration: underline; }
.node .count { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.node .meta { color: var(--muted); font-size: 0.82rem; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.node .actions { margin: 0; opacity: 0; flex: none; }
.node:hover .actions, .node:focus-within .actions { opacity: 1; }
@media (hover: none) { .node .actions { opacity: 1; } }
@media (max-width: 40rem) { .node .who, .node .when { display: none; } }

.d0 { padding-left: 0.5rem; }
.d1 { padding-left: 1.6rem; }
.d2 { padding-left: 2.7rem; }
.d3 { padding-left: 3.8rem; }
.d4 { padding-left: 4.9rem; }
.d5 { padding-left: 6rem; }
.d6 { padding-left: 7.1rem; }
.d7 { padding-left: 8.2rem; }
.d8 { padding-left: 9.3rem; }
.d9 { padding-left: 10.4rem; }
.d10 { padding-left: 11.5rem; }

/* Subida compacta: los dos selectores lado a lado para que el árbol quede a la vista */
.upload { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.25rem; }
.upload .target, .upload .row { grid-column: 1 / -1; }
.tree .ico { width: 1.1rem; height: 1.1rem; stroke-width: 1.4; }
@media (max-width: 40rem) { .upload { grid-template-columns: 1fr; } }

.upload-errors { margin: 0; padding-left: 1.2rem; color: var(--danger); font-size: 0.92rem; grid-column: 1 / -1; }
.upload-errors:empty { display: none; }
