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

#os {
  width: 100vw;
  height: 100vh;
  transform-origin: top left;
  position: relative;
}

:root {
  --blood-dark: #230505;
  --blood: #690e0e;
  --blood-hover: #7a1010;
}

body {
  height: 100vh;
  background: linear-gradient(rgba(14, 10, 8, 0.7), rgba(14, 10, 8, 0.7)), url("img/EB8sT3hVUAALfaB.png");
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

#dock {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  min-width: 340px;
  min-height: 67px;
  justify-content: center;
  align-items: center;
  background: #1c1410;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--blood-dark);
  border-radius: 12px;
  z-index: 9999; /* o oltre topBar */
}

#dock.dock-empty::before {
  content: "";
  width: 30px;
  height: 30px;
  background: url('https://static.wikia.nocookie.net/bindingofisaacre_gamepedia/images/4/46/Collectible_Brimstone_icon.png/revision/latest?cb=20210821045528');
  animation: dockpulse 2s ease-in-out infinite;
}

@keyframes dockpulse {
  0%, 100% { transform: scale(1.3); opacity: 0.8; }
  50%      { transform: scale(1.6); opacity: 1; }
}

@keyframes dockItemIn {
  from { opacity: 0; transform: translateY(20px) scale(0.8); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes dockItemOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.8); }
}

.dock-item {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: #14100c;
  border: 2px solid #000;
  box-shadow: 0 0 0 1px var(--blood-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  flex-direction: column;
  animation: dockItemIn 0.25s ease-out;
}

.dock-item.leaving {
  animation: dockItemOut 0.2s ease-in forwards;
}

.dock-item img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  pointer-events: none;
}

.dock-item:hover {
  background: #241a14;
  transform: translateY(-4px);
  box-shadow: 0 0 0 1px var(--blood), 0 8px 20px rgba(0,0,0,0.4);
} 

.dock-item.active {
  background: var(--blood);
  border-color: #000;
  box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(93,13,13,0.6);
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #14100c;
  border-bottom: 2px solid var(--blood-dark);
  color: #e8d5a8;
  font-size: 13px;
  font-weight: 500;
  z-index: 10;
  position: relative;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-left .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(232, 213, 168, 0.2);
}

.topbar-left .dot.active {
  background: var(--blood);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right .time {
  background: #1c1410;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--blood-dark);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #e8d5a8;
}

.window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border-radius: 14px;
  width: 480px;
  color: #e8d5a8;
  text-align: center;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.window::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--blood-dark);
  border-radius: 14px;
  z-index: 10;
}

.window-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #1c1410;
}

.window.closing {
  animation: windowClose 0.2s ease-in forwards;
}

.window.opening {
  animation: windowOpen 0.25s ease-out;
}

@keyframes windowClose {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

@keyframes windowOpen {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.window.genie-out {
  --genie-dy: 0px;
  animation: windowGenieOut 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards,
             windowGenieClip 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes windowGenieOut {
  0% {
    opacity: 1;
    filter: brightness(1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    transform: translate(-50%, -50%) translateY(0) scale(1);
  }
  35% {
    filter: brightness(0.75);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  70% {
    opacity: 1;
    filter: brightness(0.45);
    transform: translate(-50%, -50%) translateY(calc(var(--genie-dy) * 0.7)) scale(0.25, 0.9);
  }
  100% {
    opacity: 0;
    filter: brightness(0.2);
    transform: translate(-50%, -50%) translateY(var(--genie-dy)) scale(0.06, 0.45);
  }
}

@keyframes windowGenieClip {
  0% {
    clip-path: polygon(0 0, 100% 0, 100% 33%, 100% 66%, 100% 100%, 0 100%, 0 66%, 0 33%);
  }
  35% {
    clip-path: polygon(0 0, 100% 0, 97% 30%, 93% 66%, 88% 100%, 12% 100%, 7% 66%, 3% 30%);
  }
  70% {
    clip-path: polygon(4% 0, 96% 0, 80% 28%, 60% 66%, 52% 100%, 48% 100%, 40% 66%, 20% 28%);
  }
  100% {
    clip-path: polygon(36% 0, 64% 0, 56% 30%, 51% 66%, 50% 100%, 50% 100%, 49% 66%, 44% 30%);
  }
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 10;
}

.resize-handle::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--blood);
  border-bottom: 2px solid var(--blood);
}

.resize-handle:hover::after {
  width: 9px;
  height: 9px;
  transition: 0.1s;
}

.windowheader {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  cursor: grab;
  user-select: none;
  background: #14100c;
  border-bottom: 2px solid #2a1c14;
  position: relative;
  flex-shrink: 0;
}

.window-body {
  padding: 48px;
  display: flex;
  flex-direction: column;
}

.window-body .avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 16px;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--blood-dark);
  align-self: center;
}

.window-body h1 {
  font-size: 36px;
  font-family: 'VT323', monospace;
  color: #e8d5a8;
  margin-bottom: 8px;
}

.window-body p {
  font-size: 14px;
  color: #d8c9a8;
  line-height: 1.6;
  margin-bottom: 16px;
}

.links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.links a {
  color: #e8d5a8;
  text-decoration: none;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  background: #241a14;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--blood);
  transition: background 0.2s;
}

.links a:hover {
  background: #3a2418;
  color: #fff;
}

.closebutton {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blood);
  border: 1px solid #000;
  cursor: pointer;
  flex-shrink: 0;
}

.minbutton {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #815f1c;
  border: 1px solid #000;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
}

.minbutton:hover {
  background: #c99f4a;
}

.minbutton:active {
  background: #8a6a2e;
}

.openbutton {
  cursor: pointer;
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: #e8d5a8;
}

.window-title {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: #e8d5a8;
}

#desktopApps {
  position: absolute;
  top: 64px;
  left: 16px;
  z-index: 1;
}

.appicon {
  position: absolute;
  width: 88px;
  text-align: center;
  padding: 12px;
  border-radius: 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

#notesicon { top: 0; left: 0; }
#contactsicon { top: 112px; left: 0; }
#browsericon { top: 224px; left: 0; }
#calculatoricon { top: 336px; left: 0; }

.appicon:hover {
  background: rgba(232, 213, 168, 0.06);
}

.appicon.selected {
  background: rgba(93, 13, 13, 0.35);
  box-shadow: 0 0 0 2px var(--blood-dark);
}

.appicon-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgb(41, 23, 19), rgb(87, 48, 48));
  border: 2px solid #000;
  box-shadow: 0 0 0 1px var(--blood);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
  overflow: hidden;
}

.appicon-img img {
  width: 90%;
  height: 90%;
  object-fit: cover;
  border-radius: 10px;
}

.appicon-label {
  margin: 0;
  color: #e8d5a8;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

#notesicon .appicon-img img {
  width: 75%;
  height: 75%;
}

#browsericon .appicon-img img {
  width: 90%;
  height: 90%;
}

#calculatoricon .appicon-img img {
  width: 120%;
  height: 120%;
  transform: scale(0.8);
}

#notes {
  width: 640px;
  height: 520px;
}

.notes-app {
  display: flex;
  flex-direction: row;
  margin: 12px;
  background: #1c1410;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--blood-dark);
  border-radius: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  color: #d8c9a8;
  text-align: left;
}

.sidebar {
  width: 180px;
  background: #14100c;
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 2px solid #2a1c14;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-note-btn {
  background: #241a14;
  border: 1px solid #000;
  border-radius: 6px;
  color: #e8d5a8;
  font-size: 22px;
  font-family: 'VT323', monospace;
  line-height: 1;
  padding: 4px 0;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.new-note-btn:hover {
  background: var(--blood);
  color: #fff;
}

.sidebar-item {
  background: #241a14;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #000;
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-item:hover {
  background: #33241a;
}

.sidebar-item.active {
  background: rgba(93, 13, 13, 0.4);
  border-color: var(--blood-dark);
  outline: 2px solid var(--blood-dark);
}

.sidebar-item .item-title {
  margin: 0;
  font-weight: 600;
  font-size: 14px;
  color: #e8d5a8;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-item .item-trash {
  font-size: 13px;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.sidebar-item:hover .item-trash {
  opacity: 1;
}

.sidebar-item .item-trash:hover {
  transform: scale(1.2);
}

.sidebar-item .item-date {
  margin: 0;
  font-size: 11px;
  color: rgba(232, 213, 168, 0.5);
}

.note-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  font-size: 14px;
  color: #d8c9a8;
}

.note-content:focus {
  outline: none;
}

.note-content h2 {
  font-size: 24px;
  font-family: 'VT323', monospace;
  margin-bottom: 8px;
  color: #e8d5a8;
}

.note-content blockquote {
  background: #241a14;
  padding: 12px 16px;
  border-radius: 6px;
  border-left: 3px solid var(--blood-dark);
  margin: 12px 0;
  font-style: italic;
  color: #d8c9a8;
}

.note-content img {
  max-width: 100%;
  border-radius: 10px;
}

#contacts {
  width: 400px;
}

.contacts-app {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contacts-app h2 {
  font-size: 26px;
  font-family: 'VT323', monospace;
  font-weight: 400;
  text-align: left;
  color: #e8d5a8;
}

.contacts-sub {
  font-size: 13px;
  color: rgba(232, 213, 168, 0.6);
  text-align: left;
  margin-bottom: 4px;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #241a14;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--blood);
  text-decoration: none;
  color: #e8d5a8;
  transition: background 0.2s, transform 0.1s;
}

.contact-card:hover {
  background: #33241a;
  box-shadow: 0 0 0 1px var(--blood-hover);
  transform: translateY(-1px);
}

.contact-emoji {
  font-size: 22px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #14100c;
  border: 1px solid #000;
  flex-shrink: 0;
}

.contact-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-align: left;
}

.contact-name {
  font-weight: 600;
  font-size: 15px;
}

.contact-handle {
  font-size: 12px;
  color: rgba(232, 213, 168, 0.55);
}

.contact-arrow {
  font-size: 16px;
  color: rgba(232, 213, 168, 0.4);
}

#browser {
  width: 720px;
  height: 520px;
}

.browser-app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #14100c;
  border-bottom: 2px solid #2a1c14;
  flex-shrink: 0;
}

.browser-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #000;
  border-radius: 6px;
  background: #241a14;
  color: #e8d5a8;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.browser-btn:hover {
  background: #33241a;
}

.browser-btn.browser-go {
  width: auto;
  padding: 0 12px;
  background: var(--blood);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.browser-btn.browser-go:hover {
  background: var(--blood-hover);
}

.browser-url {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 12px;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--blood);
  border-radius: 6px;
  background: #14100c;
  color: #e8d5a8;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
}

.browser-url:focus {
  border-color: var(--blood-hover);
  box-shadow: 0 0 0 1px var(--blood-hover);
}

.browser-url::placeholder {
  color: rgba(232, 213, 168, 0.35);
}

.browser-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 1;
  padding: 32px;
  min-height: 0;
  text-align: center;
}

.browser-home h2 {
  font-size: 44px;
  font-family: 'VT323', monospace;
  font-weight: 400;
  color: #e8d5a8;
}

.browser-home-sub {
  font-size: 14px;
  color: rgba(232, 213, 168, 0.6);
  margin-top: -8px;
}

.browser-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.browser-links a {
  color: #e8d5a8;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 6px;
  background: #241a14;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px rgba(160, 24, 24, 0.3);
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.browser-links a img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.browser-links a:hover {
  background: #33241a;
  box-shadow: 0 0 0 1px var(--blood-hover);
}

.browser-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  display: none;
  background: #fff;
}

.browser-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  padding: 24px;
  color: #e8d5a8;
  text-align: center;
}

.browser-error p {
  font-size: 14px;
  color: rgba(232, 213, 168, 0.7);
}

#calculator {
  width: 280px;
}

.calc-app {
  margin: 12px;
  background: #1c1410;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--blood-dark);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.calc-display {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid #000;
  box-shadow: 0 0 0 1px rgba(160, 24, 24, 0.3);
  border-radius: 8px;
  background: #14100c;
  color: #e8d5a8;
  font-size: 20px;
  font-family: 'VT323', monospace;
  text-align: right;
  outline: none;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-btn {
  height: 44px;
  border: 1px solid #000;
  border-radius: 8px;
  background: #241a14;
  color: #e8d5a8;
  font-size: 18px;
  font-family: 'VT323', monospace;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.calc-btn:hover {
  background: #33241a;
}

.calc-btn:active {
  background: rgba(160, 24, 24, 0.35);
}

.calc-op {
  background: #33220f;
}

.calc-op:hover {
  background: #4a3016;
}

.calc-eq {
  background: var(--blood);
  color: #fff;
}

.calc-eq:hover {
  background: var(--blood-hover);
}
