/* ==========================================================================
   StudyHub design system
   Palette comes from the desk it lives on: ink, paper, highlighter, red pen.
   ========================================================================== */

:root {
  --ink:        #16213A;
  --ink-soft:   #33405C;
  --paper:      #EDF0F5;
  --surface:    #FFFFFF;
  --line:       #DDE3EC;
  --muted:      #6B7789;
  --marker:     #D6F45B;
  --marker-dim: #EAF9AE;
  --redpen:     #E2413B;
  --ok:         #1E9E6A;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;

  --shadow: 0 1px 2px rgba(22,33,58,.06), 0 8px 24px rgba(22,33,58,.06);

  --font-display: 'Bricolage Grotesque', 'Public Sans', system-ui, sans-serif;
  --font-body:    'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  --nav-h: 58px;
  --tab-h: 62px;
}

* { box-sizing: border-box; }

/* The browser hides [hidden] with display:none, but any author rule that sets
   a display wins over it. .composer-shut and .composer-quick both do, so the
   collapsed composer stayed on screen underneath the expanded one and the
   writing box appeared below it instead of replacing it. The question banner
   and the empty attachment tray had the same problem. One rule covers the lot
   and stops the next one happening. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 .5rem;
  line-height: 1.2;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--ink); text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* --- signature: the highlighter swipe ------------------------------------ */

.mark {
  position: relative;
  display: inline;
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-size: 100% 42%;
  background-position: 0 78%;
  padding: 0 .12em;
}

/* --- layout -------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 14px;
}
.wrap-wide { max-width: 1280px; }
.main .wrap { max-width: none; padding: 0; }

.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- top bar -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}
.brand em { font-style: normal; }
.logo { flex: none; border-radius: 8px; }

.topsearch {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 420px;
  padding: 0 14px;
  height: 38px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
}
.topsearch input {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: .9rem;
  height: 100%;
}
.topsearch input:focus { outline: none; box-shadow: none; }

.topacts { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.avlink { display: inline-flex; padding: 4px; }

.iconbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}
.iconbtn:hover { background: var(--paper); }
.ic { flex: none; }

.dot {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  background: var(--redpen);
  color: #fff;
  border-radius: 9px;
  font-size: .64rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* --- the three column shell ---------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 14px 0;
}
.main { min-width: 0; }
.side, .rail { display: none; }

/* --- left sidebar (desktop) ---------------------------------------------- */

.side nav { display: flex; flex-direction: column; gap: 1px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.2;
}
.side-link:hover { background: var(--surface); color: var(--ink); }
.side-link.on { background: var(--surface); color: var(--ink); box-shadow: inset 3px 0 0 var(--marker); }
.side-link .ic { flex: none; opacity: .85; }

/* --- right rail (desktop) ------------------------------------------------ */

.rail .card { padding: 14px; }
.rail-head {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.rail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: .88rem;
  text-decoration: none;
  color: var(--ink);
}
.rail-row:hover { color: var(--ink); text-decoration: underline; }
.rail-dark {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
  text-decoration: none;
  display: block;
}
.rail-foot a { font-size: .78rem; color: var(--muted); text-decoration: none; margin-right: 10px; line-height: 1.9; }

/* --- bottom tabs (mobile) ------------------------------------------------ */

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: flex;
  height: var(--tab-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabs a, .tabs button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: .66rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.tabs .active { color: var(--ink); }
.tabs .active .tl {
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-size: 100% 50%;
  background-position: 0 70%;
  padding: 0 3px;
}

/* --- the More sheet ------------------------------------------------------ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(22, 33, 58, .45);
  display: flex;
  align-items: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: sheet-up .18s ease;
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } }
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.sheet-grid a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: .74rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.25;
}
.sheet-grid a.on { border-color: transparent; background: var(--marker-dim); color: var(--ink); }

.only-mobile { display: inline-flex; }

/* --- cards --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-flush { padding: 0; overflow: hidden; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
}
.section-head h2 { margin: 0; }
.section-head a { font-size: .85rem; color: var(--muted); }

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  font-family: var(--font-body);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--ink); }

.btn-marker { background: var(--marker); color: var(--ink); border-color: var(--marker); }

.btn-danger { background: var(--redpen); border-color: var(--redpen); }

.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-block { width: 100%; }

/* --- forms --------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field .hint { margin-top: 5px; font-size: .78rem; color: var(--muted); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=url],
select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px; /* keeps iOS from zooming on focus */
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--marker-dim);
}
textarea { min-height: 96px; resize: vertical; }

.field-error input, .field-error select, .field-error textarea { border-color: var(--redpen); }
.err { margin-top: 5px; font-size: .78rem; color: var(--redpen); font-weight: 600; }

.choice {
  display: flex;
  gap: 8px;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  flex: 1;
  margin: 0;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-align: center;
  font-size: .85rem;
  cursor: pointer;
  background: var(--surface);
}
.choice input:checked + label {
  border-color: var(--ink);
  background: var(--marker-dim);
}
.choice input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }

/* --- flash --------------------------------------------------------------- */

.flash {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border-left: 4px solid var(--ink);
  background: var(--surface);
  font-size: .9rem;
  margin-bottom: 14px;
}
.flash-error   { border-left-color: var(--redpen); }
.flash-success { border-left-color: var(--ok); }
.flash-info    { border-left-color: var(--ink); }

/* --- avatars & chips ----------------------------------------------------- */

.av {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper);
  flex: none;
}
.av-sm { width: 30px; height: 30px; }
.av-lg { width: 76px; height: 76px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  text-decoration: none;
}
.chip-marker { background: var(--marker-dim); border-color: transparent; }
.chip-pending { background: #FFF3CD; border-color: transparent; }
.chip-danger { background: #FDE7E6; border-color: transparent; color: var(--redpen); }

/* --- empty state --------------------------------------------------------- */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { color: var(--ink); }

/* --- tables (admin) ------------------------------------------------------ */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  background: var(--surface);
}
table.data th, table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
table.data th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--paper);
}

/* --- footer -------------------------------------------------------------- */

.foot {
  margin-top: 32px;
  padding: 22px 0 30px;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
}
.foot a { color: var(--muted); text-decoration: none; margin-right: 14px; line-height: 2; }
.foot a:hover { color: var(--ink); }

/* --- desktop -------------------------------------------------------------- */

@media (min-width: 820px) {
  body { padding-bottom: 0; }
  .tabs, .sheet, .only-mobile { display: none !important; }
  .topsearch { display: flex; }
  .shell { grid-template-columns: 216px minmax(0, 1fr); padding-bottom: 40px; }
  .side { display: block; position: sticky; top: calc(var(--nav-h) + 18px); align-self: start; }
}

@media (min-width: 1120px) {
  .shell { grid-template-columns: 216px minmax(0, 1fr) 300px; }
  .shell-norail { grid-template-columns: 216px minmax(0, 1fr); }
  .rail { display: block; position: sticky; top: calc(var(--nav-h) + 18px); align-self: start; }
  .shell-norail .rail { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --- accessibility: skip link ------------------------------------------- */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 0 0 var(--r-sm) 0;
  font-weight: 600;
}
.skip:focus { left: 0; }

/* --- chat receipts ------------------------------------------------------- */

.receipt { font-size: .72rem; }

/* --- inline spinner ------------------------------------------------------ */

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sh-spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes sh-spin { to { transform: rotate(360deg); } }

/* --- images -------------------------------------------------------------- */

img { max-width: 100%; }

/* --- form helper: password reveal --------------------------------------- */

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 62px; }
.pass-wrap button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
}

/* --- dark mode ----------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #E8ECF3;
    --ink-soft:   #B7C0D0;
    --paper:      #0F1522;
    --surface:    #172033;
    --line:       #26314A;
    --muted:      #8794AA;
    --marker:     #C7E84F;
    --marker-dim: #2C3A1B;
    --redpen:     #FF6B63;
    --ok:         #35C48C;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
  .btn { background: var(--marker); color: #0F1522; border-color: var(--marker); }
  .btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
  .btn-marker { background: var(--marker); color: #0F1522; }
  .btn-danger { background: var(--redpen); border-color: var(--redpen); color: #0F1522; }
  .mark { color: #0F1522; }
  .chip-pending { background: #4A3D12; color: #F0DFA0; }
  .chip-danger  { background: #4A1F1D; }
  .skip { background: var(--marker); color: #0F1522; }
  img { filter: brightness(.92); }
}

/* --- print (a student printing notes or a result) ------------------------ */

@media print {
  .topbar, .tabs, .foot, .skip, form, .btn, .iconbtn { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}

/* --- advert slots -------------------------------------------------------- */

.ad-slot {
  margin: 14px 0;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  text-align: center;
  overflow: hidden;
}
.ad-slot .ad-label {
  display: block;
  margin-bottom: 6px;
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.ad-slot img, .ad-slot iframe { max-width: 100%; }
@media print { .ad-slot { display: none; } }

/* --- the feed's context strip -------------------------------------------- */

.strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }

.strip-card {
  flex: none;
  min-width: 132px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  line-height: 1.25;
}
.strip-card:hover { border-color: var(--ink); }
.strip-card .small { color: var(--muted); }
.strip-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.strip-dark .small { color: inherit; opacity: .75; }

@media (min-width: 820px) {
  .strip-card { min-width: 150px; }
}

/* --- icons sitting inside buttons and meta lines -------------------------- */

.btn .ic { margin-right: -2px; }
.btn-sm .ic { width: 16px; height: 16px; }
.small .ic { width: 14px; height: 14px; vertical-align: -2px; }
.chip .ic { width: 15px; height: 15px; }

/* --- the post composer ---------------------------------------------------- */

.composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  margin-bottom: 12px;
}

.composer-shut { display: flex; align-items: center; gap: 10px; }

.composer-pill {
  flex: 1;
  text-align: left;
  padding: 11px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .93rem;
  cursor: text;
}
.composer-pill:hover { background: var(--line); }

.composer-quick {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.composer-quick button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.composer-quick button:hover { background: var(--paper); color: var(--ink); }
.composer-quick .ic { opacity: .8; }

/* expanded */

.composer-vis {
  width: auto;
  padding: 3px 26px 3px 9px;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--paper);
  border-color: transparent;
}

.composer-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: var(--r-sm);
  background: var(--marker-dim);
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink);
}
.composer-mode button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
}

#composer-text {
  border: 0;
  padding: 4px 2px;
  min-height: 84px;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
}
#composer-text:focus { box-shadow: none; }

.composer-subjects {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 4px;
  scrollbar-width: none;
}
.composer-subjects::-webkit-scrollbar { display: none; }
.composer-subjects .chip { white-space: nowrap; cursor: pointer; border-style: dashed; }
.composer-subjects .chip.on { border-style: solid; background: var(--marker-dim); border-color: transparent; }
.composer-subjects .small { flex: none; padding-right: 2px; }

.composer-files {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 2px;
}
.composer-file {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: .62rem;
  text-align: center;
  color: var(--muted);
  word-break: break-all;
}
.composer-file img { width: 100%; height: 100%; object-fit: cover; }
.composer-file button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(22, 33, 58, .78);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.composer-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.composer-attach:hover { background: var(--paper); color: var(--ink); }
.composer-attach.on { background: var(--marker-dim); color: var(--ink); }
.composer-count {
  margin-left: auto;
  font-size: .75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.composer-count.near { color: var(--redpen); font-weight: 600; }

/* --- image lightbox ------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(10, 14, 24, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); }
.lightbox button {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- empty states, which most of a new site will be ---------------------- */

.empty-art {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--marker-dim);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-art .ic { width: 26px; height: 26px; }
.empty h3 { margin-bottom: 6px; }
.empty p { max-width: 34em; margin: 0 auto; }
.empty .btn { margin-top: 16px; }

/* --- mentions ------------------------------------------------------------- */

.mention {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--marker-dim);
  padding: 0 4px;
  border-radius: 4px;
}
.mention:hover { text-decoration: underline; }

.composer-typing { position: relative; }

.mention-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 60;
  max-height: 250px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 4px;
}
.mention-menu[hidden] { display: none; }
.mention-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink);
}
.mention-menu button.on,
.mention-menu button:hover { background: var(--paper); }
.mention-menu img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.mention-menu strong { display: block; font-size: .88rem; }
.mention-menu em {
  display: block;
  font-style: normal;
  font-size: .76rem;
  color: var(--muted);
}

/* --- anonymous author ----------------------------------------------------- */

.av-anon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--muted);
  border: 1px dashed var(--line);
}

.composer-anon {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
}
.composer-anon[hidden] { display: none; }
.composer-anon input { width: auto; margin: 2px 0 0; flex: none; }
.composer-anon .ic { flex: none; margin-top: 1px; color: var(--muted); }
.composer-anon em {
  display: block;
  font-style: normal;
  font-weight: 400;
  font-size: .76rem;
  color: var(--muted);
  margin-top: 2px;
}

/* --- draft note ----------------------------------------------------------- */

.composer-draft {
  font-size: .74rem;
  color: var(--muted);
  padding: 4px 2px 0;
}
.composer-draft[hidden] { display: none; }

/* --- editing in place ----------------------------------------------------- */

.edit-box { margin-top: 10px; }
.edit-box textarea {
  min-height: 80px;
  font-size: .96rem;
  line-height: 1.5;
}

/* --- pinned posts --------------------------------------------------------- */

.pinned-wrap { position: relative; }
.pinned-wrap .card { border-color: var(--marker); }
.pinned-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: -6px;
  padding: 4px 10px 9px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--marker);
  color: var(--ink);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* --- loading placeholders ------------------------------------------------- */

.sk {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--paper) 25%, var(--line) 37%, var(--paper) 63%);
  background-size: 400% 100%;
  animation: sk-slide 1.3s ease-in-out infinite;
}
.sk-av { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.sk-line { height: 11px; margin-bottom: 8px; }
.skel { pointer-events: none; }
@keyframes sk-slide {
  from { background-position: 100% 50%; }
  to   { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; background: var(--line); }
}

/* --- photos in posts ------------------------------------------------------ */

.post-photo { display: block; }
.post-photo img { transition: opacity .2s ease; }

/* --- desktop hover, kept subtle ------------------------------------------ */

@media (hover: hover) and (min-width: 820px) {
  a.card { transition: border-color .15s ease, transform .15s ease; }
  a.card:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
  .rail-dark:hover, .strip-dark:hover { border-color: var(--ink); transform: translateY(-1px); }
  time[title] { cursor: help; }
}

/* --- long words and pasted links must not widen the card ----------------- */

.post-body, .comment-body, .card p { overflow-wrap: anywhere; }

/* --- announcement banner -------------------------------------------------- */

.flash-warning { border-left-color: #B4762A; }
.flash[data-announce] { align-items: flex-start; }
.flash[data-announce] .iconbtn { width: 30px; height: 30px; margin: -4px -6px 0 auto; flex: none; }

/* --- consent bar ---------------------------------------------------------- */

.consent {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tab-h) + 12px);
  z-index: 160;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 10px 34px rgba(22, 33, 58, .22);
}
.consent .row { justify-content: flex-end; }

@media (min-width: 820px) {
  .consent {
    bottom: 16px;
    left: auto;
    right: 16px;
    max-width: 400px;
  }
}

.ad-waiting { opacity: .7; }
.ad-slot:empty { display: none; }

/* --- checklist marks (installer and money page) --------------------------- */

.mk.ok   { color: var(--ok); }
.mk.warn { color: #B4762A; }
.mk.no   { color: var(--redpen); }

/* --- the online marker in chat -------------------------------------------- */

.online-dot { color: var(--ok); font-weight: 600; }
.online-dot::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}

/* StudyHub Learning Suite */
.learning-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.learning-grid > *{min-width:0}
@media(max-width:720px){.learning-grid{grid-template-columns:1fr}}


/* --- admin side navigation ------------------------------------------------ */
/* Twenty-three destinations do not belong in a sideways-scrolling strip. Wide
   screens get a rail beside the content; phones get a drawer behind the menu
   button, because a rail that narrow is unreadable and one that wide leaves no
   room for the page itself. */

.adminlayout { display: block; }
.adminmain   { min-width: 0; }

.adminside-open { display: inline-flex; }

.adminside {
  position: fixed;
  top: 0; bottom: 0; right: 0;
  width: min(80vw, 300px);
  z-index: 60;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 12px 12px 40px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .18s ease;
  -webkit-overflow-scrolling: touch;
}
.adminside.is-open { transform: translateX(0); }

.adminside-veil {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(16, 24, 40, .45);
}

.adminside-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 10px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.adminside-group { margin-bottom: 14px; }

.adminside-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 0 8px; margin-bottom: 4px;
}

.adminside-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14.5px;
}
.adminside-link:hover { background: var(--paper); }
.adminside-link.on { background: var(--marker-dim); }
.adminside-link em {
  font-style: normal; font-weight: 700; font-size: 12px;
  background: var(--redpen); color: #fff;
  border-radius: 999px; padding: 1px 7px; flex: none;
}

@media (min-width: 900px) {
  .adminlayout { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: 22px; align-items: start; }
  .adminside {
    position: sticky; top: 74px;
    transform: none; width: auto; z-index: 1;
    max-height: calc(100vh - 90px);
    border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 8px;
  }
  .adminside-head,
  .adminside-veil,
  .adminside-open { display: none; }
}
