/* ── Code Moshiach — shared chrome (header + auth cards) ────────────
   Hand-authored, no build step (same rule as site.css). Loaded by BOTH
   layouts (MainLayout + ReviewWorkspaceLayout) so the header reads as one
   surface on the dark landing and the workspace alike: the bar keeps
   the brand's dark commitment on both.
   ──────────────────────────────────────────────────────────────────────── */

.trr-site-header {
  /* Aliases of the shared tokens (tokens.css) — kept so the header's
     rules read as their own surface, with no second copy of a color. */
  --th-bg: var(--bg);
  --th-line: var(--line);
  --th-ink: var(--ink);
  --th-ink-dim: var(--ink-dim);
  --th-accent: var(--accent);
  --th-accent-ink: var(--accent-ink);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: var(--th-bg);
  border-bottom: 1px solid var(--th-line);
  font-family: var(--sans);
}

.trr-site-header__brand {
  color: var(--th-ink);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.trr-site-header__brand .trr-site-header__dot {
  color: var(--th-accent);
}

.trr-site-header__brand:hover { text-decoration: none; }

.trr-site-header__links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.trr-site-header__user {
  color: var(--th-ink-dim);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16rem;
}

.trr-header-btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--th-line);
  font-size: 0.85rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  color: var(--th-ink);
}

.trr-header-btn:hover { text-decoration: none; border-color: var(--th-ink-dim); }

.trr-header-btn--solid {
  background: var(--th-accent);
  border-color: var(--th-accent);
  color: var(--th-accent-ink);
  font-weight: 600;
}

.trr-header-btn--solid:hover { border-color: var(--th-accent); filter: brightness(1.05); }

/* ── Header auth dropdown (tobor-kit <noizu-auth mode="dropdown">) ────────
   The kit positions its panel `left:0` of the trigger wrap, so a panel
   opened from "Log In" — the right-most control cluster in the bar — runs
   rightward off the viewport and is clipped. Both header entry points share
   this one panel ("Sign Up" sets flow="signup" on the same element), so the
   fix is made once, here, through the kit's exposed parts:
   end-align the panel to its trigger and clamp it to the viewport with a
   1rem gutter. On narrow screens the trigger's right edge sits too far in
   for a right-anchored panel to fit, so the wrap stops being the positioning
   context and the panel anchors to the header's link cluster instead, whose
   right edge is the header gutter (1rem), so the panel never crosses either
   viewport edge; on phones it is a full-width sheet with a 1rem gutter.
   At ≤640px the header itself is the positioning context: the sheet's top
   is the header's bottom edge (plus a gap), not the link cluster's, which
   sits inside the header padding and let the sheet slide under the header;
   and its gutters are left/right 1rem of the header box, which excludes a
   classic scrollbar where `100vw` does not. */

.trr-site-header noizu-auth::part(dropdown-panel) {
  left: auto;
  right: 0;
  max-width: min(26rem, calc(100vw - 2rem));
}

@media (max-width: 640px) {
  .trr-site-header { position: relative; padding: 0.7rem 1rem; }
  .trr-site-header__user { max-width: 8rem; }

  .trr-site-header noizu-auth::part(dropdown-wrap) { position: static; }
  .trr-site-header noizu-auth::part(dropdown-panel) {
    top: calc(100% + 0.25rem);
    left: 1rem;
    right: 1rem;
    width: auto;
    max-width: none;
    z-index: 50;
  }
}

/* ── Auth cards (login / signup) ──────────────────────────────────────── */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 2rem 1rem;
  font-family: var(--sans);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-card h1 {
  margin: 0 0 1.2rem;
  color: var(--ink);
  font-size: 1.4rem;
}

.auth-card .auth-error {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger);
  font-size: 0.88rem;
}

.auth-card .auth-lede {
  margin: 0 0 1.2rem;
  color: var(--ink-dim);
  font-size: 0.92rem;
}

.auth-provider-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.auth-provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line-hi);
  background: var(--bg-card-hi);
  color: var(--ink);
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
}

.auth-provider:hover { text-decoration: none; border-color: var(--ink-dim); background: var(--bg-hover); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 1.2rem;
  color: var(--ink-mute);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-field { margin-bottom: 1rem; }

.auth-field label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink-dim);
  font-size: 0.85rem;
}

.auth-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--line-hi);
  background: var(--bg-alt);
  color: var(--ink);
  font-size: 0.95rem;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-submit {
  display: inline-block;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-submit[disabled] { opacity: 0.6; cursor: wait; }

.auth-footer {
  margin-top: 1.2rem;
  color: var(--ink-mute);
  font-size: 0.88rem;
  text-align: center;
}

.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Use-case catalog (TrrSite.Components.UseCaseBrowser) ──────────────
   The browser moved from the public landing page onto the authenticated
   dashboard home (ReviewWorkspaceLayout loads chrome.css but not site.css),
   so its styles live here — the one stylesheet BOTH layouts load. Scoped
   under .uc- and reading tokens.css only: no restated hex values. The
   story card carries its own surface (site.css's .card does not load in
   the workspace; the markup keeps both class names unchanged). */

.uc-browser { margin-top: 1rem; }

.uc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.uc-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
}
.uc-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
}
.uc-filter input,
.uc-filter select {
  min-width: 12rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-card);
  color: var(--ink);
  font: inherit;
}
.uc-filter input:focus,
.uc-filter select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}
.uc-clear {
  align-self: end;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
.uc-clear:hover { color: var(--ink); border-color: var(--line-hi); }
.uc-count {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-mute);
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

.uc-epic { margin-bottom: 3rem; }
.uc-epic-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 1rem;
  font-size: 1.25rem;
}
.uc-epic-num {
  color: var(--accent);
  font-size: 0.85rem;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 0.05rem 0.45rem;
}
.uc-epic-count {
  margin-left: auto;
  color: var(--ink-mute);
  font-size: 0.85rem;
}

/* The story card: its own surface, so it renders identically whether or not
   site.css (the landing stylesheet, which styles the bare .card) is loaded. */
.uc-story {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.4rem 1.35rem;
  margin-bottom: 1rem;
}
.uc-story-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.6rem;
}
.uc-id {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-mute);
}
.uc-title { margin: 0; font-size: 1.05rem; }
.uc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}
.uc-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  color: var(--ink-dim);
  background: var(--bg-card-hi);
  white-space: nowrap;
}
.uc-story-text {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  margin: 0 0 0.5rem;
}
.uc-bullets {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-dim);
  font-size: 0.95rem;
}
.uc-bullets li { margin: 0.25rem 0; }
.uc-empty {
  color: var(--ink-mute);
  text-align: center;
  padding: 3rem 0;
}
/* site.css styles .fineprint; on the dashboard this is the only fineprint,
   so the .uc-source half of the pair carries the look itself. */
.uc-source {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--ink-mute);
}

@media (max-width: 640px) {
  .uc-toolbar { flex-direction: column; align-items: stretch; }
  .uc-chips { margin-left: 0; }
}

/* ── Header account menu (signed in) ──────────────────────────────────────
   The account email is the dropdown trigger; Admin / Log Out live in the
   panel beneath it. The backdrop is an invisible fixed layer that swallows
   the click-outside and closes the menu; the panel stacks above it. */

.trr-account-menu { position: relative; }

.trr-account-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: default;
}

.trr-site-header__user--trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 0;
  padding: 0.4rem 0;
  font: inherit;
  cursor: pointer;
}

.trr-account-menu__caret { font-size: 0.7rem; color: var(--th-ink-dim); }

.trr-account-menu__panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 100;
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
  border: 1px solid var(--th-line);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.trr-account-menu__item {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--th-ink);
  text-decoration: none;
  white-space: nowrap;
}

.trr-account-menu__icon {
  display: inline-block;
  width: 1.4em;
  margin-right: 0.15rem;
  text-align: center;
  color: var(--th-ink-dim);
}

.trr-account-menu__item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

/* ── Repositories browser: org rail + repo table ────────────────────────── */

.repos-filter {
  width: 100%;
  margin-top: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

.repos-filter:focus { outline: 1px solid var(--accent); }

.repos-browser {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
  align-items: start;
}

.repos-browser__orgs {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
}

.repos-browser__org {
  display: block;
  text-decoration: none;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.repos-browser__org:hover { color: var(--ink); background: var(--bg-hover); }

.repos-browser__org[aria-current="true"] {
  color: var(--ink);
  background: var(--bg-hover);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

.repos-browser__repos {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.25rem 1.25rem;
  min-width: 0;
  overflow-x: auto;
}

.repos-browser__org-name { font-size: 1rem; margin: 0; color: var(--ink); }

.repos-browser__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.repos-browser__add {
  display: inline-block;
  align-self: start;
  text-decoration: none;
  background: transparent;
  border: 1px dashed var(--line-hi);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.repos-browser__add:hover { color: var(--ink); border-color: var(--ink-dim); }

.repos-browser__table { width: 100%; min-width: 44rem; border-collapse: collapse; font-size: 0.85rem; }

.repos-browser__table th {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--ink-mute);
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line-hi);
}

.repos-browser__table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  white-space: nowrap;
}

/* One line per row: long owner/name slugs truncate instead of wrapping. */
.repos-browser__repo-link {
  display: block;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repos-browser__table tbody tr:hover td { background: var(--bg-hover); }

.repos-browser__table a { color: var(--ink); text-decoration-color: var(--line-hi); }
.repos-browser__table a:hover { color: var(--accent); }

.repos-browser__state {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border: 1px solid var(--line-hi);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

.repos-browser__state--removed {
  color: var(--danger);
  border-color: var(--danger-line, rgba(239, 68, 68, 0.4));
  background: var(--danger-bg, rgba(239, 68, 68, 0.12));
}

.repos-browser__state--active {
  color: var(--fixed);
  border-color: color-mix(in srgb, var(--fixed) 35%, transparent);
  background: color-mix(in srgb, var(--fixed) 10%, transparent);
}

.repos-browser__state--removed {
  color: var(--danger);
  border-color: var(--danger-line, rgba(239, 68, 68, 0.4));
  background: var(--danger-bg, rgba(239, 68, 68, 0.12));
}

/* ── Settings: LLM provider selector + test ─────────────────────────────── */

.settings-section {
  margin-top: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.settings-heading { font-size: 1rem; margin: 0 0 0.75rem; color: var(--ink); }

.settings-llm-choices { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-bottom: 0.9rem; }

.settings-choice {
  display: inline-flex !important;
  align-items: baseline;
  gap: 0.45rem;
  white-space: nowrap;
  color: var(--ink-dim);
  font-size: 0.9rem;
  cursor: pointer;
}

.settings-choice input { accent-color: var(--accent); }

.settings-choice-name { color: var(--ink); }

/* The model / base-url / key fields render only while "user provided" is
   picked (state-driven conditional in the page template). */
.settings-llm-user-fields { flex-direction: column; gap: 0.6rem; margin-bottom: 0.9rem; }

.settings-llm-fields { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.9rem; }

.settings-llm-user-fields label,
.settings-llm-fields label {
  display: grid;
  grid-template-columns: 6rem 1fr;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-mute);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.settings-llm-fields input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
}

.settings-llm-fields input:focus { outline: 1px solid var(--accent); }

.settings-llm-hint { color: var(--ink-mute); font-size: 0.8rem; margin: 0 0 0.9rem; }

.settings-llm-actions { display: flex; gap: 0.6rem; align-items: center; }

.settings-llm-save,
.settings-llm-test {
  border: 0;
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.settings-llm-save {
  background: var(--bg-hover);
  color: var(--ink);
  border: 1px solid var(--line-hi);
}

.settings-llm-save:hover { border-color: var(--ink-dim); }

.settings-llm-test {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.settings-llm-test:hover { filter: brightness(1.05); }

@media (max-width: 640px) {
  .repos-browser { grid-template-columns: minmax(0, 1fr); }
  .repos-browser__orgs { flex-direction: row; flex-wrap: wrap; }
  /* The 6-column table's min-content width exceeds a phone viewport; keep
     the sideways scroll inside the card so the page itself never scrolls. */
  .repos-browser__repos { overflow-x: auto; }
}

/* ── Repositories: starred card + star toggles ──────────────────────────── */

.repos-starred {
  margin-top: 1rem;
  margin-bottom: 1.25rem;
  background: var(--bg-card-hi);
  border: 1px solid var(--line-hi);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.repos-starred:not(:has(.repos-starred__row)) { display: none; }

.repos-starred .settings-heading { margin-bottom: 0.25rem; }

.repos-starred__rows {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.repos-starred__row { min-width: 0; max-width: 100%; }

.repos-starred__link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  background: var(--bg-alt);
  border: 1px solid var(--line-hi);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  line-height: 1.4;
  text-decoration: none;
}
.repos-starred__link:hover { color: var(--accent); border-color: var(--accent); }

.repos-star__form { display: inline; margin: 0; }

.repos-star__btn {
  background: transparent;
  border: 0;
  padding: 0.1rem 0.3rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-mute);
}

.repos-star__btn:hover { color: var(--ink); }
.repos-star__btn--on { color: var(--accent); }

/* ── Repo detail: code audit trigger ──────────────────────────────────── */

.repo-audit__form { margin: 0.75rem 0 0; }

.repo-audit__form .settings-llm-save { font-weight: 600; }

/* ── Repo reviews toggle (list chip + detail button) ──────────────────── */

.repo-reviews__form { display: inline; margin: 0; }

.repos-reviews__btn {
  background: transparent;
  border: 1px solid var(--ink-mute);
  border-radius: 999px;
  min-height: 0;
  padding: 0.05rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  color: var(--ink-mute);
}

.repos-reviews__btn:hover { color: var(--ink); }
.repos-reviews__btn--on {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Repo onboarding wizard ────────────────────────────────────────────── */

.onboarding__error { color: var(--danger); }

.onboarding__actions {
  display: flex;
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.onboarding__amend { margin: 0.4rem 0 0.2rem; }

.onboarding__file { margin: 0.6rem 0; }

.onboarding__file-path {
  font-size: 0.8rem;
  color: var(--ink-mute);
  margin-bottom: 0.15rem;
}

.onboarding__pre {
  background: rgba(127, 127, 127, 0.08);
  border: 1px solid var(--ink-mute);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.onboarding__saveform { margin: 0.9rem 0 0.3rem; }

/* Keep repository checklist columns within the page on narrow screens. */
.repo-checklist__table-wrap { max-width: 100%; overflow-x: auto; }
