/* MedAI 資訊 — the feed page (feed.js). Shares digest.css (variables, .dg-prose, buttons,
 * modal, login card, toast) with the 日报; this file is only what the feed adds: post
 * cards, their attachments, the composer, the lightbox and the preview modal. */
.feed-main { max-width: 820px; }
.feed-layout { padding-top: 4px; }
.feed-home { display: none; }
[data-feed-post] .feed-home { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--fg); text-decoration: none; }
/* the page head sits on the column(s) it heads */
.tools.feed-tools { max-width: 820px; padding-top: 22px; align-items: flex-end; }
.feed-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 750; letter-spacing: .01em; }
.feed-tagline { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.feed-tools-left { min-width: 0; flex: 1; }
.feed-new { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 4px; }
.feed-search { display: flex; gap: 8px; margin-bottom: 10px; }
.feed-search input { min-width: 0; flex: 1; height: 38px; background: var(--surface); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 14px; font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.feed-search input:focus, .feed-time input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.feed-search .btn { height: 38px; }

.feed-controls, .feed-desktop, .feed-pager { display: flex; align-items: center; gap: 8px; }
.feed-controls { justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 16px; font-size: 13px; }
.feed-calendar { position: relative; }
.feed-calendar-toggle {
  position: relative; display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.feed-calendar-toggle:hover, .feed-calendar-toggle[aria-expanded="true"], .feed-calendar-toggle[data-active] {
  background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--brand);
}
.feed-calendar-toggle[data-active]::after {
  content: ''; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.feed-calendar-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.feed-calendar-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.feed-time {
  position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; display: grid; gap: 10px;
  width: min(270px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}
.feed-time input { min-width: 0; width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--fg); padding: 0 9px; font: inherit; }
.feed-time-actions { display: flex; justify-content: flex-end; gap: 8px; }
.feed-time .btn { height: 34px; padding: 0 12px; font-size: 13px; flex: none; }
.feed-desktop { display: none; margin-left: auto; gap: 10px; }
/* segmented switches (单列/双列, 瀑布/翻页): same look as the bar's language switch */
.seg { display: inline-flex; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); flex: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 0 11px; border-radius: 7px;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.seg svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.feed-pager { justify-content: center; padding: 18px 0 6px; }
.feed-pager #feedPage { min-width: 64px; text-align: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.feed-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
@media (min-width: 900px) {
  .feed-desktop { display: flex; }
  [data-feed-columns="two"] .feed-main, [data-feed-columns="two"] .tools.feed-tools { max-width: 1240px; }
  [data-feed-columns="two"] .feed-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.post {
  background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 20px 24px 16px;
  box-shadow: var(--shadow); min-width: 0;
  content-visibility: auto; contain-intrinsic-block-size: auto 320px;
  transition: border-color .16s ease;
}
.post:hover { border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); }
.post-h { display: flex; align-items: center; gap: 10px; min-width: 0; }
.post-av {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); overflow: hidden;
  font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; font-size: 14px;
}
.post-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-who { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.post-who b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-who .sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 4px 6px; flex-wrap: wrap; align-items: center; }
.post-who .sub .posted::before, .post-who .sub .edited::before { content: '·'; margin-right: 6px; opacity: .55; }
.post-who .bot { font-size: 11px; padding: 0 6px; line-height: 18px; border-radius: 999px; background: var(--surface-2); color: var(--fg-2); font-weight: 600; }
.post-tools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.post-title { margin: 12px 0 0; font-size: 20px; line-height: 1.38; font-weight: 700; overflow-wrap: anywhere; text-wrap: pretty; }
.post-body { margin-top: 10px; min-width: 0; }
.post-body.dg-prose > :first-child { margin-top: 0; }
.post-body.dg-prose > :last-child { margin-bottom: 0; }
.post-body.dg-prose h1 { font-size: 19px; }
.post-tags { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.ed-announcement { display: flex; align-items: center; gap: 7px; color: var(--fg-2); font-size: 14px; }
.feed-ed-form > .ed-announcement { align-self: end; min-height: 38px; cursor: pointer; }
.ed-announcement input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.feed-ed-form > .ed-language { grid-column: 1 / -1; }
.ed-split > .ed-f:last-child .ed-preview { flex: 1; }

/* attachments: a picture block by count, then a file list */
.post-atts { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.pf-grid { display: grid; gap: 4px; border-radius: 12px; overflow: hidden; }
.pf-img { position: relative; display: block; overflow: hidden; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 1; }
.pf-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.pf-img:hover img { transform: scale(1.02); }
.pf-grid.n1 .pf-img { aspect-ratio: 16 / 9; max-height: 460px; }
.pf-grid.n1 { justify-items: start; border-radius: 0; }
.pf-grid.n1 .pf-img { border-radius: 12px; max-width: 100%; }
.pf-grid.n2 { grid-template-columns: 1fr 1fr; }
.pf-grid.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.pf-grid.n3 .pf-img { aspect-ratio: auto; }
.pf-grid.n3 .pf-img:first-child { grid-row: span 2; }
.pf-grid.n4 { grid-template-columns: 1fr 1fr; }
.pf-grid.n4 .pf-img { aspect-ratio: 4 / 3; }
.pf-grid.n5 { grid-template-columns: repeat(3, 1fr); }
.pf-rest {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 20, .5); color: #fff; font-size: 22px; font-weight: 700; letter-spacing: .02em;
}
.pf-list { display: flex; flex-direction: column; gap: 6px; }
.pf-card {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); min-width: 0; transition: border-color .15s, background-color .15s;
}
.pf-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); background: var(--surface); }
.pf-ico {
  width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px; background: var(--brand-soft); color: var(--brand); flex: none; letter-spacing: .02em;
}
.pf-meta { min-width: 0; flex: 1 1 150px; }
.pf-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-size { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pf-actions { display: flex; gap: 6px; flex: none; margin-left: auto; }
.pf-btn {
  height: 30px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--fg-2); text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap;
  transition: border-color .14s, color .14s, background-color .14s;
}
.pf-btn:hover { border-color: var(--brand); color: var(--fg); background: var(--brand-soft); text-decoration: none; }
.post-sentinel { height: 1px; }
.feed-end { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0 6px; }
.feed-loading { padding: 18px 0 6px; }

/* ── composer ─────────────────────────────────────────────────────────── */
.feed-editor .modal-card { width: min(1100px, 100%); }
.feed-ed-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ed-format { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface); align-self: flex-start; }
.ed-format button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--muted); }
.ed-format button.on { background: var(--brand); color: #fff; font-weight: 600; }
.ed-drop {
  grid-column: 1 / -1; border: 1.5px dashed var(--line); border-radius: 10px; padding: 12px 14px; display: flex;
  flex-wrap: wrap; gap: 10px; align-items: center; cursor: pointer; min-height: 56px; color: var(--fg-2); font-size: 13.5px;
}
.ed-drop.over { border-color: var(--brand); background: var(--brand-soft); }
.ed-drop .link { color: var(--link); font-weight: 600; }
.ed-drop .hint { color: var(--muted); font-size: 12.5px; width: 100%; }
.ed-atts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.ed-att {
  position: relative; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px; display: flex; gap: 8px;
  align-items: center; min-width: 0; background: var(--surface);
}
.ed-att img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; }
.ed-att .pf-meta { min-width: 0; }
.ed-att .st { font-size: 11.5px; color: var(--muted); }
.ed-att.err .st { color: var(--down); }
.ed-att-x {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--fg-2); cursor: pointer; font-size: 12px; line-height: 1; padding: 0;
}
.ed-att-x:hover { color: var(--down); }
.ed-hint-row { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* ── lightbox ─────────────────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8, 10, 14, .92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: calc(100% - 40px); object-fit: contain; border-radius: 6px; }
.lb-btn {
  position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1;
}
.lb-btn:hover { background: rgba(255, 255, 255, .22); }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-cap { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .8); font-size: 13px; padding: 0 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── preview modal (PDF in a frame, markdown / text as html) ──────────── */
.feed-preview-card { width: min(1000px, 100%); height: min(88vh, 900px); }
.feed-preview-card .modal-b { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.feed-preview-card iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.feed-preview-card .pv-html { flex: 1; overflow: auto; padding: 18px 24px 24px; }
.pv-html.dg-prose { font-size: 15px; }
.dg-pre {
  white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 13px; line-height: 1.6;
  background: var(--surface-2); padding: 12px 14px; border-radius: 10px; margin: 0;
}

@media (max-width: 720px) {
  .feed-main { padding-top: 14px; }
  .tools.feed-tools { padding-top: 14px; }
  .feed-title { font-size: 21px; }
  .feed-tagline { font-size: 13px; }
  .feed-controls { margin-bottom: 12px; }
  .post { padding: 16px 14px 10px; border-radius: 14px; }
  .post-title { font-size: 18px; }
  .feed-ed-form { grid-template-columns: minmax(0, 1fr); }
  .ed-split { grid-template-columns: minmax(0, 1fr); }
  .lightbox { padding: 8px; }
  .lb-btn { width: 38px; height: 38px; }
}
.pf-img.broken { display: none; }
.pv-tools { display: flex; align-items: center; gap: 8px; }
.pv-tools .btn { height: 32px; font-size: 13px; padding: 0 12px; text-decoration: none; }
@media (max-width: 360px) {
  .feed-main, .tools.feed-tools { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 768px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select { font-size: 16px !important; }
}
