:root {
  color-scheme: light;

  --bg-default: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;
  --bg-hover: #f7f7f8;

  --text-fg: #000000;
  --text-fg-muted: #52525b;
  --text-fg-subtle: #a1a1aa;

  --border-default: #e4e4e7;
  --ring: rgba(37, 99, 235, 0.18);

  --gray-fg: #27272a;
  --gray-muted: #e4e4e7;
  --gray-subtle: #f4f4f5;

  --pink-fg: #a41752;
  --pink-muted: #fbcfe8;

  --purple-fg: #641ba3;
  --purple-muted: #e9d5ff;

  --green-fg: #116932;
  --green-muted: #bbf7d0;
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --fg-success: #16a34a;

  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --fg-info: #2563eb;

  --orange-50: #fff7ed;
  --orange-100: #ffedd5;
  --fg-warning: #ea580c;

  --font-body: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --line-height-xs: 16px;
  --line-height-sm: 20px;

  --radius-sm: 8px;
  --radius-lg: 12px;
  --radius-panel: 24px;

  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-layout: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 120ms;
  --duration-normal: 180ms;
  --duration-slow: 320ms;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.9), rgba(250, 250, 250, 0) 38%),
    var(--bg-subtle);
  color: var(--text-fg);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input {
  font: inherit;
}

.stage {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 16px;
  overflow: hidden;
}

.closed-screen {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 21px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-50% - 31px)) scale(0.96);
  transition:
    opacity 220ms var(--ease-standard),
    transform 420ms var(--ease-spring),
    filter 220ms var(--ease-standard);
  filter: blur(3px);
}

body.palette-closed .closed-screen {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, calc(-50% - 31px)) scale(1);
  filter: blur(0);
}

.closed-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 172px;
  height: 112px;
  gap: 0;
  padding: 6px 24px;
  border: 0;
  border-radius: 50px;
  background: var(--bg-muted);
  color: var(--text-fg-muted);
  cursor: pointer;
  transform-origin: 50% 58%;
  transition:
    transform 180ms var(--ease-spring),
    background-color 160ms var(--ease-standard);
}

.closed-trigger:hover {
  background: #eeeeef;
  transform: translateY(-1px) scale(1.015);
}

.closed-trigger:active {
  transform: translateY(0) scale(0.98);
}

.closed-trigger:focus-visible {
  outline: 2px solid var(--text-fg-subtle);
  outline-offset: 4px;
}

.closed-trigger .closed-trigger__icon {
  position: relative;
  width: 74.2px;
  height: 74.2px;
  overflow: hidden;
}

.closed-trigger .closed-trigger__icon svg {
  position: absolute;
  inset: 15% 15% 18% 15%;
  width: auto;
  height: auto;
  stroke-width: 3.2px;
  overflow: visible;
  transform: none;
}

.closed-trigger__letter {
  color: #52525b;
  font-size: 74.2px;
  font-weight: var(--font-weight-medium);
  line-height: 98.933px;
}

.closed-hint {
  width: 318px;
  margin: 0;
  color: #71717a;
  font-size: 16px;
  font-weight: var(--font-weight-semibold);
  line-height: 24px;
  text-align: center;
  white-space: nowrap;
}

.closed-hint strong {
  color: var(--text-fg);
  font-weight: var(--font-weight-semibold);
}

.palette {
  position: relative;
  z-index: 2;
  width: min(597px, calc(100vw - 32px));
  max-height: min(784px, calc(100vh - 64px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  box-shadow: none;
  transform-origin: 50% 46%;
  transition:
    opacity 180ms var(--ease-standard),
    transform 260ms var(--ease-layout),
    filter 180ms var(--ease-standard);
}

body.palette-closed .palette {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.94);
  filter: blur(4px);
}

.palette__header {
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border-default);
}

.search-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-fg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
  caret-color: var(--text-fg);
  appearance: none;
}

.search-input::placeholder {
  color: var(--text-fg-subtle);
  opacity: 1;
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-fg-muted);
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity var(--duration-normal) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.search-clear:hover,
.search-clear:focus-visible {
  opacity: 1;
}

.search-clear:active {
  transform: scale(0.94);
}

.search-clear:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.search-clear[hidden] {
  display: none;
}

.search-clear .icon {
  width: 14px;
  height: 14px;
}

.palette:focus-within {
  box-shadow: none;
}

.palette__results {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding-top: 9px;
  overflow-y: auto;
  scrollbar-width: none;
}

.selection-highlight {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  width: 100%;
  height: 52px;
  background: var(--bg-muted);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, var(--highlight-y, 0px), 0);
  transition:
    transform 260ms var(--ease-layout),
    height 260ms var(--ease-layout),
    opacity 120ms var(--ease-standard);
  will-change: transform, height;
}

.palette__results.has-highlight .selection-highlight {
  opacity: 1;
}

.filter-bar {
  position: relative;
  z-index: 2;
  flex: 0 0 40px;
  width: 100%;
  animation: filter-bar-enter 340ms var(--ease-spring) both;
}

.filter-bar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 160px;
  height: 40px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--bg-default) 68%);
}

.filter-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 40px;
  padding: 8px 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-strip::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 4px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-default);
  color: var(--text-fg-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-xs);
  cursor: pointer;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  animation: filter-chip-enter 420ms var(--ease-spring) both;
  animation-delay: calc(var(--filter-index) * 34ms);
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    opacity var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.filter-chip:hover,
.filter-chip[data-active="true"] {
  background: var(--bg-muted);
  color: var(--text-fg);
}

.filter-chip:active {
  transform: translateY(0) scale(0.97);
}

.filter-chip:disabled {
  cursor: default;
  opacity: 0.38;
}

.filter-chip .icon {
  width: 14px;
  height: 14px;
}

.palette__results::-webkit-scrollbar {
  display: none;
}

.section {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.section__label {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 24px;
  color: var(--text-fg-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-xs);
  white-space: nowrap;
}

.section__count {
  color: var(--text-fg-subtle);
  font-weight: var(--font-weight-medium);
}

.section__rows {
  display: flex;
  flex-direction: column;
}

.row {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  outline: 0;
  opacity: 0;
  transform: translateY(-5px);
  animation: result-row-enter 320ms var(--ease-layout) both;
  animation-delay: calc(var(--row-index, 0) * 22ms);
  transition:
    color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.row::after {
  content: none;
}

.row:active {
  transform: scale(0.995);
}

.row--person {
  min-height: 52px;
}

.row--project {
  min-height: 58px;
}

.row--resource {
  min-height: 58px;
}

.row--action {
  min-height: 48px;
}

.row__main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.row--action .row__main {
  gap: 16px;
}

.row__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.row__line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.row__title {
  color: var(--text-fg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
  white-space: nowrap;
}

.row__meta,
.row__support {
  min-width: 0;
  color: var(--text-fg-subtle);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__support {
  font-weight: var(--font-weight-normal);
}

.dot {
  width: 4px;
  height: 4px;
  flex: 0 0 4px;
  border-radius: 999px;
  background: var(--border-default);
}

.avatar,
.icon-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.avatar {
  width: 36px;
  height: 36px;
  color: var(--avatar-fg);
  background: var(--avatar-bg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
}

.avatar--pink {
  --avatar-bg: var(--pink-muted);
  --avatar-fg: var(--pink-fg);
}

.avatar--purple {
  --avatar-bg: var(--purple-muted);
  --avatar-fg: var(--purple-fg);
}

.avatar--gray {
  --avatar-bg: var(--gray-muted);
  --avatar-fg: var(--gray-fg);
}

.avatar--green {
  --avatar-bg: var(--green-muted);
  --avatar-fg: var(--green-fg);
}

.avatar--blue {
  --avatar-bg: var(--blue-50);
  --avatar-fg: var(--fg-info);
}

.avatar--orange {
  --avatar-bg: var(--orange-50);
  --avatar-fg: var(--fg-warning);
}

.icon-button {
  position: relative;
  width: var(--icon-box-size, 36px);
  height: var(--icon-box-size, 36px);
  color: var(--icon-fg, var(--text-fg-muted));
  background: var(--icon-bg, var(--gray-subtle));
}

.icon-button > .icon {
  position: relative;
  z-index: 1;
}

.icon-button--action {
  --icon-box-size: 32px;
}

.project-waves {
  position: absolute;
  inset: 0;
  z-index: 0;
  color: var(--icon-line);
  pointer-events: none;
}

.project-waves svg {
  position: absolute;
  left: -10px;
  top: 0;
  width: 56px;
  height: 36px;
  display: block;
  stroke: currentColor;
}

.icon-button--blue {
  --icon-bg: var(--blue-50);
  --icon-line: var(--blue-100);
  --icon-fg: var(--fg-info);
}

.icon-button--orange {
  --icon-bg: var(--orange-50);
  --icon-line: var(--orange-100);
  --icon-fg: var(--fg-warning);
}

.icon-button--green {
  --icon-bg: var(--green-50);
  --icon-line: var(--green-100);
  --icon-fg: var(--fg-success);
}

.row__aside {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-fg-subtle);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-xs);
}

.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 18px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--text-fg-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-xs);
}

.palette__footer {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px 16px 28px;
  overflow-x: auto;
  border-top: 1px solid var(--border-default);
  background: var(--bg-subtle);
  scrollbar-width: none;
}

.palette__footer::-webkit-scrollbar {
  display: none;
}

.helper-group {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-fg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
  white-space: nowrap;
}

.keycap {
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-default);
  color: var(--text-fg-muted);
}

.keycap--wide {
  min-width: 34px;
}

.keycap--text {
  min-width: 37px;
}

.keycap--inline {
  height: 22px;
  min-width: 30px;
  padding: 4px 5px;
}

.keycap strong,
.shortcut strong {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-xs);
}

.icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: currentColor;
}

.icon--search,
.palette__header > .icon {
  width: 18px;
  height: 18px;
  color: var(--text-fg);
}

.keycap .icon,
.shortcut .icon {
  width: 12px;
  height: 12px;
}

.icon svg {
  width: 100%;
  height: 100%;
  display: block;
  stroke: currentColor;
}

.empty-state {
  margin: 52px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-fg-subtle);
  text-align: center;
  animation: fade-lift 220ms var(--ease-standard) both;
}

.empty-state__icon {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-default);
  color: var(--text-fg-muted);
}

.empty-state__icon::before {
  content: "";
  position: absolute;
  inset: 8px 7px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-muted);
  transform: rotate(-7deg);
}

.empty-state__icon svg {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
}

.empty-state strong {
  color: var(--text-fg-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.empty-state span {
  max-width: 260px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-sm);
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-fg-muted);
  box-shadow: 0 12px 36px rgba(24, 24, 27, 0.1);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
  white-space: nowrap;
  animation: toast-enter 260ms var(--ease-spring) both;
}

.toast[data-exiting="true"] {
  animation: toast-exit 150ms var(--ease-standard) forwards;
}

.toast .icon {
  color: var(--fg-success);
}

@keyframes palette-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes fade-lift {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes filter-bar-enter {
  from {
    opacity: 0;
    transform: translateY(-10px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes filter-chip-enter {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes result-row-enter {
  from {
    opacity: 0;
    transform: translateY(-6px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-exit {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
}

@media (max-width: 640px) {
  .stage {
    align-items: start;
    padding-top: 24px;
  }

  .closed-screen {
    transform: translate(-50%, calc(-50% - 18px)) scale(0.96);
  }

  body.palette-closed .closed-screen {
    transform: translate(-50%, calc(-50% - 18px)) scale(1);
  }

  .closed-hint {
    width: min(318px, calc(100vw - 48px));
    white-space: normal;
  }

  .palette {
    max-height: calc(100vh - 48px);
  }

  .row {
    padding-inline: 18px;
  }

  .section__label {
    padding-inline: 18px;
  }

  .row__line {
    max-width: 100%;
  }

  .row__title,
  .row__meta,
  .row__support {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .row--person .row__line {
    display: grid;
    grid-template-columns: minmax(0, auto) 4px minmax(80px, 1fr);
  }

  .row--project .row__line {
    display: grid;
    grid-template-columns: minmax(0, auto) 4px minmax(70px, 1fr);
  }
}

@media (max-width: 430px) {
  .palette__header {
    padding-inline: 18px;
  }

  .palette__footer {
    padding-inline: 18px;
  }

  .row__aside {
    display: none;
  }
}

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