:root {
  --bg0: #0c1220;
  --bg1: #152238;
  --panel: rgba(12, 18, 32, 0.82);
  --panel-solid: #141c2e;
  --text: #f3efe6;
  --muted: rgba(243, 239, 230, 0.68);
  --accent: #e8b84a;
  --accent-2: #3db8a0;
  --line: rgba(232, 184, 74, 0.28);
  --danger: #e35d5d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
}

.os {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.wallpaper {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(160deg, rgba(12, 18, 32, 0.35), rgba(12, 18, 32, 0.72)),
    url("../icons/wallpaper.png") center / cover no-repeat,
    radial-gradient(ellipse 80% 60% at 70% 10%, rgba(232, 184, 74, 0.18), transparent 55%),
    linear-gradient(160deg, #243656 0%, var(--bg1) 45%, var(--bg0) 100%);
  z-index: 0;
}

.topbar, .desktop, .taskbar, .start-menu, .window {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: rgba(232, 184, 74, 0.12);
  color: var(--text);
  border-radius: 999px;
  padding: 0.28rem 0.7rem 0.28rem 0.35rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.start-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
}

.start-btn[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(232, 184, 74, 0.35);
}

.top-apps {
  display: flex;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
}

.top-apps a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.2rem 0.45rem;
  border-radius: 8px;
}

.top-apps a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.top-status {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.net { color: var(--accent-2); }

.start-menu {
  position: absolute;
  top: 3rem;
  left: 0.75rem;
  width: min(18rem, calc(100vw - 1.5rem));
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  z-index: 5;
  display: grid;
  gap: 0.35rem;
}

.start-menu[hidden] { display: none; }

.start-title {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.start-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}

.start-item:hover {
  background: rgba(232, 184, 74, 0.12);
}

.start-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px;
}

.desktop {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 7.2rem);
  align-content: start;
  justify-content: start;
  gap: 0.35rem 0.55rem;
  padding: 1.1rem 1rem 1rem;
  overflow: auto;
}

.icon {
  width: 6.4rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.3rem;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}

.icon:hover,
.icon:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.icon-plate {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(20, 28, 46, 0.78);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.icon-plate img {
  width: 2.35rem;
  height: 2.35rem;
  object-fit: contain;
}

.icon-label {
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
}

.window {
  position: absolute;
  z-index: 4;
  left: 4%;
  right: 4%;
  top: 3.6rem;
  bottom: 3.4rem;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.window[hidden] { display: none; }

.window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.55rem;
  background: #0f1626;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.window-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 0;
}

.window-title img {
  border-radius: 4px;
  background: #fff;
}

.window-actions { display: flex; gap: 0.35rem; }

.win-btn {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.win-close:hover {
  background: var(--danger);
  border-color: transparent;
}

#appFrame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #0a0f18;
}

.taskbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.8rem;
  background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.task-left {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.task-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.task-hint {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-right {
  display: flex;
  gap: 0.4rem;
}

.task-app {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 10px;
  padding: 0.28rem 0.55rem;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.task-app.active {
  border-color: var(--accent);
  background: rgba(232, 184, 74, 0.15);
}

@media (max-width: 720px) {
  .top-apps { display: none; }
  .task-hint { display: none; }
  .desktop {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: none;
  }
  .icon { width: auto; }
}
