/* ===========================================================================
   CASE CONSENSUS — the Feed (Consult Thread)
   Social feed UI for multi-LLM second opinions. Faithfully ported from the
   chosen design mockup (design/second-opinions/1-consult-thread.html) onto the
   live Calm-Paper "Plum Dusk" tokens.

   The :root tokens (--accent, --paper, --ink*, --line, --cp-card, fonts) come
   from calm_paper.css, which is already @imported into the Tailwind build, so
   they are available globally. Provider-identity tokens live here.

   Everything is `cc-`prefixed and scoped under `.cc-page` so it can never
   collide with the app-wide `.card` / `.chip` / `.btn` primitives.
   =========================================================================== */
:root {
  /* Provider identity — small accents only; plum stays dominant. */
  --cc-p-openai:    #1f8f74;
  --cc-p-anthropic: #b8623f;
  --cc-p-google:    #4a6fa5;
  --cc-p-xai:       #2b2b33;
  --cc-p-deepseek:  #5a51c4;
  --cc-p-mistral:   #b9952f;
}

/* ---- page shell -------------------------------------------------------- */
.cc-page {
  position: relative;
  min-height: 70vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 620px at 8% -8%, rgba(122, 62, 134, 0.10), transparent 60%),
    radial-gradient(1000px 720px at 102% -2%, rgba(74, 111, 165, 0.07), transparent 55%),
    radial-gradient(900px 700px at 50% 120%, rgba(46, 139, 116, 0.05), transparent 60%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* faint paper grain */
.cc-page::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}
.cc-page > * { position: relative; z-index: 1; }

/* ---- typographic primitives ------------------------------------------- */
.cc-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cc-serif { font-family: var(--font-display); font-weight: 400; }
.cc-mono  { font-family: var(--font-mono); }

/* ---- buttons ----------------------------------------------------------- */
.cc-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  background: var(--accent); color: var(--paper);
  border: 1px solid var(--accent);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background .2s, transform .2s, border-color .2s, box-shadow .2s;
}
.cc-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); }
.cc-btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.cc-btn--ghost:hover { background: rgba(11, 11, 20, .04); border-color: rgba(11, 11, 20, .2); }
.cc-btn--sm { padding: 7px 14px; font-size: 13px; }
.cc-btn svg { width: 15px; height: 15px; }
.cc-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ---- card + rule ------------------------------------------------------- */
.cc-card {
  background: var(--cp-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.cc-rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---- avatars ----------------------------------------------------------- */
.cc-pa {
  --p: var(--accent);
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  color: #fff; letter-spacing: .02em;
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--p), white 16%),
    color-mix(in srgb, var(--p), black 16%));
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--p) 80%, transparent);
}
.cc-pa--sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }

.cc-ha {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 14px;
  color: var(--ink-soft); background: var(--paper-2);
  border: 1px solid var(--line);
}

/* ---- chips / tags ------------------------------------------------------ */
.cc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--cp-card);
  font-size: 12.5px; color: var(--ink-soft); white-space: nowrap;
}
.cc-chip .k { color: var(--ink-faint); font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; }
.cc-chip .v { font-weight: 500; color: var(--ink); }
.cc-chip--warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.cc-chip--warn .v { color: var(--warn); }
.cc-chip--bad  { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.cc-chip--bad .v { color: var(--bad); }

.cc-tag {
  display: inline-flex; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
  text-decoration: none;
}
.cc-tag:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* ---- confidence pill --------------------------------------------------- */
.cc-conf {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-mute);
}
.cc-conf .bar { width: 54px; height: 5px; border-radius: 999px; background: var(--paper-inset); overflow: hidden; }
.cc-conf .bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ======================================================================== */
/*  FEED                                                                     */
/* ======================================================================== */
.cc-feed { max-width: 720px; margin: 0 auto; padding: 28px 20px 96px; }

.cc-feed__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.cc-feed__head .cc-kicker { margin-bottom: 6px; }
.cc-feed__head h1 { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; font-size: 30px; margin: 0; }
.cc-feed__head p { margin: 4px 0 0; color: var(--ink-mute); font-size: 13.5px; }

.cc-empty {
  margin-top: 8px; padding: 40px 24px; text-align: center;
  color: var(--ink-mute); font-size: 14px;
}
.cc-empty a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.cc-morelink { display: block; text-align: center; margin-top: 18px; color: var(--ink-mute); font-size: 13px; text-decoration: none; }
.cc-morelink:hover { color: var(--accent); }

/* ---- the case "post" --------------------------------------------------- */
.cc-post { margin-bottom: 26px; overflow: hidden; }

/* a feed post is a link to the thread — keep it feeling like a card, not a link */
a.cc-post { display: block; color: inherit; text-decoration: none; transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .22s ease, border-color .22s; }
a.cc-post:hover { transform: translateY(-3px); box-shadow: 0 26px 52px -34px rgba(26, 22, 32, .5); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); }

.cc-post__head { display: flex; align-items: center; gap: 13px; padding: 18px 20px 12px; }
.cc-post__who { line-height: 1.3; min-width: 0; }
.cc-post__who .name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.cc-post__who .verified { color: var(--accent); font-size: 13px; }
.cc-post__who .meta { font-size: 12.5px; color: var(--ink-mute); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.cc-post__menu { margin-left: auto; color: var(--ink-faint); font-size: 20px; letter-spacing: 2px; align-self: flex-start; }

.cc-post__body { padding: 0 20px 4px; }
.cc-post__title { font-family: var(--font-display); font-weight: 400; font-size: 22px; line-height: 1.25; margin: 2px 0 10px; color: var(--ink); }
.cc-post__prose { font-size: 15px; color: var(--ink-soft); line-height: 1.62; white-space: pre-line; margin: 0; }
.cc-post__prose b, .cc-post__prose strong { color: var(--ink); font-weight: 600; }

.cc-vitals { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }

.cc-attach {
  margin: 14px 0 6px; display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px dashed var(--rule); border-radius: 14px; background: var(--paper);
}
.cc-attach .glyph { width: 38px; height: 38px; border-radius: 10px; background: var(--paper-2); display: grid; place-items: center; font-size: 18px; }
.cc-attach .t { font-size: 13.5px; font-weight: 500; }
.cc-attach .s { font-size: 12px; color: var(--ink-mute); }

.cc-tags { display: flex; gap: 7px; flex-wrap: wrap; padding: 12px 20px 4px; }

/* counts + action row */
.cc-counts { display: flex; align-items: center; gap: 14px; padding: 12px 20px; color: var(--ink-mute); font-size: 13px; flex-wrap: wrap; }
.cc-counts b { color: var(--ink); font-weight: 600; }
.cc-stack { display: flex; }
.cc-stack .cc-pa { width: 26px; height: 26px; border-radius: 8px; font-size: 9px; box-shadow: 0 0 0 2px var(--cp-card); margin-left: -7px; }
.cc-stack .cc-pa:first-child { margin-left: 0; }

.cc-actions { display: flex; padding: 6px 12px; gap: 4px; }
.cc-act {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: 12px; background: transparent; border: 0; cursor: pointer;
  color: var(--ink-mute); font: inherit; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.cc-act:hover { background: var(--accent-soft); color: var(--accent); }
.cc-act svg { width: 17px; height: 17px; }

/* ---- consensus banner -------------------------------------------------- */
.cc-consensus {
  margin: 4px 20px 0; padding: 13px 16px; border-radius: 14px;
  background: linear-gradient(120deg, var(--accent-soft), color-mix(in srgb, var(--mode-5) 6%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  display: flex; gap: 12px; align-items: center;
}
.cc-consensus .ring {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  background: conic-gradient(var(--accent) 0 var(--pct, 70%), var(--paper-inset) 0 100%);
  display: grid; place-items: center; position: relative;
}
.cc-consensus .ring::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--cp-card); }
.cc-consensus .ring span { position: relative; z-index: 1; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.cc-consensus .t { min-width: 0; }
.cc-consensus .t .k { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.cc-consensus .t .d { font-family: var(--font-display); font-size: 17px; color: var(--ink); }
.cc-consensus .t .d em { color: var(--ink-mute); font-style: italic; }
.cc-consensus .t .diverge { margin-top: 3px; font-size: 12px; color: var(--warn); }

/* the "weighing in" / failed states */
.cc-consensus--pending { background: var(--paper); border-color: var(--line); color: var(--ink-mute); font-size: 13.5px; }
.cc-consensus--failed  { background: color-mix(in srgb, var(--bad) 6%, var(--paper)); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); color: var(--bad); font-size: 13.5px; }
.cc-pulse { animation: cc-pulse 1.4s ease-in-out infinite; }
@keyframes cc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ======================================================================== */
/*  THREAD — model replies = comments                                        */
/* ======================================================================== */
.cc-comments { padding: 6px 12px 16px; }
.cc-comments__bar { display: flex; align-items: center; gap: 10px; padding: 14px 8px 8px; }
.cc-comments__bar .cc-kicker { color: var(--ink-mute); }
.cc-comments__bar .pick { margin-left: auto; font-size: 13px; color: var(--ink-mute); }

.cc-cm { display: flex; gap: 12px; padding: 12px 8px; }
.cc-cm__body { flex: 1; min-width: 0; }
.cc-cm__bubble {
  --p: var(--accent);
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 16px; position: relative;
  border-left: 3px solid color-mix(in srgb, var(--p) 60%, var(--line));
}
.cc-cm__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.cc-cm__name { font-weight: 600; font-size: 14px; }
.cc-cm__provider { font-size: 12px; color: var(--ink-mute); }
.cc-badge-model {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.cc-badge-diverge {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); font-weight: 600;
}
.cc-cm__time { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); font-family: var(--font-mono); }

.cc-cm__dx { font-size: 14.5px; line-height: 1.55; color: var(--ink-soft); }
.cc-cm__dx .lead { font-weight: 600; color: var(--ink); }
.cc-cm__dx .label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); display: block; margin-top: 9px; margin-bottom: 2px; }
.cc-cm__dx ul { margin: 2px 0 0; padding-left: 18px; color: var(--ink-soft); }
.cc-cm__dx li { margin: 2px 0; }
.cc-cm__meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.cc-cm__meta .diverge { font-size: 12px; color: var(--warn); font-weight: 500; }
.cc-cm__failed { font-size: 13px; color: var(--bad); }

/* a human reply */
.cc-cm--human .cc-cm__bubble { border-left: 3px solid var(--rule); background: color-mix(in srgb, var(--paper-2) 50%, var(--paper)); }
.cc-cm--human .cc-cm__dx { color: var(--ink-soft); }

/* reply composer */
.cc-composer { display: flex; gap: 12px; padding: 14px 8px 4px; align-items: center; }
.cc-composer input {
  flex: 1; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); font: inherit; font-size: 14px; color: var(--ink);
}
.cc-composer input::placeholder { color: var(--ink-faint); }
.cc-composer input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.cc-composer input:disabled { background: var(--paper); cursor: not-allowed; }

/* ---- thread page chrome ------------------------------------------------ */
.cc-thread { max-width: 720px; margin: 0 auto; padding: 22px 20px 96px; }
.cc-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-mute); text-decoration: none; margin-bottom: 16px; }
.cc-back:hover { color: var(--accent); }
.cc-disclaimer { margin-top: 22px; text-align: center; font-size: 11.5px; color: var(--ink-faint); }

/* ======================================================================== */
/*  NEW CASE FORM                                                            */
/* ======================================================================== */
.cc-form { max-width: 640px; margin: 0 auto; padding: 22px 20px 96px; }
.cc-form__head h1 { font-family: var(--font-display); font-weight: 400; font-size: 28px; margin: 6px 0 4px; }
.cc-form__head p { margin: 0; color: var(--ink-mute); font-size: 14px; }
.cc-note {
  margin: 18px 0; padding: 12px 16px; border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 0 12px 12px 0;
  font-size: 13px; color: color-mix(in srgb, var(--warn) 70%, var(--ink));
}
.cc-field { margin-bottom: 16px; }
.cc-field label { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.cc-input, .cc-textarea, .cc-select {
  width: 100%; padding: 11px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--cp-card);
  font: inherit; font-size: 14.5px; color: var(--ink);
}
.cc-textarea { border-radius: 16px; line-height: 1.55; resize: vertical; }
.cc-input:focus, .cc-textarea:focus, .cc-select:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 0 0 3px var(--accent-soft); }
.cc-grid3 { display: grid; gap: 14px; }
@media (min-width: 640px) { .cc-grid3 { grid-template-columns: repeat(3, 1fr); } }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 640px) {
  .cc-feed, .cc-thread { padding: 16px 12px 80px; }
  .cc-actions .cc-act span { display: none; }
  .cc-feed__head { flex-direction: column; align-items: flex-start; }
}
