/* Pedia app shell: top bar, tabs, chips, bottom bar, floating buttons, side menu.
   Matches the look of the existing Pedia app (v37). */

body.has-shell { background: var(--paper); padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
.pd-wrap { max-width: 640px; margin: 0 auto; background: var(--paper); min-height: 100vh; }

/* Top bar */
.pd-top {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.pd-top .l { justify-self: start; }
.pd-top .r { justify-self: end; }
.pd-logo { width: 38px; height: 38px; border-radius: 50%; display: block; }
.pd-ibtn {
  width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; padding: 0;
  display: grid; place-items: center; color: var(--ink); cursor: pointer; text-decoration: none;
}
.pd-ibtn:hover { background: var(--mist); }
.pd-ibtn svg, .pd-nav svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pd-me {
  width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer;
  background: linear-gradient(145deg, #1e3a8a, #0f1d4d); color: #fff;
  font: 700 1rem var(--font-body);
}

/* Home tabs */
.pd-tabs {
  display: flex; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--line);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pd-tabs::-webkit-scrollbar { display: none; }
.pd-tabs a {
  flex: none; padding: 16px 18px 14px; font: 500 1.05rem var(--font-body); color: var(--ink-soft);
  text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.pd-tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--blue); }

/* Chips under the tabs */
.pd-chips { display: flex; gap: 10px; overflow-x: auto; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.pd-chips::-webkit-scrollbar { display: none; }
.pd-chips a {
  flex: none; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font: 500 1rem var(--font-body); text-decoration: none; white-space: nowrap;
}
.pd-chips a:hover { background: var(--mist); }

/* Content area and cards */
.pd-main { padding: 0 0 24px; }
.pd-pad { padding: 20px 16px; }
.pd-title { font: 800 2rem/1.1 var(--font-display); letter-spacing: -0.03em; background: linear-gradient(90deg, #2563eb, #7c3aed); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pd-card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 8px 24px -16px rgba(15, 23, 42, .25); overflow: hidden;
}
.pd-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #60a5fa, #8b5cf6); }
.pd-label { font: 500 .78rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.pd-empty { padding: 40px 16px; text-align: center; color: var(--ink-soft); display: grid; gap: 8px; justify-items: center; }
.pd-empty h2 { font: 700 1.3rem var(--font-display); color: var(--ink); }

/* Bottom bar */
.pd-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  height: calc(60px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card); border-top: 1px solid var(--line);
}
.pd-nav-in { width: 100%; max-width: 640px; display: flex; }
.pd-nav a { flex: 1; display: grid; place-items: center; color: var(--ink-soft); text-decoration: none; position: relative; }
.pd-nav a[aria-current="page"] { color: var(--ink); }
.pd-nav a[aria-current="page"] svg { stroke-width: 2.3; }
.pd-nav .dot { position: absolute; top: 14px; left: 56%; width: 9px; height: 9px; border-radius: 50%; background: #dc2626; border: 2px solid var(--card); }

/* Floating buttons */
.pd-fab {
  position: fixed; z-index: 29; right: max(16px, calc(50% - 304px)); width: 58px; height: 58px; border-radius: 50%; border: 0;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  box-shadow: 0 10px 24px -8px rgba(15, 23, 42, .5);
}
.pd-fab.p { bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 86px); background: #0a0a0a; }
.pd-fab.p img { width: 100%; height: 100%; border-radius: 50%; }
.pd-fab.plus { bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px); background: var(--blue); color: #fff; box-shadow: 0 10px 24px -8px rgba(37, 99, 235, .7); }
.pd-fab.plus svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }

/* Side menu */
.pd-veil { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .5); }
.pd-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 61; width: min(86vw, 360px); background: var(--card);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px);
  box-shadow: 18px 0 40px -20px rgba(15, 23, 42, .5);
}
.pd-veil[hidden], .pd-drawer[hidden] { display: none; }
.pd-dhead { padding: 22px 22px 14px; position: relative; border-bottom: 1px solid var(--line); }
.pd-dhead .x { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.pd-dhead .x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pd-dhead .av { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(145deg, #1e3a8a, #0f1d4d); color: #fff; display: grid; place-items: center; font: 700 1.6rem var(--font-body); }
.pd-dhead h2 { margin-top: 12px; font: 800 1.45rem/1.15 var(--font-display); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.pd-dhead p { margin-top: 2px; color: var(--ink-soft); font-size: 1rem; }
.pd-dlist { flex: 1; overflow-y: auto; padding: 6px 0; }
.pd-dlist a, .pd-dlist summary, .pd-dlist button.row {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 22px; border: 0; background: none;
  color: var(--ink); font: 500 1.1rem var(--font-body); text-decoration: none; cursor: pointer; text-align: left; list-style: none;
}
.pd-dlist summary::-webkit-details-marker { display: none; }
.pd-dlist a:hover, .pd-dlist summary:hover, .pd-dlist button.row:hover { background: var(--mist); }
.pd-dlist svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pd-dlist summary .chev { margin-left: auto; width: 20px; height: 20px; transition: transform .2s; color: var(--ink-soft); }
.pd-dlist details[open] > summary .chev { transform: rotate(180deg); }
.pd-dlist .sub a { padding-left: 62px; font-size: 1.05rem; color: var(--ink); }
.pd-dlist hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.pd-dfoot { display: flex; align-items: center; justify-content: space-between; padding: 12px 22px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.pd-dfoot span { display: flex; align-items: center; gap: 10px; font: 700 1.1rem var(--font-display); }
.pd-dfoot img { width: 36px; height: 36px; border-radius: 50%; }
.pd-dfoot button { border: 0; background: none; color: #dc2626; font: 600 1.05rem var(--font-body); cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 8px; }
.pd-dfoot button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Toast */
.pd-toast {
  position: fixed; left: 50%; bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 96px); transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: 999px; font: 500 .95rem var(--font-body);
  max-width: 88vw; text-align: center; box-shadow: 0 10px 24px -10px rgba(15, 23, 42, .6);
}

@media (prefers-reduced-motion: reduce) { .pd-dlist summary .chev { transition: none; } }

/* Signed-out pages: Sign in, Register and friends */
.pd-signin {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 22px; border-radius: 999px;
  background: var(--ink); color: var(--on-ink); font: 700 1rem var(--font-body); text-decoration: none;
}
.pd-signin:hover { background: var(--ink-hover); color: var(--on-ink); }
.pd-ibtn.pd-round { border: 1px solid var(--line); background: var(--card); }
.pd-logo.big { width: 64px; height: 64px; }
.pd-sub { margin-top: 6px; font-size: 1.15rem; color: var(--ink-soft); line-height: 1.4; }
.pd-auth .pd-pad { padding: 44px 16px 24px; display: grid; gap: 14px; }
.pd-auth .pd-pad > .pd-title { font-size: 2.6rem; }
.pd-auth #form { margin-top: 10px; gap: 20px; }

.pd-auth .field { gap: 8px; }
.pd-auth .field label, .pd-auth .field .label {
  font: 500 .85rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
.pd-auth .optional { font: inherit; text-transform: none; letter-spacing: 0; }
.pd-auth input, .pd-auth select {
  min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 1.1rem; padding: 0 18px;
}
.pd-auth select { padding-right: 44px; }
.pd-auth input::placeholder { color: var(--ink-soft); }
.pd-auth input:focus-visible, .pd-auth select:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); border-color: var(--blue); }
.pd-auth .pw input { padding-right: 60px; }
.pd-auth .pw-toggle { right: 8px; top: 6px; bottom: 6px; width: 44px; padding: 0; display: grid; place-items: center; color: var(--ink-soft); }
.pd-auth .pw-toggle svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.pd-auth .seg { grid-template-columns: 1fr 1fr; padding: 6px; border-radius: 999px; background: var(--mist); gap: 4px; }
.pd-auth .seg span { min-height: 52px; border-radius: 999px; font: 700 1.05rem var(--font-body); color: var(--ink); }
.pd-auth .seg input:checked + span { background: var(--ink); color: var(--on-ink); box-shadow: none; }

.pd-auth .btn-primary {
  background: var(--ink); color: var(--on-ink); min-height: 60px; border-radius: 999px; font-size: 1.2rem; gap: 12px; border-color: var(--ink);
}
.pd-auth .btn-primary:hover { background: var(--ink-hover); }
.pd-auth .btn-primary svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pd-auth .btn-ghost { border-radius: 999px; min-height: 52px; }
.pd-note { font-size: 1.05rem; line-height: 1.5; color: var(--ink-soft); }
.pd-links { margin: 0; }
.pd-links a { font: 500 .85rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); text-decoration: none; }
.pd-links a:hover { color: var(--blue); }

.pd-foot { border-top: 1px solid var(--line); margin-top: 28px; padding: 28px 16px 20px; display: grid; gap: 12px; }
.pd-foot a { color: var(--ink-soft); font-size: .95rem; }
.pd-auth #studentFields { display: grid; gap: 20px; }
.pd-auth #studentFields[hidden], .pd-auth #facultyNote[hidden] { display: none; }

/* profile picture inside the round buttons */
.pd-me, .pd-dhead .av, .st-av { overflow: hidden; padding: 0; }
.pd-me img, .pd-dhead .av img, .st-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-me { display: grid; place-items: center; }

/* Tabs: a thick, rounded indicator under the word, as in the first Pedia */
.pd-tabs a { position: relative; display: flex; align-items: center; height: 50px; padding: 0 18px; margin-bottom: 0; border-bottom: 0; font-size: 1rem; }
.pd-tabs a[aria-current="page"]::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 4px; border-radius: 9999px; background: var(--blue); }

/* "＋" circle for video stories at the start of the home chips */
.vs-add{position:relative;flex:none;width:44px;height:44px;border-radius:50%;border:2px dashed var(--ink-soft);background:none;color:var(--ink);font-size:22px;line-height:1;cursor:pointer;display:grid;place-items:center;padding:0}
.vs-add.has{border:0;padding:2px;background:linear-gradient(135deg,#2563eb,#22d3ee)}
.vs-add .vs-in{width:100%;height:100%;border-radius:50%;background:var(--card);display:grid;place-items:center;border:2px solid var(--card);color:var(--ink)}
.vs-plus{position:absolute;right:-4px;bottom:-4px;width:20px;height:20px;border-radius:50%;background:var(--blue,#2563eb);color:#fff;font-style:normal;font-size:14px;display:grid;place-items:center;border:2px solid var(--card)}

/* Story row at the top of For You */
.vs-row{display:flex;gap:14px;overflow-x:auto;padding:12px 16px 10px;background:var(--card);border-bottom:1px solid var(--line);scrollbar-width:none}
.vs-row::-webkit-scrollbar{display:none}
.vs-o{position:relative;flex:none;width:64px;display:flex;flex-direction:column;align-items:center;gap:5px;border:0;background:none;color:var(--ink);font:inherit;cursor:pointer;padding:0}
.vs-o .vs-av{width:58px;height:58px;border-radius:50%;display:grid;place-items:center;overflow:hidden;background:var(--mist);font-weight:700;border:3px solid var(--card);box-shadow:0 0 0 2px var(--line);box-sizing:border-box}
.vs-o .vs-av img{width:100%;height:100%;object-fit:cover;display:block}
.vs-o.has .vs-av{box-shadow:0 0 0 2px #2563eb}.vs-o.has.seen .vs-av{box-shadow:0 0 0 2px var(--line)}
.vs-o small{max-width:64px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--ink-soft)}
.vs-o .vs-plus{position:absolute;right:2px;top:38px;width:22px;height:22px;border-radius:50%;background:var(--blue,#2563eb);color:#fff;font-style:normal;font-size:15px;line-height:1;display:grid;place-items:center;border:2px solid var(--card)}

/* The side menu never pans sideways (a row that is slightly too wide must not shift the whole list). */
.pd-dlist { overflow-x: hidden; }
.pd-dlist a, .pd-dlist summary, .pd-dlist button.row { min-width: 0; max-width: 100%; box-sizing: border-box; }
