.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-header);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
  color: var(--text-soft);
}

.nav-link {
  position: relative;
  padding: 4px 0;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  transition: color var(--transition-fast);
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background var(--transition-fast), transform var(--transition-fast);
  transform-origin: center;
  transform: scaleX(0);
}

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

.nav-link.is-active {
  color: var(--accent);
}

.nav-link.is-active::after {
  background: var(--accent);
  transform: scaleX(1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  border-radius: 50%;
}

.theme-toggle__icon {
  font-size: 15px;
  line-height: 1;
}

.btn {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-soft);
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.btn:hover {
  background: var(--surface-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn-primary,
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-dark);
}

.btn-primary:hover,
.btn--primary:hover {
  background: var(--color-primary-600);
  border-color: var(--color-primary-600);
}

.btn-ai {
  position: relative;
  overflow: hidden;
  padding-inline: 14px;
}

.btn-ai::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.0),
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.0)
  );
  background-size: 180% 100%;
  opacity: 0.0;
  pointer-events: none;
  /* transition: opacity var(--transition-fast); */
  /* animation: aiShimmer 5s ease-in-out infinite; */
}

.btn-ai:hover::before {
  opacity: 1;
}

.btn-ai-icon {
  font-size: 15px;
  line-height: 1;
}

.btn-ai-short {
  display: none;
  letter-spacing: 0.2px;
}

@keyframes aiShimmer {
  0% {
    background-position: -60% 0;
    opacity: 0.2;
  }
  50% {
    background-position: 60% 0;
    opacity: 0.35;
  }
  100% {
    background-position: -60% 0;
    opacity: 0.2;
  }
}

.btn--secondary {
  background: var(--surface-soft);
  border-color: var(--border-subtle);
  color: var(--text-soft);
}

.btn--outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-soft);
}

.btn--small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-dark {
  background: var(--text-main);
  border-color: var(--text-main);
  color: var(--bg);
}

.btn-dark:hover {
  background: color-mix(in oklab, var(--text-main), black 12%);
  border-color: color-mix(in oklab, var(--text-main), black 12%);
}

.btn-icon-only {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.btn-like {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  font-size: 15px;
}

.btn-like[aria-pressed="true"] {
  background: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: var(--status-danger-text);
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  background: var(--surface-soft);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  font-size: 13px;
  color: var(--text-soft);
}

.profile-chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-dark);
  font-weight: 600;
  font-size: 13px;
}

.profile-chip-arrow {
  font-size: 12px;
}

.profile-chip:hover {
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 8px;
  display: none;
  z-index: 60;
}

.user-menu__link {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-main);
  font: inherit;
}

.user-menu__link:hover,
.user-menu__link:focus-visible {
  background: var(--bg-alt);
}

.user-menu:hover .user-menu__dropdown,
.user-menu:focus-within .user-menu__dropdown {
  display: grid;
  gap: 4px;
}

.header-burger {
  display: none;
}

@media (max-width: 840px) {
  .nav,
  .header-actions .btn-primary:not(.btn-ai) {
    display: none;
  }

  .brand-subtitle {
    display: none;
  }

  .header-burger {
    display: inline-flex;
  }
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  box-shadow: var(--shadow-soft);
}

.back:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.crumbs {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.crumbs a {
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.crumbs a:hover {
  color: var(--text-soft);
  border-color: var(--border-subtle);
}

.crumbs-sep {
  color: var(--text-placeholder);
}

.counter-badge {
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: var(--text-soft);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.footer {
  padding: 16px 0 24px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-note {
  color: var(--text-muted);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 60;
}

[data-theme="dark"] .user-menu__link:hover,
[data-theme="dark"] .user-menu__link:focus-visible {
  background: var(--surface-soft);
}

[data-theme="dark"] .modal-panel {
  background: var(--surface);
  border-color: var(--border-subtle);
}

.btn:focus-visible,
.nav-link:focus-visible,
.profile-chip:focus-visible,
.back:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent), transparent 30%);
  outline-offset: 2px;
}

.ui-kit {
  font-size: var(--type-body);
  line-height: var(--lh-body);
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark-soft);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal[aria-hidden='false'] {
  display: flex;
}

.modal-panel {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: background var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-alt);
  transform: translateY(-1px);
}

.modal-body {
  padding: 12px 14px 14px;
  font-size: 13px;
  color: var(--text-soft);
  display: grid;
  gap: 10px;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 560px) {
  .btn-ai-text {
    display: none;
  }

  .btn-ai-short {
    display: inline;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}
