:root {
  --font-family: 'Outfit', sans-serif;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 600;

  /* Evinced palette — from the brand banner: cornflower, sky, cream, pink, navy */
  --cornflower: #6e8fd6;
  --sky: #b9d1f0;
  --sky-soft: #e4eefb;
  --cream: #f6f3ed;
  --pink: #f3b9ce;
  --pink-soft: #fae3ec;
  --navy: #1b3a8e;
  --navy-deep: #142e72;
  --brand: #ce2c85;
  --accent: #1e6fd2;

  --content-1: #1a2235;   /* near-navy ink */
  --content-2: #3c4a66;
  --content-3: #7a869c;

  --bg-0: #ffffff;        /* cards */
  --bg-1: #faf8f3;        /* page (warm cream) */
  --bg-2: #f1f0ea;        /* inputs */
  --border-2: #e7e4dc;

  --shadow-soft: 0 6px 24px -10px rgba(27, 58, 142, 0.16);
  --shadow-lift: 0 18px 44px -20px rgba(27, 58, 142, 0.28);
  --shadow-focus: 0 0 0 3px rgba(110, 143, 214, 0.45);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  --r-m: 10px; --r-l: 18px; --r-xl: 26px; --r-pill: 999px;
  --gap-s: 0.5rem; --gap-m: 1rem; --gap-l: 1.5rem; --gap-xl: 2rem;
}
[data-color-theme='dark'] {
  --cream: #11151f; --sky-soft: #1a2740; --pink-soft: #2a1922;
  --content-1: #f3f5fa; --content-2: #c8d0de; --content-3: #8b97ac;
  --bg-0: #161b27; --bg-1: #0e1118; --bg-2: #1f2533; --border-2: #2a3140;
  --accent: #6e9eea; --navy: #8aa6e8;
  --shadow-soft: 0 6px 24px -10px rgba(0,0,0,0.5);
  --shadow-lift: 0 18px 44px -20px rgba(0,0,0,0.6);
  --shadow-focus: 0 0 0 3px rgba(110, 158, 234, 0.5);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--font-family); background: var(--bg-1);
  color: var(--content-1); font-weight: var(--font-weight-normal);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 6px; }

/* ---- Top nav ---- */
header {
  display: flex; align-items: center; gap: var(--gap-m);
  padding: var(--gap-m) var(--gap-xl); background: var(--bg-0);
  border-bottom: 1px solid var(--border-2); position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img { width: 28px; height: 28px; display: block; }
.brand .wordmark { font-size: 1.15rem; font-weight: var(--font-weight-bold); letter-spacing: -0.01em; color: var(--navy); }
header .spacer { flex: 1; }
header .user { color: var(--content-3); font-size: 0.875rem; }

main { max-width: 1140px; margin: 0 auto; padding: 0 var(--gap-xl) var(--gap-xl); }

/* ---- Organic hero (blobs + grain), matches the brand banner ---- */
.hero {
  position: relative; margin: 0 0 var(--gap-xl); padding: 3.4rem var(--gap-xl) 3rem;
  border-radius: 0 0 var(--r-xl) var(--r-xl); overflow: hidden; background: var(--cream);
}
.hero .blob { position: absolute; filter: blur(6px); border-radius: 50%; opacity: 0.92; }
.hero .b1 { width: 460px; height: 360px; left: -120px; top: -90px; background: var(--cornflower);
  border-radius: 52% 48% 57% 43% / 56% 44% 56% 44%; }
.hero .b2 { width: 380px; height: 320px; left: 120px; top: -40px; background: var(--sky);
  border-radius: 46% 54% 44% 56% / 52% 48% 52% 48%; }
.hero .b3 { width: 520px; height: 420px; right: -160px; top: -110px; background: var(--pink);
  border-radius: 54% 46% 50% 50% / 48% 56% 44% 52%; }
.hero .b4 { width: 220px; height: 220px; right: -70px; bottom: -90px; background: var(--navy);
  border-radius: 50%; filter: blur(2px); }
.hero .grain {
  position: absolute; inset: 0; background-image: var(--grain); background-size: 180px 180px;
  opacity: 0.12; mix-blend-mode: multiply; pointer-events: none;
}
.hero .hero-content { position: relative; z-index: 2; max-width: 60ch; }
.hero h2 { margin: 0 0 0.5rem; font-size: 2.3rem; font-weight: var(--font-weight-bold);
  letter-spacing: -0.025em; color: var(--navy-deep); line-height: 1.1; }
.hero p { margin: 0; color: var(--content-2); font-size: 1.05rem; }
[data-color-theme='dark'] .hero h2 { color: #eaf0ff; }
[data-color-theme='dark'] .hero p { color: #d4ddf0; }

/* ---- Controls ---- */
.controls { display: flex; gap: var(--gap-m); flex-wrap: wrap; align-items: center; margin-bottom: var(--gap-l); }
.search-wrap { position: relative; flex: 1; min-width: 240px; }
.search-wrap::before { content: '🔍'; position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); font-size: 0.85rem; opacity: 0.45; pointer-events: none; }
.controls input[type='search'] {
  width: 100%; padding: 0.7rem 1rem 0.7rem 2.4rem; font: inherit;
  background: var(--bg-0); border: 1px solid var(--border-2); border-radius: var(--r-pill);
  color: var(--content-1); box-shadow: var(--shadow-soft);
}
.chips { display: flex; gap: var(--gap-s); flex-wrap: wrap; }
.chip { padding: 0.4rem 0.95rem; border-radius: var(--r-pill); border: 1px solid var(--border-2);
  background: var(--bg-0); cursor: pointer; font: inherit; font-size: 0.8125rem; color: var(--content-2); transition: all 0.14s ease; }
.chip:hover { border-color: var(--cornflower); color: var(--navy); }
.chip[aria-pressed='true'] { background: var(--navy); color: #fff; border-color: var(--navy); }

.btn { padding: 0.7rem 1.3rem; border: none; border-radius: var(--r-pill); cursor: pointer;
  font: inherit; font-weight: var(--font-weight-medium); background: var(--navy); color: #fff;
  transition: filter 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease; box-shadow: var(--shadow-soft); }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--bg-0); color: var(--navy); border: 1px solid var(--border-2); box-shadow: none; }
.btn.link { background: none; color: var(--accent); padding: 0; font-weight: var(--font-weight-medium); text-decoration: none; box-shadow: none; }
.btn.link:hover { text-decoration: underline; filter: none; }

/* ---- Grid + cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap-l); }
.card { position: relative; background: var(--bg-0); border: 1px solid var(--border-2); border-radius: var(--r-l);
  padding: var(--gap-l); box-shadow: var(--shadow-soft); display: flex; flex-direction: column; gap: 0.6rem;
  transition: box-shadow 0.18s ease, transform 0.18s ease; }
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-3px); }
.card-head { display: flex; align-items: center; gap: 0.7rem; }
.type-badge { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 50%; font-size: 0.95rem; flex: none; }
.type-badge.link { background: var(--sky-soft); }
.type-badge.file { background: var(--pink-soft); }
.cat { font-size: 0.7rem; padding: 0.2rem 0.65rem; border-radius: var(--r-pill); font-weight: var(--font-weight-medium); letter-spacing: 0.01em; }
.cat.p0 { background: var(--sky-soft); color: #2c4a7a; }
.cat.p1 { background: var(--pink-soft); color: #9c3568; }
.cat.p2 { background: #eae6f7; color: #5a3c93; }
.cat.p3 { background: #e3f1ea; color: #2c6e54; }
.cat.p4 { background: #f6ecda; color: #8a6320; }
[data-color-theme='dark'] .cat.p0 { background: #1c2c46; color: #a9c5f0; }
[data-color-theme='dark'] .cat.p1 { background: #341a26; color: #f0a9c5; }
[data-color-theme='dark'] .cat.p2 { background: #261d40; color: #c5b0f0; }
[data-color-theme='dark'] .cat.p3 { background: #16301f; color: #a0e0bd; }
[data-color-theme='dark'] .cat.p4 { background: #322712; color: #e8c98a; }
.card h3 { margin: 0; font-size: 1.15rem; font-weight: var(--font-weight-bold); line-height: 1.3; color: var(--content-1); }
.card p { margin: 0; color: var(--content-2); font-size: 0.9rem; line-height: 1.5; }
.card .meta { color: var(--content-3); font-size: 0.75rem; }
.card .row { display: flex; align-items: center; gap: var(--gap-s); margin-top: auto; padding-top: 0.6rem; }
.card .row .spacer { flex: 1; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--content-3); padding: 0.3rem 0.45rem; border-radius: 8px; }
.icon-btn:hover { color: var(--brand); background: var(--bg-2); }

.empty, .loading { text-align: center; color: var(--content-3); padding: 3.5rem var(--gap-xl); }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: var(--gap-s); }
.section-title { display: flex; align-items: center; gap: var(--gap-s); margin: var(--gap-xl) 0 var(--gap-m);
  font-size: 0.95rem; color: var(--content-2); font-weight: var(--font-weight-bold);
  padding-bottom: var(--gap-s); border-bottom: 1px solid var(--border-2); }

/* ---- Sign-in ---- */
.signin-card { max-width: 440px; margin: 4rem auto; text-align: center; background: var(--bg-0);
  border: 1px solid var(--border-2); border-radius: var(--r-xl); padding: 2.6rem var(--gap-xl); box-shadow: var(--shadow-soft); }
.signin-card img { width: 60px; height: 60px; margin-bottom: var(--gap-m); }
.signin-card h2 { margin: 0 0 0.4rem; font-size: 1.5rem; color: var(--navy-deep); }
.signin-card p { color: var(--content-3); margin: 0 0 var(--gap-l); }

/* ---- Dialog ---- */
dialog { border: none; border-radius: var(--r-xl); padding: 2.2rem; width: min(480px, 92vw);
  background: var(--bg-0); color: var(--content-1); box-shadow: var(--shadow-lift); }
dialog::backdrop { background: rgba(27, 58, 142, 0.28); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 var(--gap-m); font-size: 1.3rem; color: var(--navy-deep); }
dialog label { display: block; margin: var(--gap-m) 0 0.3rem; font-size: 0.8125rem; color: var(--content-2); font-weight: var(--font-weight-medium); }
dialog input, dialog textarea, dialog select { width: 100%; padding: 0.65rem 0.8rem; font: inherit;
  border: 1px solid var(--border-2); border-radius: var(--r-m); background: var(--bg-1); color: var(--content-1); }
dialog .actions { display: flex; gap: var(--gap-s); justify-content: flex-end; margin-top: var(--gap-l); }
.errors { color: var(--brand); font-size: 0.8125rem; margin-top: var(--gap-m); white-space: pre-line; }
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--navy-deep); color: #fff; padding: 0.8rem 1.3rem; border-radius: var(--r-pill);
  box-shadow: var(--shadow-lift); font-size: 0.875rem; z-index: 50; }
.hidden { display: none !important; }
.progress { height: 6px; background: var(--bg-2); border-radius: var(--r-pill); overflow: hidden; margin-top: var(--gap-s); }
.progress > div { height: 100%; width: 0; background: var(--cornflower); transition: width 0.2s; }
