:root {
  /* Material You Light Palette (Default) */
  --md-sys-color-primary: #006399;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #cde5ff;
  --md-sys-color-on-primary-container: #001d32;
  --md-sys-color-surface: #f7f9fe;
  --md-sys-color-surface-container: #edeef2;
  --md-sys-color-surface-container-high: #e7e8ed;
  --md-sys-color-on-surface: #191c1e;
  --md-sys-color-on-surface-variant: #41474d;
  --md-sys-color-outline: #72787e;
  --md-sys-color-outline-variant: #c1c7ce;
  --md-sys-color-state-hover: rgba(0, 0, 0, 0.06);
  --md-sys-color-state-active: rgba(0, 0, 0, 0.10);
  --md-sys-elevation-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  /* Material You Dark Palette */
  --md-sys-color-primary: #94ccff;
  --md-sys-color-on-primary: #003353;
  --md-sys-color-primary-container: #004b75;
  --md-sys-color-on-primary-container: #cde5ff;
  --md-sys-color-surface: #111417;
  --md-sys-color-surface-container: #1d2024;
  --md-sys-color-surface-container-high: #272a2e;
  --md-sys-color-on-surface: #e1e2e6;
  --md-sys-color-on-surface-variant: #c1c7ce;
  --md-sys-color-outline: #8b9198;
  --md-sys-color-outline-variant: #41474d;
  --md-sys-color-state-hover: rgba(255, 255, 255, 0.08);
  --md-sys-color-state-active: rgba(255, 255, 255, 0.12);
  --md-sys-elevation-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.icon-button {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: var(--md-sys-elevation-shadow);
}

.icon-button:hover {
  background: var(--md-sys-color-surface-container-high);
  transform: scale(1.05);
}

.icon-button .icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-button:active {
  transform: scale(0.95);
}

/* Layout Wrapper */
.layout-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 1300px;
}

@media (max-width: 1140px) {
  .layout-wrapper {
    max-width: 860px;
  }
}

/* Card Container */
.card-container {
  width: 100%;
  max-width: 400px;
  flex: 1 1 320px;
  background-color: var(--md-sys-color-surface-container);
  border-radius: 32px;
  padding: 36px 24px;
  box-shadow: var(--md-sys-elevation-shadow);
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.main-profile-card {
  order: 2;
}

.projects-window {
  order: 1;
  position: relative;
}

.devices-window {
  order: 3;
}

@media (max-width: 860px) {
  .layout-wrapper {
    flex-direction: column;
    align-items: center;
  }

  .card-container {
    max-width: 440px;
    flex: none;
  }

  .main-profile-card {
    order: 1;
  }

  .projects-window {
    order: 2;
  }

  .devices-window {
    order: 3;
    min-height: auto;
  }
}

.projects-header {
  margin-bottom: 20px;
}

.projects-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card .m3-button {
  padding: 12px 18px;
}

.project-card .m3-label {
  font-size: 14px;
}

.project-desc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0;
  padding: 0 4px;
}

/* Devices Window */
.devices-window {
  position: relative;
}

.devices-header {
  margin-bottom: 16px;
}

.devices-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.devices-canvas {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 320px;
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: 20px;
  border: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
}

.device-item {
  position: relative;
  left: auto !important;
  top: auto !important;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1), z-index 0.25s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none;
}

.device-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.device-thinkpad .device-img {
  animation: minecraft-bob 2.8s ease-in-out infinite;
}

.device-phone .device-img {
  animation: minecraft-bob 2.8s ease-in-out infinite;
  animation-delay: -1.4s;
}

@keyframes minecraft-bob {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.device-thinkpad {
  width: 175px;
  max-width: 58%;
}

.device-phone {
  width: 80px;
  max-width: 28%;
}

.device-item:hover {
  transform: scale(1.08) !important;
  z-index: 10;
}

/* Floating Tooltip */
.device-tooltip {
  position: fixed;
  background-color: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translate(12px, 12px);
  transition: opacity 0.15s ease;
  z-index: 9999;
}

.device-tooltip.visible {
  opacity: 1;
}

/* Header & Avatar */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 32px;
}

.avatar-wrapper {
  position: relative;
  width: 112px;
  height: 112px;
  margin-bottom: 18px;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 40px;
  font-weight: 700;
  user-select: none;
}

.hidden {
  display: none !important;
}

.nickname {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 6px;
}

.bio {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 400;
}

/* Links Section */
.links-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Material You Buttons */
.m3-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: 14px 20px;
  border-radius: 20px;
  font-weight: 500;
  font-size: 15px;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.m3-button:hover {
  background-color: var(--md-sys-color-state-hover);
  border-color: var(--md-sys-color-outline-variant);
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-shadow);
}

.m3-button:active {
  background-color: var(--md-sys-color-state-active);
  transform: translateY(0);
}

.m3-button-content {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.m3-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  fill: var(--md-sys-color-on-surface-variant);
  transition: fill 0.2s ease;
}

.m3-button:hover .m3-icon {
  fill: var(--md-sys-color-on-surface);
}

.m3-label {
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m3-arrow {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 18px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.m3-button:hover .m3-arrow {
  color: var(--md-sys-color-on-surface);
  transform: translateX(3px);
}
