/* ============================================================
   Kailash Yadav — Portfolio
   Design inspired by rybkr.com (PaperMod-based, vim aesthetic)
   ============================================================ */

/* ---------- Base variables (light default) ---------- */
:root {
  --gap: 24px;
  --content-gap: 20px;
  --nav-width: 1024px;
  --main-width: 720px;
  --header-height: 60px;
  --footer-height: 60px;
  --radius: 8px;

  --theme: #f7f8f6;
  --entry: #ffffff;
  --primary: #20272a;
  --secondary: #586467;
  --tertiary: #d3ddda;
  --content: #273033;
  --code-block-bg: #1c1d21;
  --code-bg: #edf2f1;
  --border: #d9e2df;
  --accent: #2f7882;
  --accent-hover: #286a72;
  --accent-subtle: rgba(47, 120, 130, 0.12);
  --accent-warm: #5f765a;
  --accent-warm-subtle: rgba(95, 118, 90, 0.13);
  --shadow-soft: 0 12px 32px rgba(24, 36, 40, 0.07);
  --shadow-tight: 0 4px 14px rgba(24, 36, 40, 0.07);
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --theme: #101416;
  --entry: #171d1f;
  --primary: #eef3f2;
  --secondary: #adb7b8;
  --tertiary: #3b4645;
  --content: #dde5e3;
  --code-block-bg: #2e2e33;
  --code-bg: #1d2526;
  --border: #2c3635;
  --accent: #8ecdd4;
  --accent-hover: #addfe3;
  --accent-subtle: rgba(142, 205, 212, 0.16);
  --accent-warm: #b0c59b;
  --accent-warm-subtle: rgba(176, 197, 155, 0.14);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.28);
  --shadow-tight: 0 5px 16px rgba(0, 0, 0, 0.22);
  color-scheme: dark;
}

/* ---------- Statusline variables ---------- */
:root {
  --statusline-height: 1.72rem;
  --statusline-command-height: 1.6rem;
  --statusline-footer-gap: 0.85rem;
  --statusline-bg: #ecefeb;
  --statusline-mode-bg: #8fa88f;
  --statusline-mode-fg: #17221a;
  --statusline-mid-bg: #d4dfdc;
  --statusline-mid-fg: #273434;
  --statusline-tail-fg: #667174;
}

:root[data-theme='dark'] {
  --statusline-bg: color-mix(in srgb, var(--entry) 88%, black);
  --statusline-mode-bg: color-mix(in srgb, var(--accent-warm) 72%, var(--accent) 28%);
  --statusline-mode-fg: #101419;
  --statusline-mid-bg: color-mix(in srgb, var(--accent) 24%, var(--entry));
  --statusline-mid-fg: color-mix(in srgb, var(--primary) 78%, var(--accent-warm));
  --statusline-tail-fg: var(--secondary);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body,
figure,
ul {
  margin: 0;
}

ul {
  list-style: none;
}

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

button {
  font: inherit;
}

/* ---------- Typography ---------- */
body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  word-break: break-word;
  background: var(--theme);
  -webkit-font-smoothing: antialiased;
}

body,
body.list {
  background: linear-gradient(var(--theme), var(--theme)),
    repeating-linear-gradient(
      90deg,
      color-mix(in srgb, var(--border) 32%, transparent) 0 1px,
      transparent 1px 56px
    );
  background-blend-mode: normal, multiply;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  color: var(--primary);
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: 0;
}

a,
button {
  color: var(--primary);
}

a {
  text-decoration: none;
  color: var(--accent);
  transition: color 0.15s ease-out;
}

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

::selection {
  background: var(--accent-warm-subtle);
  color: var(--primary);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

code,
kbd,
pre,
.shortcut-key,
.search-hint-key,
.command-palette-hint {
  font-family: var(--mono);
}

kbd,
.shortcut-key,
.search-hint-key,
.command-palette-hint {
  border-bottom-width: 2px;
  border-radius: 5px;
  box-shadow: 0 1px rgba(255, 255, 255, 0.28) inset;
  font-weight: 500;
}

@media screen and (min-width: 768px) {
  ::-webkit-scrollbar {
    width: 19px;
    height: 11px;
  }
}

::-webkit-scrollbar-track {
  background: 0 0;
}

::-webkit-scrollbar-thumb {
  background: var(--tertiary);
  border: 5px solid var(--theme);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

::-webkit-scrollbar:not(.highlighttable, .highlight table, .gist .highlight) {
  background: var(--theme);
}

/* ---------- Layout harness ---------- */
body:not(.chrome-less) {
  padding-bottom: calc(var(--statusline-height) + env(safe-area-inset-bottom));
}

body:not(.chrome-less) .main {
  min-height: calc(100vh - var(--header-height) - var(--footer-height) - var(--statusline-height) - var(--statusline-footer-gap));
}

/* ---------- Header / Nav ---------- */
.header {
  background: color-mix(in srgb, var(--theme) 88%, transparent);
  backdrop-filter: blur(12px);
}

@supports not (backdrop-filter: blur(12px)) {
  .header {
    background: var(--theme);
  }
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  max-width: calc(var(--nav-width) + var(--gap) * 2);
  margin-inline-start: auto;
  margin-inline-end: auto;
  line-height: var(--header-height);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

.nav a {
  display: block;
  color: var(--primary);
  text-decoration: none;
}

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

.logo,
#menu {
  display: flex;
  margin: auto var(--gap);
}

.logo {
  flex-wrap: inherit;
  align-items: center;
}

.logo a {
  font-size: 24px;
  font-weight: 700;
}

.logo-switches {
  display: inline-flex;
  margin: auto 4px;
  flex-wrap: inherit;
}

#menu {
  list-style: none;
  word-break: keep-all;
  overflow-x: auto;
  white-space: nowrap;
}

#menu li + li {
  margin-inline-start: var(--gap);
}

#menu a {
  font-size: 16px;
}

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

button#theme-toggle {
  font-size: 26px;
  margin: auto 4px;
  line-height: var(--header-height);
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--primary);
  transition: color 0.15s ease-out;
}

button#theme-toggle:hover {
  color: var(--accent);
}

button#theme-toggle svg {
  display: inline-block;
  vertical-align: middle;
}

[data-theme='dark'] #moon {
  display: none;
}

[data-theme='light'] #sun {
  display: none;
}

#theme-toggle:focus {
  outline: 0;
}

/* ---------- Home intro ---------- */
.home-intro {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 4.75rem 1rem 3.5rem;
}

.home-intro > :not(.home-boids) {
  position: relative;
  z-index: 1;
}

.home-boids {
  position: fixed;
  inset: var(--header-height) 0 0;
  width: 100vw;
  height: calc(100vh - var(--header-height));
  z-index: 0;
  pointer-events: none;
  opacity: 0.48;
}

.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.45rem;
}

.home-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 1.25rem;
}

.home-headshot {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: 0 0 0 4px var(--entry), var(--shadow-tight);
  background: var(--code-bg);
}

.home-name {
  font-size: 2.65rem;
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 0;
}

/* ---------- Home sections ---------- */
.home-section {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.35rem 1rem;
  margin: 0;
  padding: 1rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

.home-section h2 {
  margin: 0;
  color: var(--accent-warm);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: lowercase;
  line-height: 1.5;
}

.home-section h2::before {
  content: './';
}

.home-section p {
  margin: 0;
  color: var(--secondary);
  font-size: 0.93rem;
  line-height: 1.5;
}

.home-section p + p {
  grid-column: 2;
  margin-top: 0.35rem;
}

.home-section p a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}

.home-section p a:hover {
  text-decoration-color: var(--accent-hover);
}

.home-about {
  border-top: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

/* ---------- Home links ---------- */
.home-links {
  position: relative;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.05rem 0 1rem;
  text-align: center;
}

.home-links a,
.home-links button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid color-mix(in srgb, var(--border) 88%, var(--secondary));
  border-radius: 7px;
  background: color-mix(in srgb, var(--code-bg) 72%, transparent);
  text-decoration: none;
  color: var(--accent);
  line-height: 1;
  transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out, transform 0.15s ease-out;
}

.home-links a:hover,
.home-links button:hover {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: var(--accent-subtle);
  color: var(--accent-hover);
  transform: translateY(-1px);
}

.home-links a[href^='http']::after {
  display: none !important;
}

.home-links svg {
  width: 1.12rem;
  height: 1.12rem;
  flex: none;
}

.home-links button.email-copy {
  cursor: pointer;
}

.home-links button.email-copy.is-copied {
  color: var(--accent-hover);
}

.home-email-status {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 5.4rem;
  min-height: 1.45rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 9999px;
  color: var(--secondary);
  font-size: 0.78rem;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 1px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.home-email-status.is-visible {
  border-color: var(--border);
  background: var(--code-bg);
  color: var(--accent);
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Home command hint ---------- */
.home-command-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.1rem 0 0;
  border: 0;
  background: 0 0;
  color: var(--secondary);
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.15s ease-out, color 0.15s ease-out, transform 0.15s ease-out;
}

.home-command-hint:hover {
  color: var(--primary);
  transform: translateY(-1px);
}

.home-command-hint kbd {
  padding: 0.12rem 0.38rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--entry) 90%, transparent);
  color: var(--accent-warm);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Page sections (Projects / Library / Resume) ---------- */
.main > section {
  max-width: calc(var(--main-width) + var(--gap) * 2);
  margin: 0 auto 3rem;
  padding: 2.5rem 1rem;
}

.page-section h2 {
  color: var(--accent-warm);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: lowercase;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.page-section h2::before {
  content: './';
}

/* ---------- Post entries (project & library cards) ---------- */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-entry {
  position: relative;
  margin-bottom: var(--gap);
  padding: var(--gap);
  background: var(--entry);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px rgba(255, 255, 255, 0.32) inset;
  transition: transform 0.1s, border-color 0.15s ease-out, box-shadow 0.15s ease-out;
  display: block;
}

.post-entry:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow-tight);
}

.post-entry:active {
  transform: scale(0.96);
}

.entry-header h2 {
  font-size: 1.125rem;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.entry-header h2 a:hover {
  color: var(--accent);
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.entry-meta .entry-date {
  color: var(--secondary);
}

.entry-content {
  color: var(--secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.entry-content p {
  margin: 0;
}

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.post-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--secondary);
  background: var(--code-bg);
  border: 1px solid transparent;
  border-radius: 99px;
  padding: 0.12rem 0.55rem;
  transition: color 0.15s, border-color 0.15s;
}

.post-tag:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
}

.entry-footer {
  margin-top: 0.9rem;
  color: var(--secondary);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.entry-footer a {
  color: var(--accent);
}

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

/* Resume */
.resume-block {
  margin-bottom: 2rem;
}

.resume-subtitle {
  font-family: var(--mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-warm);
  margin-bottom: 1rem;
}

.resume-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.resume-row-sub {
  margin-top: 0.6rem;
}

.resume-role {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.resume-dates {
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.resume-desc {
  color: var(--secondary);
  font-size: 0.9rem;
}

.resume-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.skill-chip {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--secondary);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.32rem 0.7rem;
  transition: border-color 0.15s, color 0.15s;
}

.skill-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
}

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

/* ---------- Footer ---------- */
.footer {
  max-width: calc(var(--main-width) + var(--gap) * 2);
  margin: auto;
  padding: calc((var(--footer-height) - var(--gap)) / 2) var(--gap);
  text-align: center;
  line-height: 24px;
  font-size: 12px;
  color: var(--secondary);
}

.footer span {
  margin-inline-start: 1px;
  margin-inline-end: 1px;
}

.footer span:last-child {
  white-space: nowrap;
}

.footer a {
  color: inherit;
  border-bottom: 1px solid var(--secondary);
}

.footer a:hover {
  color: var(--primary);
  border-bottom: 1px solid var(--primary);
}

body:not(.chrome-less) .footer {
  margin-bottom: var(--statusline-footer-gap);
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--theme);
  border: 1px solid var(--border);
  color: var(--secondary);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-tight);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* ---------- Command palette ---------- */
.command-palette {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
}

.command-palette.open {
  display: block;
}

.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.command-palette-modal {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 560px;
  background: var(--theme);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px rgba(255, 255, 255, 0.28) inset, var(--shadow-soft);
  overflow: hidden;
}

.command-palette-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.command-palette-icon {
  width: 20px;
  height: 20px;
  color: var(--secondary);
  flex-shrink: 0;
}

.command-palette-prompt {
  display: none;
  width: 20px;
  color: var(--accent-warm);
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
}

.command-palette[data-mode='command'] .command-palette-icon {
  display: none;
}

.command-palette[data-mode='command'] .command-palette-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#command-palette-input {
  flex: 1;
  border: none;
  background: 0 0;
  font-size: 16px;
  color: var(--primary);
  outline: none;
  font-family: inherit;
}

#command-palette-input::placeholder {
  color: var(--secondary);
  opacity: 0.7;
}

.command-palette-hint {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--secondary);
}

.command-palette-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.command-palette-empty {
  padding: 24px;
  text-align: center;
  color: var(--secondary);
}

.command-palette-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--primary);
  transition: background 0.1s;
  cursor: pointer;
  border: 0;
  background: 0 0;
  font: inherit;
  text-align: left;
  width: 100%;
}

.command-palette-result:hover,
.command-palette-result.selected {
  background: var(--accent-subtle);
}

.command-palette-result.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.command-palette-title {
  font-weight: 500;
}

.command-palette-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--secondary);
}

.command-palette-section {
  text-transform: capitalize;
}

.command-palette-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.command-palette-tag {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--code-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--secondary);
}

.command-palette-command-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
}

.command-palette-command-list.is-muted .command-palette-command {
  opacity: 0.58;
}

.command-palette-command-list.is-muted .command-palette-command:hover,
.command-palette-command-list.is-muted .command-palette-command.selected {
  opacity: 1;
}

.command-palette-command {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 7px;
  background: 0 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background 0.1s, opacity 0.1s;
}

.command-palette-command:hover,
.command-palette-command.selected {
  background: var(--accent-subtle);
}

.command-palette-command.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.command-palette-command-name {
  color: var(--accent-warm);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.command-palette-command-aliases {
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.72;
}

.command-palette-command-description {
  grid-column: 1 / -1;
  color: var(--secondary);
  font-size: 13px;
}

.command-palette-results::-webkit-scrollbar {
  width: 8px;
}

.command-palette-results::-webkit-scrollbar-track {
  background: 0 0;
}

.command-palette-results::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  border: 0;
}

.command-palette-results::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

/* ---------- Shortcuts modal ---------- */
.shortcuts-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
}

.shortcuts-modal.open {
  display: block;
}

.shortcuts-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.shortcuts-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 460px;
  max-height: min(82vh, 680px);
  overflow-y: auto;
  background: var(--theme);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px rgba(255, 255, 255, 0.28) inset, var(--shadow-soft);
  padding: 24px;
}

.shortcuts-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.shortcuts-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

.shortcuts-modal-close {
  background: 0 0;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.shortcuts-modal-close:hover {
  color: var(--primary);
}

.shortcuts-help-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.shortcuts-section {
  min-width: 0;
}

.shortcuts-section-title {
  margin: 0 0 10px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.shortcut-label {
  color: var(--primary);
  font-size: 14px;
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shortcut-combo {
  display: inline-flex;
  gap: 4px;
}

.shortcut-key-separator {
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  color: var(--secondary);
  opacity: 0.55;
  font-size: 12px;
}

.shortcut-key {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--secondary);
  min-width: 24px;
  text-align: center;
}

.command-help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
}

.command-help-row span {
  color: var(--secondary);
  font-size: 13px;
}

.command-help-row kbd.command-help-key {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-warm);
  font-weight: 600;
  min-width: unset;
}

/* ---------- Statusline ---------- */
.statusline {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 90;
  min-height: var(--statusline-height);
  border-top: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  background: var(--statusline-bg);
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1;
  backdrop-filter: blur(12px);
}

@supports not (backdrop-filter: blur(12px)) {
  .statusline {
    background: var(--entry);
  }
}

.statusline-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  height: var(--statusline-height);
}

.statusline-left,
.statusline-right {
  display: flex;
  align-items: center;
  height: 100%;
  min-width: 0;
}

.statusline-left {
  overflow: hidden;
}

.statusline-right {
  position: relative;
  justify-content: flex-end;
  white-space: nowrap;
}

.statusline-mode,
.statusline-section,
.statusline-path,
.statusline-position {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  min-height: var(--statusline-height);
}

.statusline-mode {
  z-index: 3;
  padding: 0 0.72rem 0 0.9rem;
  background: var(--statusline-mode-bg);
  color: var(--statusline-mode-fg);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.statusline-mode::after,
.statusline-section::after {
  content: '';
  position: absolute;
  top: 0;
  left: 100%;
  width: 1rem;
  height: 100%;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.statusline-mode::after {
  background: var(--statusline-mode-bg);
}

.statusline-section {
  z-index: 2;
  margin-left: 0;
  padding: 0 0.86rem 0 1.7rem;
  background: var(--statusline-mid-bg);
  color: var(--statusline-mid-fg);
  font-weight: 650;
}

.statusline-section::after {
  background: var(--statusline-mid-bg);
}

.statusline-path {
  min-width: 0;
  margin-left: 0;
  padding: 0 0.9rem 0 1.65rem;
  overflow: hidden;
  background: var(--statusline-bg);
  color: var(--statusline-tail-fg);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusline-position {
  justify-content: center;
  min-width: 3.45rem;
  margin-left: 0;
  padding: 0 0.75rem 0 0.85rem;
  background: var(--statusline-mode-bg);
  color: var(--statusline-mode-fg);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.statusline-position::after {
  content: '';
  position: absolute;
  top: 0;
  right: 100%;
  width: 1rem;
  height: 100%;
  background: var(--statusline-mode-bg);
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.statusline-command-wrap {
  position: relative;
  display: none;
  align-items: center;
  width: 100%;
  min-height: var(--statusline-command-height);
  border-top: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  background: color-mix(in srgb, var(--statusline-bg) 94%, black);
}

.statusline-command-wrap.is-active,
.statusline-command-wrap.is-editing {
  display: flex;
}

.statusline-command {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 2.25rem;
  min-height: var(--statusline-command-height);
  padding: 0 0.55rem;
  color: color-mix(in srgb, var(--accent-warm) 82%, var(--primary));
  font-weight: 500;
}

.statusline-command.is-active {
  color: color-mix(in srgb, var(--accent-warm) 82%, var(--primary));
  font-weight: 600;
}

.statusline-command:empty {
  min-width: 0;
  padding: 0 0.55rem;
}

.statusline-command-input {
  display: none;
  width: 100%;
  min-height: var(--statusline-command-height);
  padding: 0 0.55rem;
  border: 0;
  outline: 0;
  background: 0 0;
  color: color-mix(in srgb, var(--accent-warm) 82%, var(--primary));
  font-family: var(--mono);
  font-size: inherit;
  font-weight: 600;
  line-height: 1;
}

.statusline-command-input::selection {
  background: var(--accent-subtle);
}

.statusline-command-wrap.is-editing .statusline-command {
  display: none;
}

.statusline-command-wrap.is-editing .statusline-command-input {
  display: inline-flex;
}

.statusline-completions {
  position: absolute;
  left: var(--statusline-completion-left, 0.55rem);
  bottom: calc(var(--statusline-command-height) + var(--statusline-height) + 0.35rem);
  width: clamp(17rem, 36vw, 32rem);
  max-height: min(17rem, 50vh);
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  border-radius: 4px;
  background: color-mix(in srgb, var(--entry) 96%, var(--statusline-bg));
  box-shadow: 0 10px 32px rgb(0 0 0 / 0.16);
  backdrop-filter: blur(12px);
}

.statusline-completion {
  display: grid;
  grid-template-columns: minmax(6rem, auto) minmax(0, 1fr);
  gap: 0.8rem;
  width: 100%;
  padding: 0.48rem 0.65rem;
  color: var(--secondary);
  text-align: left;
  background: 0 0;
  border: 0;
  cursor: pointer;
}

.statusline-completion:hover,
.statusline-completion.is-selected {
  background: var(--accent-subtle);
  color: var(--primary);
}

.statusline-completion-name {
  color: color-mix(in srgb, var(--accent-warm) 82%, var(--primary));
  font-weight: 600;
}

.statusline-completion-description {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Enter animation ---------- */
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.enter {
  animation: enter 0.25s cubic-bezier(0, 0, 0.2, 1) both;
}

.enter-d1 {
  animation-delay: 0.04s;
}

.enter-d2 {
  animation-delay: 0.08s;
}

.enter-d3 {
  animation-delay: 0.12s;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  #menu {
    position: static;
  }

  .nav {
    overflow-x: auto;
  }
}

@media (max-width: 700px) {
  body:not(.chrome-less) {
    padding-bottom: env(safe-area-inset-bottom);
  }

  body:not(.chrome-less) .main {
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
  }

  body:not(.chrome-less) .footer {
    margin-bottom: 0;
  }

  .statusline {
    display: none;
  }

  .home-intro {
    padding-top: 3.25rem;
    padding-bottom: 2.75rem;
  }

  .home-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .home-identity {
    gap: 1rem;
  }

  .home-headshot {
    width: 80px;
    height: 80px;
  }

  .home-name {
    font-size: 2.25rem;
  }

  .home-section {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .home-section p + p {
    grid-column: auto;
  }

  .home-links {
    margin: 1rem 0 0.85rem;
  }

  .home-command-hint {
    display: none;
  }

  .search-hint-key,
  .shortcuts-modal {
    display: none !important;
  }
}

@media (max-width: 600px) {
  .command-palette-modal {
    top: 10%;
    width: 95%;
    max-height: 80vh;
  }

  .command-palette-results {
    max-height: 60vh;
  }

  .command-palette-hint {
    display: none;
  }

  .command-palette-command {
    grid-template-columns: 1fr;
  }

  .command-palette-command-aliases {
    display: none;
  }

  .shortcuts-modal-content {
    width: 95%;
    padding: 20px;
  }

  .shortcuts-help-grid {
    grid-template-columns: 1fr;
  }

  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 520px) {
  .statusline-section {
    display: none;
  }

  .statusline-path {
    margin-left: 1rem;
  }

  .statusline-right {
    padding-right: 0.5rem;
  }
}

@media (min-width: 701px) and (max-width: 760px) {
  .statusline,
  .statusline-main {
    grid-template-columns: minmax(0, 1fr) auto;
    font-size: 0.7rem;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .enter {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .home-boids {
    display: none;
  }

  .post-entry:active {
    transform: none;
  }

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