/* ============================================
   DESIGN SYSTEM — Sujal Portfolio
   Principles: Apple hierarchy + Notion structure + Obsidian workspace feel
   ============================================ */

:root {
  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --duration-fast: 150ms;
  --duration-normal: 220ms;
  --duration-slow: 320ms;

  /* Layout */
  --sidebar-width: 240px;
  --content-max: 720px;
  --content-wide: 860px;

  /* Dark theme (default) */
  --bg: #0c0e12;
  --bg-elevated: #12151b;
  --bg-surface: #181c24;
  --bg-hover: #1e2430;
  --bg-active: #252b38;

  --border: #252b38;
  --border-subtle: #1c212b;
  --border-strong: #32394a;

  --text: #e8eaed;
  --text-secondary: #9aa3b2;
  --text-muted: #6b7380;
  --text-inverse: #0c0e12;

  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --accent-muted: rgba(91, 141, 239, 0.15);
  --accent-text: #8bb0f7;

  --success: #3fb950;
  --success-muted: rgba(63, 185, 80, 0.15);
  --danger: #f85149;
  --danger-muted: rgba(248, 81, 73, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);

  --status: #3fb950;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-surface: #ffffff;
  --bg-hover: #f0f2f5;
  --bg-active: #e8ebf0;

  --border: #e2e5eb;
  --border-subtle: #eceef2;
  --border-strong: #c8cdd6;

  --text: #1a1d24;
  --text-secondary: #4a5160;
  --text-muted: #6b7380;
  --text-inverse: #ffffff;

  --accent: #3b6fd9;
  --accent-hover: #2f5fc4;
  --accent-muted: rgba(59, 111, 217, 0.12);
  --accent-text: #3b6fd9;

  --success: #1a7f37;
  --success-muted: rgba(26, 127, 55, 0.12);
  --danger: #cf222e;
  --danger-muted: rgba(207, 34, 46, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);

  --status: #1a7f37;
}

/* ========== RESET & BASE ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul {
  list-style: none;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.7em;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: var(--weight-medium);
  transition: top var(--duration-fast);
}

.skip-link:focus {
  top: var(--space-4);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ========== APP SHELL ========== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--duration-normal) var(--ease);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  color: var(--text);
}

.logo-mark {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.sidebar-close {
  display: none;
  padding: var(--space-2);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.sidebar-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}

.nav-group {
  margin-bottom: var(--space-6);
}

.nav-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--bg-active);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.nav-item.active .nav-badge {
  background: var(--accent);
  color: white;
}

.nav-item.external svg {
  opacity: 0.5;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  width: 100%;
  transition: background var(--duration-fast);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

.theme-toggle.mobile .theme-label {
  display: none;
}

.cmd-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-xs);
  transition: background var(--duration-fast);
}

.cmd-hint:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.cmd-hint kbd {
  font-size: 0.65rem;
}

/* Mobile bar */
.mobile-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  z-index: 90;
}

.menu-toggle {
  padding: var(--space-2);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.menu-toggle:hover {
  background: var(--bg-hover);
}

.mobile-logo {
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 95;
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ========== MAIN ========== */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  padding: var(--space-10) var(--space-8) var(--space-16);
  max-width: calc(var(--content-wide) + var(--space-16));
}

.section {
  margin-bottom: var(--space-20);
  scroll-margin-top: var(--space-8);
}

.section-header {
  margin-bottom: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.section-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.section-desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 42ch;
  line-height: var(--leading-relaxed);
}

/* ========== HERO ========== */
.hero {
  padding-top: var(--space-8);
  margin-bottom: var(--space-20);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status);
  box-shadow: 0 0 0 3px var(--success-muted);
}

.hero-title {
  font-size: clamp(2rem, 5vw, var(--text-5xl));
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-5);
  color: var(--text);
}

.hero-accent {
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 36ch;
  margin-bottom: var(--space-8);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-10);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--duration-fast), color var(--duration-fast), transform var(--duration-fast), box-shadow var(--duration-fast);
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
}

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

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.meta-value {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

/* ========== PROJECTS ========== */
.project-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.search-wrap {
  position: relative;
  max-width: 280px;
}

.search-wrap svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-10);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast);
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}

.chip:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.chip.active {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent-text);
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.project-card:hover {
  border-color: var(--border-strong);
}

.project-card.hidden {
  display: none;
}

.project-main {
  padding: var(--space-5);
}

.project-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.project-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  color: var(--text);
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.project-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
  max-width: 60ch;
}

.project-links {
  display: flex;
  gap: var(--space-4);
}

.link {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent-text);
  transition: color var(--duration-fast);
}

.link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.project-expand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.project-expand:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.project-expand[aria-expanded="true"] {
  color: var(--text-secondary);
}

.project-expand[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.project-expand svg {
  transition: transform var(--duration-fast);
}

.project-detail {
  padding: 0 var(--space-5) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  animation: fadeIn var(--duration-normal) var(--ease);
}

.project-detail[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-5);
  padding-top: var(--space-5);
}

.detail-grid h4 {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.detail-grid p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.projects-empty {
  text-align: center;
  padding: var(--space-12);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ========== PAGINATION ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  margin-top: var(--space-8);
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), opacity var(--duration-fast);
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-info {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  min-width: 100px;
  text-align: center;
}

/* ========== STACK ========== */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
}

.stack-group {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stack-group-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.stack-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.stack-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stack-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
}

.stack-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ========== ABOUT ========== */
.about-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.about-intro {
  max-width: 52ch;
}

.about-lead {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--text);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}

.about-intro p {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.about-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.panel-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.panel-list li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  line-height: var(--leading-snug);
}

.panel-list li:last-child {
  border-bottom: none;
}

/* ========== CONTACT ========== */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: var(--space-10);
  align-items: start;
}

.contact-subtitle {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-5);
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.channel {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}

.channel:hover {
  background: var(--bg-surface);
  border-color: var(--border);
}

.channel-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.channel:hover .channel-icon {
  border-color: var(--border-strong);
  color: var(--text);
}

.channel-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
}

.channel-handle {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.contact-form-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-field {
  margin-bottom: var(--space-4);
}

.form-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  resize: vertical;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--text-muted);
}

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

.form-field input.invalid,
.form-field textarea.invalid {
  border-color: var(--danger);
}

.field-error {
  display: block;
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-1);
  min-height: 1.2em;
}

.form-actions {
  margin-top: var(--space-2);
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.spinner {
  animation: spin 0.8s linear infinite;
}

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

.form-status {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.form-status.success {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid var(--success);
}

.form-status.error {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ========== FOOTER ========== */
.footer {
  padding-top: var(--space-10);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footer-note {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ========== COMMAND PALETTE ========== */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeOverlay var(--duration-fast) var(--ease);
}

.cmd-overlay[hidden] {
  display: none;
}

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

.cmd-palette {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideDown var(--duration-normal) var(--ease);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.cmd-input-wrap svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmd-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: var(--text-base);
  color: var(--text);
  outline: none;
}

.cmd-input-wrap input::placeholder {
  color: var(--text-muted);
}

.cmd-esc {
  font-size: 0.65rem;
}

.cmd-list {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-2);
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.cmd-item:hover,
.cmd-item.selected {
  background: var(--bg-hover);
  color: var(--text);
}

.cmd-item.selected {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.cmd-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmd-item.selected .cmd-item-icon {
  color: var(--accent-text);
}

.cmd-item-label {
  flex: 1;
}

.cmd-item-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.cmd-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.cmd-footer {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.cmd-footer span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .mobile-bar {
    display: flex;
  }

  .main {
    margin-left: 0;
    padding: calc(56px + var(--space-8)) var(--space-5) var(--space-12);
  }

  .contact-layout {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .hero-meta {
    gap: var(--space-5);
  }
}

@media (max-width: 600px) {
  .main {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .hero-title {
    font-size: var(--text-3xl);
  }

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

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .section-title {
    font-size: var(--text-xl);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .cmd-palette {
    margin: 0 var(--space-3);
    max-width: none;
  }

  .cmd-overlay {
    padding-top: 10vh;
  }
}

/* ========== MULTI-PAGE ADDITIONS ========== */
.page-intro {
  margin-bottom: var(--space-10);
}

.page-title {
  font-size: clamp(1.75rem, 4vw, var(--text-4xl));
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: var(--space-3);
}

.page-lead {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 48ch;
}

.section-header.row {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}

/* Featured cards */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

.featured-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.featured-card:hover {
  border-color: var(--border-strong);
}

.featured-card.highlight {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.featured-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-text);
  background: var(--accent-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  width: fit-content;
}

.featured-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text);
  letter-spacing: -0.01em;
}

.featured-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  flex: 1;
}

.featured-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.featured-links {
  margin-top: var(--space-1);
}

.featured-detail {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.featured-detail p {
  margin-bottom: var(--space-2);
}

.featured-detail p:last-child {
  margin-bottom: 0;
}

.featured-detail strong {
  color: var(--text);
  font-weight: var(--weight-medium);
}

/* Focus grid (home) */
.focus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.focus-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.focus-num {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.focus-item h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.focus-item p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Stack pills */
.stack-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pill {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* CTA block */
.cta-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.cta-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.cta-desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  max-width: 40ch;
  margin-left: auto;
  margin-right: auto;
}

.cta-block .hero-actions {
  justify-content: center;
  margin-bottom: 0;
}

/* APK section */
.apk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.apk-card {
  display: flex;
  gap: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  align-items: flex-start;
}

.apk-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.apk-body {
  flex: 1;
  min-width: 0;
}

.apk-name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.apk-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}

.apk-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
  max-width: 60ch;
}

/* How I work */
.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.how-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.how-item h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.how-item p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Contact extras */
.contact-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  line-height: var(--leading-relaxed);
}

.contact-topics {
  margin-top: var(--space-8);
}

.topic-list {
  margin-top: var(--space-3);
}

.topic-list li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  padding-left: var(--space-4);
  position: relative;
}

.topic-list li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

.topic-list li:last-child {
  border-bottom: none;
}

@media (max-width: 900px) {
  .section-header.row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ========== PAGE TRANSITIONS ========== */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 320ms;
  animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
}

::view-transition-old(root) {
  animation-name: page-slide-out;
}

::view-transition-new(root) {
  animation-name: page-slide-in;
}

@keyframes page-slide-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-24px);
  }
}

@keyframes page-slide-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fallback overlay (browsers without View Transitions) */
.page-transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: var(--bg);
  opacity: 0;
  transform: translateX(0);
  transition:
    opacity 280ms cubic-bezier(0.25, 0.1, 0.25, 1),
    transform 280ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.page-transition-overlay.is-leaving {
  pointer-events: auto;
  opacity: 1;
  transform: translateX(0);
}

.page-transition-overlay.is-entering {
  opacity: 0;
  transform: translateX(-16px);
}

/* Main content enter on load (fallback) */
.main.page-enter {
  animation: content-enter 360ms cubic-bezier(0.25, 0.1, 0.25, 1) both;
}

@keyframes content-enter {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  .page-transition-overlay {
    transition: none !important;
  }

  .main.page-enter {
    animation: none !important;
  }
}

/* Cross-document view transitions (Chrome 126+, Edge) */
@view-transition {
  navigation: auto;
}
