:root {
  --header: #4b2ea8;
  --header-link: #f4efff;
  --header-link-border: #a88ff5;
  --tool-link: #2f2551;
  --tool-border: #cabef2;
  --tool-bg: #f8f5ff;
  --tool-active-a: #4b2ea8;
  --tool-active-b: #35206f;
  --footer-ink: #332b52;
  --footer-link: #5533bf;
  --footer-border: #cabef2;
}

.topbar {
  background: var(--header);
  color: #f4efff;
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid #a88ff5;
  box-shadow:
    0 10px 24px rgba(48, 28, 119, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  position: relative;
  overflow: visible;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 1.7rem;
  color: #f4efff;
  text-decoration: none;
}

.brand:visited {
  color: #f4efff;
}

.brand:hover {
  text-decoration: none;
}

.dot,
.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #efe8ff;
  box-shadow: 0 0 0 4px rgba(194, 174, 255, 0.28);
}

.menu,
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}

.menu a,
.nav a {
  color: var(--header-link);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.menu a:hover,
.menu a.active,
.nav a:hover,
.nav a.active {
  border-color: var(--header-link-border);
  background: rgba(194, 174, 255, 0.2);
}

.header-search-toggle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #a88ff5;
  background: rgba(194, 174, 255, 0.15);
  color: var(--header-link);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  margin-left: 2px;
  flex: 0 0 auto;
}

.header-menu-toggle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #a88ff5;
  background: rgba(194, 174, 255, 0.15);
  color: var(--header-link);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  margin-left: 0;
  flex: 0 0 auto;
}

.header-menu-toggle svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.header-menu-toggle:hover,
.header-menu-toggle:focus-visible {
  background: rgba(194, 174, 255, 0.26);
  border-color: #b89ff7;
  transform: translateY(-1px);
}

.header-search-toggle svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.header-search-toggle:hover,
.header-search-toggle:focus-visible {
  background: rgba(194, 174, 255, 0.26);
  border-color: #b89ff7;
  transform: translateY(-1px);
}

.header-search-panel {
  position: absolute;
  left: 18px;
  right: 18px;
  top: calc(100% + 8px);
  width: auto;
  border: 1px solid #c7b9f2;
  border-radius: 14px;
  background: rgba(250, 247, 255, 0.98);
  box-shadow: 0 14px 28px rgba(48, 28, 119, 0.18);
  z-index: 260;
  padding: 10px;
}

.header-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 480;
  background: rgba(17, 20, 27, 0.48);
  backdrop-filter: blur(1px);
}

.header-mobile-overlay[hidden] {
  display: none !important;
}

.header-mobile-shell {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
}

.header-mobile-sidebar {
  width: min(60vw, 420px);
  min-width: 260px;
  max-width: 88vw;
  height: 100%;
  background: #f7f5ff;
  border-right: 1px solid #cabef2;
  box-shadow: 0 20px 44px rgba(24, 16, 64, 0.35);
  padding: 14px 12px 20px;
  overflow: auto;
  transform: translateX(-105%);
  transition: transform 0.2s ease;
}

.header-mobile-overlay.is-open .header-mobile-sidebar {
  transform: translateX(0);
}

.header-mobile-sidebar nav {
  display: grid;
  gap: 6px;
}

.header-mobile-sidebar a {
  display: block;
  color: #2f2551;
  text-decoration: none;
  border: 1px solid #d0c5f4;
  border-radius: 10px;
  padding: 10px 11px;
  background: #ffffff;
  font-size: 0.97rem;
  font-weight: 600;
}

.header-mobile-sidebar a:hover,
.header-mobile-sidebar a.active {
  color: #ffffff;
  border-color: transparent;
  background: #4b2ea8;
}

.header-mobile-close {
  margin: 12px 0 0 8px;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid #a88ff5;
  background: #4b2ea8;
  color: #ffffff;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 18px rgba(38, 23, 92, 0.35);
}

.header-mobile-close:hover,
.header-mobile-close:focus-visible {
  background: #3f2495;
}

.header-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.header-search-input-wrap {
  position: relative;
}

.header-search-input {
  width: 100%;
  border: 1px solid #c7b9f2;
  border-radius: 10px;
  background: #ffffff;
  color: #2f2551;
  font-size: 1rem;
  line-height: 1.2;
  padding: 10px 36px 10px 11px;
}

.header-search-input:focus,
.header-search-input:focus-visible {
  outline: none;
  border-color: #a88ff5;
  box-shadow: 0 0 0 3px rgba(168, 143, 245, 0.26);
}

.header-search-input::placeholder {
  color: #7665ad;
}

.header-search-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #c7b9f2;
  background: #efe9ff;
  color: #5533bf;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.header-search-close:hover,
.header-search-close:focus-visible {
  background: #e2d8ff;
}

.header-search-spinner {
  position: absolute;
  right: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(199, 185, 242, 0.35);
  border-top-color: #673de6;
  opacity: 0;
  pointer-events: none;
}

.header-search-spinner.is-loading {
  opacity: 1;
  animation: header-spin 0.6s linear infinite;
}

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

.header-search-results {
  margin-top: 8px;
  width: 100%;
  max-height: 360px;
  overflow: auto;
  border: 1px solid #c7b9f2;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 0 0 0 1px rgba(226, 216, 255, 0.65);
  padding: 5px;
}

.search-item {
  display: grid;
  gap: 2px;
  text-decoration: none;
  border-radius: 9px;
  padding: 8px 9px;
  border: 1px solid transparent;
  color: #2f2551;
}

.search-item:hover,
.search-item.active {
  background: #f0ebff;
  border-color: #cabef2;
}

.search-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #372c5b;
}

.search-title mark {
  background: #e2d8ff;
  color: #372c5b;
  border-radius: 4px;
  padding: 0 2px;
}

.search-meta {
  font-size: 0.77rem;
  color: #6e5ca6;
}

.search-empty {
  font-size: 0.84rem;
  color: #6e5ca6;
  padding: 9px 8px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tool-menu {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  margin-bottom: 12px;
  position: sticky;
  top: 8px;
  z-index: 30;
  padding: 8px;
  border: 1px solid rgba(199, 185, 242, 0.8);
  border-radius: 12px;
  background: rgba(248, 245, 255, 0.8);
  box-shadow: 0 10px 22px rgba(56, 38, 130, 0.12);
  backdrop-filter: blur(6px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.tool-menu a {
  text-decoration: none;
  font-size: 0.88rem;
  color: var(--tool-link);
  border: 1px solid var(--tool-border);
  border-radius: 10px;
  padding: 6px 11px;
  background: var(--tool-bg);
  font-weight: 600;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.tool-menu::-webkit-scrollbar {
  height: 8px;
}

.tool-menu::-webkit-scrollbar-thumb {
  background: #c6cad2;
  border-radius: 999px;
}

.tool-menu::-webkit-scrollbar-track {
  background: rgba(234, 226, 255, 0.75);
  border-radius: 999px;
}

.tool-menu a:hover,
.tool-menu a.active {
  color: #fff;
  border-color: transparent;
  background: var(--tool-active-a);
  box-shadow: 0 8px 16px rgba(55, 37, 130, 0.22);
}

.tool-menu a:hover {
  transform: translateY(-1px);
}

.footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--footer-ink);
  font-size: 0.84rem;
  border-top: 1px solid var(--footer-border);
  padding-top: 8px;
}

.footer > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.footer a {
  color: var(--footer-link);
  text-decoration: none;
  margin-right: 0;
}

.footer a:hover {
  text-decoration: underline;
}

.tool-description h2 {
  margin: 0 0 8px;
  color: #2f2551;
}

.tool-description p {
  margin: 0 0 10px;
  line-height: 1.62;
  color: #53467a;
}

/* Shared typography for page hero/title areas across all pages. */
.container h1 {
  margin: 0;
  font-size: clamp(1.55rem, 1.4vw + 1rem, 2.2rem) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
  line-height: 1.14;
  color: #0f1114;
}

.container .subtitle,
.container .tagline {
  margin: 8px 0 10px;
  color: #4d4368;
  font-size: 1rem !important;
  font-weight: 400 !important;
  line-height: 1.5;
  max-width: none;
  width: 100%;
}

.container .hero p {
  margin: 8px 0 0;
  color: #4d4368;
  font-size: 1rem !important;
  font-weight: 400 !important;
  line-height: 1.5;
  max-width: 980px;
}

/* Shared UI-mode control style (Text Compare + QuickCopy). */
.container .hero-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.container .ui-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4d4368;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
  line-height: 1.2;
  background: #f8f5ff;
  border: 1px solid #cabef2;
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}

.container .ui-mode select {
  border: 1px solid #c7b9f2;
  border-radius: 8px;
  padding: 4px 7px;
  min-width: 130px;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
  line-height: 1.2;
  color: #2f2551;
  background: #ffffff;
}

@media (max-width: 860px) {
  .header-search-panel {
    left: 12px;
    right: 12px;
    padding: 8px;
  }

  .header-search-input {
    width: 100%;
    font-size: 0.95rem;
  }

  .tool-menu {
    top: 6px;
  }

  .container .hero-right {
    justify-content: flex-start;
  }
}

/* Mobile/tablet: use uniform compact header on all pages. */
@media (max-width: 1024px) {
  .topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    flex-wrap: nowrap;
  }

  .menu,
  .nav {
    display: none !important;
  }

  .topbar .brand {
    grid-column: 2;
    justify-self: center;
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar .header-menu-toggle {
    grid-column: 1;
    display: none !important;
  }

  .topbar .header-search-toggle {
    grid-column: 3;
    justify-self: end;
    margin-left: 0;
    flex: 0 0 auto;
  }
}
