/* ── CSS Variables for Light/Dark Themes ── */

:root {
  /* Light theme (default) - Premium Slate Palette */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --accent-primary: #0284c7;
  --accent-hover: #0369a1;
  --accent-light: rgba(2, 132, 199, 0.08);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --radius-pill: 999px;
  --transition-speed: 0.25s;
  --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  /* Dark theme - Premium Deep Ocean Slate */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: #1f2937;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #374151;
  --accent-primary: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-light: rgba(56, 189, 248, 0.1);
  --danger: #f87171;
  --danger-hover: #ef4444;
  --success: #34d399;
  --warning: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

/* ── Reset & Base ── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  min-width: 320px;
  letter-spacing: -0.011em;
}

h1, h2, h3, h4 {
  letter-spacing: -0.03em;
  line-height: 1.15;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-speed);
}

a:hover {
  color: var(--accent-hover);
}

/* Respect reduced-motion preferences: kill scroll animation & reveal transitions */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Scroll Reveal ── */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s var(--ease-premium), transform 0.7s var(--ease-premium);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Layout Container ── */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Header ── */

.site-header {
  background-color: var(--bg-secondary);
  background-color: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
  border-bottom: 1px solid transparent;
  padding: 1.125rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed), padding var(--transition-speed);
}

.site-header.is-scrolled {
  border-bottom-color: var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.site-brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  flex-shrink: 0;
}

.site-brand:hover {
  color: var(--accent-primary);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin: 0 auto;
}

.nav-link {
  position: relative;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  padding-bottom: 0.2rem;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 2px;
  background-color: var(--accent-primary);
  border-radius: var(--radius-pill);
  transition: right var(--transition-speed) var(--ease-premium);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link:hover::after {
  right: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .site-nav {
    gap: 1rem;
  }

  .header-content {
    flex-wrap: wrap;
    justify-content: center;
  }

  .site-nav {
    order: 3;
    width: 100%;
    justify-content: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
  }
}

.user-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* ── Footer ── */

.site-footer {
  margin-top: auto;
  padding: 2.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-speed) var(--ease-premium), box-shadow var(--transition-speed), background-color var(--transition-speed), border-color var(--transition-speed);
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-color: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--bg-secondary);
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
  box-shadow: var(--shadow-md);
}

.btn-icon {
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  border-radius: var(--radius-pill);
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.75rem;
  border-radius: var(--radius-pill);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.hidden {
  display: none !important;
}

/* ── Status Messages ── */

.status-message {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}

.status-message.error {
  color: var(--danger);
  background-color: rgba(239, 68, 68, 0.1);
  border-radius: var(--border-radius);
  margin: 1rem;
}

/* ── Spinner ── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Offline Banner ── */

.offline-banner {
  background-color: var(--warning);
  color: #1f2937;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.875rem;
}

/* ── Hero Section ── */

.hero-section {
  padding: 6rem 0 5rem;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 800px 420px at 50% -10%, var(--accent-light) 0%, transparent 70%);
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
  max-width: 680px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero-avatar-wrap {
  width: 152px;
  height: 152px;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--bg-card);
  padding: 4px;
  background-image: linear-gradient(var(--bg-card), var(--bg-card)), linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
  background-origin: border-box;
  background-clip: content-box, border-box;
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}

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

.hero-avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-muted);
  background-color: var(--bg-secondary);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--accent-light);
  color: var(--accent-primary);
  font-size: 0.8125rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  letter-spacing: 0.01em;
}

.hero-heading {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--text-primary);
}

.hero-intro {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 560px;
}

.hero-intro.skeleton-text {
  color: var(--text-muted);
}

.hero-actions {
  display: flex;
  gap: 0.875rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.5rem;
}

.hero-tech-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
}

.hero-tech-pill {
  padding: 0.375rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
}

@media (max-width: 640px) {
  .hero-section {
    padding: 4rem 0 3rem;
  }

  .hero-avatar-wrap {
    width: 116px;
    height: 116px;
  }

  .hero-intro {
    font-size: 1rem;
  }
}

/* ── Section Eyebrow + Heading (shared by Apps / About / Contact) ── */

.section-eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: 0.625rem;
}

.section-heading {
  font-size: clamp(1.625rem, 3vw, 2.125rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.625rem;
}

.section-lead {
  color: var(--text-muted);
  font-size: 1.0625rem;
  margin-bottom: 0.5rem;
  max-width: 620px;
}

.section-header-block {
  padding-top: 5rem;
  text-align: center;
}

.section-header-block--tight {
  padding-top: 0;
}

.section-header-block .section-lead {
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 640px) {
  .section-header-block {
    padding-top: 3.5rem;
  }
}

/* ── About Me Section ── */

.about-section {
  padding: 5rem 0;
}

.about-content {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  line-height: 1.8;
  max-width: 720px;
  margin: 0 auto;
  text-align: left;
}

.about-content p {
  margin-bottom: 1rem;
}

.about-content p:last-child {
  margin-bottom: 0;
}

/* ── Contact Me Section ── */

.contact-section {
  padding: 5rem 0 6rem;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.contact-form {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  text-align: left;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.contact-form .form-actions {
  margin-top: 0.5rem;
}

/* Honeypot field: hidden from sighted users and screen readers, but present
   in the DOM/tab flow bypass to trap simple bots. Real users never see it. */
.honeypot-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ── Portfolio Grid (Public) ── */

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  padding: 2.5rem 0;
}

/* ── Portfolio Card ── */

.portfolio-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform var(--transition-speed), box-shadow var(--transition-speed), border-color var(--transition-speed);
}

.portfolio-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
}

.card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
}

.portfolio-card:hover .card-image img {
  transform: scale(1.04);
}

.card-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.card-description-container {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
}

.card-description {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
}

/* Tags - no longer pushed down */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
}

.tag {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Branded Download Store Buttons (pushed to bottom) ── */

.card-store-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-store-buttons:has(> :only-child) {
  justify-content: center;
}

.btn-store {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: #0f172a; /* Slate 900 background */
  color: #ffffff;
  border: 1px solid #1e293b;
  border-radius: 8px;
  text-decoration: none;
  min-height: 44px; /* Standard accessible target size */
  flex: 1 1 0;
  min-width: 0;
  transition: background-color var(--transition-speed), border-color var(--transition-speed), transform var(--transition-speed);
}

[data-theme="dark"] .btn-store {
  background-color: #1e293b; /* Slate 800 background */
  border-color: #334155;
}

.btn-store:hover {
  background-color: #020617;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-store:hover {
  background-color: #0f172a;
  border-color: var(--accent-primary);
}

.store-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.store-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.store-subtitle {
  font-size: 0.5625rem;
  text-transform: uppercase;
  font-weight: 500;
  color: #94a3b8;
}

.store-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #ffffff;
}

.card-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 0.875rem;
}

.card-link {
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* ── Card Bottom Section (pushes store buttons/footer to bottom) ── */

.card-bottom-section {
  margin-top: auto; /* Push store buttons and footer to the bottom of card */
}

/* "Read more" row — right-aligned with spacing below */
.card-readmore-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.card-description-trigger {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color var(--transition-speed), transform var(--transition-speed);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.card-description-trigger:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.card-description-trigger:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
  border-radius: 4px;
}

/* ── Admin Body ── */

.admin-header h1 {
  font-size: 1.25rem;
}

/* ── Auth Section (Login) ── */

.auth-section {
  min-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ── Admin Tabs ── */

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 1.5rem 0 0;
}

.admin-tab-btn {
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-speed);
}

.admin-tab-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.admin-tab-btn.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* ── Dashboard Grid (Admin) ── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  padding: 2rem 0;
}

@media (max-width: 960px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Panels ── */

.panel {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.panel h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

/* ── Admin Item List ── */

.admin-item-list {
  margin-top: 1rem;
}

.admin-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.admin-item:last-child {
  border-bottom: none;
}

.admin-item-preview {
  width: 60px;
  height: 45px;
  border-radius: var(--border-radius);
  overflow: hidden;
  flex-shrink: 0;
}

.admin-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.625rem;
}

.admin-item-info {
  flex: 1;
  min-width: 0;
}

.admin-item-info h3 {
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-item-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-item-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.admin-item-actions {
  display: flex;
  gap: 0.5rem;
}

.empty-text {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* ── Editor Panel ── */

.editor-panel {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

/* ── Form Styles ── */

.admin-form {
  display: flex;
  flex-direction: column;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* ── Admin: Hero / Profile Panel ── */

.hero-editor-panel {
  max-width: 640px;
}

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  flex-shrink: 0;
}

.admin-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-avatar-preview .no-image-placeholder {
  font-size: 0.625rem;
  text-align: center;
  padding: 0.5rem;
}

.avatar-upload-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
}

/* ── Admin: About Me Panel ── */

.about-editor-panel textarea#about-content-input {
  min-height: 220px;
}

/* ── Admin: Messages Panel ── */

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.message-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.message-from {
  font-weight: 600;
  font-size: 0.9375rem;
}

.message-email {
  color: var(--accent-primary);
  font-size: 0.8125rem;
}

.message-date {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.message-body {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: pre-wrap;
  margin-bottom: 0.75rem;
}

/* ── Upload Preview ── */

.upload-preview-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
}

#upload-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Modal ── */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
}

.modal-sm {
  max-width: 400px;
}

.modal-content h3 {
  margin-bottom: 0.75rem;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* ── Progress Bar ── */

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  height: 100%;
  background-color: var(--accent-primary);
  width: 0%;
  transition: width 0.3s ease;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
  }

  .site-header h1 {
    font-size: 1.25rem;
  }

  .header-actions {
    gap: 0.5rem;
  }

  .auth-card {
    padding: 1.5rem;
  }

  .editor-panel {
    position: static;
    max-height: none;
  }

  .admin-item {
    flex-wrap: wrap;
  }

  .admin-item-actions {
    width: 100%;
    margin-top: 0.5rem;
  }

  .admin-item-actions button {
    flex: 1;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .header-content {
    flex-direction: column;
    gap: 0.75rem;
  }

  .container {
    padding: 0 0.75rem;
  }

  .portfolio-grid {
    gap: 1rem;
    padding: 1rem 0;
  }

  .card-title {
    font-size: 1.15rem;
  }

  .card-description {
    font-size: 0.875rem;
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }
}

/* ── Live Preview Card (Admin Editor) ── */

.live-preview-section {
  margin-bottom: 1.25rem;
}

.live-preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.live-preview-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 2px dashed var(--border-color);
}

.live-preview-card .card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--bg-secondary);
  position: relative;
}

.live-preview-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-preview-card .no-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.live-preview-card .card-content {
  padding: 0.875rem;
}

.live-preview-card .card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  min-height: 1.25rem;
}

.live-preview-card .card-description {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 0.625rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8rem;
}

.live-preview-card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  min-height: 1.5rem;
}

/* ── Image Editor Modal ── */

.image-editor-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.editor-modal-content {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 100%;
  max-height: 95vh;
  overflow-y: auto;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.editor-header h2 {
  font-size: 1.125rem;
  margin: 0;
}

.editor-close-btn {
  font-size: 1.125rem;
  padding: 0.375rem;
  line-height: 1;
}

.editor-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .editor-body {
    grid-template-columns: 1fr;
  }
}

.editor-viewport {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--border-radius);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  position: relative;
  cursor: grab;
}

.editor-viewport canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.editor-preview-section {
  display: flex;
  flex-direction: column;
}

.editor-preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.editor-preview-section .portfolio-card {
  max-width: 350px;
  width: 100%;
}

.editor-preview-section .card-image canvas {
  width: 100%;
  height: 100%;
}

/* Avatar editor variant: square viewport, circular crop guide + preview */

.editor-viewport-square {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
}

.avatar-editor-preview-circle {
  width: 160px;
  height: 160px;
  max-width: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  margin: 0 auto;
}

.avatar-editor-preview-circle canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Editor Controls ── */

.editor-controls {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.editor-control-group {
  margin-bottom: 1rem;
}

.editor-control-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 3rem;
}

.slider-label:first-child {
  text-align: right;
}

.slider-label:last-child {
  text-align: left;
}

.slider-row input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.zoom-value-display {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-top: 0.25rem;
}

.editor-size-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
}

.editor-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .editor-actions {
    flex-direction: column;
  }

  .editor-actions button {
    width: 100%;
  }

  .editor-modal-content {
    max-height: 100vh;
    border-radius: 0;
  }

  .editor-body {
    padding: 1rem;
  }

  .editor-controls {
    padding: 1rem;
  }
}

/* ── Description Modal (Public Card Detail) ── */

.description-modal {
  border: none;
  background: transparent;
  max-width: 640px;
  width: 92%;
  max-height: 80vh;
  padding: 0;
  outline: none;
  overflow: hidden;
  /* Explicit centering — replaces broken native <dialog> positioning */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Neutralize browser's internal ::before pseudo-element that also centers <dialog> */
.description-modal::before {
  display: none !important;
}

.description-modal[open] {
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* backdrop must cover the full viewport */
.description-modal::backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  animation: modalFadeIn 0.25s ease forwards;
}

.description-modal-content {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.description-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.description-modal-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.description-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: var(--border-radius);
  transition: color var(--transition-speed), background-color var(--transition-speed);
}

.description-modal-close:hover {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.description-modal-close:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.description-modal-body {
  padding: 1.5rem;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.75;
  overflow-y: auto;
  flex-grow: 1;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScaleIn {
  from { transform: translate(-50%, -50%) scale(0.95); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (max-width: 768px) {
  .description-modal {
    width: 100vw;
    height: 100dvh; /* dynamic viewport — adapts when mobile keyboard opens */
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .description-modal-content {
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .description-modal-body {
    font-size: 1rem;
    padding: 1.25rem;
  }

  .card-store-buttons {
    gap: 0.5rem;
  }
}

/* ── Print Styles ── */

@media print {
  .site-header,
  .site-footer,
  #theme-toggle,
  .offline-banner {
    display: none !important;
  }

  body {
    background-color: white;
    color: black;
  }

  .portfolio-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
