/* Work Search — components. Landing view, search pill, results, states.
 * Narrow viewports (extension side panel) compact via media queries at the
 * bottom. */

/* ── views ──────────────────────────────────────────────────────────────── */

.view-results[hidden],
.view-landing[hidden] {
  display: none;
}

/* ── profile chip (top-right) ───────────────────────────────────────────── */

.profile {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 5;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: var(--surface);
  cursor: pointer;
  width: 36px;
  height: 36px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.view-results .profile {
  position: static;
  flex-shrink: 0;
  margin-left: auto; /* flush the account icon to the far right on the results bar */
}

.profile:hover {
  box-shadow: var(--shadow-pill);
}

.profile .avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile .avatar-initial {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ── landing ────────────────────────────────────────────────────────────── */

.view-landing {
  position: relative;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(60rem 40rem at 85% -10%, rgba(255, 197, 38, 0.16), transparent 60%),
    radial-gradient(50rem 36rem at -10% 110%, rgba(13, 148, 136, 0.08), transparent 60%),
    var(--surface);
}

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: min(36rem, calc(100vw - 3rem));
  padding-bottom: 8vh;
}

.landing-mark {
  width: 54px;
  height: auto;
}

/* Wordmark: the W glyph IS the logo mark; remaining letters carry the logo
 * palette (Google-style multicolor, blue included). */
.wordmark {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-wordmark);
  font-weight: 640;
  letter-spacing: -0.03em;
  line-height: 1;
}

.wordmark-mark {
  width: auto;
  height: 0.82em;
}

.wordmark-gap {
  display: inline-block;
  width: 0.32em;
}

.letters span:nth-child(4n + 1) { color: var(--blue); }
.letters span:nth-child(4n + 2) { color: var(--pink); }
.letters span:nth-child(4n + 3) { color: var(--gold-deep); }
.letters span:nth-child(4n + 4) { color: var(--teal); }

.landing-actions {
  display: flex;
  gap: 12px;
}

.btn {
  border: 1px solid transparent;
  cursor: pointer;
  padding: 9px 18px;
  border-radius: 6px;
  background: var(--surface-sunken);
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--ink);
}

.btn:hover {
  box-shadow: var(--shadow-pill);
}

/* Sign in with Worklyn — mirrors product/desk's .worklyn-signin:
 * outlined, hairline border, medium weight, two-tone W mark. */
.btn-karibu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

.btn-karibu:hover,
.btn-karibu:active {
  background: var(--surface-sunken);
}

.btn-karibu svg {
  flex-shrink: 0;
}

.save-hint {
  margin: -6px 0 0;
  font-size: 0.8438rem;
  color: var(--teal);
  font-weight: 550;
}

.save-hint.hidden {
  display: none;
}

/* # tag autocomplete — floating chips under the active field */
.tag-suggest {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 320px;
  padding: 8px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e3e3e8);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.tag-suggest.hidden {
  display: none;
}

.tag-chip {
  font: inherit;
  font-size: 0.8438rem;
  padding: 3px 10px;
  border: 1px solid var(--border, #e3e3e8);
  border-radius: 999px;
  background: var(--chip-bg, #f3f3f6);
  color: var(--text, #1a1a1f);
  cursor: pointer;
}

.tag-chip:hover,
.tag-chip:focus-visible {
  border-color: var(--brand, #5b5be6);
  color: var(--brand, #5b5be6);
  outline: none;
}

/* Save-link overlay — modal card over a dimmed page, like desk's uploads. */
.save-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 45%);
  backdrop-filter: blur(2px);
}

.save-overlay.hidden {
  display: none;
}

.save-card {
  width: min(30rem, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.4rem;
  border-radius: var(--radius-row-hover);
  background: var(--surface, #fff);
  box-shadow: 0 18px 50px rgb(0 0 0 / 25%);
}

.save-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.save-card-head h2 {
  margin: 0;
  font-size: 1.125rem;
}

.overlay-close {
  border: none;
  background: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

.save-list {
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  max-height: 8.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-row-hover);
}

.save-list.hidden {
  display: none;
}

.save-list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: calc(var(--radius-row-hover) - 4px);
  cursor: pointer;
}

.save-list-item:hover {
  background: var(--surface-sunken);
}

.save-list-item.active {
  background: var(--surface-sunken);
  font-weight: 600;
}

.save-list-item.has-error .save-list-title {
  color: #b3261e;
}

.save-list-title {
  flex: 1;
  min-width: 0;
  font-size: 0.8438rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-list-remove {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 0.2rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 999px;
}

.save-list-remove:hover {
  background: rgb(0 0 0 / 8%);
  color: var(--ink);
}

.save-preview {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 3.4rem;
}

.preview-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.9688rem;
}

.preview-url {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--teal);
  word-break: break-all;
}

.preview-desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.preview-loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.save-note {
  resize: vertical;
  min-height: 4.2rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgb(0 0 0 / 15%);
  border-radius: var(--radius-row-hover);
  font: inherit;
  font-size: 0.9063rem;
}

.save-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.save-error {
  font-size: 0.8125rem;
  color: #b3261e;
}

.landing-note {
  margin: 0;
  min-height: 1.4em;
  padding: 0.6rem 0;
  font-size: 0.9063rem;
  color: var(--text-muted);
}

.landing-note.hidden {
  visibility: hidden;
}

/* Save confirmation, styled as a breadcrumb trail: check icon + message. */
.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--teal);
}

.breadcrumb svg {
  flex-shrink: 0;
}

/* Whole-page drop zone — shown while a link is dragged over the window,
 * pointer-events off so it never steals the drag/drop itself. */
.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(19 151 193 / 12%);
  pointer-events: none;
}

.drag-overlay.hidden {
  display: none;
}

.drag-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2rem 2.6rem;
  border: 2px dashed var(--teal);
  border-radius: var(--radius-row-hover);
  background: var(--surface, #fff);
  color: var(--teal);
  font-weight: 600;
  font-size: 1.05rem;
}

.drag-overlay-card svg {
  width: 28px;
  height: 28px;
}

/* ── search pill ────────────────────────────────────────────────────────── */

.searchbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.landing .searchbar {
  max-width: 34rem;
}

.searchbar-field {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 18px;
  height: 50px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pill);
  transition: box-shadow 120ms ease;
}

.searchbar-field:focus-within {
  box-shadow: 0 1px 10px rgba(32, 33, 36, 0.28);
}

.searchbar-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.searchbar-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 1.0625rem;
}

.searchbar-clear {
  flex-shrink: 0;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  color: var(--text-muted);
  display: none;
}

.searchbar-clear.visible {
  display: block;
}

.searchbar-clear:hover {
  background: rgba(35, 26, 52, 0.06);
}

/* ── sign-in (top-right; inside the topbar it flows inline) ─────────────── */

.js-signin {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 6;
}

.topbar .js-signin {
  position: static;
  flex-shrink: 0;
  margin-left: auto; /* push the auth action flush right on desktop */
}

/* ── per-link semantic note input (below the pill) ──────────────────────── */

.searchbar {
  flex-wrap: wrap;
}

.searchbar-note {
  flex: 0 1 auto;
  width: min(100%, 22rem);
  margin: 0;
  padding: 9px 18px 9px 46px;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-row-hover);
  box-shadow: var(--shadow-pill);
  outline: none;
}

.searchbar-note:focus {
  border-color: var(--teal);
}

.searchbar-note.hidden {
  display: none;
}

.searchbar-note::placeholder {
  color: var(--text-muted);
}

/* ── results header ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  color: var(--ink);
}

.brand-mark {
  width: 21px;
  height: auto;
}

/* Topbar brand = the homepage wordmark component at heading-link scale. */
.brand-wordmark {
  font-size: 1.125rem;
  gap: 3px;
}

.brand-wordmark .wordmark-mark {
  height: 0.8em;
}

.brand-name {
  font-size: 1.125rem;
  font-weight: 640;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topbar .searchbar {
  flex: 1;
  max-width: 40rem;
}

.topbar .searchbar-field {
  height: 42px;
  padding: 0 15px;
}

.results-meta {
  padding: 12px 60px 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── results view — fixed app pane; only the list scrolls ──────────────── */

.view-results {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.view-results::-webkit-scrollbar {
  display: none;
}

.results-meta {
  flex-shrink: 0;
}

/* ── results list — google-style blue links ─────────────────────────────── */

.results {
  list-style: none;
  margin: 0;
  padding: 12px 60px 48px;
  max-width: 52rem;
  flex: 0 0 auto;
  min-height: 0;
}

.result {
  padding: 11px 12px;
  margin: 0 -12px;
  border-radius: var(--radius-row-hover);
}

.result:hover {
  background: var(--surface-sunken);
}

.result-url {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-url);
  margin-bottom: 4px;
  overflow: hidden;
  min-width: 0;
}

.result-site {
  color: var(--url-green);
  font-weight: 550;
  white-space: nowrap;
}

.result-path {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.result-title {
  font-weight: 640;
  letter-spacing: 0.01em;
}

/* Per-letter colour cycle mirroring the homepage wordmark (.letters). */
.result-title .wm-c0 { color: var(--blue); }
.result-title .wm-c1 { color: var(--pink); }
.result-title .wm-c2 { color: var(--gold-deep); }
.result-title .wm-c3 { color: var(--teal); }

.result-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--link-blue);
  font-size: var(--fs-title);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.result-title:hover {
  text-decoration: underline;
}

.result-title:visited {
  color: var(--link-visited);
}

.result-snippet {
  margin: 3px 0 0;
  font-size: var(--fs-snippet);
  line-height: 1.55;
  color: var(--snippet-ink);
  overflow-wrap: break-word;
}

.result-snippet b,
.result-title b {
  font-weight: 700;
}

/* ── status states ──────────────────────────────────────────────────────── */

.status {
  padding: 28px 72px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.status[hidden] {
  display: none;
}

.status-error {
  color: var(--pink);
}

.signin-callout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-inline: auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── narrow surfaces (side panel, small windows) ────────────────────────── */

@media (max-width: 540px) {
  .topbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }

  .topbar .brand {
    order: 1;
  }

  .topbar .searchbar {
    order: 3;
    flex-basis: 100%;
  }

  .topbar .js-signin,
  .topbar .profile {
    order: 2;
    margin-left: auto;
  }

  .results-meta {
    padding: 10px 18px 0;
  }

  .results {
    padding: 8px 18px 32px;
  }

  .status {
    padding: 22px 20px;
  }

  :root {
    --fs-title: 1.0625rem;
    --fs-snippet: 0.875rem;
  }
}

/* In-page profile panel — bua-style card instead of navigating away. */
.profile-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--surface, #fff);
  overflow-y: auto;
}

.profile-panel.hidden {
  display: none;
}

.panel-head {
  padding: 14px 20px;
}

.linklike {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--teal);
  cursor: pointer;
}

.linklike:hover {
  text-decoration: underline;
}

.profile-card {
  max-width: 26rem;
  margin: 8vh auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 0 1rem;
}

.panel-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-sunken);
  font-size: 1.8rem;
  font-weight: 640;
  color: var(--ink);
}

.panel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card h2 {
  margin: 6px 0 0;
  font-size: 1.25rem;
}

.muted {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9063rem;
}

.profile-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--teal);
  font-weight: 550;
  text-decoration: none;
}

.profile-link:hover {
  text-decoration: underline;
}

/* On-device AI enable toggle inside the profile panel. */
.ai-section {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ai-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
}

.ai-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.ai-dot.is-busy {
  background: var(--gold, #ffc526);
}

.ai-dot.is-on {
  background: #3fb950;
}

.ai-btn {
  margin-top: 2px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.ai-btn:hover {
  filter: brightness(1.05);
}

.ai-progress {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.ai-meta {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Once enabled, drop the card chrome — just an inline "AI enabled" status. */
.ai-section.is-enabled {
  border: none;
  border-radius: 0;
  padding: 0;
  background: none;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

/* Force the pages estimate onto its own line below the status row. */
.ai-section.is-enabled .ai-meta {
  flex-basis: 100%;
}

.logout-btn {
  margin-top: 18px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: none;
  font: inherit;
  cursor: pointer;
}

.logout-btn:hover {
  background: var(--surface-sunken);
}

/* ── on-device AI summary (AI Overview style) ───────────────────────────── */

.ai-overview {
  flex-shrink: 0;
  margin: 12px 60px 0;
  max-width: calc(52rem - 120px);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pill);
}

.ai-overview[hidden] {
  display: none;
}

.ov-answer {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink);
  overflow-wrap: break-word;
}

.ov-answer p {
  margin: 0;
}

.ov-answer p + p,
.ov-answer ul + p,
.ov-answer p + ul {
  margin-top: 8px;
}

.ov-answer ul {
  margin: 8px 0 0;
  padding-left: 1.1rem;
}

.ov-answer li {
  margin: 2px 0;
}

.ov-cite {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  margin-left: 1px;
}

.ov-cite:hover {
  text-decoration: underline;
}

.ov-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
}

.ov-sources-label {
  color: var(--text-muted);
  font-weight: 550;
  margin-right: 2px;
}

.ov-source {
  color: var(--teal);
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16rem;
}

.ov-source:hover {
  background: var(--surface-sunken);
}

.ov-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.ov-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ov-skeleton > div {
  border-radius: 6px;
  background: var(--surface-sunken);
  animation: ov-pulse 1.3s ease-in-out infinite;
}

@keyframes ov-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.ov-sk-title {
  height: 16px;
  width: 42%;
}

.ov-sk-line {
  height: 12px;
}

.ov-sk-line.w90 { width: 90%; }
.ov-sk-line.w100 { width: 100%; }
.ov-sk-line.w80 { width: 80%; }
.ov-sk-line.w95 { width: 95%; }

@media (max-width: 540px) {
  .ai-overview {
    margin: 10px 18px 0;
  }
}
