/* ==========================================================================
   Sudota Intelligence — homepage inbox demo
   fig.1 · your ai-powered inbox. Two panes, like an email client:
   messages on the left (dark), the draft reader on the right (light).
   Sources live in hover tooltips only — no ledgers, no meters.
   ========================================================================== */

.console {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 560px;
  background: var(--panel);
  text-align: left;
}

/* --------------------------------------------------------------------------
   left pane — the inbox (dark)
   -------------------------------------------------------------------------- */
.inbox {
  display: flex;
  flex-direction: column;
  background: var(--inkband);
  color: #fff;
  min-width: 0;
}
.inbox__h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .72);
}
.inbox__h-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.inbox__h .num { color: #93C5FD; font-weight: 700; letter-spacing: 0; }
.inbox__list { flex: 1; overflow-y: auto; }

.mitem {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  padding: 13px 16px 14px;
  background: none;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
  cursor: pointer;
  transition: background .18s var(--ease-out);
}
.mitem:hover { background: rgba(255, 255, 255, .05); }
.mitem[aria-current="true"] { background: rgba(255, 255, 255, .08); }
.mitem[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--volt);
}
.mitem__av {
  width: 30px; height: 30px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #fff;
}
.mitem__who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mitem__name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mitem__ch {
  flex: none;
  font-size: 9px;
  letter-spacing: .1em;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  color: rgba(255, 255, 255, .78);
}
.mitem__text {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mitem__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.mitem__id {
  font-size: 9.5px;
  color: rgba(255, 255, 255, .68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.qstate {
  font-size: 9px;
  letter-spacing: .12em;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, .32);
  color: rgba(255, 255, 255, .78);
}
.qstate[data-state="drafted"] { border-color: #93C5FD; color: #93C5FD; }
.qstate[data-state="posted"]  { border-color: #7fd18b; color: #7fd18b; }

.inbox__foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, .14);
  font-size: 10.5px;
  color: rgba(255, 255, 255, .75);
}

/* --------------------------------------------------------------------------
   right pane — the draft reader
   -------------------------------------------------------------------------- */
.reader {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* top clearance keeps the header row below the floating LIVE pill */
  padding: 48px 22px 18px;
  min-width: 0;
}
.reader__h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.reader__who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.reader__av {
  flex: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.reader__who > div { min-width: 0; }
.reader__who b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader__post {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  flex: none;
  font-size: 10px;
  letter-spacing: .08em;
  padding: 3px 10px;
  border: 1px solid var(--line);
  color: var(--muted-2);
  white-space: nowrap;
}
.status[data-tone="run"]  { border-color: var(--volt); color: var(--volt); }
.status[data-tone="ok"]   { border-color: var(--pass); color: var(--pass-ink); }
.status[data-tone="warn"] { border-color: var(--fail); color: var(--fail); }

.reader__comment {
  padding: 12px 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 2px solid var(--volt);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
}

.reader__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  font-size: 10.5px;
  color: var(--muted);
}
.reader__meta b { color: var(--ink); font-weight: 600; }

/* sources pill — the whole ledger lives in its hover tooltip */
.srcpill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 10.5px;
  color: var(--muted-2);
  cursor: help;
  transition: border-color .15s, color .15s;
}
.srcpill:hover, .srcpill:focus-visible { border-color: var(--ink); color: var(--ink); outline: none; }
.srcpill b { color: var(--volt); font-weight: 700; }

/* pipeline rail */
.pipe {
  display: flex;
  padding: 6px 2px 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.pipe__node { position: relative; flex: 1; min-width: 92px; padding: 16px 10px 0 0; }
.pipe__node::before {
  content: "";
  position: absolute;
  top: 5px; left: 0; right: 0;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
}
.pipe__node::after {
  content: "";
  position: absolute;
  top: 2px; left: 0;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--line);
  transition: background .2s, box-shadow .2s;
}
.pipe__node.is-active::after { background: var(--volt); box-shadow: 0 0 0 4px var(--volt-soft); }
.pipe__node.is-done::after { background: var(--volt); }
.pipe__node.is-done::before { background: var(--volt); }
.pipe__node.is-skip::after { background: var(--muted-faint); }
.pipe__node.is-skip::before { background: var(--muted-faint); opacity: .4; }
.pipe__name { font-size: 11px; font-weight: 600; color: var(--muted); }
.pipe__node.is-done .pipe__name,
.pipe__node.is-active .pipe__name { color: var(--ink); }
.pipe__out { display: block; margin-top: 3px; min-height: 15px; font-size: 10px; color: var(--muted-2); }
.pipe__node.is-skip .pipe__out { font-style: italic; color: var(--muted); }

/* draft card */
.draft {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 15px 18px 16px;
}
.draft__h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--muted);
}
.draft__toggles { display: inline-flex; align-items: center; gap: 8px; }

/* segmented toggles — language + model */
.seg { display: grid; grid-template-columns: repeat(2, auto); border: 1px solid var(--line); background: var(--panel); }
.seg--lang { grid-template-columns: repeat(3, auto); }
.seg { border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  padding: 6px 11px;
  background: none;
  border: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.reply {
  margin-top: 12px;
  flex: 1;
  min-height: 168px;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--ink-2);
  transition: background .3s var(--ease-out);
}
.draft.is-typing .reply { background: var(--volt-soft); }

.caret {
  display: inline-block;
  width: 8px; height: 15px;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--volt);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* citation chips — semantic hues, tooltip on hover */
.cite-ref {
  display: inline-grid;
  place-items: center;
  min-width: 15px; height: 15px;
  margin: 0 1px;
  padding: 0 3px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  vertical-align: super;
  cursor: help;
  transition: box-shadow .15s;
}
.cite-ref[data-type="kb"]      { color: var(--cite-kb); }
.cite-ref[data-type="voice"]   { color: var(--cite-voice); }
.cite-ref[data-type="playbook"]{ color: var(--cite-play); }
.cite-ref[data-type="web"]     { color: var(--cite-web); }
.cite-ref.is-lit { box-shadow: 0 0 0 3px var(--volt-soft); }
.cite-ref.is-pop { animation: pop .3s var(--ease-out); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.draft__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 16px; }
.draft__actions .btn[disabled] { opacity: .38; pointer-events: none; }

/* tooltip — hosted by the reader pane */
.tip {
  position: absolute;
  z-index: 20;
  width: 280px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  transition: opacity .16s var(--ease-out), transform .16s var(--ease-out);
}
.tip.is-on { opacity: 1; transform: none; }
.tip__k { font-size: 9px; letter-spacing: .14em; font-weight: 700; color: var(--muted-2); }
.tip[data-type="kb"]       .tip__k { color: var(--cite-kb); }
.tip[data-type="voice"]    .tip__k { color: var(--cite-voice); }
.tip[data-type="playbook"] .tip__k { color: var(--cite-play); }
.tip[data-type="web"]      .tip__k { color: var(--cite-web); }
.tip__body { display: block; margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--ink); }
.tip__q { display: block; margin-top: 6px; font-size: 11px; line-height: 1.65; color: var(--muted-2); }
.tip__rows { display: block; margin-top: 4px; }
.tip__row { display: flex; gap: 8px; align-items: flex-start; margin-top: 7px; }
.tip__n {
  flex: none;
  width: 16px; height: 16px;
  margin-top: 1px;
  border-radius: 4px;
  background: var(--cite-kb);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
}
.tip__n[data-type="voice"]    { background: var(--cite-voice); }
.tip__n[data-type="playbook"] { background: var(--cite-play); }
.tip__n[data-type="web"]      { background: var(--cite-web); }
.tip__rt { font-size: 11px; line-height: 1.5; color: var(--muted-2); }
.reader { position: relative; }

.toast {
  position: absolute;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 8;
  padding: 12px 14px;
  background: var(--inkband);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.toast.is-on { opacity: 1; transform: none; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .console { grid-template-columns: 250px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .console { grid-template-columns: 1fr; min-height: 0; }
  .inbox { max-height: 262px; }
  .reader { border-top: 1px solid var(--line); padding: 18px 16px 16px; }
  .reader__h { flex-wrap: wrap; }
  /* Six stages at a 92px minimum do not fit a 342px shell, so the rail used
     to clip mid-node behind a sideways scroll with no affordance. Wrap it to
     a 3x2 grid: every stage is visible and nothing is cut off. */
  .pipe {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px 12px;
    overflow: visible;
  }
  .pipe__node { min-width: 0; padding-right: 0; }
  .pipe__node::before { right: -12px; }
  .pipe__node:nth-child(3n)::before { right: 0; }
  .pipe__out { min-height: 18px; }
  .tip { width: 240px; }
}

/* --------------------------------------------------------------------------
   Touch ergonomics — 44px targets and a 12px type floor
   (WCAG 2.2 SC 2.5.8 / WCAG 1.4.3). Coarse pointers only, so the desktop
   console keeps its density.
   -------------------------------------------------------------------------- */
@media (pointer: coarse) {
  .mitem { padding: 15px 16px 16px; }
  .seg button { min-height: 44px; padding: 10px 14px; }
  .srcpill { min-height: 44px; padding: 10px 14px; }
  .draft__actions .btn { min-height: 44px; }
  /* citation markers stay inline, so they grow inside the existing line box
     (.reply is 13.5px x 1.95 = 26px) rather than pushing the draft taller */
  .cite-ref { min-width: 19px; height: 19px; font-size: 12px; }
  .tip__n { width: 18px; height: 18px; font-size: 11px; }
  .inbox__h, .inbox__foot, .reader__post, .reader__meta, .srcpill, .draft__h, .seg button,
  .pipe__name, .pipe__out, .mitem__text, .mitem__id, .mitem__ch, .qstate,
  .tip__k, .tip__body, .tip__q, .tip__rt, .status { font-size: 12px; }
  .tip { width: min(300px, calc(100vw - 48px)); }
}
