:root {
  --bg: #0b0e14;
  --panel: #11161f;
  --panel-2: #161c28;
  --border: #232b3a;
  --border-2: #2e3849;
  --text: #e6e9ef;
  --muted: #8b95a8;
  --accent: #4f8cff;
  --accent-2: #3a74e6;
  --gold: #f2b84b;
  --ok: #3ecf8e;
  --err: #ff6b6b;
  --radius: 12px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, .control { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 9px 16px; background: var(--panel-2); transition: background .15s, opacity .15s, transform .05s; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .control:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #fff; font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-2); }
.ghost { background: transparent; border: 1px solid var(--border-2); }
.ghost:hover { background: var(--panel-2); }
.pill { border-radius: 999px; padding: 7px 14px; font-size: 14px; border: 1px solid var(--border-2); }
.pill.connected { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); }
.control { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.control:hover { border-color: var(--border-2); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1080px; margin: 0 auto; padding: 20px var(--gutter) 8px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 13px; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #8b5cf6); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 9px 10px; background: var(--bg); clip-path: polygon(50% 0, 100% 18%, 100% 52%, 50% 100%, 0 52%, 0 18%); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* paste */
.paste { max-width: 1080px; margin: 0 auto; padding: 8px var(--gutter); }
.paste form { display: flex; gap: 8px; }
.paste input { flex: 1; padding: 12px 14px; }

/* sticky toolbar */
.toolbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; max-width: 1080px; margin: 0 auto; padding: 10px var(--gutter); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.toolbar #jump { font-weight: 600; }
.toolbar #search { flex: 1; min-width: 160px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); user-select: none; }
#count { font-size: 13px; margin-left: auto; }

/* sections */
main { max-width: 1080px; margin: 0 auto; padding: 8px var(--gutter) 80px; }
.section { margin-top: 26px; }
.section h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 10px; letter-spacing: .01em; }
.section h2 .n { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); border-radius: 999px; padding: 1px 9px; }
.section.top-picks h2 { color: var(--gold); }
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.item { display: flex; gap: 14px; align-items: flex-start; padding: 13px 16px; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item:hover { background: var(--panel-2); }
.item-main { flex: 1; min-width: 0; }
.item .title { text-decoration: none; font-weight: 550; overflow-wrap: anywhere; }
.item .title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.meta { font-size: 13px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.item .orig { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; overflow-wrap: anywhere; }
.why { font-size: 13px; color: var(--gold); margin-top: 5px; }
.why::before { content: "★ "; }
.cat-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--border-2); border-radius: 6px; padding: 0 6px; margin-right: 6px; }
.actions { flex: none; }
.post-btn { padding: 7px 14px; font-size: 14px; font-weight: 600; background: color-mix(in srgb, var(--accent) 16%, transparent); color: #a9c6ff; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.post-btn:hover { background: var(--accent); color: #fff; }
.posted { display: inline-block; font-size: 13px; color: var(--ok); text-decoration: none; padding: 7px 4px; white-space: nowrap; }
details.section summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details.section .list { margin-top: 10px; }
.empty { max-width: 640px; margin: 60px auto; text-align: center; padding: 0 var(--gutter); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border-2); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--err); color: var(--err); }

/* dialogs */
dialog { padding: 0; border: 1px solid var(--border-2); border-radius: 16px; background: var(--panel); color: var(--text); width: min(1040px, calc(100% - 24px)); max-height: calc(100% - 24px); }
dialog::backdrop { background: rgba(3, 5, 10, .72); backdrop-filter: blur(3px); }
#keydlg { width: min(440px, calc(100% - 24px)); }
.modal { display: flex; flex-direction: column; max-height: calc(100vh - 26px); }
.small-modal { padding: 22px; gap: 10px; }
.small-modal h2 { margin: 0; font-size: 18px; }
.small-modal p { margin: 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-head { display: flex; align-items: baseline; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; flex: none; }
#source-link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { background: transparent; font-size: 22px; line-height: 1; padding: 2px 8px; color: var(--muted); }
.icon:hover { color: var(--text); background: var(--panel-2); }
.loading { display: flex; align-items: center; gap: 12px; padding: 48px 20px; justify-content: center; color: var(--muted); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.error { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); border: 1px solid color-mix(in srgb, var(--err) 35%, transparent); border-radius: 10px; padding: 10px 14px; margin: 16px 20px; font-size: 14px; }
.small-modal .error { margin: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 16px 20px; overflow: auto; }
.tools { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.tool { padding: 5px 11px; background: var(--panel-2); border: 1px solid var(--border); }
.tool.wide { margin-left: 4px; }
#chars { margin-left: auto; }
#chars.over { color: var(--err); }
#draft { width: 100%; min-height: 420px; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.editor p { margin: 8px 0 0; }
.label { margin: 4px 0 8px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
#pub-status { flex: 1; min-width: 0; }
#pub-status.ok { color: var(--ok); }
#pub-status.err { color: var(--err); }
#pub-status a { color: var(--accent); }

/* LinkedIn-style preview (light, like the real feed) */
.li-post { background: #fff; color: rgba(0, 0, 0, .9); border-radius: 10px; overflow: hidden; font: 14px/1.43 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.li-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px 4px; }
.li-head img, .avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar { display: grid; place-items: center; background: #0a66c2; color: #fff; font-weight: 700; }
.li-head div { display: flex; flex-direction: column; }
.li-head .muted { color: rgba(0, 0, 0, .6); }
.li-text { padding: 8px 14px 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 520px; overflow: auto; }
.li-card { display: block; text-decoration: none; background: #edf3f8; border-top: 1px solid #e0e0e0; }
.li-card img { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; }
.li-card-body { padding: 10px 14px; }
.li-card-title { font-weight: 600; color: rgba(0, 0, 0, .9); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.li-card .muted { color: rgba(0, 0, 0, .6); }

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  #draft { min-height: 300px; }
  .paste form { flex-direction: column; }
  .item { flex-direction: column; gap: 8px; }
  #count { width: 100%; margin-left: 0; }
}
