* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }

body {
  font-family: "Chicago", "ChicagoFLF", "Charcoal", "Geneva", "Helvetica Neue", sans-serif;
  font-size: 13px;
  color: #000;
  background-color: #a3a3d6;
  background-image: conic-gradient(#8a8ac2 25%, transparent 0 50%, #8a8ac2 0 75%, transparent 0);
  background-size: 4px 4px;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: none;
}

/* ---------- barra de menu ---------- */
.menubar {
  position: fixed; inset: 0 0 auto 0; height: 22px; z-index: 50;
  display: flex; align-items: center; padding: 0 8px 0 6px;
  background: #fff; border-bottom: 1px solid #000; font-weight: bold;
}
.menus { display: flex; height: 100%; }
.menu { position: relative; }
.menu-title {
  font: inherit; font-weight: bold; color: #000;
  height: 21px; padding: 0 10px; background: none; border: 0; cursor: default;
}
.menu-title.logo { color: #c0306a; font-size: 15px; }
.menu.open .menu-title { background: #000; color: #fff; }
.dropdown {
  display: none; position: absolute; top: 21px; left: 0; z-index: 80;
  min-width: 190px; margin: 0; padding: 3px 0; list-style: none;
  background: #fff; border: 1px solid #000; box-shadow: 2px 2px 0 #000;
  font-weight: normal;
}
.menu.open .dropdown { display: block; }
.dropdown li { display: flex; justify-content: space-between; gap: 24px; padding: 2px 16px; white-space: nowrap; cursor: default; }
.dropdown li:not(.sep):not(.disabled):hover { background: #000; color: #fff; }
.dropdown li.disabled { color: #aaa; }
.dropdown li.sep { padding: 0; margin: 3px 0; border-top: 1px dotted #aaa; }
.dropdown kbd { font: inherit; }
.dropdown li.flash { animation: flash .24s steps(1) 1; }
@keyframes flash { 0%, 50% { background: #000; color: #fff; } 25%, 75% { background: #fff; color: #000; } }

#alertText { white-space: pre-line; }
.shutdown { position: fixed; inset: 0; z-index: 100; background: #000; }
.menubar .clock { margin-left: auto; font-weight: normal; }

/* ---------- ícones do desktop ---------- */
.icons { position: fixed; right: 14px; top: 38px; }
.icon { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px; font-size: 11px; }
.icon span { background: #fff; padding: 0 3px; }
.trash { position: fixed; right: 14px; bottom: 14px; }

/* ---------- área de trabalho ---------- */
.desktop { position: absolute; inset: 22px 0 0 0; display: grid; place-items: center; padding: 16px; }

/* ---------- janelas ---------- */
.window {
  width: min(520px, 94vw);
  background: #eee;
  border: 1px solid #000;
  box-shadow: 2px 2px 0 #000;
  animation: pop .18s steps(3);
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

.titlebar {
  position: relative; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid #000; cursor: grab; touch-action: none;
  background:
    repeating-linear-gradient(to bottom, #000 0 1px, #eee 1px 2px) 3px 4px / calc(100% - 6px) 11px no-repeat,
    #eee;
}
.titlebar:active { cursor: grabbing; }
.title { position: relative; background: #eee; padding: 0 8px; font-weight: bold; }

.close {
  position: absolute; left: 8px; top: 4px;
  width: 13px; height: 11px; padding: 0;
  background: #eee; border: 1px solid #000;
  box-shadow: 0 0 0 2px #eee; cursor: pointer;
}
.close:active {
  background:
    linear-gradient(45deg, transparent 45%, #000 45% 55%, transparent 55%),
    linear-gradient(-45deg, transparent 45%, #000 45% 55%, transparent 55%), #eee;
}

.content { padding: 14px; }
.row { display: flex; gap: 14px; align-items: flex-start; }
.row p { margin: 4px 0 12px; line-height: 1.4; }
.big-icon { font-size: 32px; line-height: 1; }
.muted { color: #555; font-size: 11px; }

/* ---------- formulários ---------- */
.fields { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin-bottom: 12px; }
.fields label { font-weight: bold; text-align: right; }

input, textarea {
  font: inherit; color: #000; background: #fff;
  border: 1px solid #000; border-radius: 0; padding: 4px 6px;
  outline: none; box-shadow: inset 1px 1px 0 #999;
  user-select: text;
}
input:focus, textarea:focus { box-shadow: inset 1px 1px 0 #999, 0 0 0 1px #000; }
#link { width: 100%; font-family: Monaco, monospace; font-size: 11px; }

textarea {
  display: block; width: 100%; height: 230px; resize: vertical;
  font-family: Monaco, "Courier New", monospace; line-height: 22px; padding: 0 10px;
  background: #fffef6 repeating-linear-gradient(transparent 0 21px, #d8def0 21px 22px);
  background-attachment: local;
}

.toolbar { display: flex; margin-bottom: 8px; }
.tool {
  display: grid; place-items: center; width: 28px; height: 20px; padding: 0;
  margin-right: -1px; background: #fff; border: 1px solid #000; cursor: pointer;
}
.tool svg { fill: #000; }
.tool.active, .tool:active { background: #000; }
.tool.active svg, .tool:active svg { fill: #fff; }

.actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.actions .muted { margin-right: auto; }

.btn {
  font: inherit; font-weight: bold; color: #000;
  min-width: 78px; padding: 4px 14px;
  background: #fff; border: 1px solid #000; border-radius: 7px;
  cursor: pointer;
}
.btn:active { background: #000; color: #fff; }
.btn.default { box-shadow: 0 0 0 2px #eee, 0 0 0 5px #000; margin: 4px; }

/* ---------- envelope (pixel art 1-bit) ---------- */
.mailwin { width: min(440px, 94vw); }
.infobar {
  display: flex; justify-content: space-between;
  padding: 2px 10px 3px; font-size: 11px;
  border-bottom: 1px solid #000;
  box-shadow: 0 2px 0 #eee, 0 3px 0 #000;
  margin-bottom: 3px;
}
.mail {
  background: #fff; text-align: center;
  padding: 64px 20px 26px;
  border-bottom: 1px solid #000;
}
.actions.pad { margin: 0; padding: 10px 14px; }

.envelope {
  position: relative; margin: 0 auto;
  width: min(320px, 76vw); aspect-ratio: 80 / 50;
  perspective: 700px; cursor: pointer; outline: none;
}
.envelope canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.env-back  { z-index: 0; }
.paper {
  position: absolute; left: 7.5%; right: 7.5%; top: 6%; height: 86%; z-index: 1;
  border: 2px solid #000;
  background: #fff repeating-linear-gradient(transparent 0 10px, #000 10px 12px, transparent 12px 16px) 0 18px / 100% 100% no-repeat;
  background-clip: padding-box;
  transition: transform .6s steps(6) .45s;
}
.env-front { z-index: 2; }
.env-flap  { z-index: 3; transform-origin: 50% 0; transition: transform .4s steps(4), z-index 0s .2s; }
.envelope .seal {
  inset: auto; left: 50%; top: 60%; z-index: 4;
  width: 16.25%; height: auto; aspect-ratio: 13 / 12;
  transform: translate(-50%, -50%);
  transition: opacity .15s steps(2);
}
.envelope:hover:not(.open) .seal { transform: translate(-50%, -54%); }
.envelope.open .seal     { opacity: 0; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .paper    { transform: translateY(-50%); }

/* rótulo de ícone do Finder: inverte quando selecionado */
.env-label { display: inline-block; margin-top: 14px; padding: 1px 4px; font-size: 12px; }
.envelope:hover + .env-label,
.envelope:focus-visible + .env-label,
.envelope.open + .env-label { background: #000; color: #fff; }

/* animação de "zoom" clássica ao abrir */
.zoom { position: fixed; z-index: 60; border: 1px dotted #000; pointer-events: none; }

/* ---------- carta ---------- */
.letter { width: min(560px, 94vw); }
.sheet {
  font-family: Monaco, "Courier New", monospace; font-size: 13px; line-height: 22px;
  min-height: 280px; max-height: 58vh; overflow: auto;
  padding: 22px 26px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: #fffef6 repeating-linear-gradient(transparent 0 21px, #d8def0 21px 22px);
  background-attachment: local;
  border: 1px solid #000; box-shadow: inset 1px 1px 0 #999;
  user-select: text; cursor: text;
}
.sheet p { margin: 0 0 22px; }
.sheet .date { text-align: right; color: #555; }
.sheet .sign { text-align: right; opacity: 0; transition: opacity .6s; }
.sheet .sign.show { opacity: 1; }
.typing::after { content: "▌"; animation: blink .8s steps(1) infinite; }

/* ---------- alerta ---------- */
.alert {
  position: fixed; inset: 0; margin: auto; z-index: 70;
  width: min(380px, 92vw); height: fit-content;
  border: 1px solid #000; outline: 3px solid #eee; box-shadow: 0 0 0 4px #000, 5px 5px 0 4px #000;
}

@media (max-width: 640px) {
  .icons, .trash { display: none; }
  .menu-title { padding: 0 7px; }
}
