:root {
  --font-sans: "MiSans", "MiSans VF", sans-serif;
  --deep-blue: #184e77;
  --brand-cyan: #168aad;
  --vital-green: #52b69a;
  --fresh-green: #b5e48c;
  --glow-green: #d9ed92;

  --background: #f5f8f4;
  --surface: #ffffff;
  --surface-soft: #eef5f0;
  --heading: #184e77;
  --text: #29454c;
  --muted-text: #647b7a;
  --border: #c9d9d1;
  --primary: #1a759f;
  --on-accent: #ffffff;
  --desktop-sea: #a7d8e5;
  --desktop-sea-deep: #7dc5d2;
  --app-tile: #eff7e4;
  --window-bar: #214e59;
  --window-shadow: rgba(24, 78, 119, 0.18);
  --dialog-backdrop: rgba(11, 23, 26, 0.34);
  --icon-shadow: rgba(24, 78, 119, 0.16);
  --mascot-fill: #b5e48c;
  --mascot-accent: #52b69a;
}

:root[data-theme="dark"] {
  --background: #0b171a;
  --surface: #12252a;
  --surface-soft: #193239;
  --heading: #edf6f2;
  --text: #c7dad4;
  --muted-text: #91aaa3;
  --border: #294148;
  --primary: #52b69a;
  --on-accent: #ffffff;
  --desktop-sea: #123b45;
  --desktop-sea-deep: #0f3038;
  --app-tile: #193239;
  --window-bar: #0f3038;
  --window-shadow: rgba(0, 0, 0, 0.32);
  --dialog-backdrop: rgba(0, 0, 0, 0.58);
  --icon-shadow: rgba(0, 0, 0, 0.3);
  --mascot-fill: #52b69a;
  --mascot-accent: #b5e48c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--background);
  font-family: var(--font-sans);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--background);
  font-family: var(--font-sans);
  font-weight: 380;
  -webkit-font-smoothing: antialiased;
  transition: color 250ms ease, background-color 250ms ease;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button,
input,
textarea,
select,
dialog,
a,
h1,
h2,
h3,
p,
span,
small,
strong {
  font-family: var(--font-sans);
}

.ambient-glow {
  display: none;
}

.desktop-scene {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 23%, color-mix(in srgb, var(--brand-cyan) 9%, transparent), transparent 30%),
    var(--background);
  isolation: isolate;
}

.utility-bar {
  position: absolute;
  z-index: 20;
  top: 22px;
  left: 24px;
}

.theme-toggle {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 0;
  color: var(--heading);
  background: transparent;
  cursor: pointer;
}

.theme-icon {
  position: absolute;
  width: 29px;
  height: 29px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 250ms ease, opacity 250ms ease;
}

.theme-icon--moon {
  transform: rotate(-30deg) scale(0.7);
  opacity: 0;
}

:root[data-theme="dark"] .theme-icon--sun {
  transform: rotate(30deg) scale(0.7);
  opacity: 0;
}

:root[data-theme="dark"] .theme-icon--moon {
  transform: none;
  opacity: 1;
}

.desktop-main {
  position: relative;
  z-index: 4;
  display: flex;
  min-height: 100svh;
  padding: 48px 24px 94px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.desktop-badge {
  position: relative;
  z-index: 2;
  width: 70px;
  height: 70px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 3px solid var(--fresh-green);
  border-radius: 23px;
  background: linear-gradient(145deg, var(--deep-blue), var(--brand-cyan), var(--vital-green));
  box-shadow: 0 12px 30px var(--window-shadow);
  transform: rotate(-4deg);
  animation: badge-arrive 560ms both cubic-bezier(0.22, 1, 0.36, 1);
}

.desktop-badge::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glow-green) 50%, transparent);
  content: "";
}

.desktop-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-window {
  --drag-x: 0px;
  --drag-y: 0px;
  width: min(800px, calc(100vw - 48px));
  height: min(490px, 60svh);
  min-height: 420px;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 10px 0 color-mix(in srgb, var(--window-bar) 16%, transparent), 0 30px 68px var(--window-shadow);
  translate: var(--drag-x) var(--drag-y);
  animation: window-arrive 620ms 80ms both cubic-bezier(0.22, 1, 0.36, 1);
  transition: background-color 250ms ease, border-color 250ms ease;
}

.window-titlebar {
  display: flex;
  height: 48px;
  padding: 0 20px;
  align-items: center;
  justify-content: space-between;
  color: var(--on-accent);
  background: var(--window-bar);
  letter-spacing: 0.02em;
}

.window-titlebar__signal {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
}

.window-titlebar__signal i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glow-green);
  box-shadow: 0 0 12px var(--glow-green);
  animation: signal-pulse 2.2s ease-in-out infinite;
}

.home-window__content {
  display: flex;
  height: calc(100% - 48px);
  padding: 34px 40px 30px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

h1 {
  margin: 0;
  color: var(--brand-cyan);
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  font-weight: 630;
  letter-spacing: -0.045em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

h1 span {
  color: var(--heading);
  font-weight: 380;
}

.home-window__bio {
  margin: 14px 0 0;
  color: var(--text);
  font-size: 17px;
}

.home-window__status {
  margin: 4px 0 0;
  color: var(--muted-text);
  font-size: 14px;
}

.desktop-apps {
  display: flex;
  margin-top: 32px;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(26px, 6vw, 50px);
}

.desktop-app {
  display: flex;
  width: 94px;
  min-height: 116px;
  padding: 0;
  flex-direction: column;
  align-items: center;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.desktop-app__icon {
  display: grid;
  width: 86px;
  height: 78px;
  place-items: center;
  color: var(--heading);
  filter: drop-shadow(0 7px 1px var(--icon-shadow));
  transition: transform 220ms ease, color 220ms ease;
}

.desktop-app__icon svg {
  width: 72px;
  height: 66px;
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.desktop-app__icon .github-mark {
  width: 62px;
  height: 62px;
  fill: currentColor;
  stroke: none;
}

.desktop-app__label {
  margin-top: 8px;
  font-weight: 630;
  letter-spacing: 0.05em;
}

.desktop-app:hover .desktop-app__icon,
.desktop-app:focus-visible .desktop-app__icon {
  color: var(--primary);
  transform: translateY(-5px) rotate(-2deg);
}

.sea-layer {
  position: absolute;
  z-index: 1;
  right: -5%;
  bottom: -7%;
  left: -5%;
  height: 38%;
  border-radius: 50% 50% 0 0 / 13% 13% 0 0;
  background: linear-gradient(var(--desktop-sea), var(--desktop-sea-deep));
  transform: rotate(-0.8deg);
  animation: sea-breathe 9s ease-in-out infinite alternate;
}

.sea-layer::after {
  position: absolute;
  top: 12px;
  right: 0;
  left: 0;
  height: 1px;
  background: color-mix(in srgb, var(--glow-green) 38%, transparent);
  content: "";
}

.sea-friend {
  position: absolute;
  z-index: 5;
  right: 26px;
  bottom: 30px;
  width: 108px;
  overflow: visible;
  animation: friend-bob 4s ease-in-out infinite;
}

.sea-friend ellipse {
  fill: color-mix(in srgb, var(--deep-blue) 25%, transparent);
  stroke: none;
}

.sea-friend path {
  fill: var(--mascot-fill);
  stroke: var(--heading);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sea-friend path:nth-of-type(3) {
  fill: none;
}

.sea-friend circle {
  fill: var(--heading);
}

.desktop-footer {
  position: absolute;
  z-index: 6;
  bottom: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  transform: translateX(-50%);
}

.desktop-footer p,
.desktop-footer a {
  margin: 0;
  opacity: 0.78;
}

.desktop-footer__separator {
  opacity: 0.52;
}

.desktop-footer a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.desktop-footer a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.child-window {
  --drag-x: 0px;
  --drag-y: 0px;
  width: min(620px, calc(100vw - 32px));
  max-height: min(560px, calc(100svh - 64px));
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 90px var(--window-shadow);
  translate: var(--drag-x) var(--drag-y);
}

.child-window[open] {
  animation: dialog-arrive 260ms both cubic-bezier(0.22, 1, 0.36, 1);
}

.child-window::backdrop {
  background: var(--dialog-backdrop);
  backdrop-filter: blur(2px);
}

.child-window__titlebar {
  display: flex;
  height: 48px;
  padding: 0 12px 0 18px;
  align-items: center;
  justify-content: space-between;
  color: var(--on-accent);
  background: var(--window-bar);
}

@media (min-width: 560px) {
  .window-titlebar,
  .child-window__titlebar {
    cursor: grab;
    touch-action: none;
    user-select: none;
  }

  .home-window.is-dragging,
  .child-window.is-dragging {
    cursor: grabbing;
  }

  .home-window.is-dragging .window-titlebar,
  .child-window.is-dragging .child-window__titlebar {
    cursor: grabbing;
  }
}

.child-window__close {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.child-window__content {
  padding: 36px 40px 42px;
  overflow: auto;
}

.about-view,
.link-view {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}

.about-view__avatar {
  width: 142px;
  height: 142px;
  border: 3px solid var(--fresh-green);
  border-radius: 50%;
  object-fit: cover;
}

.about-view h2,
.link-view h2 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 630;
  letter-spacing: -0.035em;
}

.about-view p,
.link-view p {
  margin: 8px 0 0;
  line-height: 1.7;
}

.about-view__handle {
  color: var(--muted-text);
}

.about-view__quote {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted-text);
}

.link-view__icon {
  display: grid;
  width: 130px;
  height: 130px;
  place-items: center;
  border-radius: 24px;
  color: var(--heading);
  background: var(--app-tile);
}

.link-view__icon svg {
  width: 82px;
  height: 74px;
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.link-view__icon .github-mark {
  width: 76px;
  height: 76px;
  fill: currentColor;
  stroke: none;
}

.dialog-link {
  display: inline-flex;
  min-height: 44px;
  margin-top: 18px;
  padding: 0 18px;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  color: var(--on-accent);
  background: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.dialog-link span {
  transition: transform 200ms ease;
}

.dialog-link:hover span {
  transform: translate(2px, -2px);
}

:focus-visible {
  outline: 3px solid var(--fresh-green);
  outline-offset: 4px;
}

@keyframes badge-arrive {
  from { transform: translateY(12px) rotate(-10deg); opacity: 0; }
}

@keyframes window-arrive {
  from { transform: translateY(18px) scale(0.985); opacity: 0; }
}

@keyframes dialog-arrive {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
}

@keyframes sea-breathe {
  to { transform: translateY(-8px) rotate(0.8deg); }
}

@keyframes friend-bob {
  50% { transform: translateY(-8px) rotate(2deg); }
}

@keyframes signal-pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.72);
    box-shadow: 0 0 5px var(--glow-green);
  }
}

@media (max-width: 559px) {
  .desktop-scene {
    min-height: 100svh;
  }

  .utility-bar {
    top: 14px;
    left: 14px;
  }

  .desktop-main {
    min-height: auto;
    padding: clamp(112px, 17svh, 150px) 20px 150px;
    justify-content: flex-start;
  }

  .desktop-badge,
  .window-titlebar {
    display: none;
  }

  .home-window {
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .home-window__content {
    height: auto;
    padding: 0;
  }

  h1 {
    font-size: clamp(2.5rem, 12vw, 3.4rem);
  }

  .home-window__bio {
    margin-top: 10px;
    font-size: 15px;
  }

  .home-window__status {
    font-size: 12px;
  }

  .desktop-apps {
    width: 100%;
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .desktop-app {
    width: auto;
    min-width: 0;
    min-height: 122px;
  }

  .desktop-app__icon {
    width: 100%;
    height: 88px;
    border-radius: 12px;
    background: var(--app-tile);
    filter: none;
  }

  .desktop-app__icon svg {
    width: 60px;
    height: 56px;
  }

  .desktop-app__label {
    margin-top: 7px;
    font-size: 12px;
  }

  .sea-layer {
    right: -18%;
    bottom: -5%;
    left: -18%;
    height: 31%;
    border-radius: 50% 50% 0 0 / 9% 9% 0 0;
  }

  .sea-friend {
    right: 6px;
    bottom: 18px;
    width: 76px;
  }

  .desktop-footer {
    bottom: 7px;
  }

  .child-window {
    width: calc(100vw - 24px);
    max-height: calc(100svh - 48px);
  }

  .child-window__content {
    padding: 28px 24px 32px;
  }

  .about-view,
  .link-view {
    grid-template-columns: 1fr;
    gap: 18px;
    text-align: center;
  }

  .about-view__avatar,
  .link-view__icon {
    width: 104px;
    height: 104px;
    margin: 0 auto;
  }

  .link-view__icon svg {
    width: 66px;
    height: 60px;
  }
}

@media (min-width: 560px) and (max-height: 720px) {
  .desktop-main {
    padding-top: 30px;
    padding-bottom: 76px;
  }

  .desktop-badge {
    width: 58px;
    height: 58px;
    margin-bottom: 10px;
    border-radius: 19px;
  }

  .home-window {
    height: min(430px, 60svh);
    min-height: 390px;
  }

  .home-window__content {
    padding-top: 24px;
    padding-bottom: 22px;
  }

  .desktop-apps {
    margin-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
