:root {
  --ink: #222F2D;
  --ink-soft: #4D5B5A;
  --muted: #718482;
  --faint: #B1BCBB;
  --line: #C9D4D2;
  --line-strong: #A9B7B4;
  --surface: #F1F4F3;
  --surface-2: #ECF1F0;
  --blue: #2365AB;        /* brand navy700 */
  --blue-bg: #EAF1FB;     /* brand navy100 */
  --blue-line: #B9D2EA;
  --teal: #10756E;        /* brand teal700 */
  --teal-bg: #EFFAF8;     /* brand teal100 */
  --dark: #222F2D;
  --dark-hover: #18211F;
  --error-bg: #FDECE7;
  --error-ink: #C0370C;
  --card-shadow: 0 1px 2px rgba(34, 47, 45, .04);
  --card-shadow-hover: 0 10px 28px rgba(34, 47, 45, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #fff;
  color: var(--ink);
  line-height: 1.5;
}

@keyframes ss-shimmer { 0% { background-position: -360px 0; } 100% { background-position: 360px 0; } }
@keyframes ss-spin { to { transform: rotate(360deg); } }

a { color: var(--blue); }

/* ── header ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 16px clamp(20px, 5vw, 48px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brand .logo { display: flex; color: var(--ink); }
.brand .logo svg { display: block; }
.brand .titles { display: flex; flex-direction: column; line-height: 1.15; }
.brand .name { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.brand .tagline { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.account .sep { width: 1px; height: 14px; background: var(--line); }
.account a { color: var(--blue); text-decoration: none; font-weight: 600; }
.account a:hover { text-decoration: underline; }

/* ── layout ─────────────────────────────────────────── */
main {
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
  padding: 32px clamp(20px, 5vw, 40px) 72px;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; }

/* ── search hero ────────────────────────────────────── */
.search-hero { display: flex; gap: 10px; flex-wrap: wrap; margin: 0; }
.search-box {
  flex: 1;
  min-width: 240px;
  display: flex;
  height: 50px;
  border-radius: 13px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 101, 171, .15);
}
.search-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 4px 0 18px;
}
.search-input-wrap input[type=search] {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.search-input-wrap input[type=search]::placeholder { color: var(--faint); font-weight: 500; }
.search-input-wrap input[type=search]::-webkit-search-decoration,
.search-input-wrap input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
.clear-q {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.clear-q:hover { background: #E3EAE9; color: var(--ink); }
.clear-q[hidden] { display: none; }

.btn-search {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  flex: none;
  padding: 0;
  border: 0;
  background: var(--dark);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.btn-search:hover { background: var(--dark-hover); }
.btn-search:disabled { opacity: .55; cursor: default; }

/* ── filters ────────────────────────────────────────── */
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  flex-wrap: wrap;
}
.filters .spacer { flex: 1; }
.dropdown { position: relative; z-index: 30; }
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.dropdown-toggle:hover { background: var(--line); }
.dropdown-toggle .caret { display: flex; color: var(--faint); transition: transform .15s; }
.dropdown-toggle.is-active,
.dropdown-toggle.is-open {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 600;
}
.dropdown-toggle.is-active .caret,
.dropdown-toggle.is-open .caret { color: var(--blue); }
.dropdown-toggle.is-open .caret { transform: rotate(180deg); }
.dropdown-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.clear-filters {
  height: 36px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.clear-filters[hidden] { display: none; }

.dropdown-panel {
  position: absolute;
  z-index: 31;
  top: calc(100% + 8px);
  left: 0;
  width: 264px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(34, 47, 45, .16);
  overflow: hidden;
}
.dropdown-panel[hidden] { display: none; }
.panel-head {
  padding: 11px 14px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--faint);
}
.panel-list {
  max-height: 248px;
  overflow: auto;
  padding: 0 6px 6px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink);
}
.opt:hover { background: var(--surface); }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt .box {
  position: relative;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: #fff;
}
.opt .box svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}
.opt input:checked + .box,
.opt input:indeterminate + .box { background: var(--ink); border-color: var(--ink); }
.opt input:checked + .box svg:not(.dash) { opacity: 1; }
.opt input:indeterminate + .box .dash { opacity: 1; }
.opt input:focus-visible + .box { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Curso filter: stage columns with a select-all header per column */
.curso-panel { width: min(580px, 86vw); }
.curso-columns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0 10px 4px;
}
.curso-col { flex: 1; min-width: 150px; }
.curso-col .opt { font-size: 13px; }
.curso-col .opt:not(.stage-head) .txt { color: var(--ink-soft); }
.stage-head { padding: 8px 10px; gap: 9px; }
.stage-name {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
}
.col-divider { height: 1px; background: var(--surface-2); margin: 2px 10px 4px; }
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--surface-2);
}
.panel-clear {
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.panel-clear:hover { color: var(--ink); }

/* ── results meta ───────────────────────────────────── */
.meta {
  margin: 24px 2px 14px;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}
.meta .term { color: var(--ink-soft); font-weight: 600; }

#results { display: flex; flex-direction: column; gap: 14px; }

/* ── infinite scroll status ─────────────────────────── */
.scroll-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.2em;
  margin: 16px 2px 8px;
}
.scroll-status:empty { display: none; }
.scroll-status .loading-head { margin: 0; }
.end-marker { font-size: 13px; color: var(--muted); text-align: center; }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
#scroll-sentinel { height: 1px; }

/* ── result card ────────────────────────────────────── */
.hit {
  background: #fff;
  border-radius: 16px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.hit:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--line-strong);
}
.hit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.hit-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.hit-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.hit-title:hover { color: var(--blue); }
.hit-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 7px;
  padding: 4px 10px;
}
.hit-desc {
  margin: 14px 0 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.hit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.hit-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
.hit-chip .chip-ico { flex: none; }
.chip-grade { color: var(--blue); }
.chip-region { color: var(--teal); }

/* ── state panels (empty / error) ───────────────────── */
.state {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.state .icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.state.empty .icon { background: var(--surface-2); color: var(--faint); }
.state.error .icon { background: var(--error-bg); color: var(--error-ink); }
.state .title { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.state .body { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 16px; max-width: 32ch; }
.state .ghost-btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--blue);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.state .ghost-btn:hover { border-color: var(--blue-line); background: var(--blue-bg); }
.state .retry-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--dark);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.state .retry-btn:hover { background: var(--dark-hover); }

/* ── loading skeleton ───────────────────────────────── */
.loading-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
  padding: 0 2px;
  font-size: 13.5px;
  color: var(--muted);
}
.loading-head .spinner {
  width: 17px;
  height: 17px;
  color: var(--blue);
  display: flex;
}
.loading-head .spinner svg { animation: ss-spin .8s linear infinite; }
.skeleton-card { background: #fff; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--card-shadow); padding: 20px 24px; }
.sk {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, #F3F7F6 37%, var(--line) 63%);
  background-size: 720px 100%;
  animation: ss-shimmer 1.4s infinite linear;
}
.sk.title { height: 16px; width: 48%; }
.sk.line { height: 11px; width: 80%; margin-top: 11px; }

/* ── detail page ────────────────────────────────────── */
.detail { background: #fff; }
.back-link {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0 0 1rem; padding: 0;
  background: none; border: 0; cursor: pointer; text-decoration: none;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--muted);
}
.back-link:hover { color: var(--ink); }
.back-link .back-arrow { font-size: 16px; line-height: 1; }
.detail h1 { font-size: 2rem; letter-spacing: -0.02em; }
.edit-guide-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  margin-left: .6rem;
  vertical-align: middle;
  padding: .25rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); color: var(--blue);
  text-decoration: none; font-weight: 600; font-size: 13px;
  white-space: nowrap;
}
.edit-guide-btn:hover { border-color: var(--blue-line); background: var(--blue-bg); }
.detail .sub {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--muted); font-size: .9rem; margin: 0 0 1.25rem; word-break: break-all;
}
.detail .description { margin: 0 0 1.5rem; color: var(--ink-soft); font-size: 15px; line-height: 1.6; }
.detail-ident {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 1.25rem;
}
.detail-ident .sub { margin: 0; }
.ident-sep { color: var(--faint); }
/* On the detail page the chips read as plain inline metadata: keep the
   colored icon + label but drop the pill background and padding. */
.detail .hit-chip { background: none; padding: 0; }
.manager-link { margin: 0 0 .6rem; }
.manager-link a {
  display: inline-block; padding: .6rem 1.1rem; border-radius: 10px;
  background: var(--dark); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
}
.manager-link a:hover { background: var(--dark-hover); }
.empty { color: var(--muted); }

/* ── login page ─────────────────────────────────────── */
.login { text-align: center; padding-top: 4rem; }
.login p { color: var(--muted); margin: 0 0 1.75rem; }
.signin-google {
  display: inline-flex; align-items: center; gap: .65rem;
  padding: .7rem 1.2rem; font-size: 1rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); text-decoration: none;
}
.signin-google:hover { border-color: var(--line-strong); background: var(--surface); }
.signin-google svg { width: 18px; height: 18px; }
