:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --text: #16181d;
  --muted: #666a73;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-soft: #15181f;
    --text: #eaebef;
    --muted: #9297a3;
    --accent: #6ea8fe;
    --accent-2: #b794f6;
    --border: #262a33;
    --card-bg: #171a21;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  /* Safety net: Safari's flexbox implementation can let a text-heavy flex
     child refuse to shrink below its unwrapped width (see .role-header),
     which forces page-wide horizontal scroll. This guarantees it can't. */
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

img {
  max-width: 100%;
  display: block;
}

/* Header */

header.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

header.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
}

.site-title .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 0.75rem;
}

nav.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav.site-nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding-bottom: 2px;
}

nav.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.15s ease;
}

nav.site-nav a:hover {
  color: var(--text);
}

nav.site-nav a:hover::after,
nav.site-nav a.active::after {
  transform: scaleX(1);
}

nav.site-nav a.active {
  color: var(--text);
}

main {
  padding-bottom: 4rem;
}

h1 {
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

p.lede {
  color: var(--muted);
  font-size: 1.05rem;
}

a {
  color: var(--accent);
}

/* Avatar (generated, no photo needed) */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

/* Hero */

.hero {
  position: relative;
  padding: 4.5rem 0 3.5rem;
  overflow: hidden;
  background:
    radial-gradient(600px 300px at 15% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
    radial-gradient(500px 260px at 100% 0%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent);
  border-bottom: 1px solid var(--border);
}

.hero .container {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

.hero-content {
  min-width: 0;
}

.hero .avatar {
  width: 128px;
  height: 128px;
  font-size: 2.4rem;
  box-shadow: var(--shadow-hover);
}

.hero-avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-hover);
  border: 3px solid var(--bg);
}

.hero-content h1 {
  margin-bottom: 0.35rem;
}

.hero-eyebrow {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.social-links {
  display: flex;
  gap: 0.85rem;
  margin-top: 1.4rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.social-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.social-links svg {
  width: 18px;
  height: 18px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  padding: 0.65rem 1.3rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Sections */

section.section {
  /* longhand, not shorthand: this is combined with .container on the same
     element, and a shorthand here would win on specificity and wipe out
     .container's left/right padding, pushing content edge-to-edge */
  padding-top: 3rem;
  padding-bottom: 3rem;
}

section.section + section.section {
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Feature grid (home page: blog / guestbook / apps) */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.feature-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.feature-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  margin-bottom: 0.9rem;
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

.feature-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Skills / tech chips */

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

/* Cards (blog / guestbook entries) */

.card {
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.25rem;
}

.card .meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card a.card-link {
  text-decoration: none;
  color: inherit;
}

.card a.card-link:hover h2 {
  color: var(--accent);
}

.timeline-item:hover {
  box-shadow: var(--shadow);
  transform: none;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-item .role-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.timeline-item .role-title {
  font-weight: 600;
  font-size: 1.05rem;
  min-width: 0;
  overflow-wrap: break-word;
}

.timeline-item .role-dates {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.timeline-item .role-company {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.timeline-item ul {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.92rem;
}

.timeline-item li + li {
  margin-top: 0.4rem;
}

.empty-state,
.error-state {
  color: var(--muted);
  font-style: italic;
}

/* Forms */

form.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 480px;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

button {
  align-self: flex-start;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.65rem 1.4rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

button:hover {
  opacity: 0.9;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.honeypot-field {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

.app-list {
  display: grid;
  gap: 1rem;
}

.app-list .card p {
  margin: 0;
  color: var(--muted);
}

.status-message {
  font-size: 0.9rem;
  margin-top: -0.25rem;
}

.status-message.success {
  color: #16a34a;
}

.status-message.error {
  color: #dc2626;
}

/* Footer */

footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

footer.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

footer.site-footer .social-links {
  margin-top: 0;
}

footer.site-footer .social-links a {
  width: 32px;
  height: 32px;
}

footer.site-footer .social-links svg {
  width: 16px;
  height: 16px;
}

/* Music player */

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-title-row h1 {
  margin-bottom: 0;
}

.add-song-form {
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  max-width: 480px;
}

.cover-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.cover-preview img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.add-song-actions {
  display: flex;
  gap: 0.75rem;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 7rem;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}

.track-row:hover {
  background: var(--bg-soft);
}

.track-row.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.track-row.active .track-title {
  color: var(--accent);
}

.track-cover,
.np-cover {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.track-cover svg,
.np-cover svg {
  width: 20px;
  height: 20px;
}

.track-cover img,
.np-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-title,
.np-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist,
.np-artist {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  color: var(--muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.now-playing-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.25rem;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
}

.now-playing-bar .np-info {
  min-width: 0;
  width: 160px;
  flex-shrink: 0;
}

.np-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.np-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.np-btn {
  background: none;
  border: none;
  padding: 0.25rem;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.np-btn svg {
  width: 20px;
  height: 20px;
}

.np-btn-play svg {
  width: 28px;
  height: 28px;
}

.np-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.np-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.np-time {
  color: var(--muted);
  font-size: 0.78rem;
  width: 34px;
  flex-shrink: 0;
}

.np-time:last-child {
  text-align: right;
}

.np-seek {
  flex: 1;
  min-width: 0;
}

.np-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 130px;
  flex-shrink: 0;
  color: var(--muted);
}

.np-volume svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.np-volume input[type="range"] {
  /* Range inputs render at a browser-default width (~129px in Chromium)
     that doesn't actually shrink to fit a flex item's declared width,
     which was pushing the whole bar past the viewport edge. */
  width: 90px;
  min-width: 0;
}

input[type="range"] {
  accent-color: var(--accent);
}

@media (max-width: 640px) {
  .hero .container {
    flex-direction: column;
    text-align: center;
  }

  .hero-actions,
  .social-links {
    justify-content: center;
  }

  footer.site-footer .container {
    flex-direction: column;
    text-align: center;
  }

  .now-playing-bar {
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
  }

  .now-playing-bar .np-info {
    width: auto;
    order: 1;
    flex: 1;
  }

  .np-cover {
    order: 0;
  }

  .np-controls {
    order: 2;
  }

  .np-main {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }

  .np-volume {
    display: none;
  }
}

/* Sign-in control in the header nav (js/auth.js) */
nav.site-nav {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

.auth-slot {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-slot .auth-btn {
  align-self: center;
  font-size: 0.88rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
}

.auth-slot .auth-user {
  align-self: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid var(--border);
}

.auth-slot .auth-user img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-slot .auth-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 220px;
  max-width: min(300px, calc(100vw - 2rem));
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
}

.auth-slot .auth-menu small {
  color: var(--muted);
  overflow-wrap: anywhere;
  margin-bottom: 8px;
}

.auth-slot .auth-menu .auth-out {
  font-size: 0.88rem;
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

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