/* pspsps — pseudo-escritorio de ventanas para colectivos pequeños.
   Línea meowrhino: negro cálido + dorado + JetBrains Mono + textura de puntos.
   Escritorio con ventanas flotantes (rumrum-like) + dock. Mobile-first: en
   pantallas estrechas las ventanas se maximizan y el dock cambia entre ellas. */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0d0c0a;
  --surface: #16130f;
  --surface-2: #1d1914;
  --border: #2a2622;
  --hairline: #221e1a;
  --text: #d8d2c4;
  --text-dim: #a89e8b;
  --muted: #6b6357;
  --accent: #e8b04a;
  --accent-dim: #b58836;
  --danger: #e87a7a;
  --online: #4ade80;
  --dots: #1a1612;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* textura de fondo (viñeta + puntitos) anclada al viewport — el "escritorio" */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 60% at 50% 42%, var(--bg) 0%, var(--bg) 35%, transparent 85%),
    radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: auto, 22px 22px;
}

.hidden { display: none !important; }

/* inputs / botones comunes */
input, button, textarea { font: inherit; }
input[type="text"], textarea {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .6rem;
  width: 100%;
  font-size: 16px; /* >=16px evita el zoom automático de iOS al enfocar */
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 4.5rem; }
button {
  font-weight: 600;
  color: #1a1206;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  padding: .5rem 1rem;
  cursor: pointer;
}
button:hover { background: var(--accent-dim); }
button.ghost { color: var(--text-dim); background: none; border: 1px solid var(--border); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }

.swatch {
  width: 22px; height: 22px; padding: 0; background: none;
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
  align-self: center; flex-shrink: 0;
}
.swatch-lg { width: 44px; height: 44px; }
.swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch::-webkit-color-swatch { border: none; border-radius: 2px; }
.swatch::-moz-color-swatch { border: none; border-radius: 2px; }

.iconbtn {
  background: none; border: 0; color: var(--text-dim);
  padding: 0 .2rem; font-size: 1rem; line-height: 1; cursor: pointer;
}
.iconbtn:hover { color: var(--text); background: none; }

.brand { font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.brand-cat { filter: saturate(.85); }
.brand-big { font-size: 2rem; }
.tagline { margin: .2rem 0 1.2rem; color: var(--muted); font-size: .8rem; }

/* ── puerta de identidad ──────────────────────────────────────────────────── */
.boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.card {
  display: flex; flex-direction: column; width: min(340px, 92vw);
  padding: 1.6rem 1.4rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5); text-align: center;
}
.card .field-label { text-align: left; color: var(--text-dim); font-size: .8rem; margin-bottom: .35rem; }
.card .field-label small { color: var(--muted); }
.identity-row { display: flex; gap: .6rem; align-items: center; margin-top: .7rem; }
.identity-row button { flex: 1; }
.fineprint { margin: 1.1rem 0 0; color: var(--muted); font-size: .68rem; line-height: 1.45; text-align: left; }

/* ── avatares de gato ─────────────────────────────────────────────────────── */
.cat-avatar-lg { width: 88px; height: 88px; margin: 0 auto; }
.cat-avatar-sm { width: 30px; height: 30px; flex-shrink: 0; }
.cat-avatar-lg svg, .cat-avatar-sm svg, #launcher-avatar svg, .sala-avatar svg { width: 100%; height: 100%; display: block; }
.identity-cat-row { display: flex; align-items: center; justify-content: center; gap: .6rem; margin: .2rem 0 1rem; }
.identity-cat-row #identity-reroll { padding: .4rem .55rem; font-size: 1rem; }
#launcher-avatar { width: 22px; height: 22px; display: inline-flex; }

/* ── editor de gato ───────────────────────────────────────────────────────── */
.catmaker { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.cat-preview { width: 120px; height: 120px; margin: .8rem auto .4rem; flex-shrink: 0; }
.cat-preview svg { width: 100%; height: 100%; }
.cat-controls { flex: 1; min-height: 0; overflow-y: auto; padding: .4rem .8rem .8rem; }
.cm-label { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; margin: .7rem 0 .3rem; }
.cm-swatches { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.cm-swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.cm-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.cm-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.cm-chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); border-radius: var(--radius); padding: .3rem .5rem; font-size: .72rem; cursor: pointer; }
.cm-chip:hover { color: var(--text); }
.cm-chip.active { background: var(--accent); color: #1a1206; border-color: var(--accent); }
.cm-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.cm-actions button { flex: 1; }

/* ── el patio (espacio caminable) ─────────────────────────────────────────── */
.patio-floor {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: crosshair;
  background:
    radial-gradient(ellipse 130% 90% at 50% 125%, #33422a 0%, #1d271a 42%, #12160f 100%),
    radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: auto, 20px 20px;
}
.patio-hint {
  position: absolute; top: 8px; left: 0; right: 0; text-align: center;
  color: var(--muted); font-size: .64rem; pointer-events: none; z-index: 9999;
}
.patio-cat {
  position: absolute;
  transform: translate(-50%, -100%);
  transition: left .45s ease, top .45s ease;
  cursor: pointer;
  width: 50px;
}
.patio-cat-sprite { width: 44px; height: 44px; margin: 0 auto; }
.patio-cat:hover .patio-cat-sprite { filter: brightness(1.15); }
.patio-cat-label {
  font-size: .58rem; color: var(--text-dim);
  background: rgba(13, 12, 10, .72); border-radius: 4px; padding: 0 .25rem;
  white-space: nowrap; max-width: 70px; overflow: hidden; text-overflow: ellipsis;
  margin: .1rem auto 0; width: fit-content;
}
.patio-cat.me .patio-cat-label { color: var(--accent); }
.patio-cat.me .patio-cat-sprite { filter: drop-shadow(0 0 5px rgba(232, 176, 74, .55)); }

/* ── escritorio ───────────────────────────────────────────────────────────── */
#desktop { position: fixed; inset: 0; overflow: hidden; }

/* ── ventana ──────────────────────────────────────────────────────────────── */
.win {
  position: absolute;
  width: 340px;
  max-width: calc(100vw - 16px);
  height: 440px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .55);
  overflow: hidden;
}
.win-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .55rem .45rem .7rem;
  background: linear-gradient(var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--border);
  cursor: grab; user-select: none; flex-shrink: 0;
}
.win-bar:active { cursor: grabbing; }
.win-ic { font-size: .8rem; line-height: 1; filter: saturate(.85); }
.win-title { flex: 1; min-width: 0; color: var(--accent); font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-ctrls { display: flex; gap: .1rem; flex-shrink: 0; }
.win-btn {
  width: 22px; height: 22px; display: grid; place-items: center;
  background: none; color: var(--text-dim); border: 1px solid transparent;
  border-radius: 4px; font-size: 1rem; line-height: 1; cursor: pointer; padding: 0;
}
.win-btn:hover { background: var(--surface-2); color: var(--text); }
.win-ctrls .win-btn:last-child:hover { color: var(--danger); }
.win-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── sala dentro de la ventana ────────────────────────────────────────────── */
.room-tools {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .6rem; border-bottom: 1px solid var(--hairline);
  background: var(--bg); flex-shrink: 0; overflow-x: auto; white-space: nowrap;
}
.room-tools .spacer { flex: 1; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; transition: background .3s; }
.conn-dot.online { background: var(--online); box-shadow: 0 0 6px var(--online); }
.conn-dot.connecting { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.presence-inline { display: flex; align-items: center; gap: .3rem; font-size: .68rem; color: var(--muted); min-width: 0; }
.pres-count { margin-right: .15rem; }
.presence-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; box-shadow: 0 0 4px currentColor; flex-shrink: 0; }

.messages {
  flex: 1; overflow-y: auto; list-style: none; margin: 0;
  padding: .8rem .7rem; display: flex; flex-direction: column; gap: .35rem;
}
.bubble { max-width: 82%; padding: .4rem .6rem; border-radius: 13px; word-break: break-word; }
.bubble .text { white-space: pre-wrap; }
.bubble .text .link { color: inherit; text-decoration: underline; word-break: break-all; }
.bubble .meta-line { display: block; margin-top: .15rem; font-size: .6rem; opacity: .65; }
.bubble.mine { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--accent); color: #1a1206; }
.bubble.mine .meta-line { text-align: right; }
.bubble.theirs { align-self: flex-start; border-bottom-left-radius: 4px; background: var(--surface-2); color: var(--text); }
.bubble.theirs .author { font-weight: 600; display: block; font-size: .7rem; margin-bottom: .08rem; }
.bubble.theirs .bubble-head { display: flex; align-items: center; gap: .3rem; margin-bottom: .12rem; }
.bubble.theirs .bubble-head .author { display: inline; margin: 0; }
.mini-cat { width: 18px; height: 18px; flex-shrink: 0; }
.mini-cat svg, .patio-cat svg { width: 100%; height: 100%; display: block; }
.bubble.pending { opacity: .6; }
.bubble.undecryptable { background: var(--hairline); color: var(--muted); font-style: italic; }
.daysep { display: flex; align-items: center; gap: .6rem; align-self: stretch; margin: .4rem 0; color: var(--muted); font-size: .66rem; }
.daysep::before, .daysep::after { content: ''; flex: 1; height: 1px; background: var(--hairline); }

.composer { display: flex; gap: .45rem; padding: .5rem .6rem; border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0; }
.composer .body { flex: 1; }
.composer button { flex-shrink: 0; padding: .5rem .8rem; }

/* ── dock ─────────────────────────────────────────────────────────────────── */
#dock {
  position: absolute; left: 0; right: 0; bottom: 0; height: 52px;
  display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem;
  background: rgba(13, 12, 10, .9); border-top: 1px solid var(--border);
  backdrop-filter: blur(6px); z-index: 9000;
}
.launch {
  display: flex; align-items: center; gap: .4rem; flex-shrink: 0;
  background: var(--accent); color: #1a1206; border: 0; border-radius: var(--radius);
  padding: .45rem .7rem; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.launch-cat { filter: saturate(.85); }
.tasks { display: flex; align-items: center; gap: .4rem; flex: 1; overflow-x: auto; min-width: 0; }
.task {
  display: flex; align-items: center; gap: .35rem; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: var(--radius); padding: .4rem .6rem; font-size: .76rem; cursor: pointer; max-width: 160px;
}
.task .chip-ic { font-size: .7rem; }
.task .chip-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task:hover { color: var(--text); }
.task.front { color: #1a1206; background: var(--accent); border-color: var(--accent); }
.task.min { opacity: .5; }
.dock-right { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }

/* ── menú del lanzador ────────────────────────────────────────────────────── */
.launcher-menu {
  position: absolute; left: 8px; bottom: 58px; width: min(300px, calc(100vw - 16px));
  max-height: min(440px, calc(100vh - 80px)); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 50px rgba(0, 0, 0, .6); z-index: 9500;
}
.lm-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem; border-bottom: 1px solid var(--hairline); }
.lm-who { flex: 1; font-size: .76rem; color: var(--muted); }
.lm-who b { color: var(--text-dim); font-weight: 500; }
.lm-actions { display: flex; gap: .45rem; padding: .6rem .8rem; }
.lm-actions button { flex: 1; padding: .45rem .5rem; font-size: .78rem; }
.lm-section { padding: .5rem .8rem .2rem; color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }

#salas { list-style: none; margin: 0; padding: 0 0 .4rem; }
#salas li { display: flex; align-items: center; gap: .55rem; padding: .55rem .8rem; cursor: pointer; }
#salas li:hover { background: var(--surface-2); }
#salas li.plaza { border-left: 2px solid var(--accent); }
.sala-avatar { width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); }
.sala-main { min-width: 0; flex: 1; }
.sala-name { color: var(--text); font-weight: 500; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sala-last { color: var(--muted); font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sala-time { color: var(--muted); font-size: .62rem; flex-shrink: 0; }

/* banner de avisos (Web Push) */
.push-banner { display: flex; flex-direction: column; gap: .5rem; padding: .7rem .8rem; border-top: 1px solid var(--hairline); background: var(--surface-2); font-size: .74rem; color: var(--text-dim); }
.push-actions { display: flex; gap: .4rem; }
.push-actions button { flex: 1; padding: .35rem .5rem; font-size: .74rem; }

/* ── modal ────────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; background: rgba(0, 0, 0, .6); padding: 1rem; }
.modal-card { position: relative; width: min(420px, 94vw); max-height: 86vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; box-shadow: 0 12px 50px rgba(0, 0, 0, .6); }
.modal-card h2 { margin: 0 0 .8rem; color: var(--accent); font-size: 1rem; }
.modal-close { position: absolute; top: .5rem; right: .6rem; background: none; color: var(--muted); font-size: 1.3rem; padding: 0 .3rem; }
.modal-close:hover { color: var(--text); background: none; }
.modal p { color: var(--text-dim); font-size: .82rem; line-height: 1.5; }
.modal label { display: block; color: var(--text-dim); font-size: .78rem; margin: .8rem 0 .3rem; }
.invite-link { display: flex; gap: .4rem; margin-top: .3rem; }
.invite-link input { font-size: .72rem; }
.modal-row { display: flex; gap: .5rem; margin-top: 1rem; }
.modal-row button { flex: 1; }
.warn { color: var(--accent); font-size: .72rem; margin-top: .8rem; }
.copied { color: var(--online); font-size: .72rem; margin-top: .4rem; }

/* pie del menú del lanzador (toggle de tema) */
.lm-foot { padding: .5rem .8rem; border-top: 1px solid var(--hairline); }
.lm-foot button { width: 100%; font-size: .74rem; padding: .4rem; }

/* ══════════════════════════════════════════════════════════════════════════
   TEMA "XP CÁLIDO" — la calidez de Windows XP (glossy, redondeado, acogedor)
   en la paleta meowrhino (negro cálido + dorado). Conmutable desde el menú.
   ══════════════════════════════════════════════════════════════════════════ */

/* escritorio: viñeta cálida tipo "bliss" + puntitos más cálidos */
.theme-xp body::before,
body.theme-xp::before {
  background-image:
    radial-gradient(ellipse 92% 78% at 50% 24%, #1d1610 0%, #120f0a 55%, #080605 100%),
    radial-gradient(#241a10 1px, transparent 1px);
  background-size: auto, 22px 22px;
}

/* ventanas: esquinas redondeadas, borde cálido, sombra honda */
.theme-xp .win {
  border-radius: 10px 10px 7px 7px;
  border: 1px solid #0c0906;
  box-shadow: 0 14px 50px rgba(0, 0, 0, .62), 0 0 0 1px rgba(255, 220, 150, .05);
}
/* barra de título INACTIVA (ventana de fondo) */
.theme-xp .win-bar {
  background: linear-gradient(#3a322a, #2a241d);
  border-bottom: 1px solid #14100b;
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, .08);
  padding: .5rem .55rem .5rem .8rem;
}
.theme-xp .win-title { color: #9a8e76; text-shadow: 0 1px 0 rgba(0, 0, 0, .4); }
/* barra de título ACTIVA (ventana enfocada) — el dorado glossy de XP */
.theme-xp .win.front .win-bar {
  background: linear-gradient(#f5cd72 0%, #e6ab3c 48%, #d2922a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15);
}
.theme-xp .win.front .win-title { color: #3a2608; text-shadow: 0 1px 0 rgba(255, 255, 255, .35); }
.theme-xp .win.front .win-ic { filter: none; }

/* botones de ventana (minimizar/cerrar) tipo XP */
.theme-xp .win-btn {
  border-radius: 5px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(0, 0, 0, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
  color: #2a1c06;
}
.theme-xp .win:not(.front) .win-btn { background: rgba(255, 255, 255, .06); color: var(--text-dim); }
.theme-xp .win-btn:hover { background: rgba(255, 255, 255, .3); }
.theme-xp .win-ctrls .win-btn:last-child {
  background: linear-gradient(#ec8460, #c0432a);
  color: #fff; border-color: rgba(0, 0, 0, .25);
}
.theme-xp .win-ctrls .win-btn:last-child:hover { background: linear-gradient(#f29478, #d24e32); color: #fff; }

/* botones dorados glossy */
.theme-xp button {
  border-radius: 8px;
  background: linear-gradient(#f5cd72, #e3a838 55%, #cf9326);
  color: #3a2608;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 1px 2px rgba(0, 0, 0, .35);
}
.theme-xp button:hover { background: linear-gradient(#f8d585, #e8b04a 55%, #d89a2e); }
.theme-xp button.ghost {
  background: linear-gradient(#2e2820, #211b15);
  color: var(--text-dim);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  border: 1px solid #14100b;
}
.theme-xp button.ghost:hover { background: linear-gradient(#3a3228, #2a241d); color: var(--text); }
.theme-xp input[type="text"], .theme-xp textarea {
  border-radius: 7px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .4);
}

/* dock = barra de tareas glossy */
.theme-xp #dock {
  height: 58px;
  background: linear-gradient(#34280f 0%, #271c0f 10%, #1c140d 100%);
  border-top: 1px solid #4a3a1e;
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, .22);
}
/* el lanzador = botón de inicio (glossy, redondo, en cursiva como el "start") */
.theme-xp .launch {
  border-radius: 18px;
  background: linear-gradient(#f8d585, #e6ab3c 50%, #cf9326);
  color: #3a2608;
  font-style: italic;
  padding: .5rem 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 5px rgba(0, 0, 0, .45);
}
.theme-xp .task {
  border-radius: 7px;
  background: linear-gradient(#3a2e1c, #281e10);
  border: 1px solid #4a3a1e;
  color: #d8c8a8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}
.theme-xp .task.front {
  background: linear-gradient(#241a0e, #34280f);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .55);
  color: #f0c878;
  border-color: #5a4622;
}

/* burbujas propias con brillo cálido */
.theme-xp .bubble.mine { background: linear-gradient(#f5cd72, #e3a838); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4); }

/* menú, tarjeta, modal: esquinas redondeadas y borde cálido */
.theme-xp .launcher-menu, .theme-xp .card, .theme-xp .modal-card { border-radius: 10px; border-color: #4a3a1e; }
.theme-xp .lm-head { background: linear-gradient(#34280f, #241a0e); }

/* ── móvil: las ventanas se maximizan; el dock cambia entre ellas ─────────── */
@media (max-width: 640px) {
  .win {
    left: 6px !important; top: 6px !important; right: 6px !important;
    width: auto !important; height: auto !important;
    bottom: 64px !important; max-height: none !important; max-width: none !important;
  }
  .win-bar { cursor: default; }
  .launch span:not(.launch-cat) { display: none; }
}
