
/* CSS Variables and Color Schemes */
:root {
  --bg: #fff;
  --fg: #1a1a1a;
  --container-bg: #fff;
  --container-border: #e2e8f0;
  --container-shadow: 0 8px 30px rgba(0,0,0,0.08);
  --avatar-border: #e2e8f0;
  --avatar-shadow: 0 4px 16px rgba(0,0,0,0.08);
  --name-color: #1a1a1a;
  --bio-color: #4a5568;
  --bio-first-color: #1a1a1a;
  --links-border: #e2e8f0;
  --link-color: #718096;
  --link-hover: #2563eb;
  --focus-outline: #2563eb;
}

body.light-mode, html.light-mode {
  --bg: #fff;
  --fg: #1a1a1a;
  --container-bg: #fff;
  --container-border: #e2e8f0;
  --container-shadow: 0 8px 30px rgba(0,0,0,0.08);
  --avatar-border: #e2e8f0;
  --avatar-shadow: 0 4px 16px rgba(0,0,0,0.08);
  --name-color: #1a1a1a;
  --bio-color: #4a5568;
  --bio-first-color: #1a1a1a;
  --links-border: #cbd5e1; /* slightly darker than previous light border */
  --link-color: #718096;
  --link-hover: #60a5fa; /* match dark-mode hover color */
  --focus-outline: #2563eb;
}

body.dark-mode, html.dark-mode {
  --bg: #18181b;
  --fg: #e5e7eb;
  --container-bg: #23232a;
  --container-border: #2d2d36;
  --container-shadow: 0 8px 30px rgba(0,0,0,0.32);
  --avatar-border: #2d2d36;
  --avatar-shadow: 0 4px 16px rgba(0,0,0,0.18);
  --name-color: #e5e7eb;
  --bio-color: #a1a1aa;
  --bio-first-color: #e5e7eb;
  --links-border: #3a3a44; /* slightly brighter in dark mode */
  --link-color: #a1a1aa;
  --link-hover: #60a5fa;
  --focus-outline: #60a5fa;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --fg: #e5e7eb;
    --container-bg: #23232a;
    --container-border: #2d2d36;
    --container-shadow: 0 8px 30px rgba(0,0,0,0.32);
    --avatar-border: #2d2d36;
    --avatar-shadow: 0 4px 16px rgba(0,0,0,0.18);
    --name-color: #e5e7eb;
    --bio-color: #a1a1aa;
    --bio-first-color: #e5e7eb;
    --links-border: #2d2d36;
    --link-color: #a1a1aa;
    --link-hover: #60a5fa;
    --focus-outline: #60a5fa;
  }
}

/* Global Styles */
html,
body {
  background-color: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-top: 4rem;
}

* {
  box-sizing: border-box;
}

/* Layout Containers */
.profile-container {
  background: var(--container-bg);
  border: 1px solid var(--container-border);
  box-shadow: var(--container-shadow);
  max-width: 28rem;
  margin: 0 auto 2rem;
  padding: 3rem 2rem;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

/* Components */
.profile-avatar {
  box-shadow: var(--avatar-shadow);
  width: 8.5rem;
  height: 8.5rem;
  border-radius: 50%;
  border: 4px solid var(--avatar-border);
  margin-bottom: 1.5rem;
  object-fit: cover;
}

.theme-btn {
  position: absolute;
  top: 1rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--theme-btn-bg, #596673);
  color: var(--theme-btn-fg, #222);
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}
.theme-btn.clear {
  right: 4.5rem;
  margin-top: 0.2rem
}
.theme-btn.toggle {
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
}
html.light-mode .theme-btn,
body.light-mode .theme-btn {
  --theme-btn-fg: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
html.dark-mode .theme-btn,
body.dark-mode .theme-btn {
  --theme-btn-fg: #111;
  box-shadow: 0 2px 10px rgba(255,255,255,0.04);
}

.profile-name {
  color: var(--name-color);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.025em;
  text-align: center;
}
.profile-bio {
  text-align: center;
  margin-bottom: 2rem;
}
.profile-bio p {
  color: var(--bio-color);
  margin: 0 0 1rem 0;
}
.profile-bio p:first-child {
  color: var(--bio-first-color);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}
.profile-bio p:last-child {
  margin-bottom: 0;
  line-height: 1.7;
}
.profile-links {
  border-top: 1px solid var(--links-border);
  padding-top: 1.5rem;
  width: 90%;
}

/* Utility and Interaction Styles */
.links-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}
.links-list a {
  color: var(--link-color);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  text-decoration: none;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
}
.links-list a:hover {
  color: var(--link-hover);
}
.links-list a:active {
  transform: translateY(0);
}
.links-list svg {
  width: 1.75rem;
  height: 1.75rem;
}
a:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
}

/* Media Queries */
@media (max-width: 640px) {
  .profile-container {
    width: calc(100% - 2rem);
    max-width: 28rem;
    padding: 2rem 1.5rem;
  }

  .theme-btn {
    position: static;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .theme-actions {
    position: fixed;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    z-index: 9999;
    pointer-events: auto;
  }

  .theme-actions .theme-btn.clear { order: 0; }
  .theme-actions .theme-btn.toggle { order: 1; }
}