/* ============================================================
   BARAEM GRADEFLOW — GLOBAL SEARCH

   A quiet overlay, not a second application. One field, grouped results, and a
   footer that tells the user two honest things: how to drive it with the
   keyboard, and that results respect their permissions. That second line is
   not decoration — it is the honest answer to "why can't I find that pupil?".
   ============================================================ */

.gs {
  position: fixed; inset: 0; z-index: 9800;
  display: none;
}
.gs.is-open { display: block; }

.gs-scrim {
  position: absolute; inset: 0;
  background: rgba(12, 22, 17, .34);
  backdrop-filter: blur(2px);
  animation: gs-fade .14s var(--ease-out) both;
}
@keyframes gs-fade { from { opacity: 0; } to { opacity: 1; } }

.gs-panel {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  margin: clamp(56px, 11vh, 128px) auto 0;
  max-height: min(72vh, 620px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 64px rgba(12, 22, 17, .26), 0 2px 6px rgba(12, 22, 17, .08);
  overflow: hidden;
  animation: gs-rise .18s var(--ease-out) both;
}
@keyframes gs-rise {
  from { opacity: 0; transform: translateY(-8px) scale(.995); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- the field */
.gs-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.gs-ic { display: grid; place-items: center; color: var(--text-faint); flex: 0 0 auto; }
.gs-ic svg { width: 17px; height: 17px; }

.gs-in {
  flex: 1 1 auto; min-width: 0;
  border: 0; background: none; outline: none;
  font: inherit; font-size: var(--t-15);
  color: var(--text);
  padding: var(--s-1) 0;
}
.gs-in::placeholder { color: var(--text-faint); }
.gs-in::-webkit-search-cancel-button { display: none; }

.gs-kbd, .gs-hint kbd {
  font: inherit; font-size: var(--t-10, 10px); font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs, 3px);
  padding: 2px 5px;
  white-space: nowrap;
}

/* -------------------------------------------------------------- results */
.gs-results {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-2) 0;
}

.gs-group {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-1);
  font-size: var(--t-10); font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint);
}
.gs-count {
  font-size: var(--t-10, 10px); font-weight: 700; letter-spacing: 0;
  color: var(--text-mute);
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 0 6px;
}

.gs-row {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%;
  border: 0; background: none;
  text-align: start;
  padding: var(--s-2) var(--s-4);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  border-inline-start: 2px solid transparent;
}
.gs-row:hover { background: var(--surface-2); }
.gs-row.is-sel {
  background: var(--accent-50, rgba(16, 74, 51, .07));
  border-inline-start-color: var(--accent-600);
}
.gs-row:focus-visible { outline: 2px solid var(--accent-600); outline-offset: -2px; }

.gs-row-ic {
  display: grid; place-items: center;
  width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-mute);
}
.gs-row.is-sel .gs-row-ic { background: var(--surface); color: var(--accent-700); }
.gs-row-ic svg { width: 14px; height: 14px; }

.gs-row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gs-row-t {
  font-size: var(--t-13); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gs-row-m {
  font-size: var(--t-11); color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ------------------------------------------------------- empty / hints */
.gs-msg {
  padding: var(--s-8) var(--s-5);
  text-align: center;
  font-size: var(--t-13); color: var(--text-mute);
}
.gs-note {
  display: block;
  margin-block-start: var(--s-3);
  font-size: var(--t-11);
  color: var(--text-faint);
}
.gs-hint-pane { padding: var(--s-6) var(--s-5); text-align: center; }
.gs-msg-t { margin: 0 0 var(--s-4); font-size: var(--t-13); color: var(--text-mute); }
.gs-ex { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; }
.gs-ex button {
  font: inherit; font-size: var(--t-12);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-soft);
  padding: 3px var(--s-3);
  cursor: pointer;
}
.gs-ex button:hover { border-color: var(--accent-600); color: var(--accent-700); }

/* --------------------------------------------------------------- footer */
.gs-foot {
  display: flex; align-items: center; gap: var(--s-4);
  flex-wrap: wrap;
  flex: 0 0 auto;
  padding: var(--s-2) var(--s-4);
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.gs-hint { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-11); color: var(--text-faint); }
.gs-scope { margin-inline-start: auto; font-size: var(--t-11); color: var(--text-faint); }

body.gs-open { overflow: hidden; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 640px) {
  .gs-panel {
    width: 100%;
    margin: 0;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    border: 0;
  }
  .gs-row { padding: var(--s-3) var(--s-4); }
  .gs-scope { display: none; }
}

@media print {
  .gs { display: none !important; }
}
/* ------------------------------------------------------------ the trigger */
.gs-trigger {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font: inherit; font-size: var(--t-12);
  color: #fff;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--r-pill);
  padding: 4px var(--s-2) 4px var(--s-3);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.gs-trigger:hover { background: rgba(255, 255, 255, .17); border-color: rgba(255, 255, 255, .30); }
.gs-trigger:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.gs-trigger svg { width: 14px; height: 14px; opacity: .9; }
.gs-trigger kbd {
  font: inherit; font-size: 10px; font-weight: 700;
  color: rgba(255, 255, 255, .72);
  background: rgba(255, 255, 255, .12);
  border-radius: 3px;
  padding: 1px 4px;
}
@media (max-width: 720px) {
  .gs-trigger-t, .gs-trigger kbd { display: none; }
  .gs-trigger { padding: 5px; border-radius: 50%; }
}
