:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c2b33;
  --muted: #64707a;
  --accent: #0e6b5c;
  --accent-soft: #e2f0ec;
  --line: #e3e0d8;
  --danger: #a53d3d;
}
* { box-sizing: border-box; }
html { font-size: clamp(14px, 0.55vw + 11px, 18px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px clamp(20px, 3vw, 56px);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 28px; }
h1 { margin: 0; font-size: 1.25rem; color: var(--accent); white-space: nowrap; }
nav { display: flex; gap: 6px; }
nav a {
  padding: 6px 14px; border-radius: 8px; text-decoration: none;
  color: var(--ink); font-weight: 500;
}
nav a.active { background: var(--accent-soft); color: var(--accent); }
#progress-card { min-width: min(340px, 30vw); font-size: 0.85rem; color: var(--muted); text-align: right; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 5px; }
#progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.4s; }

/* fluid: uses the whole screen, with sane margins on huge monitors */
main { padding: clamp(16px, 2.5vw, 48px) clamp(20px, 3vw, 56px); }
.view { max-width: 1900px; margin: 0 auto; }
.two-col { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.2fr); gap: clamp(20px, 2.5vw, 48px); }

h2, h3 { margin: 0 0 12px; font-size: 1.1rem; }
h3 small { color: var(--muted); font-weight: 400; }

form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
input, select, button {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
input[type="search"], input[type="text"], #q { flex: 1; min-width: 200px; }
button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); }
button:hover { filter: brightness(1.08); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.45; cursor: default; }
button[aria-busy="true"] { opacity: 0.6; cursor: progress; }

/* keyboard focus is invisible on the custom-styled controls otherwise */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.back { display: inline-block; margin-bottom: 4px; color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.back:hover { text-decoration: underline; }
#load-more { margin-top: 16px; text-align: center; }
#load-more button { background: #fff; color: var(--accent); border-color: var(--accent); }

/* auth: header user area + login screen */
#auth-area { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#auth-area .who { font-size: 0.9rem; color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }
#auth-area .avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
button.ghost { background: #fff; color: var(--accent); border-color: var(--accent); }
.signin { max-width: 460px; margin: 8vh auto 0; text-align: center; }
.signin p { color: var(--muted); }
.login-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.login-btn {
  display: block; padding: 11px 14px; border-radius: 10px; text-decoration: none;
  font-weight: 600; border: 1px solid var(--line); color: var(--ink); background: #fff;
}
.login-btn:hover { filter: brightness(0.98); border-color: var(--accent); }
.login-google { border-color: #ccc; }
.login-github { background: #1c2128; color: #fff; border-color: #1c2128; }
.login-apple { background: #000; color: #fff; border-color: #000; }
.login-facebook { background: #1877f2; color: #fff; border-color: #1877f2; }

/* professional-access panel */
#pro-access { margin-top: 18px; font-size: 0.9rem; }
.pro-ok { color: var(--accent); }
.pro-rejected { color: var(--danger); }
.pro-access-form summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.pro-access-form form { margin-top: 10px; }
.pro-access-form input, .pro-access-form select { font-size: 0.9rem; }

#search-note { color: var(--muted); font-size: 0.9rem; min-height: 1.3em; margin-bottom: 12px; }
.empty { color: var(--muted); }

/* hit cards flow in columns on wide screens */
.hits {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(430px, 100%), 1fr));
}
.hit {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
}
.hit-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.hit-head a { color: var(--ink); text-decoration: none; }
.hit-head a:hover { color: var(--accent); }
.badge { white-space: nowrap; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; }
.badge.sem { background: var(--accent-soft); color: var(--accent); }
.badge.kw { background: #ece9f5; color: #55489a; }
.meta { color: var(--muted); font-size: 0.82rem; }
.kind {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: 0 6px; font-size: 0.8rem;
}
.snippet { color: var(--muted); font-size: 0.9rem; }

.wl { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.wl.active { background: var(--accent-soft); border-radius: 8px; }
.wl-name { flex: 1; }
.wl small { color: var(--muted); }
#term-list { list-style: none; margin: 0 0 16px; padding: 0; }
#term-list li { display: flex; gap: 10px; align-items: center; padding: 5px 0; }
.alert-run { align-items: end; }
.alert-run label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
#ar-meta { color: var(--muted); font-size: 0.9rem; }
.term-section { margin-bottom: clamp(20px, 2.5vw, 40px); }

/* below tablet width the two-column watchlists layout overflows the viewport */
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
  header { flex-wrap: wrap; gap: 10px; }
  #progress-card { min-width: 100%; text-align: left; }
}

/* connected MCP assistants */
#mcp-connections { margin-top: 22px; font-size: 0.9rem; }
#mcp-connections h3 { font-size: 1rem; }
.mcp-list { list-style: none; margin: 0; padding: 0; }
.mcp-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mcp-list .wl-name { flex: 1; display: flex; flex-direction: column; }
#mcp-connections code { font-size: 0.85em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
