/* roketo — search UI. System/arial stack, no webfonts.
   Brand: charcoal #1B1B1F strokes, coral #FF4B3E accent (see /static/img/logo.svg).
   All colors live in tokens on :root; dark mode follows the system preference
   via a single prefers-color-scheme override block — no toggle. */

:root {
  color-scheme: light dark;

  /* surfaces */
  --bg: #fff;                      /* page background */
  --surface: #fff;                 /* search pill, dropdown, answer cards */
  --card-bg: #fff;                 /* settings/auth cards */
  --surface-inset: #f8f9fa;        /* code chips, token box */
  --footer-bg: #f2f2f2;
  --hover-bg: #eee;                /* autocomplete row hover/active */
  --favicon-bg: #f1f3f4;
  --favicon-border: #ecedef;

  /* text */
  --text-primary: #202124;
  --text-secondary: #4d5156;       /* snippets, card body text */
  --text-muted: #70757a;           /* kickers, meta, footer */
  --text-label: #5f6368;           /* field labels, settings header title */
  --snippet-bold: #5f6368;

  /* borders */
  --border: #dadce0;
  --border-light: #e8eaed;         /* hairlines, feed list */
  --border-pill: #dfe1e5;          /* search pill, answer cards */
  --card-border: #dfe1e5;

  /* links: result-link blue / visited purple are search-UX conventions, kept */
  --link: #1a0dab;
  --link-visited: #681da8;
  --crumb-host: #202124;
  --crumb-path: #4d5156;

  /* brand accent (coral) */
  --accent: #FF4B3E;
  --accent-strong: #e63b2f;        /* pressed/hover on light */
  --on-accent: #fff;

  /* buttons */
  --btn-bg: #f8f9fa;
  --btn-border: #f8f9fa;
  --btn-text: #3c4043;
  --btn-text-hover: #202124;

  /* misc */
  --icon-muted: #9aa0a6;
  --danger: #d93025;
  --danger-bg: #fce8e6;
  --danger-border: #f4c7c3;
  --shadow: rgba(32, 33, 36, .28);

  /* price change, crypto/stock cards [J] */
  --change-up: #188038;
  --change-down: #d93025;

  /* AQI level chips [J] — tinted bg + readable text per EAQI band */
  --aqi-good-bg: #ceead6;           --aqi-good-text: #0d652d;
  --aqi-fair-bg: #dff0cd;           --aqi-fair-text: #38761d;
  --aqi-moderate-bg: #feefc3;       --aqi-moderate-text: #b06000;
  --aqi-poor-bg: #fce8e6;           --aqi-poor-text: #c5221f;
  --aqi-very-poor-bg: #fad2cf;      --aqi-very-poor-text: #a50e0e;
  --aqi-extremely-poor-bg: #e9d2fd; --aqi-extremely-poor-text: #681da8;

  /* availability chips (Shopping vertical [N]) */
  --stock-in-bg: #ceead6;   --stock-in-text: #0d652d;
  --stock-out-bg: #fce8e6;  --stock-out-text: #c5221f;
  --stock-na-bg: #f1f3f4;   --stock-na-text: #5f6368;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --surface: #303134;
    --card-bg: #303134;
    --surface-inset: #202124;
    --footer-bg: #171717;
    --hover-bg: #3c4043;
    --favicon-bg: #303134;
    --favicon-border: #3c4043;

    --text-primary: #e8eaed;
    --text-secondary: #bdc1c6;
    --text-muted: #9aa0a6;
    --text-label: #9aa0a6;
    --snippet-bold: #bdc1c6;

    --border: #3c4043;
    --border-light: #3c4043;
    --border-pill: #5f6368;
    --card-border: #3c4043;

    --link: #8ab4f8;
    --link-visited: #c58af9;
    --crumb-host: #969ba1;
    --crumb-path: #969ba1;

    --accent: #FF4B3E;
    --accent-strong: #ff6a5f;      /* hover lightens on dark */
    --on-accent: #fff;

    --btn-bg: #303134;
    --btn-border: #303134;
    --btn-text: #e8eaed;
    --btn-text-hover: #e8eaed;

    --icon-muted: #9aa0a6;
    --danger: #f28b82;
    --danger-bg: rgba(242, 139, 130, .12);
    --danger-border: #5c3d39;
    --shadow: rgba(0, 0, 0, .45);

    --change-up: #81c995;
    --change-down: #f28b82;

    --aqi-good-bg: rgba(129, 201, 149, .16);           --aqi-good-text: #81c995;
    --aqi-fair-bg: rgba(174, 213, 129, .16);           --aqi-fair-text: #aed581;
    --aqi-moderate-bg: rgba(253, 214, 99, .16);        --aqi-moderate-text: #fdd663;
    --aqi-poor-bg: rgba(242, 139, 130, .16);           --aqi-poor-text: #f28b82;
    --aqi-very-poor-bg: rgba(242, 139, 130, .28);      --aqi-very-poor-text: #f6aea9;
    --aqi-extremely-poor-bg: rgba(197, 138, 249, .16); --aqi-extremely-poor-text: #c58af9;

    --stock-in-bg: rgba(129, 201, 149, .16);  --stock-in-text: #81c995;
    --stock-out-bg: rgba(242, 139, 130, .16); --stock-out-text: #f28b82;
    --stock-na-bg: rgba(154, 160, 166, .16);  --stock-na-text: #bdc1c6;
  }

  /* Charcoal logo strokes turn light; hue-rotate keeps the coral flick warm. */
  .brand-logo { filter: invert(1) hue-rotate(180deg); }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: arial, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  accent-color: var(--accent);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

input, button { font-family: arial, sans-serif; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.inline-form { display: inline; margin: 0; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

/* ---------- top bar (home) ---------- */

.topbar {
  display: flex;
  justify-content: flex-end;
  padding: 6px;
}

.topbar-nav, .serp-user {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
}

.topbar-email { color: var(--text-muted); }

.topbar-link, .serp-user .topbar-link {
  color: var(--text-primary);
  text-decoration: none;
}
.topbar-link:hover { text-decoration: underline; }

/* ---------- home ---------- */

.home-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
  margin-top: max(60px, 10vh);
}

.home-logo {
  display: block;
  width: 340px;
  max-width: 86vw;
  height: auto;
  user-select: none;
}

.home-search {
  width: 100%;
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- search pill ---------- */

.search-form { position: relative; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 584px;
  height: 44px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-pill);
  border-radius: 24px;
  padding: 0 16px 0 14px;
}

.search-box:hover,
.search-box:focus-within {
  border-color: transparent;
  box-shadow: 0 1px 6px var(--shadow);
}

/* dropdown open: square the pill's bottom corners, keep the shadow */
.search-box.ac-open {
  border-radius: 24px 24px 0 0;
  border-color: transparent;
  box-shadow: 0 1px 6px var(--shadow);
}

.search-icon {
  display: flex;
  align-items: center;
  margin-right: 13px;
  flex-shrink: 0;
  color: var(--icon-muted);
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-primary);
}

/* ---------- autocomplete dropdown ---------- */

.ac-dropdown {
  position: absolute;
  top: 100%;
  left: -1px;
  right: -1px;
  background: var(--surface);
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 6px var(--shadow);
  padding-bottom: 10px;
  overflow: hidden;
  z-index: 100;
}

.ac-dropdown::before {
  content: "";
  display: block;
  border-top: 1px solid var(--border-light);
  margin: 0 20px 6px 14px;
}

.ac-item {
  display: flex;
  align-items: center;
  padding: 6px 20px 6px 14px;
  font-size: 16px;
  color: var(--text-primary);
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-item.active,
.ac-item:hover { background: var(--hover-bg); }

.ac-item-icon {
  display: flex;
  align-items: center;
  margin-right: 13px;
  flex-shrink: 0;
  color: var(--icon-muted);
}

.ac-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- home buttons ---------- */

.home-buttons {
  display: flex;
  justify-content: center;
  gap: 11px;
  margin-top: 29px;
}

.g-button {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  color: var(--btn-text);
  font-size: 14px;
  height: 36px;
  padding: 0 16px;
  line-height: 34px;
  cursor: pointer;
  user-select: none;
}

.g-button:hover {
  border: 1px solid var(--accent);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
  color: var(--btn-text-hover);
}

.g-button:focus-visible {
  outline: 1px solid var(--accent);
}

/* ---------- footer ---------- */

.footer {
  flex-shrink: 0;
  margin-top: auto;
  background: var(--footer-bg);
  color: var(--text-muted);
  font-size: 14px;
}

.footer-row {
  padding: 15px 30px;
}

.footer-country {
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 27px;
}

.footer-left, .footer-right {
  display: flex;
  flex-wrap: wrap;
  gap: 27px;
}

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

/* ---------- SERP header ---------- */

.serp-header { padding-top: 20px; }

.serp-header-inner {
  display: flex;
  align-items: center;
  padding: 0 20px 0 28px;
}

.serp-logo {
  display: block;
  margin-right: 32px;
  flex-shrink: 0;
  text-decoration: none;
}

.serp-logo img {
  display: block;
  width: 110px;
  height: auto;
}

.serp-search {
  flex: 1;
  max-width: 690px;
}

.serp-search .search-box {
  max-width: 690px;
  margin: 0;
}

.serp-user {
  margin-left: auto;
  padding-right: 0;
  flex-shrink: 0;
}

/* ---------- vertical tabs (All | News [L]) ---------- */

.serp-tabs {
  margin-top: 14px;
  border-bottom: 1px solid var(--border-light);
}

.serp-tabs-inner {
  display: flex;
  gap: 8px;
  margin-left: 152px;
  padding-right: 20px;
}

.serp-tab {
  display: block;
  padding: 6px 12px 9px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;   /* underline sits on the hairline */
}

.serp-tab:hover { color: var(--text-primary); }

.serp-tab-active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);   /* coral active underline */
}

/* ---------- SERP body ---------- */

.serp-body {
  flex: 1 0 auto;
  margin-left: 152px;
  max-width: 652px;
  padding: 0 20px 40px 0;
}

.result-stats {
  color: var(--text-muted);
  font-size: 14px;
  padding: 18px 0 22px;
}

.result {
  max-width: 600px;
  margin-bottom: 30px;
}

.result-head {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.result-favicon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--favicon-bg);
  border: 1px solid var(--favicon-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-right: 12px;
  flex-shrink: 0;
}

.result-favicon img {
  width: 18px;
  height: 18px;
  display: block;
}

.result-cite {
  font-style: normal;
  font-size: 14px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-cite-host { color: var(--crumb-host); }
.result-cite-path { color: var(--crumb-path); }

.result-title {
  margin: 0;
  padding-top: 4px;
  margin-bottom: 3px;
  font-weight: 400;
}

.result-title a {
  color: var(--link);
  font-size: 20px;
  line-height: 1.3;
  text-decoration: none;
}

.result-title a:hover { text-decoration: underline; }
.result-title a:visited { color: var(--link-visited); }

.result-snippet {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.58;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.result-snippet b { color: var(--snippet-bold); }

.result-badge { color: var(--text-muted); }

/* ---------- empty results ---------- */

.no-results {
  max-width: 600px;
  padding-top: 8px;
  font-size: 16px;
  line-height: 1.57;
}

.no-results-main { margin: 0 0 16px; }

.no-results-hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---------- answer cards (instant answers & news [G]) ---------- */

/* Async cards [R]: empty slots contribute zero height; late-arriving
   fragments fade in (~150ms opacity) so they don't jar. */
#cards-slot:empty,
#kp-slot:empty { display: none; }

.cards-fade-in { animation: cards-fade 150ms ease-out; }

@keyframes cards-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.answer-cards { max-width: 600px; }

.answer-card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.answer-kicker {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.3;
}

/* weather */

.weather-now {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.weather-current {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
}

.weather-temp {
  font-size: 46px;
  line-height: 1;
  color: var(--text-primary);
}

.weather-unit {
  margin-top: 2px;
  font-size: 16px;
  color: var(--text-muted);
}

.weather-emoji {
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}

.weather-now-meta { min-width: 0; }

.weather-label {
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.3;
}

.weather-stats {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.weather-days {
  display: flex;
  gap: 4px;
  margin-top: 14px;
  overflow-x: auto;      /* 10 tiles scroll, never wrap */
  padding-bottom: 4px;
}

.weather-day {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 6px 4px;
  border-radius: 8px;
  text-align: center;
}

.weather-day-dow {
  color: var(--text-muted);
  font-size: 13px;
}

.weather-day-emoji {
  font-size: 22px;
  line-height: 1.5;
}

.weather-day-temps {
  font-size: 13px;
  white-space: nowrap;
}

.weather-day-max { color: var(--text-primary); }

.weather-day-min {
  color: var(--text-muted);
  margin-left: 5px;
}

/* currency */

.currency-result {
  margin-top: 4px;
  font-size: 32px;
  line-height: 1.25;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.currency-meta {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

/* dictionary [H] */

.dict-word {
  font-size: 28px;
  font-weight: bold;
  line-height: 1.2;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.dict-phonetic {
  margin-top: 2px;
  font-family: monospace;
  font-size: 14px;
  color: var(--text-muted);
}

.dict-meaning { margin-top: 12px; }

.dict-pos {
  font-style: italic;
  color: var(--text-muted);
  font-size: 14px;
}

.dict-defs {
  margin: 6px 0 0;
  padding-left: 24px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.58;
}

.dict-def { margin-bottom: 6px; }
.dict-def:last-child { margin-bottom: 0; }

.dict-def-text { overflow-wrap: break-word; }

.dict-example {
  margin-top: 2px;
  font-style: italic;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.dict-synonyms {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: break-word;
}

.dict-source {
  margin-top: 10px;
  font-size: 12px;
}

.dict-source a {
  color: var(--text-muted);
  text-decoration: none;
}
.dict-source a:hover { text-decoration: underline; }

/* translate card [M] */

.translate-result {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.3;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.translate-original {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

/* compute answer card (calculator/unit/time/datemath/color/random/ip [J]) */

.compute-primary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.25;
  color: var(--text-primary);
}

.compute-primary-text {
  min-width: 0;
  overflow-wrap: break-word;
}

.compute-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.compute-rows {
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.compute-rows td { padding: 3px 0; vertical-align: top; }

.compute-row-label {
  color: var(--text-muted);
  padding-right: 18px;
  white-space: nowrap;
}

.compute-row-value {
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: break-word;
}

/* sunrise/sunset card [J] */

.sun-times {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 36px;
  margin-top: 10px;
}

.sun-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sun-emoji {
  font-size: 26px;
  line-height: 1;
}

.sun-item-label {
  color: var(--text-muted);
  font-size: 13px;
}

.sun-item-time {
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1.2;
}

.sun-date {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

/* air quality card [J] */

.aqi-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.aqi-value {
  font-size: 28px;
  line-height: 1.2;
  color: var(--text-primary);
}

.aqi-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
  line-height: 1.4;
  background: var(--surface-inset);   /* fallback for unknown levels */
  color: var(--text-secondary);
}

.aqi-chip--good { background: var(--aqi-good-bg); color: var(--aqi-good-text); }
.aqi-chip--fair { background: var(--aqi-fair-bg); color: var(--aqi-fair-text); }
.aqi-chip--moderate { background: var(--aqi-moderate-bg); color: var(--aqi-moderate-text); }
.aqi-chip--poor { background: var(--aqi-poor-bg); color: var(--aqi-poor-text); }
.aqi-chip--very-poor { background: var(--aqi-very-poor-bg); color: var(--aqi-very-poor-text); }
.aqi-chip--extremely-poor { background: var(--aqi-extremely-poor-bg); color: var(--aqi-extremely-poor-text); }

.aqi-meta {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* crypto & stock cards [J] */

.price-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
}

.price-big {
  font-size: 28px;
  line-height: 1.25;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.price-ccy {
  font-size: 16px;
  color: var(--text-muted);
}

.price-change { font-size: 16px; }

.change-up { color: var(--change-up); }
.change-down { color: var(--change-down); }
.change-flat { color: var(--text-muted); }

.price-meta {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

/* knowledge panel (wikipedia [J]) — a normal stacked card by default;
   on wide viewports it moves into a 360px right-hand grid column. */

.kp-panel {
  max-width: 600px;
  margin-bottom: 16px;
  overflow: hidden;      /* clip the full-bleed thumbnail to the radius */
}

.kp-thumb {
  display: block;
  width: calc(100% + 32px);
  max-width: none;
  margin: -16px -16px 12px;
  max-height: 180px;
  object-fit: cover;
}

.kp-title {
  font-size: 20px;
  line-height: 1.3;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.kp-extract {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.58;
  overflow-wrap: break-word;
}

.kp-source {
  margin-top: 10px;
  font-size: 12px;
}

.kp-source a {
  color: var(--text-muted);
  text-decoration: none;
}
.kp-source a:hover { text-decoration: underline; }

/* Grid engages only when the panel exists AND the viewport is wide; the
   plain results column (no .has-kp) is untouched at every width. */
@media (min-width: 1100px) {
  .serp-body.has-kp {
    display: grid;
    grid-template-columns: minmax(0, 632px) 360px;
    grid-template-areas:
      "stats stats"
      "main  panel";
    column-gap: 48px;
    align-items: start;    /* panel top-aligns with the results column */
    max-width: none;
  }

  .serp-body.has-kp .result-stats { grid-area: stats; }

  .serp-body.has-kp .serp-main {
    grid-area: main;
    min-width: 0;
  }

  /* The panel arrives async inside #kp-slot [R]; the slot owns the grid
     area so filling it never reflows the results column. */
  .serp-body.has-kp #kp-slot {
    grid-area: panel;
    width: 100%;
    max-width: 360px;
  }

  .serp-body.has-kp .kp-panel {
    width: 100%;
    max-width: 360px;
    margin-bottom: 0;
  }
}

/* news */

.news-header {
  font-size: 16px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 10px;
}

/* Flex row: text fills the card; the optional thumbnail sits right. Rows
   without an image simply have no <img>, so nothing shifts when absent. */
.news-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.news-item:last-child { margin-bottom: 0; }

.news-item-body {
  flex: 1;
  min-width: 0;
}

.news-title {
  color: var(--link);
  font-size: 16px;
  line-height: 1.3;
  text-decoration: none;
  overflow-wrap: break-word;
}

.news-title:hover { text-decoration: underline; }
.news-title:visited { color: var(--link-visited); }

.news-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

/* article thumbnail [L] — news card items and /news rows */
.news-thumb {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface-inset);
}

.news-more {
  margin-top: 12px;
  font-size: 14px;
}

.news-more a { text-decoration: none; }
.news-more a:hover { text-decoration: underline; }

/* ---------- news vertical (/news [L]) ---------- */

.news-list { max-width: 600px; }

.news-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 26px;
}

.news-row-body {
  flex: 1;
  min-width: 0;
}

.news-row-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.news-row-source {
  font-weight: bold;
  color: var(--text-secondary);
}

.news-row-title {
  margin: 2px 0 4px;
  font-weight: 400;
}

.news-row-title a,
.news-row-title span {
  font-size: 18px;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.news-row-title a {
  color: var(--link);
  text-decoration: none;
}

.news-row-title a:hover { text-decoration: underline; }
.news-row-title a:visited { color: var(--link-visited); }

.news-row-snippet {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.58;
  overflow-wrap: break-word;
  display: -webkit-box;          /* 2-line summary clamp */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- verticals: Images / History / Shopping [N] ---------- */

/* Grid verticals get a wider column than the 652px SERP body. */
.page-images .serp-body,
.page-shopping .serp-body { max-width: 1132px; }

/* Justified thumbnail grid: per-cell flex-grow/basis carry the aspect ratio
   (inline, numeric only), so rows justify at roughly 180px tall. */
.img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 8px;
  margin-top: 20px;
}

.img-grid::after { content: ''; flex-grow: 1000000; } /* last row: no stretch */

.img-cell {
  display: block;
  min-width: 0;
  text-decoration: none;
}

.img-cell img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-inset);
}

.img-caption {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- history vertical (/history [N]) ---------- */

.history-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
}

.history-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-label);
  font-size: 13px;
}

.history-date {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}

.history-filter-clear {
  color: var(--text-muted);
  font-size: 13px;
}

.history-filter-clear:hover { color: var(--text-primary); }

.history-list { max-width: 600px; }

.history-row { margin-bottom: 24px; }

.history-time {
  color: var(--text-muted);
  font-size: 13px;
}

.history-title {
  margin: 2px 0;
  font-weight: 400;
}

.history-title a,
.history-title span {
  font-size: 18px;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.history-title a {
  color: var(--link);
  text-decoration: none;
}

.history-title a:hover { text-decoration: underline; }
.history-title a:visited { color: var(--link-visited); }

.history-crumb {
  display: block;
  margin-bottom: 2px;
}

.history-snippet {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.58;
  overflow-wrap: break-word;
  display: -webkit-box;          /* 2-line clamp */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- shopping vertical (/shopping [N]) ---------- */

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.shop-card {
  display: block;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--card-bg);
  color: inherit;
  text-decoration: none;
}

a.shop-card:hover { box-shadow: 0 1px 6px var(--shadow); }

.shop-card-media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--surface-inset);   /* neutral placeholder block */
  overflow: hidden;
}

.shop-card-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.shop-card-name {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: break-word;
  display: -webkit-box;          /* 2-line name clamp */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shop-card-price {
  margin-top: 6px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: bold;
}

.shop-chip {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.shop-chip-in  { background: var(--stock-in-bg);  color: var(--stock-in-text); }
.shop-chip-out { background: var(--stock-out-bg); color: var(--stock-out-text); }
.shop-chip-na  { background: var(--stock-na-bg);  color: var(--stock-na-text); }

.shop-card-domain {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .img-cell img { height: 130px; }

  .shop-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  /* Five tabs no longer fit a phone width: scroll the row, not the page. */
  .serp-tabs-inner { overflow-x: auto; }
  .serp-tab { padding: 6px 10px 9px; white-space: nowrap; }
}

/* ---------- pagination (Rooooketo) ---------- */

.pagination {
  display: flex;
  align-items: flex-start;
  margin: 30px 0 20px -8px;
}

.pg-cell {
  text-align: center;
  padding: 0 3px;
  min-width: 20px;
}

/* first cell holds R + Previous; right-align so R sits next to the first o */
.pagination .pg-cell:first-child { text-align: right; }
.pagination .pg-cell:first-child .pg-side { padding-right: 0; }

.pg-cell-next { text-align: left; }

.pg-letter {
  display: block;
  font-size: 27px;
  line-height: 1.2;
  font-weight: bold;
  text-decoration: none;
  user-select: none;
}

.pg-letter.pg-static { color: var(--text-primary); }
.pg-letter.pg-link { color: var(--link); }
.pg-letter.pg-link:hover { text-decoration: underline; }
.pg-letter.pg-current { color: var(--accent); }

.pg-num {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--link);
  text-decoration: none;
}

.pg-num:hover { text-decoration: underline; }

.pg-num.pg-current {
  color: var(--accent);
  font-weight: bold;
}

.pg-side {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  color: var(--link);
  text-decoration: none;
  white-space: nowrap;
  padding: 0 6px;
}

.pg-side:hover { text-decoration: underline; }
.pg-side-empty { visibility: hidden; }
.pg-letter-empty { visibility: hidden; }

.serp-footer .footer-row { padding: 15px 30px; }

/* ---------- auth (login / register) ---------- */

.page-auth { background: var(--bg); }

.auth-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px 40px;
}

.auth-card {
  width: 100%;
  max-width: 450px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 48px 40px 36px;
  text-align: center;
}

.auth-logo { width: 110px; height: auto; }

.auth-title {
  margin: 16px 0 0;
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
}

.auth-subtitle {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--text-primary);
}

.auth-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 24px 0 0;
  color: var(--danger);
  font-size: 14px;
  text-align: left;
}

.auth-error-icon { flex-shrink: 0; }

.auth-form { margin-top: 28px; text-align: left; }

.auth-input {
  display: block;
  width: 100%;
  padding: 13px 15px;
  margin-bottom: 20px;
  font-size: 16px;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
}

.auth-input:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.auth-hint {
  margin: -8px 0 20px;
  font-size: 12px;
  color: var(--text-label);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
}

.auth-alt {
  color: var(--accent);
  font-size: 14px;
  font-weight: bold;
  text-decoration: none;
  padding: 8px 8px 8px 0;
}
.auth-alt:hover { text-decoration: underline; }

.auth-button {
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--on-accent);
  font-size: 14px;
  font-weight: bold;
  height: 36px;
  padding: 0 24px;
  cursor: pointer;
}

.auth-button:hover {
  background: var(--accent-strong);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}

.auth-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth-fineprint {
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- settings ---------- */

.settings-header { border-bottom: 1px solid var(--border); }

.settings-header-inner {
  display: flex;
  align-items: center;
  max-width: 1200px;
  padding: 14px 20px 14px 28px;
}

.settings-header-title {
  font-size: 20px;
  color: var(--text-label);
  margin-left: 24px;
}

.settings-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: bold;
  color: var(--text-primary);
}

.card-title-danger { color: var(--danger); }

.card-danger { border-color: var(--danger-border); }

.card-text {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.58;
}

.setup-steps {
  margin: 0 0 20px;
  padding-left: 22px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.58;
}

.setup-steps li { margin-bottom: 8px; }

.setup-steps code, .card-text code {
  font-family: monospace;
  font-size: 13px;
  background: var(--surface-inset);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 1px 4px;
}

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  font-size: 12px;
  color: var(--text-label);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .8px;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-box {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 12px;
  white-space: nowrap;
  overflow-x: auto;
}

.field-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

/* Result-languages input [O]: token-box chrome, but editable. */
.settings-input {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 12px;
  outline: none;
}

.settings-input:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.field-note {
  color: var(--text-muted);
  font-size: 12px;
}

.btn-small { height: 34px; line-height: 32px; }

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: none;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 56px;
}

.stat-number {
  font-size: 32px;
  line-height: 1.2;
  color: var(--text-primary);
}

.stat-label {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .8px;
}

/* news feeds [I] */

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: 4px;
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.feed-row:last-child { border-bottom: none; }

.feed-info {
  flex: 1;
  min-width: 0;
}

.feed-title {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: break-word;
}

.feed-url {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: monospace;
  overflow-wrap: break-word;
  word-break: break-all;
}

.feed-count {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.feed-action {
  margin: 0;
  flex-shrink: 0;
}

.feed-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.58;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .serp-header-inner {
    flex-wrap: wrap;
    padding: 0 16px;
  }

  .serp-logo { margin-right: 20px; }

  .serp-user { order: 2; }

  .serp-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    margin-top: 14px;
  }

  .serp-body {
    margin-left: 0;
    padding: 0 16px 40px;
  }

  .serp-tabs-inner {
    margin-left: 0;
    padding: 0 16px;
  }

  .settings-header-inner { padding: 12px 16px; }
}

@media (max-width: 600px) {
  .home-logo { width: 260px; }

  .home-main { margin-top: 48px; }

  .auth-card { padding: 32px 20px 28px; border: none; background: transparent; }

  .footer-row { padding: 12px 16px; }

  .pagination { flex-wrap: wrap; }

  .token-row { flex-wrap: wrap; }

  .feed-row { flex-wrap: wrap; }

  .stats-row { gap: 20px 36px; }
}
