:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #1b2233;
  --ink-soft: #5b6478;
  --line: #e6e9f2;
  --brand: #3a6df0;
  --brand-deep: #2347b8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 28, 56, .06), 0 8px 24px rgba(20, 28, 56, .06);
  --shadow-hover: 0 4px 10px rgba(20, 28, 56, .10), 0 16px 40px rgba(20, 28, 56, .12);
  color-scheme: light dark;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #ffffff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 48px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  font-size: 22px;
  line-height: 1;
  color: var(--brand);
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.site-nav {
  display: flex;
  gap: 22px;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.site-nav a:hover { color: var(--brand); }

/* ---------- Hero / Search ---------- */
.portal {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 56px;
}

.hero {
  text-align: center;
  padding: clamp(28px, 6vw, 64px) 0 clamp(24px, 4vw, 40px);
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 800;
  letter-spacing: -.025em;
}

.hero-sub {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: clamp(15px, 2vw, 18px);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, border-color .18s ease;
}

.search:focus-within {
  border-color: var(--brand);
  box-shadow: var(--shadow-hover);
}

.search-icon {
  font-size: 17px;
  opacity: .55;
  flex: none;
}

.search-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  color: var(--ink);
  padding: 12px 6px;
  min-width: 0;
}

.search-input::placeholder { color: #9aa3b6; }

.search-btn {
  flex: none;
  border: 0;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 26px;
  border-radius: 999px;
  transition: background .15s ease;
}

.search-btn:hover { background: var(--brand-deep); }
.search-btn[disabled] { opacity: .6; cursor: default; }

.search-hint {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #9aa3b6;
}

/* ---------- Google-style home ---------- */
.home {
  text-align: center;
  padding: clamp(36px, 8vh, 96px) 0 clamp(26px, 5vw, 44px);
}

.glogo {
  display: block;
  width: clamp(150px, 38vw, 272px);
  height: auto;
  margin: 0 auto clamp(22px, 4vw, 30px);
  user-select: none;
  -webkit-user-drag: none;
}

.gsearch {
  max-width: 584px;
  margin: 0 auto;
}

.gsearch-box {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 16px;
  background: #fff;
  border: 1px solid #dfe1e5;
  border-radius: 24px;
  transition: box-shadow .18s ease, border-color .18s ease;
}

.gsearch-box:hover,
.gsearch:focus-within .gsearch-box {
  border-color: rgba(223, 225, 229, 0);
  box-shadow: 0 1px 6px rgba(32, 33, 36, .28);
}

.gsearch-g {
  flex: none;
  width: 24px;
  height: 24px;
  display: block;
}

.gsearch-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: #202124;
  min-width: 0;
}

.gsearch-input::placeholder { color: #5f6368; opacity: 1; }

.gsearch-mic {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #5f6368;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}

.gsearch-mic[hidden] { display: none; }
.gsearch-mic:hover { color: #202124; background: rgba(60, 64, 67, .08); }
.gsearch-mic.is-listening { color: #ea4335; }

.gbtns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 28px;
}

.gbtn {
  height: 36px;
  padding: 0 18px;
  border: 1px solid #f8f9fa;
  border-radius: 4px;
  background: #f8f9fa;
  color: #3c4043;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow .12s ease, border-color .12s ease;
}

.gbtn:hover {
  border-color: #dadce0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}

.gbtn[disabled] { opacity: .6; cursor: default; }

/* ---------- Feed ---------- */
.feed-section { margin-top: 26px; }

.feed-title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.feed-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform .14s ease, box-shadow .14s ease;
}

.feed-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.feed-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #eef1f8;
}

.feed-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
  flex: 1;
}

.feed-card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.feed-card-brand {
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-badge {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: #8a6d00;
  background: #fff4d6;
  border: 1px solid #f2e2ad;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .02em;
}

/* ---------- Feed status / controls ---------- */
.feed-status {
  text-align: center;
  padding: 26px 16px 4px;
  color: var(--ink-soft);
  font-size: 14px;
}

.feed-status.is-hidden { display: none; }

.feed-btn {
  border: 1px solid var(--line);
  cursor: pointer;
  background: var(--surface);
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: background .15s ease, box-shadow .15s ease;
}

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

.feed-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: feed-spin .7s linear infinite;
  vertical-align: middle;
}

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

#feed-sentinel { height: 1px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px clamp(16px, 4vw, 48px);
  text-align: center;
  background: var(--surface);
}

.footer-nav {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.footer-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
}

.footer-nav a:hover { color: var(--brand); }

.footer-copy {
  margin: 0;
  font-size: 12.5px;
  color: #9aa3b6;
}

/* ---------- Static legal pages ---------- */
.doc {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 48px) 64px;
}

.doc h1 {
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -.02em;
  margin: 0 0 6px;
}

.doc .doc-updated {
  color: #9aa3b6;
  font-size: 13px;
  margin: 0 0 28px;
}

.doc h2 {
  font-size: 18px;
  margin: 30px 0 10px;
}

.doc p, .doc li {
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 15px;
}

.doc a { color: var(--brand); }

@media (max-width: 480px) {
  .feed { grid-template-columns: 1fr; }
  .search-btn { padding: 12px 18px; }
}

/* ---------- Dark mode (follows system) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --surface: #303134;
    --ink: #e8eaed;
    --ink-soft: #9aa0a6;
    --line: #3c4043;
    --brand: #8ab4f8;
    --brand-deep: #aecbfa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
    --shadow-hover: 0 4px 10px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  }

  body { background: #202124; }

  /* Google search bar (dark) */
  .gsearch-box {
    background: #303134;
    border-color: #5f6368;
  }
  .gsearch-box:hover,
  .gsearch:focus-within .gsearch-box {
    background: #303134;
    border-color: rgba(95, 99, 104, 0);
    box-shadow: 0 1px 6px rgba(0, 0, 0, .5);
  }
  .gsearch-input { color: #e8eaed; }
  .gsearch-input::placeholder { color: #9aa0a6; }
  .gsearch-mic { color: #9aa0a6; }
  .gsearch-mic:hover { color: #e8eaed; background: rgba(232, 234, 237, .08); }

  /* Feed (dark) */
  .feed-card-img { background: #3c4043; }
  .feed-badge {
    color: #fdd663;
    background: rgba(251, 188, 5, .16);
    border-color: rgba(251, 188, 5, .30);
  }
  .feed-btn { color: #8ab4f8; }
}
