* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #16181d; color: #d7dae0;
  display: flex; flex-direction: column;
}
.hidden { display: none !important; }
button {
  background: #2b3040; color: #d7dae0; border: 1px solid #3a4155;
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}
button:hover { background: #38405a; }
button:disabled { opacity: 0.45; cursor: default; }
button.danger { border-color: #7d3540; color: #ff8d9c; }
button.primary { background: #3f6fd8; border-color: #3f6fd8; color: #fff; font-size: 14px; padding: 8px 18px; }
input, select {
  background: #20242e; border: 1px solid #3a4155; color: #d7dae0;
  border-radius: 6px; padding: 6px 10px; font-size: 13px;
}

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: #1d2027; border-bottom: 1px solid #2b3040;
  flex: 0 0 auto;
}
#topbar .brand { font-weight: 700; letter-spacing: 0.5px; }
#topbar .brand span { color: #61afef; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 1px; }
.badge.editor { background: #1e3a2a; color: #98c379; }
.badge.viewer { background: #3a2a1e; color: #e5c07b; }
.status.ok { color: #98c379; font-size: 12px; }
.status.bad { color: #e06c75; font-size: 12px; }
#session-label, #sandbox-label { font-size: 12px; color: #7d8494; }
#sandbox-label.warn { color: #e5c07b; }
.spacer { flex: 1; }

/* layout */
#workspace { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
#main { display: flex; flex: 1 1 auto; min-height: 0; }
#editor { flex: 1 1 auto; min-width: 0; }
#sidebar {
  width: 290px; flex: 0 0 auto; background: #1d2027; border-left: 1px solid #2b3040;
  overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 16px;
}
#sidebar h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #7d8494; }
#sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#sidebar li { display: flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; }
#sidebar li.empty { color: #565d6e; font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.pname { font-weight: 600; }
.prole { color: #7d8494; font-size: 11px; }
.pcontrols { margin-left: auto; display: flex; gap: 4px; }
.form-row { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; align-items: center; }
.form-row label { font-size: 12px; color: #9aa1b1; }
#invite-label { width: 110px; }
#invite-ttl { width: 64px; }

/* output panel */
#output-panel {
  flex: 0 0 auto; max-height: 0; overflow: hidden; transition: max-height 0.2s;
  background: #14161b; border-top: 1px solid #2b3040;
}
#output-panel.open { max-height: 220px; overflow-y: auto; }
#output { margin: 0; padding: 10px 14px; font: 12px/1.5 'SF Mono', Menlo, Consolas, monospace; white-space: pre-wrap; }

/* gate */
#gate {
  flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  padding: 24px; text-align: center;
}
#gate h1 { margin: 0; font-size: 26px; }
#gate p { color: #9aa1b1; max-width: 480px; margin: 0; }
#gate form { display: flex; gap: 8px; }
#gate input { font-size: 15px; padding: 9px 12px; width: 240px; }

/* overlay + toasts */
#overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 16, 0.92); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.overlay-box { text-align: center; max-width: 420px; padding: 20px; }
.overlay-box h1 { font-size: 24px; margin: 0 0 10px; }
.overlay-box p { color: #9aa1b1; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #2b3040; border: 1px solid #3a4155; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,0.4); max-width: 80vw; word-break: break-all;
}

/* replay */
#replay-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: #1d2027; border-top: 1px solid #2b3040; flex: 0 0 auto;
}
#scrubber { flex: 1; accent-color: #3f6fd8; }
#clock { font: 12px 'SF Mono', Menlo, monospace; color: #9aa1b1; white-space: nowrap; }
#feed { list-style: none; margin: 0; padding: 0; font-size: 12px; }
#feed li { padding: 5px 8px; border-radius: 6px; cursor: pointer; color: #565d6e; }
#feed li.past { color: #b9bfcc; }
#feed li.current { background: #2b3040; }
#feed li:hover { background: #262b38; }
#feed .ft { font-family: 'SF Mono', Menlo, monospace; color: #61afef; margin-right: 4px; }
.feed-output {
  background: #14161b; border: 1px solid #2b3040; border-radius: 6px;
  padding: 6px 8px; margin: 4px 0 0; font-size: 11px; max-height: 120px; overflow-y: auto; white-space: pre-wrap;
}
#replay-header { padding: 10px 16px; background: #1d2027; border-bottom: 1px solid #2b3040; }
#replay-header h1 { font-size: 16px; margin: 0; }
#replay-meta { font-size: 12px; color: #7d8494; }

/* landing */
.landing { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.landing h1 { font-size: 34px; margin: 0; }
.landing h1 span { color: #61afef; }
.landing p { color: #9aa1b1; max-width: 460px; }

/* resizers */
#dragbar {
  flex: 0 0 5px; cursor: col-resize; background: #2b3040;
}
#dragbar:hover, #dragbar.dragging { background: #3f6fd8; }
#output-dragbar {
  flex: 0 0 5px; cursor: row-resize; background: #2b3040; display: none;
}
#output-dragbar.visible { display: block; }
#output-dragbar:hover, #output-dragbar.dragging { background: #3f6fd8; }
body.resizing { user-select: none; }
body.resizing iframe, body.resizing #editor { pointer-events: none; }

/* chat */
#chat { margin-top: auto; display: flex; flex-direction: column; min-height: 120px; }
#chat-list {
  list-style: none; margin: 0 0 8px; padding: 0; overflow-y: auto; max-height: 220px;
  display: flex; flex-direction: column; gap: 4px; font-size: 13px;
}
#chat-list li { display: block; word-break: break-word; }
#chat-list .cname { font-weight: 700; margin-right: 4px; }
#chat-list .cname.host { color: #61afef; }
#chat-list .ctime { color: #565d6e; font-size: 10px; margin-left: 6px; }
#chat-form { display: flex; gap: 6px; }
#chat-form input { flex: 1; min-width: 0; }

/* recording indicators + controls */
.rec-indicator { font-size: 12px; color: #7d8494; padding: 2px 8px; border-radius: 10px; }
.rec-indicator.on { color: #ff5c6c; font-weight: 700; animation: recblink 1.4s ease-in-out infinite; }
.rec-indicator.paused { color: #e5c07b; font-weight: 600; }
@keyframes recblink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.rec-status { font-size: 12px; color: #7d8494; margin-right: auto; }
.rec-status.on { color: #ff5c6c; font-weight: 700; }
.rec-status.paused { color: #e5c07b; font-weight: 600; }
#rec-controls { align-items: center; }
#rec-lock-note { font-size: 11px; color: #8a919f; margin-top: 5px; line-height: 1.4; }
.hint { font-size: 11px; color: #8a919f; }
#rec-start-btn { background: #7d3540; border-color: #7d3540; color: #fff; }
#rec-start-btn:hover { background: #97404d; }
