/* ---------- PC: monitor CRT ---------- */
#os {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  background: var(--bezel-dk);
  opacity: 0;
  transition: opacity 0.3s;
  padding-top: calc(env(safe-area-inset-top, 0px) + 64px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#os.in {
  opacity: 1;
}
.bezel {
  position: relative;
  background: var(--bezel) var(--grain);
  border-radius: 22px;
  padding: clamp(12px, 3vmin, 30px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -6px 14px rgba(0, 0, 0, 0.4),
    0 20px 50px rgba(0, 0, 0, 0.6);
  min-height: 0;
  display: grid;
}
.bezel-brand {
  position: absolute;
  left: 50%;
  bottom: clamp(-2px, 0.5vmin, 6px);
  transform: translateX(-50%);
  font-family: var(--f-ui);
  font-size: 15px;
  letter-spacing: 0.3em;
  color: #3a3427;
  white-space: nowrap;
}
.crt {
  position: relative;
  overflow: hidden;
  border-radius: 28px/38px;
  background: radial-gradient(ellipse at 50% 45%, #0c1a0d 0%, var(--phos-bg) 75%);
  color: var(--phos);
  font-family: var(--f-ui);
  font-size: 21px;
  line-height: 1.2;
  text-shadow: 0 0 6px rgba(149, 214, 138, 0.5);
  box-shadow:
    inset 0 0 0 3px #0a0a08,
    inset 0 0 90px rgba(0, 0, 0, 0.85);
  min-height: 0;
  transform-origin: center;
}
.crt::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 49;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
#os.off .crt {
  animation: crtoff 0.42s ease-in forwards;
}
@keyframes crtoff {
  0% {
    transform: scale(1, 1);
    filter: brightness(1);
  }
  55% {
    transform: scale(1, 0.006);
    filter: brightness(3);
  }
  100% {
    transform: scale(0, 0.006);
    filter: brightness(4);
  }
}
#boot {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 22px 26px;
  white-space: pre-wrap;
  font: inherit;
  overflow: hidden;
}
.os-desk {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.os-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 20px;
  background: var(--phos);
  color: var(--phos-bg);
  text-shadow: none;
  font-size: 20px;
  letter-spacing: 0.06em;
}
.os-bar span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.os-desk > .os-area {
  flex: 1;
  overflow: hidden;
}
.os-area {
  position: relative;
  flex: 1;
  min-height: 0;
}
.os-icons {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1;
}
.os-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 96px;
  padding: 6px 2px;
  color: var(--phos);
  font-size: 17px;
  letter-spacing: 0.04em;
  text-shadow: inherit;
}
.os-icon svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
  shape-rendering: crispEdges;
  filter: drop-shadow(0 0 4px rgba(149, 214, 138, 0.45));
}
.os-icon:hover span,
.os-icon:focus-visible span {
  background: var(--phos);
  color: var(--phos-bg);
  text-shadow: none;
}
.os-icon:focus-visible {
  outline: 1px dashed var(--phos);
  outline-offset: 0;
}
.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--phos-bg);
  border: 2px solid var(--phos);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.55);
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  min-width: 0;
  z-index: 2;
}
.win-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--phos);
  color: var(--phos-bg);
  text-shadow: none;
  padding: 1px 4px 1px 10px;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.win-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Botones de la barra de título: minimizar, maximizar, cerrar */
.win-btns {
  display: flex;
  gap: 4px;
  flex: none;
}
.win-btn {
  font-family: var(--f-ui);
  font-size: 18px;
  line-height: 18px;
  width: 24px;
  height: 22px;
  color: var(--phos-bg);
  border: 2px solid var(--phos-bg);
}
.win-btn:hover {
  background: var(--phos-bg);
  color: var(--phos);
}
.win-btn:focus-visible {
  outline: 2px solid var(--phos-bg);
  outline-offset: 1px;
}
.win-body {
  flex: 1;
  overflow: auto;
  padding: 14px 16px;
  min-height: 0;
  scrollbar-color: var(--phos-dim) transparent;
}
.win-body .meta {
  color: var(--phos-dim);
}

/* Bordes para cambiar el tamaño: derecho, inferior y esquina */
.win-rs {
  position: absolute;
  z-index: 3;
  touch-action: none;
}
.win-rs-e {
  top: 24px;
  right: -5px;
  bottom: 10px;
  width: 10px;
  cursor: ew-resize;
}
.win-rs-s {
  left: 0;
  right: 10px;
  bottom: -5px;
  height: 10px;
  cursor: ns-resize;
}
.win-rs-se {
  right: -5px;
  bottom: -5px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  background: linear-gradient(
    135deg,
    transparent 50%,
    var(--phos) 50% 60%,
    transparent 60% 70%,
    var(--phos) 70% 80%,
    transparent 80%
  );
}

/* Maximizada: ocupa todo el escritorio */
.win.is-max {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  box-shadow: none;
}
.win.is-max .win-rs {
  display: none;
}
.win.is-max .win-bar {
  cursor: default;
}
.win.pop {
  animation: winpop 0.16s steps(4);
}
@keyframes winpop {
  from {
    transform: scale(0.6, 0.1) translateY(400px);
    opacity: 0.4;
  }
}

/* Barra de tareas con una pestaña por ventana abierta */
.os-taskbar {
  display: flex;
  gap: 6px;
  padding: 4px 8px;
  min-height: 34px;
  border-top: 2px solid var(--phos);
  overflow-x: auto;
  scrollbar-width: none;
}
.os-tab {
  flex: none;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px;
  font-size: 17px;
  color: var(--phos);
  border: 1px solid var(--phos-dim);
  text-shadow: inherit;
}
.os-tab:hover {
  border-color: var(--phos);
}
.os-tab.on {
  background: var(--phos);
  color: var(--phos-bg);
  text-shadow: none;
}
.os-tab.min {
  opacity: 0.6;
  border-style: dashed;
}

/* Galería de fotos de un proyecto */
.gal {
  margin: 0 0 6px;
  outline: none;
}
.gal:focus-visible .gal-stage {
  outline: 1px dashed var(--phos);
  outline-offset: 3px;
}
.gal-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  max-width: 100%;
  border: 1px solid var(--phos-dim);
  background: #020502;
}
.win.is-max .gal-stage {
  aspect-ratio: auto;
  height: 50vh;
}
.gal-slide {
  position: absolute;
  inset: 0;
  display: grid;
}
.gal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  aspect-ratio: auto;
  border: 0;
}
.gal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 44px;
  font-size: 20px;
  color: var(--phos);
  background: rgba(5, 12, 6, 0.8);
  border: 1px solid var(--phos-dim);
}
.gal-nav:hover {
  background: var(--phos);
  color: var(--phos-bg);
}
.gal-prev {
  left: 6px;
}
.gal-next {
  right: 6px;
}
.gal-count {
  position: absolute;
  right: 8px;
  bottom: 6px;
  padding: 0 6px;
  font-size: 17px;
  background: rgba(5, 12, 6, 0.8);
}
.gal-cap {
  margin: 6px 0 0;
  color: var(--phos-dim);
  font-size: 18px;
}
.gal-thumbs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.gal-thumb {
  flex: none;
  width: 72px;
  border: 1px solid var(--phos-dim);
  opacity: 0.65;
}
.gal-thumb.on {
  border-color: var(--phos);
  opacity: 1;
}
.gal-thumb-img {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  font-size: 12px;
  border: 0;
}
.pcard-img {
  display: grid;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.win-body p {
  margin: 0 0 10px;
  max-width: 62ch;
}
.win-body h3 {
  font-weight: 400;
  font-size: 28px;
  margin: 12px 0 2px;
  line-height: 1.1;
}
.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.pcard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 6px;
  border: 1px solid var(--phos-dim);
  color: var(--phos);
  text-shadow: inherit;
  font-size: 19px;
  min-width: 0;
}
.pcard:hover,
.pcard:focus-visible {
  border-color: var(--phos);
  background: rgba(149, 214, 138, 0.07);
}
.pcard .meta {
  color: var(--phos-dim);
  font-size: 17px;
}
.ph {
  display: grid;
  place-items: center;
  aspect-ratio: 4/3;
  max-width: 100%;
  background: repeating-conic-gradient(#14251a 0 25%, #0a140c 0 50%) 0 0/4px 4px;
  border: 1px dashed var(--phos-dim);
  color: var(--phos-dim);
  font-size: 17px;
  letter-spacing: 0.15em;
  text-shadow: none;
}
/* Placeholders de fotos dentro de la galería: ocupan el marco, sin doble borde */
.gal-slide > .ph {
  aspect-ratio: auto;
  height: 100%;
  border: 0;
}
.gal-thumb-img.ph {
  aspect-ratio: 16 / 10;
  border: 0;
  letter-spacing: 0.05em;
}
.ph-lg {
  max-width: 440px;
}
.chips {
  list-style: none;
  padding: 0;
  margin: 10px 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips li {
  border: 1px solid var(--phos-dim);
  padding: 0 8px;
  font-size: 17px;
}
.os-link {
  color: var(--phos-bg);
  background: var(--phos);
  text-shadow: none;
  padding: 2px 10px;
  text-decoration: none;
  display: inline-block;
}
.os-link:hover {
  background: var(--tape-ink);
}
.term {
  display: flex;
  flex-direction: column;
  min-height: 220px;
}
.term-out {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  overflow-wrap: anywhere;
}
.term-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.term-line label {
  white-space: nowrap;
}
.term-line input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--phos);
  font: inherit;
  text-shadow: inherit;
  caret-color: var(--phos);
  outline: none;
  padding: 0;
}
@media (max-width: 640px) {
  #os {
    padding-top: calc(env(safe-area-inset-top, 0px) + 84px);
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }
  .bezel {
    padding: 8px;
    border-radius: 14px;
  }
  .os-bar {
    padding: 4px 12px;
    font-size: 16px;
  }
  .crt {
    font-size: 19px;
    border-radius: 16px/22px;
  }
  /* íconos en una sola fila que se desliza de costado */
  .os-icons {
    position: absolute;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0;
    padding: 2px 4px;
    background: var(--phos-bg);
    border-top: 1px solid var(--phos-dim);
  }
  .os-icon {
    flex: none;
    width: 64px;
    font-size: 13px;
    padding: 3px 0;
  }
  .os-icon span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .os-icon svg {
    width: 22px;
    height: 22px;
  }
  .os-tab {
    font-size: 15px;
    max-width: 140px;
  }
  .win {
    left: 6px !important;
    top: 6px !important;
    right: 6px;
    bottom: 60px;
    width: auto !important;
    height: auto !important;
    max-width: none;
    max-height: none;
  }
  .win-rs {
    display: none;
  }
  .win-bar {
    cursor: default;
  }
  .bezel-brand {
    display: none;
  }
}
