/* ---- tokens ---------------------------------------------------------- */
:root {
  --bg: #0b1020;
  --bg-2: #131a33;
  --fg: #f5f7ff;
  --fg-dim: rgba(245, 247, 255, 0.62);
  --tile: 100px;
  --radius: 23%;
  --glass: rgba(255, 255, 255, 0.09);
  --glass-line: rgba(255, 255, 255, 0.14);
  --accent: #3b82f6;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: calc(var(--safe-t) + 28px) 20px calc(var(--safe-b) + 40px);
  font: 400 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(120% 90% at 12% 0%, color-mix(in oklab, var(--accent) 32%, transparent) 0%, transparent 55%),
    radial-gradient(120% 90% at 92% 8%, color-mix(in oklab, var(--accent) 26%, #7c5cff 16%) 0%, transparent 50%),
    linear-gradient(178deg, var(--bg-2), var(--bg) 62%);
  background-attachment: fixed;
  min-height: 100%;
  overscroll-behavior-y: contain;
}

.wrap { max-width: 880px; margin: 0 auto; }

/* ---- header ---------------------------------------------------------- */
header { margin-bottom: 26px; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-dim);
  margin-bottom: 14px;
  min-height: 20px;
}
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--fg); }
.crumbs .sep { opacity: 0.45; }

h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 700;
  letter-spacing: -0.022em;
}
.tagline { margin: 8px 0 0; color: var(--fg-dim); font-size: 15px; max-width: 46ch; }

/* ---- search ---------------------------------------------------------- */
.search {
  position: relative;
  margin-top: 20px;
  display: flex;
  align-items: center;
}
.search input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  font-size: 16px;
  color: var(--fg);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  outline: none;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.search input::placeholder { color: rgba(245, 247, 255, 0.4); }
.search input:focus { border-color: color-mix(in oklab, var(--accent) 70%, white 10%); }
.search svg { position: absolute; left: 13px; width: 18px; height: 18px; opacity: 0.5; pointer-events: none; }

/* ---- grid ------------------------------------------------------------ */
.section-label {
  margin: 30px 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: 22px 16px;
}
@media (min-width: 700px) { :root { --tile: 108px; } }

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.16s ease;
}
.tile:active { transform: scale(0.92); }
@media (hover: hover) { .tile:hover .icon { transform: translateY(-3px); } }

.icon {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: calc(var(--tile) * 0.46);
  line-height: 1;
  overflow: hidden;
  background: linear-gradient(160deg, color-mix(in oklab, var(--c) 92%, white 26%), var(--c) 58%, color-mix(in oklab, var(--c) 78%, black 26%));
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.16s ease;
}
.icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 46%);
  pointer-events: none;
}
.icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.icon .initials { font-size: calc(var(--tile) * 0.3); font-weight: 700; letter-spacing: -0.02em; }

/* folder tile: frosted with a mini preview grid, like an iOS folder */
.tile.folder .icon {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.7);
}
.mini {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 6%;
  width: 80%;
  height: 80%;
}
.mini span {
  flex: 0 0 28%;
  aspect-ratio: 1;
  border-radius: 26%;
  display: grid;
  place-items: center;
  font-size: calc(var(--tile) * 0.13);
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.mini span img { width: 100%; height: 100%; object-fit: cover; }

.label {
  font-size: 12.5px;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.label .name,
.label .sub {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.label .sub { font-size: 11px; color: var(--fg-dim); margin-top: 1px; }

.tile[hidden] { display: none; }
.empty { color: var(--fg-dim); font-size: 14px; padding: 24px 2px; }

/* ---- install hint ---------------------------------------------------- */
.hint {
  margin-top: 34px;
  padding: 13px 15px;
  font-size: 13px;
  color: var(--fg-dim);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  display: none;
  align-items: center;
  gap: 10px;
}
.hint b { color: var(--fg); font-weight: 600; }
.hint button {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--fg-dim);
  font-size: 17px;
  cursor: pointer;
  padding: 0 4px;
}

footer { margin-top: 42px; font-size: 12px; color: var(--fg-dim); text-align: center; }
footer a { color: inherit; }

/* standalone (home-screen) mode: tighter, no browser chrome to compete with */
@media (display-mode: standalone) {
  body { padding-top: calc(var(--safe-t) + 16px); }
  .hint { display: none !important; }
}

/* ---- write-up tiles + pages ------------------------------------------ */
/* A page tile opens a write-up, not an app. The corner dot-mark signals
   "this one reads" without needing a label. */
.tile.page .icon .kind {
  position: absolute;
  right: 8%;
  bottom: 8%;
  width: 22%;
  height: 22%;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.tile.page .icon .kind::before,
.tile.page .icon .kind::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  height: 8%;
  min-height: 1px;
  background: rgba(0, 0, 0, 0.45);
}
.tile.page .icon .kind::before { top: 30%; }
.tile.page .icon .kind::after { top: 55%; right: 45%; }

.doc { max-width: 660px; }
.doc-head { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.doc-icon {
  width: 68px;
  flex: 0 0 68px;
  aspect-ratio: 1;
  font-size: 34px;
  border-radius: 22%;
}
.doc h1 { font-size: clamp(26px, 5vw, 34px); }
.doc .tagline { margin-top: 4px; }

.badges { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; padding: 0; margin: 18px 0 0; }
.badges li {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--fg-dim);
  background: var(--glass);
  border: 1px solid var(--glass-line);
}
.doc-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.doc-links a {
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--fg);
  padding: 9px 15px;
  border-radius: 11px;
  background: color-mix(in oklab, var(--accent) 82%, black 8%);
}
.doc-links a:nth-child(n + 2) { background: var(--glass); border: 1px solid var(--glass-line); }

.media { margin: 30px 0 0; }
.media video, .media img {
  width: 100%;
  border-radius: 16px;
  display: block;
  border: 1px solid var(--glass-line);
  background: rgba(0, 0, 0, 0.3);
}
.media figcaption { margin-top: 9px; font-size: 12.5px; color: var(--fg-dim); text-align: center; }

.doc-section { margin-top: 34px; }
.doc-section h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0 0 10px;
}
.doc-section p { margin: 0 0 12px; line-height: 1.62; color: rgba(245, 247, 255, 0.86); }
.doc-section ul { margin: 0; padding-left: 20px; color: rgba(245, 247, 255, 0.86); line-height: 1.62; }
.doc-section li { margin-bottom: 6px; }
