/* The client portal's Social views (social.js): Posts, the post editor, Platforms and Hashtags. Only the shell's
   variables (portal.css: --bg, --card, --text, --muted, --line, --accent, --accent-ink, --danger, --ok, --radius), so
   light and dark follow the shell. Every class starts so-, so nothing here touches the shell or the other views. */

/* (hidden wins over the display rules below) */
.so-view [hidden], .so-dialog [hidden], .so-view[hidden] { display: none !important; }
.so-view { display: flex; flex-direction: column; gap: 16px; min-width: 0; color: var(--text); }
.so-view h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.so-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.so-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.so-grow { flex: 1 1 auto; }
.so-hint { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.so-hint.bad, .so-err { color: var(--danger); }
.so-err { font-size: 0.85rem; margin: 0; }
.so-msg { margin: 8px 0 0; font-size: 0.9rem; min-height: 0; }
.so-msg:empty { display: none; }
.so-msg[data-kind="ok"] { color: var(--ok); }
.so-msg[data-kind="error"] { color: var(--danger); }
.so-view p, .so-dialog p { margin: 0; }
.so-panel > * + * { margin-top: 10px; }
.so-empty { color: var(--muted); text-align: center; }

/* buttons, pills, chips */
.so-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px;
  padding: 8px 16px; font: inherit; font-size: 0.92rem; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.so-btn:hover { border-color: var(--accent); }
.so-btn:focus-visible, .so-view :focus-visible, .so-dialog :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.so-btn.small { padding: 5px 12px; font-size: 0.85rem; }
.so-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.so-btn.ghost { background: transparent; }
.so-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: transparent; }
.so-btn:disabled { opacity: 0.5; cursor: default; }
.so-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.so-pill {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap;
  background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); margin-left: 6px; vertical-align: middle;
}
.so-pill.live { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.so-pill.draft { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.so-pill.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.so-count { display: inline-block; margin-left: 6px; font-size: 0.8rem; color: var(--muted); font-weight: 600; }

/* the numbers on top */
.so-nums { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.so-num { border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.7); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.so-num-h { display: flex; flex-direction: column; min-width: 0; font-size: 0.85rem; }
.so-num-h b { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.so-num-h a, .so-num-h span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); text-decoration: none; }
.so-num-h a:hover { text-decoration: underline; }
.so-num-f b { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.so-num-f span { color: var(--muted); font-size: 0.85rem; }
.so-num-c { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.so-num-c.up { color: var(--ok); }
.so-num-c.down { color: var(--danger); }
.so-num-s { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 3px; }
.so-num-s b { font-variant-numeric: tabular-nums; color: var(--text); }
.so-tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); }
.so-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.6); min-width: 0; }
.so-tile b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.so-tile span { font-size: 0.78rem; color: var(--muted); }

/* folds */
details.so-about > summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
details.so-about[open] > summary { margin-bottom: 8px; }
details.so-about p + p { margin-top: 8px; }
.so-insta .so-tiles { margin-top: 8px; }
.so-insta .so-hint { margin-top: 8px; }
.so-sum { color: var(--muted); font-size: 0.88rem; flex: 1 1 260px; min-width: 0; }

/* the posts by range */
.so-groups { display: flex; flex-direction: column; gap: 10px; }
details.so-group { padding: 0; overflow: hidden; }
details.so-group > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; padding: 14px 18px; }
details.so-group > summary::-webkit-details-marker { display: none; }
details.so-group > summary::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s; flex: none;
}
details.so-group[open] > summary::before { transform: rotate(45deg); }
details.so-group[open] > summary { border-bottom: 1px solid var(--line); }
details.so-group.hot { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
details.so-group.hot > summary h2 { color: var(--danger); }
.so-range { font-size: 0.8rem; }
.so-needs { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.so-needs .so-pill { margin-left: 0; }
details.so-group > * + * { margin-top: 0; }
.so-cards { display: flex; flex-direction: column; }
.so-card { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 4px 14px; padding: 14px 18px; border-top: 1px solid var(--line); align-items: start; }
.so-card:first-child { border-top: 0; }
.so-card > .so-msg { grid-column: 2 / -1; margin: 0; }
.so-thumb {
  position: relative; width: 76px; height: 95px; border-radius: 8px; overflow: hidden; background: var(--line); border: 0; padding: 0;
  cursor: pointer; display: grid; place-items: center; grid-row: span 2; color: var(--muted);
}
.so-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.so-play { font-size: 1.3rem; }
.so-thumb .n, .so-media .n {
  position: absolute; right: 4px; bottom: 4px; font-size: 0.7rem; font-weight: 700; padding: 0 5px; border-radius: 8px; background: rgba(0, 0, 0, 0.65); color: #fff;
}
.so-body { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.so-meta { display: flex; gap: 4px 10px; align-items: center; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.so-meta b { color: var(--text); font-size: 0.9rem; }
.so-meta .so-pill { margin-left: 0; }
.so-cap { display: flex; flex-direction: column; min-width: 0; }
.so-cap b, .so-cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-cap b { font-weight: 600; }
.so-cap span { color: var(--muted); font-size: 0.85rem; }
.so-outs { display: flex; gap: 6px; flex-wrap: wrap; }
.so-chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); text-decoration: none; white-space: nowrap;
}
.so-chip.live { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.so-chip.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.so-chip.draft { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
a.so-chip:hover { text-decoration: underline; }
.so-acts { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }

/* the best times */
.so-best { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.so-best li { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.6); }
.so-best li b { min-width: 170px; }

/* the post editor */
.so-dialog {
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); color: var(--text); overflow: auto;
}
.so-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.so-form { display: flex; flex-direction: column; min-width: 0; }
.so-dhead, .so-dfoot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 18px; }
.so-dhead { justify-content: space-between; border-bottom: 1px solid var(--line); align-items: flex-start; }
.so-dfoot { border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }
.so-dtitle { font-weight: 700; font-size: 1.1rem; }
.so-dbody { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; padding: 16px 18px; align-items: start; }
.so-dmain { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; min-width: 0; }
.so-wide { grid-column: 1 / -1; }
.so-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--muted); min-width: 0; }
.so-field > span { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.so-field .so-hint { font-weight: 400; }
.so-form input:not([type="checkbox"]):not([type="file"]), .so-form select, .so-form textarea,
.so-keyform input, .so-pfset select, .so-tagadd input, .so-url input {
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.5);
  padding: 8px 10px; min-width: 0; width: 100%; box-sizing: border-box;
}
.so-form textarea { resize: vertical; line-height: 1.45; }
.so-at { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.so-at input { flex: 1 1 180px; }
.so-box { border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.7); padding: 12px; min-width: 0; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.so-where { background: var(--bg); }
.so-where legend { font-weight: 700; font-size: 0.88rem; padding: 0 4px; }
.so-media { display: flex; flex-wrap: wrap; gap: 8px; }
.so-media:empty { display: none; }
.so-media figure { position: relative; width: 88px; height: 88px; margin: 0; border-radius: 8px; overflow: hidden; background: var(--line); }
.so-media img, .so-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.so-media .n { left: 4px; right: auto; }
.so-media button {
  position: absolute; top: 4px; right: 4px; padding: 0 7px; font-size: 0.85rem; line-height: 22px; border-radius: 11px; border: 0;
  background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer;
}
.so-from { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.so-from input[type="file"] { max-width: 100%; font-size: 0.85rem; }
.so-comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.so-comments li { font-size: 0.88rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.so-comments li b { margin-right: 6px; }
.so-tagsugg { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.so-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.so-tag {
  appearance: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 2px 10px;
  font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--accent); cursor: pointer;
}
button.so-tag:hover { border-color: var(--accent); }
span.so-tag { cursor: default; }
.so-why { margin-right: 10px; font-size: 0.78rem; }
.so-pfs { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 165px), 1fr)); align-items: start; }
.so-pf { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.so-pf.on { grid-column: 1 / -1; border-color: var(--accent); }
.so-pf-h { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; color: var(--text); font-weight: 400; cursor: pointer; }
.so-pf-h b { font-weight: 700; }
.so-pf-h .so-hint { font-size: 0.78rem; flex-basis: 100%; padding-left: 24px; }
.so-pf-h .so-open { font-size: 0.78rem; margin-left: auto; }
.so-pf-pv { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.so-pf-pv .so-btn { align-self: flex-start; }
.so-pf-text {
  white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 0.82rem; line-height: 1.4; margin: 0; max-height: 120px; overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
.so-dfoot .so-links { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.so-dialog > .so-form > .so-msg { padding: 0 18px 14px; margin: 0; }

/* the phone preview: Instagram's own look, in the shell's colours */
.so-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; position: sticky; top: 0; }
.so-phone { width: min(100%, 320px); border: 1px solid var(--line); border-radius: 22px; background: var(--bg); overflow: hidden; font-size: 0.82rem; }
.so-ph-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-width: 0; }
.so-ph-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-ph-av { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.so-ph-media { position: relative; aspect-ratio: 4 / 5; background: var(--line); display: grid; place-items: center; overflow: hidden; cursor: pointer; }
.so-phone.tall .so-ph-media { aspect-ratio: 9 / 16; }
.so-ph-media img, .so-ph-media video { width: 100%; height: 100%; object-fit: cover; }
.so-ph-empty { color: var(--muted); }
.so-ph-dots { display: flex; justify-content: center; gap: 4px; padding: 6px 0 0; min-height: 12px; }
.so-ph-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.so-ph-dots i.on { background: var(--accent); }
.so-ph-acts { padding: 4px 12px; font-size: 1.1rem; letter-spacing: 6px; }
.so-ph-cap { padding: 0 12px 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.so-ph-cap .tag { color: var(--accent); }
.so-ph-cap .more { color: var(--muted); cursor: pointer; }

/* Platforms */
.so-scroll { overflow-x: auto; max-width: 100%; }
.so-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.so-table th, .so-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.so-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.so-table .n { text-align: right; font-variant-numeric: tabular-nums; }
.so-table .nw { white-space: nowrap; }
.so-table .good { color: var(--ok); }
.so-table .bad { color: var(--danger); }
.so-table .so-pill { margin-left: 6px; }
.so-pf-cards { display: flex; flex-direction: column; gap: 10px; }
details.so-pfcard > summary { cursor: pointer; list-style: none; display: flex; align-items: flex-start; gap: 10px; }
details.so-pfcard > summary::-webkit-details-marker { display: none; }
details.so-pfcard > summary h2 { flex: 1; min-width: 0; }
.so-pfsub { display: block; margin-top: 2px; font-weight: 500; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.so-facts { display: grid; gap: 10px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin: 0; }
.so-facts dt { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.so-facts dd { margin: 2px 0 0; font-size: 0.88rem; }
.so-pfset { display: flex; gap: 12px 20px; flex-wrap: wrap; align-items: flex-end; }
.so-pfset .so-field { min-width: min(100%, 220px); }
.so-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.so-keys { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.so-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.88rem; }
.so-url { display: flex; gap: 8px; min-width: 0; }
.so-url input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.so-keyform { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.so-keyform .so-btns { grid-column: 1 / -1; }
.so-keyform .so-pill { margin-left: 0; }

/* Hashtags */
.so-tagadd { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 320px; min-width: 0; }
.so-tagadd input { flex: 1 1 180px; width: auto; }
.so-spark { width: 98px; height: 20px; display: block; }
.so-spark rect.bar { fill: var(--accent); }
.so-spark rect.none { fill: var(--line); }
.so-src { margin-top: 6px; font-size: 0.88rem; }
.so-src.off { color: var(--muted); }

/* narrow: the editor in one column, the cards stacked */
@media (max-width: 760px) {
  .so-dbody { grid-template-columns: minmax(0, 1fr); }
  .so-preview { position: static; }
}
@media (max-width: 560px) {
  .so-panel { padding: 14px; }
  .so-dmain { grid-template-columns: minmax(0, 1fr); }
  .so-card { grid-template-columns: 64px minmax(0, 1fr); padding: 12px 14px; }
  .so-thumb { width: 64px; height: 80px; grid-row: span 1; }
  .so-acts { grid-column: 2; justify-content: flex-start; }
  details.so-group > summary { padding: 12px 14px; }
  .so-needs { margin-left: 0; flex-basis: 100%; }
  .so-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .so-num { padding: 10px 11px; }
  .so-num-f b { font-size: 1.3rem; }
  .so-best li { flex-direction: column; align-items: flex-start; gap: 4px; }
  .so-best li b { min-width: 0; }
  .so-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .so-dhead, .so-dfoot, .so-dbody { padding-left: 14px; padding-right: 14px; }
  .so-table .opt { display: none; }
}
