/* Scoped to channel controls; existing message/composer styles are retained. */
body[data-page="community"] .chanbar{display:flex;flex-wrap:nowrap;gap:6px;padding:7px 10px;align-items:center}
.channel-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;flex:1;min-width:0}
.channel-choices .chan{min-width:0;display:flex;justify-content:center;align-items:center;gap:7px;position:relative;min-height:36px;padding:5px 8px;letter-spacing:.02em}
.channel-choices .chan em{margin:0;font-size:12px;font-style:normal;white-space:nowrap}
.channel-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.channel-context {
  --cc-text: var(--ink, #f6eef3);
  --cc-muted: rgba(246, 238, 243, 0.72);
  --cc-accent: var(--accent, #ffb7c9);
  --cc-surface: rgba(30, 20, 40, 0.55);
  --cc-line: rgba(255, 255, 255, 0.14);

  flex:none;
  min-width:0;
  position: relative;
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas:
    "toggle pinned ."
    "desc   desc   desc"
    "nudge  nudge  nudge";
  align-items: center;
  column-gap: 8px;
  padding: 10px 14px;
  color: var(--cc-text);
  background: var(--cc-surface);
  border-top: 1px solid var(--cc-line);
  border-bottom: 1px solid var(--cc-line);
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Top-row pills */
.channel-description-toggle,
.channel-pinned-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  color: var(--cc-text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--cc-line);
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  transition: background 0.2s, border-color 0.2s;
}
.channel-description-toggle:hover,
.channel-pinned-button:hover { background: rgba(255, 255, 255, 0.16); }
.channel-description-toggle:focus-visible,
.channel-pinned-button:focus-visible,
.channel-nudge button:focus-visible { outline: 2px solid var(--cc-accent); outline-offset: 2px; }

.channel-description-toggle { grid-area: toggle; }

.channel-description-toggle svg { order: 1; transition: transform 0.25s ease; }
.channel-description-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.channel-description-toggle[aria-expanded="true"],
.channel-pinned-button[aria-expanded="true"] { border-color: rgba(255, 183, 201, 0.45); }

/* Description (animated open/close) */
.channel-description-section {
  grid-area: desc;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}
.channel-description-content { overflow: hidden; min-height: 0; opacity: 0; transition: opacity 0.2s ease; }
.channel-context:has(.channel-description-toggle[aria-expanded="true"]) .channel-description-section { grid-template-rows: 1fr; }
.channel-context:has(.channel-description-toggle[aria-expanded="true"]) .channel-description-content { opacity: 1; }
.channel-description { margin: 0; padding: 10px 2px 2px; max-width: 60ch; }

.channel-pinned{grid-area:pinned;position:relative}
.channel-pinned-button::before{content:"📌";font-size:.8em}
.channel-pinned-button[aria-expanded="true"]{border-color:rgba(255,183,201,.45)}
.channel-pinned-popover{box-sizing:border-box;position:fixed;z-index:1000;padding:12px 14px;background:rgba(34,22,46,.98);color:#f6eef3;border:1px solid rgba(255,255,255,.14);border-radius:12px;box-shadow:0 12px 30px #0006;font:14px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;max-height:calc(100dvh - 24px);overflow:auto;animation:channel-pin-in .2s ease both}
.channel-pinned-popover p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
.channel-pinned-popover.is-closing{animation:channel-pin-out .2s ease both;pointer-events:none}
@keyframes channel-pin-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
@keyframes channel-pin-out{from{opacity:1;transform:none}to{opacity:0;transform:translateY(-4px)}}
/* Japanese practice nudge */
.channel-nudge {
  grid-area: nudge;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--cc-line);
  font-size: 0.85rem;
}
.channel-nudge[hidden] { display: none; }
.channel-nudge-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; color: var(--cc-muted); }
.channel-nudge-short { display: none; }
.channel-nudge-copy button {
  padding: 0;
  color: var(--cc-accent);
  background: none;
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 183, 201, 0.4);
}
.channel-nudge-copy button:hover { text-decoration-color: var(--cc-accent); }
.channel-nudge-close {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--cc-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.channel-nudge-close:hover { background: rgba(255, 255, 255, 0.1); color: var(--cc-text); }

.channel-nudge-short,.channel-members-icon{display:none}
.channel-admin-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.channel-admin-fields label{display:flex;flex-direction:column;gap:5px;min-width:0}.channel-admin-fields textarea{width:100%;box-sizing:border-box;resize:vertical;min-height:82px}
@media(max-width:900px){
 body[data-page="community"] .memtoggle{display:flex;align-items:center;justify-content:center;flex:none;width:32px;height:32px;padding:0;margin:0;border-radius:50%}
 .memtoggle>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
 .channel-members-icon{display:block}
 .channel-choices .chan{flex-direction:column;gap:1px;min-height:44px;line-height:1.3;letter-spacing:0}
}
@media(max-width:760px){
 body[data-page="community"] .chanbar,body[data-page="community"].keyboard-open .chanbar{display:flex;padding:6px;gap:4px}
 body[data-page="community"] .channel-choices{gap:4px}
 body[data-page="community"] .channel-choices .chan{min-height:44px;gap:1px;padding:4px 2px;flex-wrap:nowrap;font-size:13px;line-height:1.3;letter-spacing:0}
 body[data-page="community"] .channel-choices .chan em{display:block;font-size:12px;margin:0}
 body[data-page="community"] .memtoggle{width:30px;height:30px}
 body[data-page="community"].keyboard-open .memtoggle{display:none}
 .channel-context{padding:6px 9px}
 .channel-nudge{font-size:12px}
 .channel-admin-fields{grid-template-columns:1fr}
}
@media(max-width:360px){body[data-page="community"] .channel-choices .chan{font-size:12px}}

@media(prefers-reduced-motion:reduce){.channel-context *{transition:none!important}.channel-pinned-popover,.channel-pinned-popover.is-closing{animation:none}}

@media(max-width:560px){.channel-nudge-prompt{display:none}.channel-nudge-short{display:inline}}

.mobile-members-island{display:none}
@media(max-width:760px){
 body[data-page="community"] .memtoggle{display:none!important}
 .mobile-members-island{position:fixed;right:0;top:50%;transform:translateY(-50%);z-index:24;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:32px;height:66px;min-height:66px;padding:0;border:1px solid rgba(255,183,201,.45);border-right:0;border-radius:22px 0 0 22px;color:var(--ink);background:rgba(35,26,51,.92);box-shadow:-3px 4px 18px #100a2440;backdrop-filter:blur(8px);cursor:pointer;transition:background .2s,border-color .2s}
 .mobile-members-island:hover,.mobile-members-island[aria-expanded="true"]{background:#43304e;border-color:var(--accent)}
 .mobile-members-island svg{display:block;flex:none}
 .members-island-grip{width:10px;height:2px;border-radius:2px;background:var(--accent);opacity:.65}
 body[data-page="community"] #members{display:block;position:absolute;right:0;top:0;bottom:0;z-index:25;width:min(280px,calc(100vw - 44px));max-width:calc(100% - 38px);opacity:0;visibility:hidden;pointer-events:none;transform:translateX(12px);animation:none;transition:opacity .22s,transform .22s,visibility 0s linear .22s}
 body[data-page="community"] #members.show{opacity:1;visibility:visible;pointer-events:auto;transform:none;animation:none;transition:opacity .22s,transform .22s,visibility 0s}
 body[data-page="community"].keyboard-open .mobile-members-island{top:calc(var(--chat-viewport-height,100dvh) / 2)}
}
@media(prefers-reduced-motion:reduce){.mobile-members-island,body[data-page="community"] #members{transition:none!important}}

.members-drawer-head{display:none}
@media(max-width:760px){
 #vChat{overflow:hidden}
 body[data-page="community"] #members{inset:0;width:100%;max-width:none;box-sizing:border-box;border-radius:12px;background:rgba(30,22,45,.98);transform:translateX(100%);transition:transform .3s cubic-bezier(.2,.8,.2,1),visibility 0s linear .3s;opacity:1}
 body[data-page="community"] #members.show{transform:translateX(0);transition:transform .3s cubic-bezier(.2,.8,.2,1),visibility 0s;opacity:1}
 .members-open .mobile-members-island{display:none}
 .members-drawer-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:2px 6px 14px;margin-bottom:12px;border-bottom:1px solid var(--line);font-size:18px}
 .members-drawer-close{display:flex;align-items:center;justify-content:center;width:36px;height:36px;min-height:36px;padding:0;line-height:1;letter-spacing:0;text-indent:0}
}

/* Channel details live in anchored dropdowns, outside the message layout. */
.channel-context{display:block;padding:0;border:0;background:transparent}
.channel-context:empty{display:none}
.channel-context .channel-nudge{margin:0;padding:6px 12px;border-top:0;border-bottom:1px solid var(--line)}
.channel-context-actions{--cc-text:var(--ink,#f6eef3);--cc-accent:var(--accent,#ffb7c9);display:flex;align-items:center;justify-content:flex-end;gap:6px;flex:none;color:var(--ink);font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.3}
.channel-context-actions button{white-space:nowrap;height:32px;min-height:32px;padding:0 10px;font-size:13px;letter-spacing:0;text-indent:0}
.channel-context-actions .channel-description-toggle svg{display:block;width:14px;height:14px;flex:none}
.channel-dropdown-title{display:block;font-size:14px}
.channel-pinned-popover .channel-description,.channel-pinned-popover p{padding:0;margin:8px 0 0;max-width:none}

@media(max-width:760px){
 .channel-context-actions{gap:3px}
 .channel-context-actions button{width:28px;height:30px;min-height:30px;padding:0;justify-content:center;font-size:0;gap:0}
 .channel-context-actions .channel-description-toggle svg{width:17px;height:17px}
 .channel-context-actions .channel-pinned-button::before{font-size:15px}
}

/* Floating channel details stay above the history, never in the channel header. */
.chat-history > .channel-context-actions{position:absolute;top:8px;right:12px;z-index:6;max-width:calc(100% - 24px);gap:6px}
.chat-history > .channel-context-actions button{width:auto;height:30px;min-height:30px;padding:0 10px;font-size:12px;gap:6px;border:1px solid rgba(255,183,201,.22);background:rgba(30,22,43,.16);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);box-shadow:0 2px 8px #0002;color:var(--ink,#f6eef3)}
.chat-history > .channel-context-actions .channel-description-toggle svg{width:12px;height:12px}
.chat-history > .channel-context-actions .channel-pinned-button::before{font-size:12px}
.chat-history .msgs{padding-top:46px}
.channel-pinned-popover{background:rgba(34,22,46,.38);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px)}
@media(max-width:760px){.chat-history > .channel-context-actions{top:6px;right:8px;gap:4px}.chat-history > .channel-context-actions button{height:28px;min-height:28px;padding:0 8px}}

.channel-sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

body[data-page="community"] .channel-tools{display:flex;flex:none;align-items:center;gap:6px}
body[data-page="community"] .channel-tools .channel-pinned{display:flex}

body[data-page="community"] .channel-tools .channel-description-toggle,
body[data-page="community"] .channel-tools .channel-pinned-button{
  position:relative;justify-content:center;gap:0;
  width:36px;height:36px;padding:0;border-radius:50%;
  color:var(--ink-soft);background:transparent;border:1px solid var(--line);
}
body[data-page="community"] .channel-tools .channel-description-toggle:hover,
body[data-page="community"] .channel-tools .channel-pinned-button:hover{
  color:var(--ink);border-color:var(--accent);background:rgba(255,176,200,.1);
}
body[data-page="community"] .channel-tools .channel-description-toggle[aria-expanded="true"],
body[data-page="community"] .channel-tools .channel-pinned-button[aria-expanded="true"]{
  color:var(--ink);border-color:var(--accent);background:rgba(255,176,200,.18);
}
body[data-page="community"] .channel-tools .channel-description-toggle svg{width:20px;height:20px;transform:none}

body[data-page="community"] .channel-tools .channel-pinned-button::before{
  content:"";width:18px;height:18px;background:var(--accent);
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4v6l-2 4v2h10v-2l-2-4V4M12 16v5M8 4h8'/%3E%3C/svg%3E") center/contain no-repeat;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4v6l-2 4v2h10v-2l-2-4V4M12 16v5M8 4h8'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* the old row only exists now to hold the description and the nudge */
body[data-page="community"] .channel-context{
  padding:0 14px;border:0;
  grid-template-columns:1fr;grid-template-areas:"desc" "nudge";
}
body[data-page="community"] .channel-description{padding:10px 2px 12px}
body[data-page="community"] .channel-description-section.is-expanded{
  grid-template-rows:1fr;border-bottom:1px solid var(--cc-line);
}
body[data-page="community"] .channel-description-section.is-expanded .channel-description-content{opacity:1}
body[data-page="community"] .channel-nudge{margin:0;padding:8px 0;border-top:0;border-bottom:1px solid var(--cc-line)}

@media(max-width:760px){
  body[data-page="community"] .channel-tools{gap:4px}
  body[data-page="community"] .channel-tools .channel-description-toggle,
  body[data-page="community"] .channel-tools .channel-pinned-button{width:30px;height:30px}
  body[data-page="community"].keyboard-open .channel-tools{display:none}
}

/* Float the channel icons inside the top-right of the history. */
body[data-page="community"] .chat-history > .channel-tools{top:12px;right:14px}
body[data-page="community"] .chat-history > .channel-tools button{background:rgba(30,22,43,.16);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
@media(max-width:760px){body[data-page="community"] .chat-history > .channel-tools{top:8px;right:10px}}
@media(max-width:760px){
 body[data-page="community"] .channel-choices .chan{min-height:62px;flex-direction:column;justify-content:center}
 body[data-page="community"] .channel-choices .channel-name{white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:normal;line-height:1.25;text-align:center;width:100%}
}
