:root {
  --fondo: #f7f7f6;
  --card: #ffffff;
  --inchiostro: #121214;
  --grigio: #6e6e76;
  --grigio-chiaro: #a3a3ab;
  --bordo: rgba(18, 18, 20, 0.09);
  --campo: #f3f3f4;
  --accento: #3b5bfd;
  --accento-chiaro: rgba(59, 91, 253, 0.1);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

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

.box {
  position: relative;
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(18, 18, 20, 0.04), 0 18px 40px -22px rgba(18, 18, 20, 0.22);
  padding: 16px 16px 10px;
}

.box__head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.box__mark { width: 26px; height: 26px; padding: 5px; border-radius: 8px; background: var(--inchiostro); fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.box__brand { font-size: 14px; font-weight: 650; }
.box__brand span { color: var(--grigio-chiaro); font-weight: 500; }
.box__count { margin-left: auto; font-size: 12.5px; color: var(--grigio); display: flex; align-items: center; gap: 4px; }

.roll { position: relative; display: inline-block; height: 1.25em; line-height: 1.25em; overflow: hidden; vertical-align: bottom; font-weight: 650; color: var(--inchiostro); text-align: right; }
.roll__in { display: block; }
.roll__out { position: absolute; left: 0; right: 0; top: 0; }

/* the field: tokens and the real input on one line */
.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--campo);
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  z-index: 3;
}
.search.is-focus { background: #fff; border-color: var(--accento); box-shadow: 0 0 0 4px var(--accento-chiaro); }
.search__lens { flex: none; width: 17px; height: 17px; fill: none; stroke: var(--grigio); stroke-width: 2; stroke-linecap: round; transition: stroke 0.2s; }
.search.is-focus .search__lens { stroke: var(--accento); }
.search__line { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.search__input {
  flex: 1; min-width: 40px;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 14px; color: var(--inchiostro);
  caret-color: var(--accento);
  height: 42px;
}
.search__input::placeholder { color: var(--grigio-chiaro); }
.search__measure { position: absolute; visibility: hidden; white-space: pre; font-size: 14px; left: 0; top: 0; }

/* a token: what the filter is, then its value, then the x */
.token {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px;
  padding: 0 4px 0 9px;
  border-radius: 99px;
  background: var(--accento-chiaro);
  color: var(--accento);
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transform-origin: left center;
}
.token__key { font-weight: 500; opacity: 0.7; }
.token__x {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 99px;
  border: 0; background: transparent; color: inherit; cursor: pointer;
  transition: background 0.15s;
}
.token__x svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.token__x.is-hover { background: rgba(59, 91, 253, 0.16); }
@media (hover: hover) { .token__x:hover { background: rgba(59, 91, 253, 0.16); } }

/* the suggestions: a small menu under the field, over the list */
.menu {
  position: absolute; left: 0; top: calc(100% + 6px);
  min-width: 220px;
  padding: 5px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--bordo);
  box-shadow: 0 14px 30px -12px rgba(18, 18, 20, 0.28);
  transform-origin: 24px top;
  visibility: hidden;
}
.menu__title { padding: 6px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--grigio-chiaro); text-transform: uppercase; }
.menu__item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--inchiostro);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.menu__item.is-on { background: var(--campo); }
.menu__item mark { background: transparent; color: var(--accento); font-weight: 650; }
.menu__icon { flex: none; width: 22px; height: 22px; border-radius: 99px; display: grid; place-items: center; background: var(--campo); color: var(--grigio); font-size: 10px; font-weight: 650; }
.menu__item.is-on .menu__icon { background: #fff; }
.menu__icon svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu__hint { margin-left: auto; font-size: 11px; color: var(--grigio-chiaro); }

/* the results */
.list { list-style: none; margin-top: 8px; }
.row {
  height: 44px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--bordo);
  overflow: hidden;
}
.row:first-child { border-top-color: transparent; }
.row__av { width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center; font-size: 11px; font-weight: 650; color: #fff; }
.row__txt { min-width: 0; }
.row__from { display: block; font-size: 12px; color: var(--grigio); line-height: 1.2; }
.row__subj { display: block; font-size: 13.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.is-unread .row__subj { font-weight: 650; }
.row__side { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--grigio-chiaro); }
.row__side svg { width: 14px; height: 14px; fill: none; stroke: var(--grigio-chiaro); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.row__side .is-star { fill: #f2b01e; stroke: #e0a10f; }
.row mark { background: rgba(59, 91, 253, 0.14); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty { position: absolute; left: 0; right: 0; top: 50%; opacity: 0; text-align: center; font-size: 13px; color: var(--grigio); pointer-events: none; }

.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  fill: var(--inchiostro); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  pointer-events: none;
  opacity: 0;
  z-index: 50;
}

@media (max-height: 520px) {
  .box { padding: 12px 12px 6px; }
  .box__head { margin-bottom: 8px; }
  .row { height: 38px; }
  .row__from { font-size: 11px; }
  .row__subj { font-size: 12.5px; }
}

@media (max-width: 380px) {
  .box { padding: 12px 12px 6px; }
  .row__side span { display: none; }
  .search__input { font-size: 13px; }
}
