/* petra — estética prestada del session view de Ableton, no de notas8:
   gris neutro (nada de calidez), superficies planas, CERO border-radius,
   etiquetas diminutas, y el color lo ponen los CLIPS: cada proyecto tiene su
   accent (un color web con nombre) y lo pinta todo dentro. Texto oscuro
   sobre el accent, como los clips de Live. La fuente sí es la de notas8. */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #161616;
  --surface: #1e1e1e;
  --surface2: #262626;
  --border: #333333;
  --hairline: #2a2a2a;
  --text: #d6d6d6;
  --text-dim: #9b9b9b;
  --muted: #676767;
  --ink: #141414;          /* texto oscuro sobre accent, como un clip */
  --accent: #daa520;       /* goldenrod de fallback; cada proyecto trae el suyo */
  --danger: #d96c6c;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
}

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

[hidden] { display: none !important; }

/* sin sesión de escritura, todo lo que escribe desaparece (el server lo
   re-valida igual con 401/403) */
body.reader .writer-only { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a.ext { text-decoration: underline; text-underline-offset: 3px; }
a.ext:hover { color: var(--accent); }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; }
.cursor { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 14px;
  align-items: center;
}

.whoami { font-size: 11px; color: var(--muted); text-transform: lowercase; }

/* ---------- controles: cajitas planas tipo Live ---------- */

button, input, textarea {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

/* botón = rectángulo plano con borde de 1px que se enciende con el accent */
button, .btn-link {
  background: transparent;
  border: 1px solid var(--border);
  padding: 3px 10px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  line-height: 1.6;
}
button:hover:not(:disabled), .btn-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}
button:disabled { opacity: 0.4; cursor: default; }

/* botón "lleno": accent sólido con tinta oscura (acción principal) */
button.solid {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 500;
}
button.solid:hover:not(:disabled) { filter: brightness(1.12); color: var(--ink); }

/* botón fantasma: solo texto, para acciones pequeñas (borrar, editar) */
button.ghost {
  border: none;
  padding: 0;
  background: none;
}
button.ghost:hover:not(:disabled) { color: var(--accent); border: none; }
button.ghost.danger:hover:not(:disabled) { color: var(--danger); }

input[type="text"], input[type="password"], input[type="url"], textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }

textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.6;
}

/* ---------- portada: lienzo de clips ---------- */

.page { padding: 20px; }

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.section-label button { letter-spacing: 0.03em; }

/* el lienzo: los clips flotan donde los dejes (o donde caigan) */
.canvas {
  position: relative;
  min-height: 76vh;
  border: 1px dashed var(--hairline);
  overflow: hidden;
}

/* un clip de Live: bloque sólido del accent, texto en tinta oscura */
.clip {
  position: absolute;
  width: 200px;
  min-height: 104px;
  background: var(--accent);
  color: var(--ink);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.clip:hover { filter: brightness(1.1); }
.clip.dragging { filter: brightness(1.12); z-index: 5; cursor: grabbing; }

.clip-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.clip-title::before { content: '▸ '; opacity: 0.55; }

.clip-meta {
  font-size: 10.5px;
  opacity: 0.75;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.empty-hint { color: var(--muted); font-size: 12px; padding: 16px; }

/* ---------- modal de proyecto ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  width: min(460px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.palette {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}
.swatch {
  aspect-ratio: 1;
  width: 100%;
  border: 1px solid transparent;
  padding: 0;
  cursor: pointer;
}
.swatch.sel { border-color: #fff; outline: 1px solid var(--ink); }

.palette-name { font-size: 11px; color: var(--text-dim); }
.palette-name span { color: var(--accent); }

.modal-row { display: flex; gap: 12px; align-items: center; }
.modal-row .danger { margin-left: auto; }

/* selector "añadir a proyecto" (desde la caja de referencias) */
.move-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.move-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 7px 10px;
  font-size: 12.5px;
}
.move-list .dot {
  width: 12px;
  height: 12px;
  flex: none;
  display: inline-block;
}

/* ---------- vista de proyecto ---------- */

.project { max-width: 900px; }

.project-head {
  background: var(--accent);
  color: var(--ink);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.project-head .back {
  border-color: color-mix(in srgb, var(--ink) 35%, transparent);
  color: var(--ink);
  flex: none;
}
.project-head .back:hover { border-color: var(--ink); color: var(--ink); }
.project-head h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.project-head .head-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.project-head button.ghost { color: var(--ink); opacity: 0.65; font-size: 13px; }
.project-head button.ghost:hover { opacity: 1; color: var(--ink); }

/* modos de orden: cronológico / personalizado */
.mode-row { display: flex; gap: 8px; margin-bottom: 12px; }
.mode-row .mode.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

/* ---------- aportes ---------- */

.items { display: flex; flex-direction: column; gap: 10px; }

.item {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  padding: 9px 14px 10px;
}

.item-meta {
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
}
.item-meta .kind {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.item-meta .spacer { margin-left: auto; }

.item-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.item-caption {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* la fecha del proyecto, abajo a la derecha, en su accent */
.project-date {
  text-align: right;
  font-size: 11px;
  color: var(--accent);
  margin: 8px 2px 14px;
}

/* player de audio: fila plana [▶][barra][tiempo] */
.player { display: flex; align-items: center; gap: 10px; }
.player-btn {
  width: 34px;
  height: 30px;
  flex: none;
  background: var(--accent);
  border: none;
  color: var(--ink);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-btn:hover:not(:disabled) { filter: brightness(1.12); color: var(--ink); }
.player-track {
  flex: 1;
  height: 30px;
  background: var(--surface2);
  border: 1px solid var(--hairline);
  position: relative;
  cursor: pointer;
}
.player-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: color-mix(in srgb, var(--accent) 45%, var(--surface2));
}
.player-time {
  font-size: 10.5px;
  color: var(--text-dim);
  flex: none;
  min-width: 76px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* tarjeta de youtube: carátula + título; al pulsar se vuelve iframe */
.yt {
  display: flex;
  gap: 12px;
  align-items: stretch;
  background: var(--surface2);
  border: 1px solid var(--hairline);
  cursor: pointer;
  overflow: hidden;
  max-width: 560px;
}
.yt:hover { border-color: var(--accent); }
.yt-thumb {
  width: 132px;
  flex: none;
  object-fit: cover;
  aspect-ratio: 4/3;
  display: block;
}
.yt-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  min-width: 0;
}
.yt-title { font-size: 13px; font-weight: 500; }
.yt-author { font-size: 11px; color: var(--text-dim); }
.yt-hint { font-size: 10px; color: var(--muted); margin-top: 4px; }
.yt-frame { aspect-ratio: 16/9; width: 100%; max-width: 560px; border: 0; background: #000; }

/* imagen y vídeo */
.item-img {
  display: block;
  max-width: 480px;
  width: 100%;
  border: 1px solid var(--hairline);
}
.item-video {
  display: block;
  max-width: 560px;
  width: 100%;
  background: #000;
  border: 1px solid var(--hairline);
}

/* ---------- composer ---------- */

.composer {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 40vh;
}
.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
#btn-rec.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--ink);
}

.status { font-size: 11px; color: var(--muted); }
.error { color: var(--danger); font-size: 12px; }

/* ---------- login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  width: min(320px, 88vw);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 24px;
}
.login-box h1 { font-size: 16px; margin-bottom: 18px; color: var(--accent); }
.login-box form { display: flex; flex-direction: column; gap: 12px; }
.login-hint { font-size: 11px; }
.login-hint a { color: var(--muted); }
.login-hint a:hover { color: var(--accent); }

@media (max-width: 600px) {
  .page { padding: 12px; }
  .clip { width: 150px; min-height: 92px; }
  .yt-thumb { width: 104px; }
  .palette { grid-template-columns: repeat(8, 1fr); }
}
