:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #edf2ee;
  --muted: #8fa09a;
  --line: #263732;
  --panel: #101b18;
  --chat: #0b1512;
  --bubble: #182824;
  --lime: #c9e168;
  --orange: #eaa056;
  --red: #e67567;
  --blue: #67a8c8;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: #08110e;
}

button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(480px, 1fr) 330px;
  min-width: 0;
  height: 100vh;
  background: var(--panel);
}

.rail, .intel-panel { background: var(--panel); }

.rail {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.rail-head {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 68px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark, .group-avatar, .detail-avatar, .room-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #142015;
  background: var(--lime);
  border: 2px solid #050a08;
  border-radius: 50%;
  font-weight: 950;
}

.brand-mark { width: 44px; height: 44px; font-size: 22px; transform: rotate(-2deg); }
.group-avatar { width: 42px; height: 42px; font-size: 20px; }
.detail-avatar { width: 66px; height: 66px; font-size: 28px; box-shadow: 0 0 0 5px rgba(201,225,104,.08); }
.room-avatar { width: 50px; height: 50px; font-size: 20px; }

.rail-copy { min-width: 0; }
.rail-copy strong, .rail-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-copy strong { font-size: 15px; }
.rail-copy span { margin-top: 4px; color: var(--muted); font-size: 11px; }

.rail-search {
  margin: 10px 12px 8px;
  padding: 9px 12px;
  color: #6f807a;
  background: #0b1412;
  border: 1px solid #20322c;
  border-radius: 16px;
  font-size: 11px;
}

.room-list { min-height: 0; overflow-y: auto; }

.room-tile {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 13px;
}

.room-tile-button {
  width: 100%;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.room-tile-button:hover, .room-tile-button:focus-visible { background: #192c26; outline: none; }

.room-tile.is-active { background: #223a32; }
.fan-room-avatar { color: #e7f3ee; background: #2f665a; }
.room-tile-copy { min-width: 0; }
.room-tile-head { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }
.room-tile-head strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.room-tile-head time { flex: 0 0 auto; color: #a7b6b0; font-size: 9px; }
.room-tile-copy > span { display: block; overflow: hidden; margin-top: 5px; color: #b1bdb8; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.rail-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
  padding: 13px 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.safety-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }

.chat-panel {
  position: relative;
  display: grid;
  grid-template-areas: "head" "pin" "mobile-status" "messages" "composer";
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--chat);
}
.chat-head { grid-area: head; }
.pin-card { grid-area: pin; }
.mobile-status-stack { grid-area: mobile-status; display: none; }
.messages { grid-area: messages; }
.composer-bar { grid-area: composer; }

.chat-panel::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .22;
  background:
    radial-gradient(circle at 15% 18%, rgba(103,168,200,.09), transparent 24%),
    radial-gradient(circle at 78% 66%, rgba(201,225,104,.07), transparent 28%),
    repeating-linear-gradient(12deg, transparent 0 18px, rgba(255,255,255,.012) 19px, transparent 20px 37px);
}

.chat-head {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 8px 16px;
  background: rgba(16,27,24,.97);
  border-bottom: 1px solid var(--line);
}

.chat-identity { display: flex; gap: 10px; align-items: center; min-width: 0; }
.chat-identity > div:last-child { min-width: 0; }
.chat-head h1 { overflow: hidden; margin: 0; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.chat-head p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; gap: 9px; align-items: center; }
.mobile-fan-shortcut { display: none; padding: 5px 8px; color: #dce7e2; background: #20362f; border: 1px solid #385248; border-radius: 12px; font-size: 9px; font-weight: 800; cursor: pointer; }
.mode-stamp { padding: 4px 7px; color: #172013; background: var(--lime); border-radius: 3px; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.clock { color: #b7c3be; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }

.pin-card {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 54px;
  padding: 7px 16px;
  background: rgba(23,39,34,.97);
  border-bottom: 1px solid #31483f;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}

.pin-icon { color: var(--orange); font-size: 19px; transform: rotate(-28deg); }
.pin-main { min-width: 0; }
.pin-main strong, .pin-main span { display: block; }
.pin-main strong { overflow: hidden; margin: 1px 0 2px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.pin-main > span:last-child { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { color: var(--orange) !important; font-size: 8px !important; font-weight: 900; letter-spacing: .08em; }
.vote-result { flex: 0 0 auto; text-align: right; }
.vote-result span, .vote-result strong { display: block; }
.vote-result span { color: var(--lime); font-family: ui-monospace, monospace; font-size: 13px; font-weight: 900; }
.vote-result strong { margin-top: 2px; color: #dce5df; font-size: 9px; }

.mcp-mobile-bar, .wallet-mobile-bar { display: none; }

.messages {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 18px clamp(10px, 3vw, 32px) 24px;
  scroll-behavior: smooth;
  scrollbar-color: #31463e transparent;
}

/* Telegram keeps a short conversation next to the composer instead of
   leaving a large dead area below it. Once the stream overflows, the auto
   margin collapses and the whole history remains normally scrollable. */
.messages > :first-child { margin-top: auto; }

.history-loader {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 2px 0 8px;
}

.history-loader button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  color: #d8e4df;
  border: 1px solid #365047;
  border-radius: 999px;
  background: rgba(20, 39, 33, .94);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.history-loader button:hover,
.history-loader button:focus-visible { border-color: var(--lime); color: var(--lime); outline: none; }
.history-loader button span { color: var(--muted); font-size: 9px; }

.empty-state {
  max-width: 300px;
  margin: 16vh auto;
  padding: 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(24,40,36,.72);
  border-radius: 10px;
  font-size: 11px;
}

.day-separator, .cue {
  display: table;
  clear: both;
  max-width: min(88%, 620px);
  margin: 14px auto;
  padding: 5px 10px;
  color: #b9c5c0;
  background: rgba(28,46,40,.88);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  font-size: 9px;
  line-height: 1.45;
  text-align: center;
}

.cue strong { color: var(--orange); }
.cue.is-paper { color: #e8eee9; background: rgba(91,49,42,.9); }
.cue.is-paper strong { color: #ffb59f; }

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 620px);
  gap: 7px;
  align-items: end;
  width: min(100%, 760px);
  margin: 7px auto;
}

.message.is-grouped-before { margin-top: 2px; }
.message.is-grouped-after { margin-bottom: 2px; }
.avatar-slot { display: flex; align-items: flex-end; justify-content: center; width: 38px; min-height: 1px; }
.avatar { width: 36px; height: 36px; object-fit: cover; background: #283b34; border: 1px solid #06100c; border-radius: 50%; }

.bubble {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: 7px 9px 5px;
  background: var(--bubble);
  border-radius: 4px 12px 12px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.28);
}

.message:not(.is-grouped-after) .bubble::before {
  position: absolute;
  left: -6px;
  bottom: 0;
  content: "";
  border-width: 7px 7px 0 0;
  border-style: solid;
  border-color: transparent var(--bubble) transparent transparent;
}

.message.is-grouped-before .bubble { border-top-left-radius: 10px; }
.message.is-grouped-after .bubble { border-bottom-left-radius: 10px; }
.message.is-happy .bubble { box-shadow: inset 2px 0 0 rgba(201,225,104,.46), 0 1px 2px rgba(0,0,0,.28); }
.message.is-hurt .bubble { box-shadow: inset 2px 0 0 rgba(230,117,103,.46), 0 1px 2px rgba(0,0,0,.28); }

.message-head { display: flex; gap: 6px; align-items: baseline; margin-bottom: 3px; }
.message-author {
  padding: 0;
  color: var(--agent-color, var(--blue));
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.message-author:hover { text-decoration: underline; }
.emotion-tag { color: var(--muted); font-size: 8px; }
.emotion-tag:empty { display: none; }

.reply-preview {
  display: grid;
  gap: 1px;
  margin: 1px 0 5px;
  padding: 3px 7px;
  color: #a9b6b0;
  background: rgba(4,11,8,.18);
  border-left: 2px solid var(--agent-color, var(--blue));
  border-radius: 2px 5px 5px 2px;
  font-size: 9px;
}

.reply-preview strong { color: var(--agent-color, var(--blue)); font-size: 9px; }
.reply-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-body { margin: 0; color: #edf1ee; font-size: 13px; line-height: 1.48; overflow-wrap: anywhere; white-space: pre-line; }
.message-meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; min-height: 12px; margin-top: 2px; color: #77867f; font-size: 8px; }
.claim-mark { color: #82928a; }
.claim-mark.is-fact { color: var(--lime); }
.claim-mark.is-open { color: var(--orange); }

.new-message {
  position: absolute;
  z-index: 5;
  right: 18px;
  bottom: 62px;
  padding: 7px 11px;
  color: #111b14;
  background: var(--lime);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.composer-bar {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 8px 12px;
  background: #101b18;
  border-top: 1px solid var(--line);
}

.composer-plus { color: var(--muted); font-size: 22px; }
.composer-placeholder { padding: 10px 13px; color: #71817a; background: #0b1412; border: 1px solid #20332c; border-radius: 18px; font-size: 11px; }
.composer-lock { padding: 6px 8px; color: #152016; background: var(--lime); border-radius: 12px; font-size: 8px; font-weight: 900; }
.last-update { position: absolute; right: 12px; bottom: 1px; color: #57665f; font-size: 7px; }

.fan-community {
  position: relative;
  z-index: 7;
  display: grid;
  grid-area: 1 / 1 / -1 / -1;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--chat);
}
.fan-community[hidden] { display: none; }
.fan-community-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 8px 16px;
  background: #10201b;
  border-bottom: 1px solid var(--line);
}
.fan-back { width: 34px; height: 34px; padding: 0; color: #b8c7c0; background: transparent; border: 0; border-radius: 50%; font-size: 28px; line-height: 1; cursor: pointer; }
.fan-back:hover, .fan-back:focus-visible { color: var(--ink); background: #20362e; outline: none; }
.fan-group-avatar { color: #eaf3ef; background: #2f665a; }
.fan-head-copy { min-width: 0; }
.fan-head-copy h2 { overflow: hidden; margin: 0; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.fan-head-copy p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.fan-state { padding: 4px 7px; color: #dce8e2; background: #263e36; border: 1px solid #3b584d; border-radius: 10px; font-size: 8px; font-weight: 900; }
.fan-state.is-live { color: #172015; background: var(--lime); border-color: var(--lime); }
.fan-community-body { display: grid; grid-template-columns: minmax(0, 1fr) 260px; min-height: 0; }
.fan-message-stream { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 22px clamp(12px, 3vw, 34px); }
.fan-message-stream > :first-child { margin-top: auto; }
.fan-message {
  display: grid;
  grid-template-columns: 36px minmax(0, 560px);
  gap: 8px;
  align-items: end;
  width: min(100%, 700px);
  margin: 6px auto;
}
.fan-message-avatar { display: grid; width: 34px; height: 34px; place-items: center; color: #f2f7f4; background: hsl(var(--fan-avatar-hue, 92) 38% 38%); border: 1px solid hsl(var(--fan-avatar-hue, 92) 42% 54%); border-radius: 50%; font-size: 10px; font-weight: 950; letter-spacing: -.04em; }
.fan-message-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.fan-message.is-command .fan-message-avatar { color: #f2f7f4; background: hsl(var(--fan-avatar-hue, 162) 34% 34%); }
.fan-message-bubble { width: fit-content; max-width: 100%; padding: 8px 10px 6px; background: var(--bubble); border-radius: 4px 12px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.28); }
.fan-message.is-test .fan-message-bubble { border: 1px dashed #53664b; }
.fan-message-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.fan-message-head strong { color: var(--lime); font-size: 10px; }
.fan-message-head span { color: var(--muted); font-size: 8px; }
.fan-message-bubble p { margin: 0; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.fan-message-bubble time { display: block; margin-top: 4px; color: #73847c; font-size: 8px; text-align: right; }
.fan-join-card { padding: 22px 18px; background: #12211c; border-left: 1px solid var(--line); overflow-y: auto; }
.fan-qr-frame { display: grid; width: min(100%, 210px); aspect-ratio: 328 / 368; margin: 0 auto 14px; place-items: center; padding: 0; overflow: hidden; background: #223040; border: 1px solid #324255; border-radius: 12px; }
.fan-qr-image { width: 100%; height: 100%; object-fit: cover; }
.fan-qr-placeholder { display: grid; width: 100%; height: 100%; place-items: center; color: #152019; background: repeating-linear-gradient(45deg, #d4ddd8 0 8px, #edf2ee 8px 16px); border: 2px dashed #6b7b73; }
.fan-qr-placeholder span { display: grid; width: 58px; height: 58px; place-items: center; color: #142018; background: var(--lime); border: 4px solid #142018; font-size: 26px; font-weight: 950; }
.fan-join-card > strong { display: block; font-size: 14px; text-align: center; }
.fan-join-card > p { color: var(--muted); font-size: 9px; line-height: 1.55; text-align: center; }
.fan-open-link { display: block; margin: 11px 0; padding: 9px 11px; color: #152018; background: var(--lime); border-radius: 8px; font-size: 10px; font-weight: 900; text-align: center; text-decoration: none; }
.fan-open-link:hover, .fan-open-link:focus-visible { background: #d8ee78; outline: none; }
.fan-privacy, .fan-boundary { padding-top: 10px; border-top: 1px solid #2b4038; }
.fan-boundary { color: #c8d5cf !important; font-weight: 800; }
.fan-command-footer { min-height: 44px; padding: 14px 18px; color: #71827a; background: #101b18; border-top: 1px solid var(--line); font-size: 9px; text-align: center; }
.app-shell.is-fan-view { grid-template-columns: 290px minmax(480px, 1fr); }
.app-shell.is-fan-view .intel-panel { display: none; }

.intel-panel {
  min-height: 0;
  padding: 14px 12px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.group-detail { display: grid; justify-items: center; padding: 12px 6px 18px; text-align: center; }
.group-detail strong { margin-top: 10px; font-size: 14px; }
.group-detail span { margin-top: 4px; color: var(--muted); font-size: 10px; }

.intel-block { margin-bottom: 10px; padding: 12px; background: #14221e; border: 1px solid #2b4038; border-radius: 8px; }
.section-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.status-chip { color: var(--lime); }
.position-price { margin-bottom: 10px; font-size: 16px; font-weight: 900; }
.risk-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; color: var(--muted); border-top: 1px solid #2c4038; font-size: 10px; }
.risk-row strong { color: #dce4df; text-align: right; }

.cast-list { display: grid; }
.cast-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 7px 3px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid #263a33;
  border-radius: 5px;
  cursor: pointer;
}
.cast-row:first-child { border-top: 0; }
.cast-row:hover, .cast-row:focus-visible { background: #1b3029; outline: none; }
.cast-row .avatar { width: 34px; height: 34px; }
.cast-copy { min-width: 0; }
.cast-copy strong, .cast-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-copy strong { font-size: 11px; }
.cast-copy span { margin-top: 2px; color: var(--muted); font-size: 8px; }
.mood-dot { width: 7px; height: 7px; border-radius: 50%; background: #68756f; }
.mood-dot.is-happy { background: var(--lime); }
.mood-dot.is-hurt { background: var(--red); }
.cast-meta { display: flex; gap: 7px; align-items: center; }
.cast-chevron { color: #66776f; font-size: 17px; line-height: 1; }

.avatar-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.avatar-button:hover, .avatar-button:focus-visible { box-shadow: 0 0 0 2px rgba(201,225,104,.55); outline: none; }

.mcp-block { border-color: #365846; background: #12251d; }
.wallet-block { border-color: #4f6037; background: #17251b; }
.wallet-state { color: #a7b5ae; font-size: 8px; font-weight: 900; white-space: nowrap; }
.wallet-state.is-live { color: var(--lime); }
.wallet-state.is-stale { color: var(--orange); }
.wallet-balance { margin-bottom: 8px; color: #edf2ee; font-size: 18px; font-weight: 950; }
.wallet-address { display: block; overflow-wrap: anywhere; color: #b8c8c0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; line-height: 1.45; text-decoration: none; }
.wallet-address:hover, .wallet-address:focus-visible { color: var(--lime); outline: none; }
.wallet-address[aria-disabled="true"] { color: var(--muted); pointer-events: none; }
.wallet-latest, .wallet-boundary { margin: 8px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.wallet-boundary { padding-top: 8px; color: #b7c5be; border-top: 1px solid #35442b; font-weight: 800; }
.mcp-state { color: #a7b5ae; font-size: 8px; font-weight: 900; white-space: nowrap; }
.mcp-state.is-verified { color: var(--lime); }
.mcp-state.is-unavailable { color: var(--orange); }
.mcp-summary { margin-bottom: 5px; color: #edf2ee; font-size: 13px; font-weight: 900; }
.mcp-latest, .mcp-boundary { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.mcp-boundary { margin-top: 9px; padding-top: 8px; color: #b7c5be; border-top: 1px solid #294338; font-weight: 800; }
.mcp-details { margin-top: 9px; color: var(--muted); font-size: 9px; }
.mcp-details summary { cursor: pointer; user-select: none; }
.mcp-details > div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 9px; margin-top: 8px; padding: 8px; background: #0b1712; border-radius: 5px; }
.mcp-details strong { overflow: hidden; color: #d8e3dd; font-family: ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }

.evidence-item { margin: 0 0 9px; padding-left: 7px; border-left: 2px solid #4b6359; }
.evidence-item.is-fact { border-color: var(--lime); }
.evidence-item.is-inference { border-color: var(--blue); }
.evidence-item.is-open { border-color: var(--orange); }
.evidence-item span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 8px; font-weight: 900; }
.evidence-item p, .model-block p { margin: 0; font-size: 10px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 10px; }
.safety-note { margin: 15px 4px 0; color: #91a099; font-size: 8px; text-align: center; }
.fan-note { margin: 16px 4px; color: #6d7d75; font-size: 8px; line-height: 1.5; }

.member-profile {
  width: min(420px, calc(100vw - 24px));
  max-height: min(720px, calc(100dvh - 24px));
  padding: 0;
  color: var(--ink);
  background: #101d19;
  border: 1px solid #33483f;
  border-radius: 14px;
  box-shadow: 0 20px 70px rgba(0,0,0,.6);
  overflow: hidden auto;
}
.pin-card[role="button"] { cursor: pointer; }
.pin-card[role="button"]:hover { background: #172b24; }
.pin-card[role="button"]:focus-visible { outline: 2px solid var(--lime); outline-offset: -3px; }
.candidate-profile {
  width: min(430px, calc(100vw - 24px));
  max-height: min(760px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: #101d19;
  border: 1px solid #31483e;
  border-radius: 13px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  overflow: auto;
}
.candidate-profile::backdrop { background: rgba(2,8,6,.72); backdrop-filter: blur(2px); }
.candidate-profile-card { min-height: 100%; }
.candidate-profile-hero { display: flex; gap: 16px; align-items: center; padding: 20px 18px 16px; background: linear-gradient(150deg, #223b31, #101d19 70%); }
.candidate-logo-wrap { display: grid; width: 82px; height: 82px; flex: 0 0 82px; place-items: center; overflow: hidden; background: radial-gradient(circle at 32% 25%, hsl(var(--candidate-logo-hue, 92) 58% 44%), hsl(var(--candidate-logo-hue, 92) 44% 19%) 72%); border: 2px solid #07100d; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 0 0 5px rgba(201,225,104,.08); }
.candidate-logo { width: 100%; height: 100%; object-fit: cover; }
.candidate-logo-fallback { max-width: 72px; overflow: hidden; color: #f2ffd1; font-size: 25px; font-weight: 900; letter-spacing: -.08em; text-align: center; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.candidate-profile-identity { min-width: 0; }
.candidate-profile-identity h2 { margin: 0; overflow-wrap: anywhere; font-size: 20px; }
.candidate-profile-identity p { margin: 5px 0 9px; color: var(--lime); font-size: 12px; font-weight: 900; }
.candidate-profile-identity > span { display: inline-block; padding: 3px 8px; color: #c0cbc6; background: #24352f; border-radius: 10px; font-size: 8px; font-weight: 800; }
.candidate-description, .candidate-contract { margin: 10px 12px 0; padding: 12px; background: #14251f; border: 1px solid #2b4138; border-radius: 9px; }
.candidate-description > span, .candidate-contract > span { color: var(--muted); font-size: 8px; font-weight: 900; }
.candidate-description p { margin: 7px 0 0; color: #dce6e1; font-size: 10px; line-height: 1.6; }
.candidate-contract code { display: block; margin-top: 7px; color: #c9d5cf; font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; white-space: normal; }
.candidate-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 10px 12px 0; }
.candidate-links a { display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; color: #dfe8e4; background: #1b3028; border: 1px solid #345044; border-radius: 8px; font-size: 9px; font-weight: 900; text-decoration: none; }
.candidate-links a:hover, .candidate-links a:focus-visible { color: #172014; background: var(--lime); outline: none; }
.candidate-links-empty { grid-column: 1 / -1; padding: 12px; color: var(--muted); background: #14251f; border-radius: 8px; font-size: 9px; text-align: center; }
.member-profile::backdrop { background: rgba(2,8,6,.72); backdrop-filter: blur(2px); }
.profile-card { min-height: 100%; }
.profile-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: 8px 12px 8px 16px;
  background: rgba(16,29,25,.96);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}
.profile-close {
  width: 32px;
  height: 32px;
  padding: 0;
  color: #b9c5c0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.profile-close:hover, .profile-close:focus-visible { color: var(--ink); background: #22352e; outline: none; }
.profile-hero { display: flex; gap: 16px; align-items: center; padding: 20px 18px 16px; background: linear-gradient(150deg, #183028, #101d19 65%); }
.profile-avatar { width: 88px; height: 88px; object-fit: cover; background: #263c34; border: 2px solid #07100d; border-radius: 50%; box-shadow: 0 0 0 5px rgba(201,225,104,.08); }
.profile-identity { min-width: 0; }
.profile-identity h2 { margin: 0; font-size: 21px; }
.profile-identity p { margin: 5px 0 9px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.profile-emotion { display: inline-block; padding: 3px 8px; color: #c0cbc6; background: #24352f; border-radius: 10px; font-size: 8px; font-weight: 800; }
.profile-emotion.is-happy { color: #172014; background: var(--lime); }
.profile-emotion.is-hurt { color: #2a1110; background: var(--red); }
.profile-facts, .profile-model, .profile-latest { margin: 10px 12px 0; padding: 5px 12px; background: #14251f; border: 1px solid #2b4138; border-radius: 9px; }
.profile-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid #293d35; font-size: 10px; }
.profile-row:first-child { border-top: 0; }
.profile-row span { color: var(--muted); }
.profile-row strong { color: #e4ebe7; text-align: right; }
.profile-section-title { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0 7px; color: var(--muted); font-size: 9px; font-weight: 900; }
.profile-section-title span:last-child { color: var(--lime); text-align: right; }
.profile-model > p { margin: 8px 0 7px; color: #98a9a1; font-size: 9px; line-height: 1.5; }
.profile-latest { padding: 12px; }
.profile-latest > span { color: var(--muted); font-size: 8px; font-weight: 900; }
.profile-latest > p { margin: 6px 0 0; font-size: 11px; line-height: 1.55; }
.profile-boundary { margin: 12px 16px 17px; color: #83948c; font-size: 9px; line-height: 1.5; text-align: center; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 260px minmax(430px, 1fr); }
  .intel-panel { display: none; }
  .mobile-status-stack { position: relative; z-index: 3; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mcp-mobile-bar, .wallet-mobile-bar {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 7px;
    align-items: center;
    min-height: 38px;
    padding: 5px 10px;
    background: #10231b;
    border-bottom: 1px solid #294338;
  }
  .wallet-mobile-bar { background: #17251b; border-right: 1px solid #35442b; }
  .fan-community-body { grid-template-columns: minmax(0, 1fr) 230px; }
  .mcp-paw, .wallet-mark { color: var(--lime); font-size: 16px; }
  .mcp-paw { transform: rotate(-25deg); }
  .wallet-mobile-copy, .mcp-mobile-copy { min-width: 0; }
  .wallet-mobile-copy strong, .wallet-mobile-copy span, .mcp-mobile-copy strong, .mcp-mobile-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wallet-mobile-copy strong, .mcp-mobile-copy strong { font-size: 9px; }
  .wallet-mobile-copy span, .mcp-mobile-copy span { margin-top: 2px; color: var(--muted); font-size: 7px; }
}

@media (max-width: 760px) {
  html, body { min-width: 0; min-height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--chat); }
  .app-shell { display: block; width: 100%; max-width: 100vw; height: 100svh; min-height: 100svh; height: 100dvh; min-height: 100dvh; }
  .rail { display: none; }
  .chat-panel { grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 100vw; height: 100%; min-height: 0; }
  .chat-head, .pin-card, .mobile-status-stack, .messages, .composer-bar { width: 100%; min-width: 0; }
  .chat-head { min-height: 54px; gap: 8px; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
  .chat-identity { flex: 1 1 auto; gap: 8px; overflow: hidden; }
  .group-avatar { width: 36px; height: 36px; font-size: 17px; }
  .chat-head h1 { font-size: 14px; }
  .chat-head p { margin-top: 2px; font-size: 9px; }
  .head-actions { display: grid; flex: 0 0 auto; grid-template-columns: auto auto; gap: 3px 5px; align-items: center; text-align: right; }
  .mobile-fan-shortcut { display: inline-grid; place-items: center; min-height: 30px; margin: 0; padding: 5px 8px; border-radius: 10px; white-space: nowrap; }
  .mode-stamp { padding: 4px 6px; font-size: 8px; white-space: nowrap; }
  .clock { grid-column: 1 / -1; display: block; margin: 0; font-size: 7px; white-space: nowrap; }
  .pin-card { grid-template-columns: 14px minmax(0, 1fr) auto; gap: 6px; min-height: 48px; padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
  .pin-icon { font-size: 16px; }
  .pin-main strong { display: -webkit-box; overflow: hidden; font-size: 11px; line-height: 1.25; text-overflow: clip; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .pin-main > span:last-child { display: -webkit-box; max-width: none; overflow: hidden; font-size: 8px; line-height: 1.3; text-overflow: clip; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .vote-result { min-width: 62px; }
  .vote-result span { font-size: 12px; }
  .vote-result strong { max-width: 96px; font-size: 8px; line-height: 1.3; white-space: normal; }
  .mobile-status-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .mcp-mobile-bar, .wallet-mobile-bar { grid-template-columns: 16px minmax(0, 1fr); gap: 5px; min-height: 42px; padding: 6px 7px; overflow: hidden; }
  .wallet-mobile-bar { border-right: 1px solid #35442b; }
  .wallet-state, .mcp-state { display: none; }
  .mcp-paw, .wallet-mark { font-size: 13px; }
  .wallet-mobile-copy strong, .mcp-mobile-copy strong { display: -webkit-box; overflow: hidden; font-size: 9px; line-height: 1.25; text-overflow: clip; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .wallet-mobile-copy span, .mcp-mobile-copy span { font-size: 6.5px; }
  .messages { overscroll-behavior: contain; padding: 10px max(5px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left)); scroll-padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .day-separator, .cue { max-width: 92%; margin: 10px auto; padding: 4px 8px; }
  .message { grid-template-columns: 32px minmax(0, 1fr); gap: 5px; margin: 5px auto; }
  .avatar-slot { width: 32px; }
  .message .avatar { width: 30px; height: 30px; }
  .message .avatar-button { width: 30px; height: 30px; min-width: 30px; min-height: 30px; }
  .bubble { max-width: min(100%, 88vw); padding: 7px 9px 5px; }
  .message-author { min-height: 22px; font-size: 11px; }
  .reply-preview { margin-bottom: 4px; padding: 3px 6px; }
  .message-body { font-size: 13px; line-height: 1.46; }
  .message-meta { font-size: 7.5px; }
  .new-message { right: 10px; bottom: calc(56px + env(safe-area-inset-bottom)); }
  .composer-bar { grid-template-columns: minmax(0, 1fr) auto; min-height: 50px; padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .composer-plus { display: none; }
  .composer-placeholder { min-height: 36px; padding: 9px 12px; font-size: 10px; }
  .composer-lock { padding: 6px 8px; }
  .last-update { display: none; }
  .member-profile, .candidate-profile { width: 100%; max-width: none; max-height: calc(100dvh - env(safe-area-inset-top)); margin: auto 0 0; padding-bottom: env(safe-area-inset-bottom); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 17px 17px 0 0; }
  .profile-close { width: 40px; height: 40px; }
  .fan-community { width: 100%; max-width: 100vw; height: 100%; }
  .fan-community-head { grid-template-columns: auto auto minmax(0, 1fr); min-height: 58px; padding: max(7px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) 7px max(9px, env(safe-area-inset-left)); }
  .fan-community-head .fan-state { display: none; }
  .fan-community-body { grid-template-columns: minmax(0, 1fr); overflow-y: auto; overscroll-behavior: contain; }
  .fan-message-stream { min-height: 48dvh; overflow: visible; padding: 14px 7px; }
  .fan-message { grid-template-columns: 32px minmax(0, 1fr); gap: 5px; }
  .fan-message-avatar { width: 30px; height: 30px; font-size: 9px; }
  .fan-join-card { border-top: 1px solid var(--line); border-left: 0; overflow: visible; }
  .fan-qr-frame { width: min(72vw, 230px); }
  .fan-command-footer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

@media (max-width: 350px) {
  .chat-head h1 { font-size: 13px; }
  .chat-head p { max-width: 168px; }
  .mode-stamp { display: none; }
  .head-actions { grid-template-columns: auto; }
  .clock { grid-column: auto; }
  .vote-result strong { max-width: 76px; }
}

@media (max-width: 300px) {
  .chat-head { gap: 5px; }
  .group-avatar { width: 32px; height: 32px; font-size: 15px; }
  .chat-head h1 { font-size: 12px; }
  .chat-head p { display: none; }
  .mobile-fan-shortcut { min-height: 26px; padding: 4px 6px; font-size: 8px; }
  .clock { font-size: 6px; }
  .vote-result { min-width: 56px; }
  .vote-result strong { max-width: 62px; }
}
