/* notas — paleta cálida de twoitter + distribución de notas5:
   texto alineado a la izquierda, meta-líneas diminutas en minúsculas con
   opacidad baja, separación por espacio en blanco (no cajas), CERO
   border-radius y botones sin borde: solo texto que se ilumina al pasar. */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0d0c0a;
  --surface: #16130f;
  --border: #2a2622;
  --hairline: #221e1a;
  --text: #d8d2c4;
  --text-dim: #a89e8b;
  --muted: #6b6357;
  --accent: #e8b04a;
  --accent-dim: #b58836;
  --danger: #d97a6a;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
}

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

/* el atributo hidden SIEMPRE gana, aunque el elemento tenga display propio */
[hidden] { display: none !important; }

/* lector = solo lectura: todo lo que escribe lleva .writer-only y
   desaparece. El server lo re-valida igual (403). */
body.reader .writer-only { display: none !important; }

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

/* ---------- layout: columna 2/3 pegada a la izquierda ---------- */

.page {
  width: min(66vw, 105ch);
  margin: 0;
  padding: 24px 0 30vh 40px;
}

@media (max-width: 720px) {
  .page { width: auto; padding: 16px 12px 30vh; }
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 40px 10px;
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  z-index: 10;
}

@media (max-width: 720px) {
  .topbar { padding: 12px 12px 8px; }
}

.topbar h1 { font-size: 16px; font-weight: 600; color: var(--accent); }
.cursor { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

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

/* ---------- controles: minimal de verdad ---------- */

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

/* botón = texto en minúsculas que se ilumina. sin borde, sin fondo, sin radius */
button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-dim);
  text-transform: lowercase;
}
button:hover:not(:disabled) { color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }

input[type="text"], input[type="search"], input[type="password"], textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 6px 0;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus { border-bottom-color: var(--accent-dim); }
input[type="search"] { width: 160px; }

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.7;
  border: 1px solid var(--hairline);
  padding: 8px 10px;
}

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

.login-page { display: grid; place-items: start; min-height: 100vh; padding: 20vh 40px; }
.login-box { width: min(90vw, 320px); display: grid; gap: 16px; }
.login-box h1 { color: var(--accent); font-size: 20px; }
.login-box form { display: grid; gap: 12px; }
.login-box button { justify-self: start; color: var(--accent); }
.error { color: var(--danger); font-size: 13px; }

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

.composer {
  display: grid;
  gap: 12px;
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--hairline);
}

.composer-bar { display: flex; gap: 18px; align-items: baseline; }
.spacer { flex: 1; }

.record-btn.is-recording {
  color: var(--danger);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

.publish-btn { color: var(--accent); }

.draft-blocks { display: grid; gap: 14px; }
.draft-blocks:empty { display: none; }

.draft-block {
  display: grid;
  gap: 6px;
  padding-left: 12px;
  border-left: 2px solid var(--hairline);
}
.draft-block .meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.05em;
}
.draft-block .status { color: var(--accent-dim); }
/* ---------- player de audio (portado de twoitter) ----------
   Mismo diseño que el feed de twoitter: botón play accent, barra de progreso
   y tiempo tabular. Radius hardcoded (twoitter usa --radius-sm/md: 4/6px;
   aquí no hay vars de radius). El <audio> interno va oculto: solo aporta
   src/duration, la reproducción real es Web Audio (audio-player.js). */

.audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}
.audio-player > audio { display: none; }

.audio-player .ap-play {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  transition: background 120ms ease, transform 80ms ease;
}
.audio-player .ap-play:hover { background: var(--accent-dim); }
.audio-player .ap-play:active { transform: scale(0.96); }
.audio-player .ap-icon-play,
.audio-player .ap-icon-pause { display: none; }
.audio-player[data-state="paused"]  .ap-icon-play  { display: inline; }
.audio-player[data-state="playing"] .ap-icon-pause { display: inline; font-size: 0.7rem; letter-spacing: -1px; }

.audio-player .ap-progress {
  flex: 1 1 auto;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.audio-player .ap-progress:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.audio-player .ap-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 80ms linear;
}

.audio-player .ap-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.audio-player .ap-time-sep { opacity: 0.5; }
.audio-player .ap-time-dur { color: var(--text-dim); }

.draft-block .audio-player { margin-top: 4px; }

/* ---------- tags ---------- */

.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 28px;
  font-size: 12px;
}
.tagbar:empty { display: none; }
.tag { color: var(--muted); font-size: 12px; }
.tag:hover { color: var(--accent); }
.tag.active { color: var(--accent); }

/* ---------- feed: notas separadas por aire, como notas5 ---------- */

.feed { display: grid; gap: 44px; }

/* meta de cada nota: diminuta, minúsculas, casi transparente (notas5) */
.note-head {
  display: flex;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.5;
  text-transform: lowercase;
  letter-spacing: 0.05em;
  transition: opacity 0.15s;
}
.note:hover .note-head { opacity: 0.9; }
.note-num { color: var(--accent); font-weight: 600; }
.note-title { font-size: 13px; font-weight: 600; color: var(--text); }
.note-head button { font-size: 11px; }

/* bloques */
.block { margin-bottom: 1.2em; }
.block:last-child { margin-bottom: 0; }

.block-body p { margin: 0 0 1em; white-space: pre-wrap; }
.block-body p:last-child { margin-bottom: 0; }
.block-body .hashtag { color: var(--accent-dim); cursor: pointer; }

/* meta-línea del bloque: audio · editado a las _ por _ · historial · corregir
   invisible casi siempre; aparece al pasar por encima del bloque */
.block-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: baseline;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.05em;
  opacity: 0.35;
  transition: opacity 0.15s;
}
.block:hover .block-meta { opacity: 1; }
.block-meta button { font-size: 11px; color: var(--muted); }
.block-meta button:hover:not(:disabled) { color: var(--accent); }
.edit-info { color: var(--muted); }

.block .audio-player { margin-top: 6px; }

/* historial de versiones */
.history {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--hairline);
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.05em;
}
.history-row { display: flex; gap: 14px; align-items: baseline; }
.history-row button { font-size: 11px; }

.version-banner {
  font-size: 11px;
  color: var(--accent-dim);
  text-transform: lowercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.version-banner button { font-size: 11px; color: var(--accent); }

/* edición inline */
.block-body textarea.editing { width: 100%; margin-bottom: 0.6em; }
.edit-bar { display: flex; gap: 18px; margin-bottom: 1em; }
.edit-bar button:first-child { color: var(--accent); }

.more-btn { display: block; margin: 32px 0; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 40px;
  background: var(--surface);
  border-left: 2px solid var(--accent-dim);
  padding: 8px 14px;
  font-size: 12px;
  z-index: 100;
}
.toast.error { border-left-color: var(--danger); color: var(--danger); }
