/* ==========================================================================
   SHINOBU — LIVE ROOM / SIDEBAR-FIRST INTERFACE
   One edge handle opens the complete room file. Closed = full-screen chat.
   Paper / ink / red only. No sound. No stored history. No new permissions.
   Loaded after paper.css and chat-motion.css.
   ========================================================================== */

#screen-live-room .chat-shell {
  --chat-gutter: clamp(20px, 4vw, 56px);
  --chat-read: 760px;
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  background: var(--paper-deep);
  overflow: hidden;
}

#screen-live-room .chat-main {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}

/* ---------- EDGE HANDLE ---------- */

#screen-live-room .chat-spine {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 46px;
  padding: 16px 0 18px;
  background: var(--ink);
  border-left: 1px solid var(--red);
  pointer-events: none;
}

#screen-live-room .chat-spine .room-menu-btn {
  pointer-events: auto;
}

#screen-live-room .spine-mark {
  margin-top: 18px;
  color: var(--red-bright);
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  opacity: 0.7;
  transform: rotate(-8deg);
}

#screen-live-room .spine-rule {
  width: 2px;
  flex: 1 1 auto;
  min-height: 36px;
  margin: 16px 0;
  background: linear-gradient(180deg, var(--red), var(--line-paper));
  opacity: 0.7;
}

#screen-live-room .spine-label,
#screen-live-room .spine-foot {
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: 0.44rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
}

#screen-live-room .spine-label { color: var(--paper); }
#screen-live-room .spine-foot { margin-top: 14px; color: var(--paper-muted); font-size: 0.4rem; }

#screen-live-room .room-menu-btn {
  width: 36px;
  min-height: 126px;
  padding: 12px 5px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: var(--red);
  border: 1px solid var(--red-bright);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

#screen-live-room .room-menu-btn:hover,
#screen-live-room .room-menu-btn[aria-expanded="true"] {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

/* ---------- HEADER ---------- */

#screen-live-room .chat-main .room-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: clamp(0.7rem, 1.5vw, 1.2rem);
  min-height: 78px;
  padding: 0.8rem var(--chat-gutter);
  background: var(--paper-lift);
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  flex-shrink: 0;
}

#screen-live-room .chat-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: auto;
  min-width: 0;
}

#screen-live-room .chat-title-kicker {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

#screen-live-room .chat-title-main {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2vw, 1.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

#screen-live-room .chat-title-dot { color: var(--red); }

#screen-live-room .chat-main .presence-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.34rem 0.55rem;
  background: var(--paper);
  border: 1px solid var(--line-strong);
}

#screen-live-room .chat-main .presence-text {
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

#screen-live-room .chat-main .expiry-timer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.34rem 0.55rem;
  border: 1px solid var(--red);
  background: var(--paper);
}

#screen-live-room .chat-main .expiry-label {
  font-family: var(--font-mono);
  font-size: 0.46rem;
  letter-spacing: 0.12em;
}

#screen-live-room .chat-main .expiry-time {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

/* ---------- CONVERSATION STAGE ---------- */

#screen-live-room .chat-main .messages-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 26px;
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: clamp(28px, 4vw, 52px) var(--chat-gutter);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 41px, rgba(10, 10, 10, 0.035) 42px),
    radial-gradient(ellipse at 12% 6%, rgba(193, 18, 31, 0.045), transparent 45%);
  border: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--red) transparent;
  scrollbar-width: thin;
}

#screen-live-room .chat-main .messages-container > * {
  width: min(100%, var(--chat-read));
  max-width: 100%;
}

#screen-live-room .chat-main .messages-container:not(.has-messages)::after {
  content: 'NO MESSAGES IN THIS FILE\A SHARE THE CODE + KEY TO BEGIN';
  white-space: pre;
  align-self: center;
  width: min(100%, var(--chat-read));
  margin: auto;
  padding: 40px 32px;
  border: 1px dashed var(--line-strong);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 2.3;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.75;
}

#screen-live-room .chat-main .message {
  position: relative;
  width: 100%;
  max-width: min(620px, 82%);
  min-width: 0;
  padding: 22px 20px 15px;
  border-radius: 0;
  box-shadow: 4px 4px 0 rgba(10, 10, 10, 0.07);
  word-break: break-word;
}

#screen-live-room .chat-main .message.received {
  align-self: flex-start;
  background: var(--paper-lift);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--red);
  color: var(--ink);
}

#screen-live-room .chat-main .message.sent {
  align-self: flex-end;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-right: 4px solid var(--red);
  color: var(--paper);
}

#screen-live-room .chat-main .message.received::before,
#screen-live-room .chat-main .message.sent::before {
  position: absolute;
  top: -1px;
  right: -1px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

#screen-live-room .chat-main .message.received::before {
  content: 'IN';
  background: var(--red);
  color: var(--paper);
}

#screen-live-room .chat-main .message.sent::before {
  content: 'OUT';
  background: var(--paper);
  color: var(--ink);
}

#screen-live-room .chat-main .message-name {
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#screen-live-room .chat-main .message-text {
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.72;
  white-space: pre-wrap;
}

#screen-live-room .chat-main .message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.48rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
}

#screen-live-room .chat-main .message.sent .message-meta {
  border-top-color: var(--line-paper);
}

#screen-live-room .chat-main .read-indicator {
  color: var(--red-bright);
  font-weight: 700;
}

#screen-live-room .chat-main .msg-delete-btn {
  margin-left: auto;
  padding: 0 3px;
  background: transparent;
  border: 0;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  cursor: pointer;
  opacity: 0.7;
}

#screen-live-room .chat-main .msg-delete-btn:hover {
  color: var(--red-bright);
  opacity: 1;
}

#screen-live-room .chat-main .msg-reply-preview {
  margin-bottom: 10px;
  padding: 6px 9px;
  border-left: 2px solid var(--red);
  background: rgba(10, 10, 10, 0.05);
}

#screen-live-room .chat-main .message.sent .msg-reply-preview {
  background: rgba(235, 227, 211, 0.08);
}

#screen-live-room .chat-main .msg-reply-preview-name {
  font-size: 0.48rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#screen-live-room .chat-main .msg-reply-preview-text {
  font-size: 0.7rem;
  line-height: 1.4;
  opacity: 0.8;
}

#screen-live-room .chat-main .message-system {
  align-self: center;
  max-width: 90%;
  padding: 6px 12px;
  border-top: 1px solid var(--red);
  border-bottom: 1px solid var(--red);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

/* ---------- COMPOSER ---------- */

#screen-live-room .chat-main .input-area {
  position: relative;
  flex-shrink: 0;
  padding: 18px calc(var(--chat-gutter) + 12px) 22px var(--chat-gutter);
  background: var(--paper-deep);
  border-top: 1px solid var(--ink);
}

#screen-live-room .chat-main .input-area::before {
  content: 'COMPOSE · NOTHING IS SAVED';
  display: block;
  margin-bottom: 12px;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.46rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

#screen-live-room .chat-main .reply-bar {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--red);
  background: var(--paper-lift);
}

#screen-live-room .chat-main .reply-bar-label {
  color: var(--red);
  font-size: 0.45rem;
}

#screen-live-room .chat-main .reply-bar-text {
  font-size: 0.7rem;
}

#screen-live-room .chat-main .input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

#screen-live-room .chat-main .message-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 58px;
  max-height: 140px;
  padding: 17px 18px;
  background: var(--paper-lift);
  border: 1px solid var(--ink);
  border-bottom: 2px solid var(--red);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.4;
  resize: none;
  outline: none;
}

#screen-live-room .chat-main .message-input::placeholder {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

#screen-live-room .chat-main .message-input:focus {
  border-color: var(--red);
  box-shadow: inset 0 -2px 0 var(--red);
}

#screen-live-room .chat-main .actions {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
}

#screen-live-room .chat-main .btn-attach,
#screen-live-room .chat-main .btn-record {
  width: 52px;
  min-height: 58px;
  background: var(--paper-lift);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

#screen-live-room .chat-main .btn-attach:hover,
#screen-live-room .chat-main .btn-record:hover {
  background: var(--ink);
  color: var(--paper);
}

#screen-live-room .chat-main .btn-send {
  width: 66px;
  min-height: 58px;
  background: var(--red);
  border: 1px solid var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background 160ms var(--ease), transform 160ms var(--ease);
}

#screen-live-room .chat-main .btn-send:hover {
  background: var(--ink);
  border-color: var(--ink);
}

#screen-live-room .chat-main .btn-send:active {
  transform: translateY(2px);
}

#screen-live-room .chat-main .voice-rec-status {
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--red);
  background: var(--paper-lift);
}

/* ---------- ROOM FILE SIDEBAR ---------- */

#screen-live-room .chat-dossier {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  display: block;
  width: min(360px, 100vw);
  height: 100%;
  padding: 0 22px 30px;
  background: var(--paper-deep);
  border-left: 3px solid var(--red);
  box-shadow: -18px 0 50px rgba(10, 10, 10, 0.32);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--red) transparent;
  scrollbar-width: thin;
  transform: translateX(105%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 260ms var(--ease), visibility 0s linear 260ms;
}

#screen-live-room .chat-dossier.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform 260ms var(--ease);
}

#screen-live-room .dossier-backdrop {
  position: fixed;
  inset: 0;
  z-index: 290;
  display: block;
  background: rgba(10, 10, 10, 0.62);
}

#screen-live-room .dossier-backdrop.hidden {
  display: none;
}

#screen-live-room .dossier-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 0 16px;
  background: var(--paper-deep);
  border-bottom: 2px solid var(--ink);
}

#screen-live-room .dossier-head-mark {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.46rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

#screen-live-room .dossier-head-title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: -0.01em;
}

#screen-live-room .dossier-close {
  position: absolute;
  top: 18px;
  right: 0;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
}

#screen-live-room .chat-dossier .room-menu-dropdown {
  position: static;
  display: block;
  width: 100%;
  padding: 18px 0 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--ink);
}

#screen-live-room .dossier-card {
  position: relative;
  min-height: 132px;
  margin-bottom: 14px;
  padding: 34px 18px 18px;
  background: var(--paper-lift);
  border: 1px solid var(--line-strong);
  box-shadow: 3px 3px 0 rgba(10, 10, 10, 0.08);
}

#screen-live-room .dossier-card-exit { border-color: var(--red); }

#screen-live-room .dossier-tab {
  position: absolute;
  top: -1px;
  left: -1px;
  padding: 4px 8px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.43rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

#screen-live-room .dossier-card-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.46rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#screen-live-room .dossier-code-value {
  min-height: 24px;
  margin-bottom: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  word-break: break-all;
}

#screen-live-room .dossier-safety-value {
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  word-break: break-all;
  cursor: pointer;
}

#screen-live-room .dossier-verified {
  display: inline-block;
  margin-bottom: 10px;
  padding: 2px 6px;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

#screen-live-room .dossier-verified.hidden,
#screen-live-room .rail-button.hidden {
  display: none;
}

#screen-live-room .dossier-actions-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

#screen-live-room .dossier-action,
#screen-live-room .dossier-leave,
#screen-live-room .dossier-people-btn,
#screen-live-room .safety-banner button {
  width: 100%;
  min-height: 38px;
  padding: 0.45rem 0.6rem;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}

#screen-live-room .dossier-action:hover,
#screen-live-room .dossier-leave:hover,
#screen-live-room .dossier-people-btn:hover,
#screen-live-room .safety-banner button:hover {
  background: var(--red);
  border-color: var(--red);
}

#screen-live-room .dossier-action-danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}

#screen-live-room .dossier-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.66rem;
  line-height: 1.6;
}

#screen-live-room .dossier-people-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}

#screen-live-room .dossier-people-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--red);
  color: var(--paper);
  font-size: 0.65rem;
}

#screen-live-room .dossier-leave {
  min-height: 42px;
  background: transparent;
  border: 2px solid var(--red);
  color: var(--red);
  font-size: 0.56rem;
}

#screen-live-room .chat-dossier .room-safety-rail {
  display: block;
  margin-top: 4px;
  padding: 0.7rem 0.85rem;
  background: var(--ink);
  border-left: 3px solid var(--red);
  color: var(--paper-soft);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.12em;
}

#screen-live-room .chat-dossier .rail-capture {
  color: var(--red-bright);
}

#screen-live-room .chat-dossier .safety-banner {
  width: auto;
  margin: 16px 0 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--red);
  border-left: 4px solid var(--red);
  background: var(--paper-lift);
}

#screen-live-room .chat-dossier .safety-banner-label {
  display: block;
  margin-bottom: 4px;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

#screen-live-room .chat-dossier .safety-banner-text {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.68rem;
  line-height: 1.5;
}

#screen-live-room .chat-dossier .safety-banner button + button {
  margin-top: 6px;
}

/* ---------- MEMBER PANEL ---------- */

#screen-live-room .chat-shell > .member-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 400;
  width: min(340px, 92vw);
  height: 100%;
  max-height: none;
  background: var(--ink);
  border-left: 2px solid var(--red);
  color: var(--paper);
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 900px) {
  #screen-live-room .chat-shell { --chat-gutter: clamp(18px, 4vw, 32px); }
  #screen-live-room .chat-title-main { font-size: 1rem; }
  #screen-live-room .chat-dossier { width: min(380px, 100vw); }
}

@media (max-width: 600px) {
  #screen-live-room .chat-shell { --chat-gutter: 18px; }

  #screen-live-room .chat-spine { width: 42px; padding-top: 12px; }
  #screen-live-room .room-menu-btn {
    width: 32px;
    min-height: 104px;
    padding: 10px 4px;
    font-size: 0.48rem;
  }
  #screen-live-room .spine-mark { margin-top: 14px; font-size: 1.4rem; }
  #screen-live-room .spine-label,
  #screen-live-room .spine-foot { font-size: 0.38rem; }

  #screen-live-room .chat-main .room-header {
    min-height: 66px;
    gap: 0.5rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }
  #screen-live-room .chat-title-main { display: none; }
  #screen-live-room .chat-title-kicker { font-size: 0.44rem; }
  #screen-live-room .chat-main .presence-indicator { padding: 0.28rem 0.4rem; }
  #screen-live-room .chat-main .presence-text {
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.44rem;
  }
  #screen-live-room .chat-main .expiry-timer { padding: 0.28rem 0.4rem; }
  #screen-live-room .chat-main .expiry-label { display: none; }

  #screen-live-room .chat-main .messages-container {
    padding: 24px var(--chat-gutter);
    gap: 20px;
  }
  #screen-live-room .chat-main .messages-container:not(.has-messages)::after {
    padding: 32px 20px;
    font-size: 0.55rem;
  }
  #screen-live-room .chat-main .message {
    max-width: 90%;
    padding: 18px 16px 13px;
  }
  #screen-live-room .chat-main .message-text {
    font-size: 0.88rem;
    line-height: 1.7;
  }

  #screen-live-room .chat-main .input-area {
    padding-top: 14px;
    padding-bottom: 16px;
  }
  #screen-live-room .chat-main .message-input {
    min-height: 50px;
    padding: 14px 15px;
  }
  #screen-live-room .chat-main .btn-attach,
  #screen-live-room .chat-main .btn-record {
    width: 42px;
    min-height: 50px;
  }
  #screen-live-room .chat-main .btn-send {
    width: 50px;
    min-height: 50px;
  }

  #screen-live-room .chat-dossier {
    width: 100vw;
    padding: 0 18px 28px;
  }
}

/* ---------- REDUCED MOTION ---------- */

@media (prefers-reduced-motion: reduce) {
  #screen-live-room .room-menu-btn,
  #screen-live-room .btn-attach,
  #screen-live-room .btn-record,
  #screen-live-room .btn-send,
  #screen-live-room .dossier-action,
  #screen-live-room .dossier-leave,
  #screen-live-room .dossier-people-btn,
  #screen-live-room .safety-banner button,
  #screen-live-room .chat-dossier {
    transition: none !important;
  }
}
