:root {
  --purple: #4b2a5c;
  --shadow: 4px 4px 0 rgba(40, 10, 50, 0.4);
  --font: Tahoma, "Segoe UI", "MS UI Gothic", sans-serif;
  /* Windowbase 300x200 measured:
     title 4-16.5%, content 21-88.5%, cyan status 90-95% */
  --title-top: 4%;
  --title-h: 12%;
  --pad-x: 4%;
  --body-top: 21%;
  --body-bottom: 12%;
  --status-bottom: 4%;
  --status-h: 6%;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--purple);
  user-select: none;
}

body {
  background-color: #2a1038;
  background-image: url("../assets/backgrounds/Hana.webp");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.desktop {
  position: relative;
  width: 100%;
  height: calc(100% - 40px);
  overflow: hidden;
}

.desktop-icons {
  position: absolute;
  top: 14px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2;
}

.desk-icon {
  width: 84px;
  background: transparent;
  border: none;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.desk-icon img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  background: rgba(255,255,255,0.4);
  border: 2px solid #4b2a5c;
  box-shadow: var(--shadow);
}

.desk-emoji {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffb6d9, #ff7eb6);
  border: 2px solid #4b2a5c;
  font-weight: 900;
  color: #4b2a5c;
  box-shadow: var(--shadow);
}

.desk-icon:hover img,
.desk-icon:hover .desk-emoji { outline: 2px dotted #fff; }

.os-window {
  position: absolute;
  width: min(440px, 92vw);
  z-index: 10;
  filter: drop-shadow(3px 5px 0 rgba(30,0,40,0.35));
}

.os-window.wide { width: min(380px, 90vw); }
.os-window.active { z-index: 40; }

.os-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 300 / 200;
}

.os-frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 1;
}

.os-window .frame-active { display: none; }
.os-window .frame-inactive { display: block; }
.os-window.active .frame-active { display: block; }
.os-window.active .frame-inactive { display: none; }

.os-titlebar {
  position: absolute;
  top: var(--title-top);
  left: 11%;
  right: 5%;
  height: var(--title-h);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  padding: 0 4px 0 8px;
}

.os-titlebar:active { cursor: grabbing; }

.os-title {
  font-size: clamp(10px, 2.2vw, 13px);
  font-weight: 700;
  color: #4b2a5c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 26px);
  line-height: 1;
}

.os-close {
  width: 16px;
  height: 14px;
  border: 2px solid #4b2a5c;
  background: #ff8ab8;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  padding: 0;
}

.os-close::before,
.os-close::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  background: #4b2a5c;
}
.os-close::before { transform: translateY(-50%) rotate(45deg); }
.os-close::after { transform: translateY(-50%) rotate(-45deg); }

.os-content {
  position: absolute;
  z-index: 3;
  top: var(--body-top);
  left: var(--pad-x);
  right: var(--pad-x);
  bottom: var(--body-bottom);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.os-content-sprite {
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 4px 0;
}

.ame-sprite {
  flex: 1 1 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  display: block;
}

.ame-caption {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #4b2a5c;
  background: rgba(255,255,255,0.85);
  border: 1px solid #4b2a5c;
  padding: 1px 8px;
  max-width: 95%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.os-content-feed {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  background:
    linear-gradient(rgba(255,248,255,0.5), rgba(255,248,255,0.5)),
    url("../assets/posts/Tweeter_bg.webp") center / cover no-repeat;
}

.tweet {
  background: rgba(255,255,255,0.92);
  border: 2px solid #4b2a5c;
  margin-bottom: 6px;
  padding: 5px;
}

.tweet header {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #4b2a5c;
  line-height: 1.2;
}

.tweet img {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center top;
  display: block;
  border: 1px solid #4b2a5c;
  background: #fff;
}

.tweet p {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.25;
}

.os-content-photo {
  align-items: center;
  justify-content: center;
  background: #1a0a22;
  padding: 2px;
}

.selfie-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.os-content-walls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  padding: 4px;
  align-content: start;
  overflow-y: auto;
  background: rgba(255,248,255,0.75);
}

.os-content-walls button {
  border: 2px solid #4b2a5c;
  padding: 0;
  background: #fff;
  cursor: pointer;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.os-content-walls img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.jine-body {
  display: block;
  padding: 8px;
  overflow-y: auto;
  background: rgba(255,248,255,0.9);
  font-size: 12px;
  line-height: 1.35;
}

.jine-body p { margin-bottom: 5px; }
.jine-body .fine { font-size: 10px; opacity: 0.7; margin-top: 6px; }

.os-statusbar {
  position: absolute;
  z-index: 5;
  left: 5%;
  right: 5%;
  bottom: var(--status-bottom);
  height: var(--status-h);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #3d1f4a;
  padding: 0 2px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}

.os-statusbar > span {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1;
}

.os-statusbar button {
  border: 1px solid #4b2a5c;
  background: #ffc1de;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 14px;
  line-height: 12px;
  padding: 0 4px;
  flex: 0 0 auto;
}

.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: linear-gradient(180deg, #d7c2ea, #b89ad0);
  border-top: 2px solid #fff;
  box-shadow: 0 -2px 0 #4b2a5c;
}

.start-btn {
  background: linear-gradient(180deg, #ffe0f0, #ff9ec8);
  border: 2px solid #4b2a5c;
  padding: 3px 12px;
  font-weight: 800;
  font-size: 12px;
  color: #4b2a5c;
  cursor: pointer;
}

.task-pills {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.task-pills button {
  border: 2px solid #4b2a5c;
  background: #efe6f7;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  color: #4b2a5c;
}

.tray {
  display: flex;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #3d1f4a;
  background: #efe6f7;
  border: 2px inset #c9b3dc;
  padding: 2px 8px;
}

.start-menu {
  position: fixed;
  left: 8px;
  bottom: 44px;
  z-index: 110;
  width: 200px;
  background: #efe6f7;
  border: 3px solid #4b2a5c;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.start-menu[hidden] { display: none !important; }

.start-menu button {
  text-align: left;
  border: none;
  border-bottom: 1px solid #c9b3dc;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  color: #4b2a5c;
}

.start-menu button:hover { background: #ffc1de; }

@media (max-width: 700px) {
  .desktop-icons { gap: 8px; left: 6px; }
  .desk-icon { width: 72px; font-size: 10px; }
  .os-window { width: min(360px, 96vw); }
  .task-pills { display: none; }
  .os-title { font-size: 11px; }
}
