:root {
  color-scheme: dark;
  --bg: #1e2326;
  --elevated: #272e33;
  --raised: #2e383c;
  --surface-soft: rgba(30, 35, 38, 0.86);
  --accent: #a7c080;
  --strong: #dbbc7f;
  --text: #d3c6aa;
  --muted: #859289;
  --faint: #5c6a72;
  --line: rgba(167, 192, 128, 0.18);
  --inset: #1b2023;
  --vis-bg: #22292d;
  --chip: #374145;
  --chip-2: #2b3337;
  --bar-bg: rgba(30, 35, 38, 0.92);
  --float-bg: rgba(30, 35, 38, .75);
  --hair: rgba(211, 198, 170, .08);
  --hair-strong: rgba(211, 198, 170, .2);
  --scrim: rgba(14, 17, 19, .72);
  --accent-line: rgba(167, 192, 128, .45);
  --strong-line: rgba(219, 188, 127, .35);
  --glow: rgba(167, 192, 128, 0.07);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Everforest hues, one per area family */
  --green: #a7c080;
  --aqua: #83c092;
  --blue: #7fbbb3;
  --yellow: #dbbc7f;
  --orange: #e69875;
  --red: #e67e80;
  --purple: #d699b6;
}
/* Everforest light: used when picked, or when the device is light and nothing was picked */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fdf6e3;
  --elevated: #f4f0d9;
  --raised: #efebd4;
  --surface-soft: rgba(244, 240, 217, 0.9);
  --accent: #7f9400;
  --strong: #b07d00;
  --text: #4d5b62;
  --muted: #6f7d6e;
  --faint: #939f91;
  --line: rgba(92, 106, 114, 0.18);
  --inset: #efebd4;
  --vis-bg: #f4f0d9;
  --chip: #e6e2cc;
  --chip-2: #e9e5cf;
  --bar-bg: rgba(253, 246, 227, 0.92);
  --float-bg: rgba(253, 246, 227, .85);
  --hair: rgba(92, 106, 114, .1);
  --hair-strong: rgba(92, 106, 114, .25);
  --scrim: rgba(92, 106, 114, .35);
  --accent-line: rgba(127, 148, 0, .45);
  --strong-line: rgba(176, 125, 0, .35);
  --glow: rgba(141, 161, 1, 0.08);
  --green: #8da101;
  --aqua: #35a77c;
  --blue: #3a94c5;
  --yellow: #c99400;
  --orange: #f57d26;
  --red: #f85552;
  --purple: #df69ba;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
  color-scheme: light;
  --bg: #fdf6e3;
  --elevated: #f4f0d9;
  --raised: #efebd4;
  --surface-soft: rgba(244, 240, 217, 0.9);
  --accent: #7f9400;
  --strong: #b07d00;
  --text: #4d5b62;
  --muted: #6f7d6e;
  --faint: #939f91;
  --line: rgba(92, 106, 114, 0.18);
  --inset: #efebd4;
  --vis-bg: #f4f0d9;
  --chip: #e6e2cc;
  --chip-2: #e9e5cf;
  --bar-bg: rgba(253, 246, 227, 0.92);
  --float-bg: rgba(253, 246, 227, .85);
  --hair: rgba(92, 106, 114, .1);
  --hair-strong: rgba(92, 106, 114, .25);
  --scrim: rgba(92, 106, 114, .35);
  --accent-line: rgba(127, 148, 0, .45);
  --strong-line: rgba(176, 125, 0, .35);
  --glow: rgba(141, 161, 1, 0.08);
  --green: #8da101;
  --aqua: #35a77c;
  --blue: #3a94c5;
  --yellow: #c99400;
  --orange: #f57d26;
  --red: #f85552;
  --purple: #df69ba;
  }
}


* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--glow), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--strong); outline-offset: 2px; }

/* ---------- header ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) clamp(16px, 4vw, 40px) 12px;
  background: var(--bar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 720; letter-spacing: -0.3px; }
.brand img {
  width: 36px; height: 28px; object-fit: contain;
  filter: hue-rotate(72deg) saturate(0.78) brightness(0.96) drop-shadow(0 0 7px rgba(167, 192, 128, 0.28));
}
.brand b { color: var(--accent); font-weight: 720; }
.scope {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}
.scope button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.scope { margin-left: auto; }
.prefs { display: flex; gap: 6px; }
.pref {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
}
.pref:hover { color: var(--text); border-color: var(--accent-line); }
.pref svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scope button:hover { color: var(--text); background: var(--elevated); }
.scope button[aria-selected="true"] { color: var(--bg); background: var(--accent); }
.scope .short { display: none; }

/* ---------- intro ---------- */
.page { padding: 34px clamp(20px, 5vw, 56px) calc(env(safe-area-inset-bottom, 0px) + 64px); max-width: 1240px; margin: 0 auto; }
.intro { max-width: 60ch; margin-bottom: 40px; }
.intro h1 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 760; letter-spacing: -1px; line-height: 1.12; text-wrap: balance; }
.intro p { margin-top: 12px; color: var(--muted); font-size: 13.5px; }

/* ---------- feed: a calm grid on wide screens, a single column on phones ---------- */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 44px 32px; }
@media (min-width: 1100px) { .feed { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.card .vis {
  width: 100%;
  min-width: 0;
  height: 220px;
  border-radius: 16px;
  border: 1px solid var(--line);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card:hover .vis { transform: translateY(-3px); border-color: color-mix(in srgb, var(--hue) 50%, transparent); box-shadow: 0 16px 36px rgba(0, 0, 0, .35); }
.card-body { display: flex; flex-direction: column; gap: 7px; padding: 16px 4px 0; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; }
.meta .area { color: var(--hue); }
.meta .who { color: var(--faint); }
.card h2 { font-size: 16px; font-weight: 720; line-height: 1.3; letter-spacing: -.2px; color: var(--text); text-wrap: pretty; }
.card p { color: var(--muted); font-size: 12.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .hint, .card .count { display: none; }
.effort { display: inline-flex; align-items: center; gap: 6px; }
.effort i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.effort.setup i { background: var(--yellow); }
.effort.dev i { background: var(--orange); }

.empty { color: var(--muted); padding: 40px 0; }

/* ---------- mini illustrations ---------- */
.vis {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px;
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--hue) 18%, transparent), transparent 60%),
    var(--vis-bg);
  font-size: 11.5px;
  overflow: hidden;
}
/* Real generated illustration fills the same tile, mosaic geometry untouched. */
.vis.photo { padding: 0; background: var(--vis-bg); }
.v-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.v-photo-fallback { position: relative; }
.vis.photo .v-photo-fallback { display: none; }

/* chat */
.v-chat { display: flex; flex-direction: column; gap: 7px; }
.bubble { max-width: 82%; padding: 7px 10px; border-radius: 12px; line-height: 1.4; }
.bubble.in { align-self: flex-start; background: var(--chip); color: var(--text); border-bottom-left-radius: 3px; }
.bubble.out { align-self: flex-end; background: color-mix(in srgb, var(--hue) 26%, var(--chip-2)); color: var(--text); border-bottom-right-radius: 3px; }

/* sheet */
.v-sheet { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--inset); border-radius: 8px; overflow: hidden; }
.v-sheet th { text-align: left; font-weight: 700; color: var(--muted); background: var(--chip-2); }
.v-sheet th, .v-sheet td { padding: 6px 9px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.v-sheet td:last-child, .v-sheet th:last-child { text-align: right; }
.v-sheet .ok { color: var(--green); }
.v-sheet .miss { color: var(--red); }
.v-sheet .up { color: var(--green); }
.v-sheet .down { color: var(--red); }

/* flow */
.v-flow { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 10px 0; }
.v-flow .node { flex: 0 1 auto; padding: 7px 10px; border: 1px solid var(--hair-strong); border-radius: 8px; background: var(--inset); white-space: nowrap; }
.v-flow .node.ai { border-color: var(--hue); color: var(--hue); box-shadow: 0 0 16px color-mix(in srgb, var(--hue) 35%, transparent); }
.v-flow .arrow { flex: 1 1 10px; min-width: 8px; height: 1px; background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); position: relative; }
.v-flow .arrow::after { content: ""; position: absolute; right: -1px; top: -3px; border: 3.5px solid transparent; border-left-color: var(--muted); }

/* doc */
.v-doc { background: #efe7d2; color: #3a3a33; border-radius: 6px; padding: 12px 14px; box-shadow: 0 8px 20px rgba(0, 0, 0, .3); transform: rotate(-1.2deg); }
.v-doc h3, .detail .v-doc h3 { font-size: 1em; font-weight: 800; margin-bottom: 7px; color: inherit; letter-spacing: normal; text-transform: none; }
.v-doc div { padding: 2px 0; }
.v-doc .flag { background: linear-gradient(transparent 55%, rgba(230, 126, 128, .45) 55%); }

/* inbox */
.v-inbox { display: flex; flex-direction: column; gap: 5px; }
.v-inbox div { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; background: var(--inset); border-radius: 7px; }
.v-inbox span:last-child { padding: 1px 7px; border-radius: 10px; font-size: .9em; background: var(--chip); color: var(--muted); }
.v-inbox .hot, .v-inbox .strong { background: color-mix(in srgb, var(--hue) 30%, var(--chip-2)) !important; color: var(--text) !important; }
.v-inbox .no { opacity: .55; }

/* voice */
.v-voice { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--inset); border-radius: 24px; }
.v-voice .play { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--hue); position: relative; }
.v-voice .play::after { content: ""; position: absolute; left: 10px; top: 7px; border: 6px solid transparent; border-left: 8px solid var(--bg); }
.v-voice .wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; }
.v-voice .wave i { flex: 1; border-radius: 2px; background: color-mix(in srgb, var(--hue) 70%, var(--muted)); }
.v-voice time { color: var(--muted); font-size: .9em; }
.v-voice-caption { margin-top: 9px; color: var(--muted); font-size: .92em; }

/* image */
.v-image { position: relative; height: 130px; border-radius: 10px; overflow: hidden; background: linear-gradient(160deg, #3a4a40, var(--chip-2) 60%, #463a3c); }
.v-image.warm { background: linear-gradient(160deg, #5a4a36, #3a3530 55%, #4a3a3c); }
.v-image .blob { position: absolute; border-radius: 50%; filter: blur(1px); }
.v-image .product { position: absolute; left: 50%; bottom: 18%; width: 22%; aspect-ratio: 3 / 4; transform: translateX(-50%); border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #efe7d2, #cfc5ad); box-shadow: 0 12px 24px rgba(0, 0, 0, .45); }
.v-image .spark { position: absolute; right: 10px; top: 10px; padding: 2px 8px; border-radius: 10px; background: var(--float-bg); color: var(--hue); font-size: .88em; font-weight: 700; }

/* calendar */
.v-cal { display: grid; gap: 4px; }
.v-cal .day { color: var(--muted); font-weight: 700; text-align: center; font-size: .9em; }
.v-cal .slot { min-height: 26px; border-radius: 5px; background: var(--inset); }
.v-cal .ev { display: flex; align-items: center; padding: 3px 6px; border-radius: 5px; background: color-mix(in srgb, var(--hue) 32%, var(--chip-2)); font-size: .86em; line-height: 1.2; }

/* code */
.v-code { display: grid; grid-template-columns: 1.1fr .9fr; gap: 8px; }
.v-code pre { margin: 0; padding: 9px 10px; background: var(--inset); border-radius: 7px; font: inherit; font-size: .92em; line-height: 1.55; white-space: pre; overflow: hidden; }
.v-code .k { color: var(--red); } .v-code .s { color: var(--green); } .v-code .t { color: var(--blue); }
.v-code .site { border-radius: 7px; background: #efe7d2; padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.v-code .site i { display: block; height: 6px; border-radius: 3px; background: #cfc5ad; }
.v-code .site .hero { height: 18px; background: color-mix(in srgb, var(--hue) 60%, #efe7d2); }
.v-code .site .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.v-code .site .grid i { height: 14px; }

/* ---------- detail ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: 4vh 16px;
  overflow-y: auto;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.detail {
  position: relative;
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px clamp(16px, 4vw, 24px) 20px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--elevated);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  outline: none;
  max-height: calc(100dvh - 8vh);
  /* Fit short desktop viewports: cap the panel height and scroll internally so
     long summaries and source links stay reachable instead of overflowing. */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Keep every detail block at its natural height; never squash children to
   fit the capped panel — let the internal scroll handle overflow instead. */
.detail > * { flex-shrink: 0; }
@media (prefers-reduced-motion: no-preference) {
  .overlay:not([hidden]) .detail { animation: rise .22s ease-out; }
  @keyframes rise { from { transform: translateY(14px); } }
}
.d-top { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.d-nav { display: flex; gap: 6px; }
.icon-btn {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-line); }
.detail h2 { font-size: clamp(16px, 2.2vw, 19px); font-weight: 760; line-height: 1.25; letter-spacing: -.4px; text-wrap: balance; }
.detail .d-photo {
  width: auto;
  max-width: min(150px, 60%);
  max-height: 110px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--vis-bg);
}
.detail h3 { margin-bottom: 4px; color: var(--strong); font-size: 9.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.d-summary p { color: var(--muted); font-size: 12px; line-height: 1.55; max-width: 60ch; }
.source { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-decoration: none; font-size: 12px; }
.source:hover { border-color: var(--accent-line); }
.source small { display: block; color: var(--faint); font-size: 11px; }
.source b { color: var(--accent); white-space: nowrap; }

/* ---------- phones: one column you scroll through normally ---------- */
@media (max-width: 620px) {
  .bar { position: sticky; top: 0; z-index: 5; flex-wrap: nowrap; gap: 10px; padding-top: calc(env(safe-area-inset-top, 0px) + 12px); padding-bottom: 10px; background: var(--bg); }
  .brand { font-size: 14px; }
  .brand .word { display: none; }
  .pref { min-width: 30px; height: 30px; padding: 0 6px; font-size: 10.5px; }
  .prefs { gap: 4px; }
  .brand img { width: 30px; height: 24px; }
  .scope button { padding: 0 9px; min-height: 30px; font-size: 11px; }
  .scope .long { display: none; }
  .scope .short { display: inline; }
  .page { width: 100%; min-width: 0; max-width: none; padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 32px); }
  .intro { display: none; }
  .feed { grid-template-columns: 1fr; gap: 30px; }
  .card .vis { height: auto; aspect-ratio: 3 / 2; font-size: 13px; border-radius: 16px; }
  .card:hover .vis { transform: none; box-shadow: none; }
  .card-body { gap: 7px; padding: 14px 2px 0; }
  .card h2 { font-size: 18px; letter-spacing: -.4px; }
  .card p { font-size: 13px; -webkit-line-clamp: 3; }
  .card .hint { display: flex; margin-top: 2px; color: var(--accent); font-size: 12px; font-weight: 700; }
  .card .hint span:last-child { display: none; }
  .empty { padding: 40px 20px; }
  .overlay { padding: 0; align-items: flex-start; }
  .detail {
    min-height: 100%;
    border-radius: 0;
    border: 0;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  }
  .d-top { position: sticky; top: 0; z-index: 1; margin: -4px -4px 0; padding: 4px; background: var(--elevated); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Detail image: as big as the screen allows while the whole popup still fits */
.detail .d-photo {
  width: auto;
  height: clamp(130px, 30vh, 280px);
  max-width: 100%;
  max-height: none;
  aspect-ratio: 1;
  object-fit: cover;
}
@media (max-width: 620px) {
  .detail { box-sizing: border-box; }
  .detail .d-photo { height: clamp(130px, 30dvh, 260px); }
}
