:root {
  --castme-guide-bg: rgba(7, 14, 24, 0.78);
  --castme-guide-panel: linear-gradient(160deg, rgba(12, 24, 38, 0.96) 0%, rgba(11, 20, 31, 0.98) 45%, rgba(7, 13, 22, 0.99) 100%);
  --castme-guide-panel-edge: rgba(149, 232, 206, 0.18);
  --castme-guide-text: #f5fbff;
  --castme-guide-muted: rgba(217, 232, 243, 0.68);
  --castme-guide-green: #7af2c5;
  --castme-guide-cyan: #7dcfff;
  --castme-guide-violet: #ac96ff;
  --castme-guide-gold: #ffd784;
  --castme-guide-shadow: 0 35px 120px rgba(2, 8, 16, 0.58);
}

.castme-command {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 9998;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--castme-guide-text);
}

.castme-command.is-hidden {
  display: none;
}

.castme-command-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  border: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(125, 207, 255, 0.14), transparent 28%),
    radial-gradient(circle at 78% 22%, rgba(172, 150, 255, 0.16), transparent 30%),
    radial-gradient(circle at 48% 75%, rgba(122, 242, 197, 0.1), transparent 36%),
    rgba(4, 10, 18, 0.68);
  backdrop-filter: blur(12px) saturate(1.04);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.castme-command.is-open .castme-command-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.castme-command-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 4;
}

.castme-command-panel {
  position: fixed;
  z-index: 3;
  right: 24px;
  bottom: 88px;
  width: min(460px, calc(100vw - 28px));
  max-height: min(720px, calc(100dvh - 110px));
  border: 1px solid var(--castme-guide-panel-edge);
  border-radius: 32px;
  background: var(--castme-guide-panel);
  box-shadow: var(--castme-guide-shadow);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.975);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease;
}

.castme-command-panel::before,
.castme-command-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.castme-command-panel::before {
  background:
    radial-gradient(circle at 14% 12%, rgba(122, 242, 197, 0.18), transparent 24%),
    radial-gradient(circle at 85% 18%, rgba(125, 207, 255, 0.18), transparent 22%),
    radial-gradient(circle at 68% 86%, rgba(172, 150, 255, 0.16), transparent 28%);
  opacity: 0.95;
}

.castme-command-panel::after {
  inset: 1px;
  border-radius: 31px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.castme-command.is-open .castme-command-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.castme-command-panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 14px;
}

.castme-command-panel-head > div {
  min-width: 0;
}

.castme-command-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(122, 242, 197, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(221, 248, 238, 0.92);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.castme-command-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--castme-guide-green), var(--castme-guide-cyan));
  box-shadow: 0 0 16px rgba(122, 242, 197, 0.65);
}

.castme-command-panel-head strong {
  display: block;
  margin-top: 14px;
  color: #f8fcff;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.castme-command-panel-head p {
  margin: 10px 0 0;
  color: var(--castme-guide-muted);
  font-size: 0.94rem;
  line-height: 1.55;
  max-width: 32ch;
}

.castme-command-close {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(245, 251, 255, 0.92);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.castme-command-close:hover,
.castme-command-close:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(125, 207, 255, 0.28);
  outline: 0;
}

.castme-command-form {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 0 24px 18px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
}

.castme-command-input {
  width: 100%;
  min-height: 46px;
  border: 0;
  outline: 0;
  border-radius: 16px;
  background: rgba(3, 9, 16, 0.24);
  color: var(--castme-guide-text);
  font: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  padding: 0 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.castme-command-input::placeholder {
  color: rgba(217, 232, 243, 0.46);
}

.castme-command-submit {
  min-width: 48px;
  min-height: 46px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--castme-guide-green), var(--castme-guide-cyan));
  color: #042134;
  cursor: pointer;
  font: inherit;
  font-size: 1.12rem;
  font-weight: 900;
  box-shadow: 0 16px 34px rgba(94, 232, 198, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.castme-command-submit:hover,
.castme-command-submit:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 20px 40px rgba(94, 232, 198, 0.28);
  outline: 0;
}

.castme-command-results {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-height: min(360px, 42dvh);
  padding: 0 24px 24px;
  overflow: auto;
}

.castme-command-result {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(8, 18, 28, 0.72);
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 18px;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.castme-command-result::after {
  content: "↗";
  align-self: center;
  color: rgba(245, 251, 255, 0.55);
  font-size: 0.92rem;
}

.castme-command-result:hover,
.castme-command-result:focus-visible,
.castme-command-result.is-active {
  transform: translateY(-1px);
  border-color: rgba(122, 242, 197, 0.22);
  background:
    linear-gradient(135deg, rgba(122, 242, 197, 0.12), rgba(125, 207, 255, 0.05)),
    rgba(11, 23, 36, 0.92);
  box-shadow:
    0 20px 38px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  outline: 0;
}

.castme-command-result-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.24), transparent 36%),
    linear-gradient(145deg, rgba(122, 242, 197, 0.22), rgba(125, 207, 255, 0.14));
  color: #dcfff1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 24px rgba(13, 26, 39, 0.28);
}

.castme-command-result strong {
  display: block;
  color: #f7fdff;
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.castme-command-result span {
  display: block;
  color: var(--castme-guide-muted);
  font-size: 0.84rem;
  line-height: 1.48;
  margin-top: 4px;
}

.castme-command-mark {
  position: relative;
  z-index: 5;
  min-width: 54px;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 28% 25%, rgba(255, 255, 255, 0.22), transparent 28%),
    linear-gradient(145deg, rgba(11, 24, 38, 0.96), rgba(14, 34, 48, 0.92));
  backdrop-filter: blur(16px) saturate(1.16);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  box-shadow:
    0 18px 36px rgba(3, 10, 18, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.castme-command-mark::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 19px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(122, 242, 197, 0.64), rgba(125, 207, 255, 0.54), rgba(172, 150, 255, 0.4));
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.8;
}

.castme-command-mark:hover,
.castme-command-mark:focus-visible {
  transform: translateY(-2px) scale(1.03);
  border-color: rgba(122, 242, 197, 0.22);
  box-shadow:
    0 24px 44px rgba(3, 10, 18, 0.38),
    0 0 28px rgba(123, 236, 206, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  outline: 0;
}

.castme-command-spark {
  width: 24px;
  height: 24px;
  position: relative;
  display: block;
}

.castme-command-spark::before,
.castme-command-spark::after,
.castme-command-spark i {
  content: "";
  position: absolute;
}

.castme-command-spark::before {
  inset: 2px;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(122, 242, 197, 0.92), rgba(125, 207, 255, 0.92));
  clip-path: polygon(50% 0%, 61% 36%, 100% 50%, 61% 64%, 50% 100%, 39% 64%, 0% 50%, 39% 36%);
  box-shadow: 0 0 18px rgba(122, 242, 197, 0.36);
}

.castme-command-spark::after {
  inset: 8px;
  border-radius: 6px;
  background: rgba(4, 18, 30, 0.92);
  clip-path: polygon(50% 0%, 61% 36%, 100% 50%, 61% 64%, 50% 100%, 39% 64%, 0% 50%, 39% 36%);
}

.castme-command-spark i {
  left: 10px;
  top: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff8d4;
  box-shadow: 0 0 9px rgba(255, 248, 212, 0.88);
}

@media (max-width: 640px) {
  .castme-command {
    right: 10px;
    bottom: 12px;
  }

  .castme-command-panel {
    right: 9px;
    left: 9px;
    bottom: 76px;
    width: auto;
    max-height: min(620px, calc(100dvh - 94px));
    border-radius: 28px;
    transform-origin: bottom center;
  }

  .castme-command-panel::after {
    border-radius: 27px;
  }

  .castme-command-panel-head {
    padding: 20px 18px 12px;
  }

  .castme-command-panel-head strong {
    font-size: 1.42rem;
  }

  .castme-command-panel-head p {
    font-size: 0.88rem;
    max-width: none;
  }

  .castme-command-form {
    margin: 0 18px 14px;
    padding: 10px;
    grid-template-columns: minmax(0, 1fr);
  }

  .castme-command-input {
    min-height: 44px;
    font-size: 16px;
  }

  .castme-command-submit {
    width: 100%;
  }

  .castme-command-results {
    padding: 0 18px 18px;
    max-height: min(320px, 38dvh);
  }

  .castme-command-result {
    grid-template-columns: 40px minmax(0, 1fr) 16px;
    padding: 14px;
    border-radius: 20px;
  }

  .castme-command-result-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .castme-command-mark {
    min-width: 50px;
    width: 50px;
    height: 50px;
    border-radius: 16px;
  }
}

/* Public discovery belongs in the header; the floating assistant is member-only. */
.castme-public-search-trigger {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 13px;
  border: 1px solid rgba(16, 40, 47, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  color: #18363d;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(7, 28, 34, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.castme-public-search-trigger:hover,
.castme-public-search-trigger:focus-visible,
.castme-public-search-trigger[aria-expanded="true"] {
  border-color: rgba(54, 209, 127, 0.54);
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(7, 28, 34, 0.12), 0 0 0 3px rgba(54, 209, 127, 0.08);
  outline: 0;
}

.castme-public-search-trigger svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: #147447;
  stroke-width: 2;
  stroke-linecap: round;
}

.castme-public-search-trigger kbd {
  padding: 4px 6px;
  border: 1px solid rgba(16, 40, 47, 0.1);
  border-radius: 6px;
  color: #607178;
  background: #f2f7f4;
  font: 700 0.64rem/1 system-ui, sans-serif;
}

.site-header .castme-command-shell,
header .castme-command-shell {
  flex: 0 0 auto;
  margin-left: 10px;
}

.castme-command.is-public-search .castme-command-backdrop {
  background: rgba(4, 15, 20, 0.24);
  backdrop-filter: none;
}

.castme-command.is-public-search .castme-command-panel {
  top: 76px;
  right: max(18px, calc((100vw - 1240px) / 2));
  bottom: auto;
  width: min(520px, calc(100vw - 28px));
  max-height: min(650px, calc(100dvh - 92px));
  border-radius: 22px;
  transform: translateY(-8px) scale(0.985);
  transform-origin: top right;
}

.castme-command.is-public-search .castme-command-panel::after {
  border-radius: 21px;
}

.castme-command.is-public-search .castme-command-panel-head {
  padding: 20px 22px 12px;
}

.castme-command.is-public-search .castme-command-panel-head strong {
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
}

.castme-command.is-public-search .castme-command-panel-head p {
  max-width: 43ch;
}

.castme-command.is-public-search .castme-command-form {
  margin: 0 22px 14px;
  padding: 8px;
  border-radius: 16px;
}

.castme-command.is-public-search .castme-command-input,
.castme-command.is-public-search .castme-command-submit {
  min-height: 42px;
  border-radius: 11px;
}

.castme-command.is-public-search .castme-command-results {
  gap: 8px;
  max-height: min(330px, 45dvh);
  padding: 0 22px 22px;
}

.castme-command.is-public-search .castme-command-result {
  border-radius: 15px;
  padding: 13px 15px;
}

@media (max-width: 720px) {
  .site-header .castme-command-shell,
  header .castme-command-shell {
    margin-left: auto;
    margin-right: 8px;
  }

  .castme-public-search-trigger {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
    border-radius: 12px;
  }

  .castme-public-search-trigger span,
  .castme-public-search-trigger kbd {
    display: none;
  }

  .castme-command.is-public-search .castme-command-panel {
    top: 70px;
    right: 8px;
    left: 8px;
    bottom: auto;
    width: auto;
    max-height: min(620px, calc(100dvh - 82px));
    border-radius: 20px;
    transform-origin: top center;
  }

  .castme-command.is-public-search .castme-command-panel::after {
    border-radius: 19px;
  }

  .castme-command.is-public-search .castme-command-panel-head {
    padding: 17px 16px 10px;
  }

  .castme-command.is-public-search .castme-command-panel-head p {
    display: none;
  }

  .castme-command.is-public-search .castme-command-form {
    grid-template-columns: minmax(0, 1fr) 42px;
    margin: 0 16px 12px;
    padding: 7px;
  }

  .castme-command.is-public-search .castme-command-submit {
    width: 42px;
  }

  .castme-command.is-public-search .castme-command-results {
    max-height: min(310px, 39dvh);
    padding: 0 16px 16px;
  }
}

