/* The AI command palette with the reordering results: the ⌘K palette of Loomwork, a made-up AI workspace, as a
   window of smoked glass over a dark room with two soft lights. Every size inside is a multiple of --u, one pixel on
   a computer and less on a short screen, so the palette keeps its proportions and stays inside a phone's preview. */
:root {
  --page: #08080b;                     /* the room */
  --light-a: #5b45ff;                  /* the violet light behind the glass */
  --light-b: #10a9c9;                  /* the teal light behind the glass */
  --glass: rgba(24, 24, 31, 0.72);     /* the smoked glass */
  --edge: rgba(255, 255, 255, 0.085);  /* the edge of the glass */
  --ink: #ececf2;                      /* the words */
  --soft: #b9b9c6;                     /* the words of a row at rest */
  --muted: #7d7d8c;                    /* the small words */
  --hit: #ffffff;                      /* the letters that match */
  --iri-a: #8a6dff;                    /* the iridescent light, violet */
  --iri-b: #41d6ff;                    /* the iridescent light, cyan */
  --iri-c: #ff7ad1;                    /* the iridescent light, pink */
  --iri-d: #ffd08a;                    /* the iridescent light, amber */
  --key: #26262f;                      /* the keys */
  --key-ink: #c4c4d0;                  /* the signs on the keys */
  --button: #f2f2f6;                   /* the main button of the answer */
  --button-ink: #0b0b10;               /* the words on it */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  --u: min(1px, calc(100vh / 540), calc(100vw / 400));
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  isolation: isolate;
}

/* ------------------------------------------------------------ the room */
.room {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.035), transparent 60%),
    var(--page);
}

.room__light {
  position: absolute;
  border-radius: 50%;
  opacity: 0.7;
}

.room__light--a {
  width: calc(420 * var(--u));
  height: calc(300 * var(--u));
  left: calc(50% - 400 * var(--u));
  top: calc(50% - 260 * var(--u));
  background: radial-gradient(closest-side, var(--light-a), rgba(91, 69, 255, 0.35) 45%, transparent);
}

.room__light--b {
  width: calc(380 * var(--u));
  height: calc(280 * var(--u));
  left: calc(50% + 40 * var(--u));
  top: calc(50% + 10 * var(--u));
  background: radial-gradient(closest-side, var(--light-b), rgba(16, 169, 201, 0.35) 45%, transparent);
  opacity: 0.42;
}

.room__light--c {
  width: calc(240 * var(--u));
  height: calc(200 * var(--u));
  left: calc(50% + 150 * var(--u));
  top: calc(50% - 250 * var(--u));
  background: radial-gradient(closest-side, var(--iri-c), transparent);
  opacity: 0.18;
}

/* the floor under the glass, where the lights land */
.room__floor {
  position: absolute;
  left: 50%;
  top: calc(50% + 190 * var(--u));
  width: calc(720 * var(--u));
  height: calc(120 * var(--u));
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(120, 100, 255, 0.22), rgba(16, 169, 201, 0.06) 60%, transparent);
  filter: blur(calc(18 * var(--u)));
}

.room__grain,
.cp__grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.16;
}

/* ------------------------------------------------------------ the palette */
.frame {
  position: relative;
  width: min(640px, 92vw, 100%);
  height: calc(470 * var(--u));
  max-height: calc(100vh - 32px);
}

.cp {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  container: cp / inline-size;
  border-radius: calc(18 * var(--u));
  opacity: 0;
}

.cp__glass,
.cp__grain,
.cp__sheen,
.cp__rim,
.cp__aura {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.cp__glass {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 38%),
    var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 10px 24px -8px rgba(0, 0, 0, 0.55),
    0 40px 80px -24px rgba(0, 0, 0, 0.75),
    0 70px 120px -50px rgba(70, 50, 190, 0.5);
}

.cp__grain {
  opacity: 0.09;
  overflow: hidden;
}

/* the light on the glass, under the pointer (or drifting by itself) */
.cp__sheen {
  overflow: hidden;
  background: radial-gradient(calc(300 * var(--u)) calc(180 * var(--u)) at var(--mx, 30%) var(--my, 0%), rgba(255, 255, 255, 0.07), transparent 70%);
}

/* the edge: a hairline that catches the light on top and goes into shadow at the bottom */
.cp__rim {
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

/* the iridescent halo around the window while the AI answers */
.cp__aura {
  inset: calc(-2 * var(--u));
  border-radius: calc(20 * var(--u));
  background: conic-gradient(from 210deg, var(--iri-a), var(--iri-b), var(--iri-c), var(--iri-d), var(--iri-a));
  filter: blur(calc(26 * var(--u)));
  opacity: 0;
  z-index: -1;
}

/* ------------------------------------------------------------ the field */
.cp__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(12 * var(--u));
  height: calc(60 * var(--u));
  padding: 0 calc(14 * var(--u)) 0 calc(20 * var(--u));
}

.cp__lens {
  flex: none;
  width: calc(18 * var(--u));
  height: calc(18 * var(--u));
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.cp__input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.cp__input,
.cp__mirror {
  font: inherit;
  font-size: max(14px, calc(17 * var(--u)));
  font-weight: 440;
  letter-spacing: -0.01em;
  font-variation-settings: 'wdth' 100;
}

.cp__input {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  outline: none;
  caret-color: var(--iri-b);
}

.cp__input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.cp__mirror {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  white-space: pre;
}

/* the drawn caret, shown while the palette types by itself */
.cp__caret {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.5px;
  height: max(16px, calc(20 * var(--u)));
  margin-top: calc(max(16px, calc(20 * var(--u))) / -2);
  border-radius: 1px;
  background: linear-gradient(180deg, var(--iri-b), var(--iri-a));
  opacity: 0;
  pointer-events: none;
}

.cp__kbd {
  flex: none;
  display: flex;
  gap: calc(4 * var(--u));
  padding: calc(4 * var(--u));
  margin: 0;
  border: 0;
  border-radius: calc(8 * var(--u));
  background: none;
  cursor: pointer;
  color: inherit;
}

.cp__kbd:focus-visible {
  outline: 1.5px solid var(--iri-b);
  outline-offset: 2px;
}

.cp__rule {
  display: block;
  height: 1px;
  margin: 0 calc(10 * var(--u));
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08) 12%, rgba(255, 255, 255, 0.08) 88%, transparent);
}

/* ------------------------------------------------------------ the keys */
.key {
  --lit: 0;
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: max(18px, calc(22 * var(--u)));
  height: max(18px, calc(22 * var(--u)));
  padding: 0 calc(6 * var(--u));
  border-radius: calc(6 * var(--u));
  font-size: max(10px, calc(11.5 * var(--u)));
  font-weight: 560;
  line-height: 1;
  color: var(--key-ink);
  background: linear-gradient(180deg, #2e2e38, var(--key));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(0, 0, 0, 0.55),
    0 2px 0 #121217,
    0 3px 6px -2px rgba(0, 0, 0, 0.6);
}

/* pressed, the key lights up from inside for a moment */
.key::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(160, 140, 255, 0.45), rgba(65, 214, 255, 0.25));
  box-shadow: inset 0 0 0 1px rgba(170, 160, 255, 0.55);
  opacity: var(--lit);
  pointer-events: none;
}

.key:not(:has(svg)) {
  padding-top: 1px;
}

.key svg {
  position: relative;
  width: max(9px, calc(11 * var(--u)));
  height: max(9px, calc(11 * var(--u)));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key--sm {
  min-width: max(16px, calc(19 * var(--u)));
  height: max(16px, calc(19 * var(--u)));
  padding: 0 calc(4 * var(--u));
  font-size: max(9px, calc(10.5 * var(--u)));
}

.key--word {
  padding: 0 calc(6 * var(--u));
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------ the results */
.cp__body {
  position: relative;
  overflow: hidden;
}

.cp__probe {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  visibility: hidden;
  pointer-events: none;
}

.cp__probe--row {
  height: calc(46 * var(--u));
}

.cp__probe--pad {
  height: calc(7 * var(--u));
}

.cp__list {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* the highlight under the chosen row: one band that glides from row to row */
.cp__hl {
  position: absolute;
  left: calc(8 * var(--u));
  right: calc(8 * var(--u));
  top: 0;
  height: calc(46 * var(--u));
  border-radius: calc(11 * var(--u));
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.045));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.cp__hl-bar {
  position: absolute;
  left: calc(5 * var(--u));
  top: 28%;
  bottom: 28%;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--iri-a), var(--iri-b));
}

.row {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(46 * var(--u));
  padding: 0 calc(22 * var(--u)) 0 calc(20 * var(--u));
  display: flex;
  align-items: center;
  gap: calc(12 * var(--u));
  color: var(--soft);
  font-size: max(12.5px, calc(14.5 * var(--u)));
  font-weight: 450;
  letter-spacing: -0.005em;
  cursor: pointer;
  visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

.row[aria-selected='true'] {
  color: var(--ink);
}

.row__icon {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: calc(28 * var(--u));
  height: calc(28 * var(--u));
  border-radius: calc(8 * var(--u));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--muted);
  transition: color 0.25s;
}

.row[aria-selected='true'] .row__icon {
  color: var(--ink);
}

.row__icon svg {
  width: calc(15 * var(--u));
  height: calc(15 * var(--u));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* a person: the initials on a soft gradient */
.row__icon--person {
  border-radius: 50%;
  font-size: max(9px, calc(10.5 * var(--u)));
  font-weight: 640;
  letter-spacing: 0.01em;
  color: #f4f4f8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), inset 0 -6px 10px -4px rgba(0, 0, 0, 0.3);
}

.row__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row__label b {
  font-weight: 640;
  color: var(--hit);
}

.row__meta {
  flex: none;
  color: var(--muted);
  font-size: max(11px, calc(12.5 * var(--u)));
  font-weight: 420;
}

.row__keys {
  flex: none;
  display: flex;
  gap: calc(4 * var(--u));
}

.row__done {
  position: absolute;
  right: calc(22 * var(--u));
  top: 50%;
  display: flex;
  align-items: center;
  gap: calc(6 * var(--u));
  transform: translateY(-50%);
  color: var(--iri-b);
  font-size: max(11px, calc(12.5 * var(--u)));
  font-weight: 560;
  opacity: 0;
  pointer-events: none;
}

.row__done-inner {
  display: flex;
  align-items: center;
  gap: calc(6 * var(--u));
}

.row__done svg {
  width: calc(14 * var(--u));
  height: calc(14 * var(--u));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Ask AI: the iridescent edge, a light running along it, and a faint wash inside */
.row--ai .row__icon {
  color: #fff;
  background: linear-gradient(140deg, rgba(138, 109, 255, 0.5), rgba(65, 214, 255, 0.28));
  box-shadow: inset 0 0 0 1px rgba(200, 190, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 14px -4px rgba(120, 100, 255, 0.7);
}

.row__ring,
.row__wash {
  position: absolute;
  top: calc(3 * var(--u));
  bottom: calc(3 * var(--u));
  left: calc(8 * var(--u));
  right: calc(8 * var(--u));
  border-radius: calc(11 * var(--u));
  overflow: hidden;
  pointer-events: none;
}

.row__ring {
  padding: 1px;
  background: rgba(255, 255, 255, 0.06);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.row__wash {
  opacity: 0.16;
}

.row__spin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 110%;
  aspect-ratio: 1;
  background: conic-gradient(from 0deg, transparent 0 52%, var(--iri-a) 62%, var(--iri-b) 71%, var(--iri-c) 80%, var(--iri-d) 87%, transparent 95%);
}

.row__wash .row__spin {
  filter: blur(calc(16 * var(--u)));
}

.row--ai .row__label {
  color: var(--ink);
}

.row__q {
  background: linear-gradient(90deg, #c9bcff, #9fe9ff 50%, #ffc1ea);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 540;
}

.row__q--idle {
  background: none;
  color: var(--muted);
  font-weight: 440;
}

/* ------------------------------------------------------------ the answer */
.ans {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: calc(8 * var(--u)) calc(24 * var(--u)) calc(16 * var(--u)) calc(28 * var(--u));
  visibility: hidden;
}

.ans__head {
  display: flex;
  align-items: center;
  gap: calc(10 * var(--u));
  height: calc(24 * var(--u));
  font-size: max(11px, calc(12.5 * var(--u)));
}

.ans__who {
  font-weight: 620;
  color: var(--ink);
  letter-spacing: 0.005em;
}

.ans__status {
  position: relative;
  color: var(--muted);
}

/* the thinking words: a light passes through them while the docs are read */
.ans__think {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 35%, #e9e4ff 50%, var(--muted) 65%, var(--muted) 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ans__found {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  opacity: 0;
}

.ans__text {
  position: relative;
  margin: calc(8 * var(--u)) 0 0;
  font-size: max(12.5px, calc(15 * var(--u)));
  line-height: 1.55;
  font-weight: 420;
  color: #d4d4de;
  letter-spacing: -0.003em;
}

.w {
  display: inline-block;
  opacity: 0;
}

.w--em {
  color: var(--ink);
  font-weight: 600;
}

/* the light that runs just ahead of the words */
.glint {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(70 * var(--u));
  height: calc(26 * var(--u));
  margin: calc(-13 * var(--u)) 0 0 calc(-26 * var(--u));
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(170, 225, 255, 0.55), rgba(140, 110, 255, 0.28) 55%, transparent);
  filter: blur(calc(5 * var(--u)));
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.glint__bar {
  position: absolute;
  left: calc(26 * var(--u));
  top: 18%;
  bottom: 18%;
  width: 2px;
  border-radius: 1px;
  background: #e6f7ff;
  box-shadow: 0 0 8px rgba(160, 220, 255, 0.9);
  filter: none;
}

.ans__src {
  display: flex;
  flex-wrap: wrap;
  gap: calc(6 * var(--u));
  margin-top: calc(14 * var(--u));
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: calc(6 * var(--u));
  height: max(22px, calc(26 * var(--u)));
  padding: 0 calc(10 * var(--u)) 0 calc(8 * var(--u));
  border-radius: calc(8 * var(--u));
  font-size: max(11px, calc(12 * var(--u)));
  color: var(--soft);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  opacity: 0;
}

.chip svg {
  width: calc(13 * var(--u));
  height: calc(13 * var(--u));
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ans__act {
  display: flex;
  gap: calc(8 * var(--u));
  margin-top: calc(14 * var(--u));
}

.act {
  height: max(26px, calc(32 * var(--u)));
  padding: 0 calc(14 * var(--u));
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: max(11.5px, calc(13 * var(--u)));
  font-weight: 560;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  cursor: pointer;
  opacity: 0;
  transition: background-color 0.2s;
}

.act--main {
  color: var(--button-ink);
  background: linear-gradient(180deg, #ffffff, var(--button));
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 6px 18px -8px rgba(160, 150, 255, 0.8);
}

.act:focus-visible {
  outline: 1.5px solid var(--iri-b);
  outline-offset: 2px;
}

@media (hover: hover) {
  .act:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }

  .act--main:hover {
    background: #ffffff;
  }
}

/* ------------------------------------------------------------ the footer */
.cp__foot {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(16 * var(--u));
  height: calc(42 * var(--u));
  padding: 0 calc(18 * var(--u));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.14);
  border-radius: 0 0 calc(18 * var(--u)) calc(18 * var(--u));
  font-size: max(10.5px, calc(12 * var(--u)));
  color: var(--muted);
}

.hint {
  display: flex;
  align-items: center;
  gap: calc(4 * var(--u));
}

.hint__word {
  margin-left: calc(3 * var(--u));
}

.hint__swap {
  position: relative;
  display: inline-grid;
}

.hint__swap > span {
  grid-area: 1 / 1;
}

.hint__swap [data-esc='back'] {
  opacity: 0;
}

.cp__brand {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: calc(6 * var(--u));
  font-weight: 560;
  color: #9a9aaa;
  letter-spacing: 0.005em;
}

.cp__brand svg {
  width: calc(14 * var(--u));
  height: calc(14 * var(--u));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* a narrow palette (a phone): fewer words, same pieces */
@container cp (max-width: 470px) {
  .row__meta,
  .row__brand,
  .hint__word {
    display: none;
  }

  .row {
    padding-right: calc(18 * var(--u));
  }

  .chip:nth-child(3) {
    display: none;
  }

  .ans {
    padding-left: calc(22 * var(--u));
    padding-right: calc(18 * var(--u));
  }
}

@container cp (max-width: 330px) {
  .cp__brand {
    display: none;
  }

  .hint:first-child .hint__word {
    display: none;
  }
}
