/* =========================================================================
   Collab Code — design system
   Warm minimalism for a focused collaborative editor.
   Dark theme is the default; [data-theme="light"] flips the tokens.
   ========================================================================= */

/* ---- Tokens — dark (default) -------------------------------------------- */
:root {
  --bg:            #1f1a16;
  --surface:       #2a231e;
  --surface-2:     #342b25;
  --surface-3:     #3e342c;
  --border:        #4a3e34;
  --border-strong: #5d4f43;

  --text:          #f5ede2;
  --text-muted:    #b5a08c;
  --text-faint:    #80705f;

  --accent:        #d49a6a;
  --accent-hover:  #e0a878;
  --accent-fg:     #1a1410;
  --accent-soft:   rgba(212, 154, 106, 0.12);
  --accent-ring:   rgba(212, 154, 106, 0.35);

  --danger:        #c66845;
  --danger-hover:  #d97757;
  --danger-soft:   rgba(198, 104, 69, 0.14);

  --success:       #8aa66f;
  --warn:          #d9a847;

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Geist', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Fira Code', Consolas, monospace;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  --ease: cubic-bezier(.2, .7, .3, 1);
  --transition-color: color .22s var(--ease), background-color .22s var(--ease), border-color .22s var(--ease);
}

/* ---- Tokens — light ----------------------------------------------------- */
[data-theme="light"] {
  --bg:            #f7f1e8;
  --surface:       #fdfaf3;
  --surface-2:     #ffffff;
  --surface-3:     #f0e8db;
  --border:        #e3d6c1;
  --border-strong: #c7b69b;

  --text:          #2a201a;
  --text-muted:    #75665a;
  --text-faint:    #a89888;

  --accent:        #a85e2c;
  --accent-hover:  #94501e;
  --accent-fg:     #fdfaf3;
  --accent-soft:   rgba(168, 94, 44, 0.10);
  --accent-ring:   rgba(168, 94, 44, 0.30);

  --danger:        #b8441e;
  --danger-hover:  #9c3614;
  --danger-soft:   rgba(184, 68, 30, 0.10);

  --success:       #5a7a4d;
  --warn:          #b8861a;

  --shadow-sm:  0 1px 2px rgba(74, 46, 28, 0.08);
  --shadow-md:  0 4px 16px rgba(74, 46, 28, 0.06), 0 1px 2px rgba(74, 46, 28, 0.10);
  --shadow-lg:  0 16px 48px rgba(74, 46, 28, 0.12), 0 2px 6px rgba(74, 46, 28, 0.10);
}

/* ---- Reset -------------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  font-feature-settings: "ss01", "cv11";
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: var(--transition-color);
}

::selection {
  background: var(--text);
  color: var(--bg);
}

/* The HTML `hidden` attribute must always win, even on flex/grid elements
   we style with explicit `display:`. */
[hidden] {
  display: none !important;
}

/* Pages with scrolling content (dashboard, admin) override this */
body.app-shell {
  height: 100vh;
  overflow: hidden;
}

/* ---- Typography --------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
  font-variation-settings: "opsz" 48;
}

h1 { font-size: 2.25rem; line-height: 1.1; font-variation-settings: "opsz" 96; }
h2 { font-size: 1.5rem; line-height: 1.2; }
h3 { font-size: 1.0625rem; font-family: var(--font-body); font-weight: 600; letter-spacing: -0.005em; }

em, .italic {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
}

a:not(.btn):not(.brand) {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s var(--ease);
}
a:not(.btn):not(.brand):hover { color: var(--accent-hover); }

code, kbd, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Eyebrow / uppercase label — for section headers, room ids, timestamps */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* ---- Buttons ------------------------------------------------------------ */
.btn,
.btn * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-color), transform .15s var(--ease), box-shadow .2s var(--ease);
}
/* Belt-and-braces against the highlight ever rendering on a primary button */
.btn::selection,
.btn *::selection {
  background: var(--text);
  color: var(--bg);
}
a.btn { text-decoration: none; }

.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-ring);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-warn {
  background: var(--warn);
  border-color: var(--warn);
  color: var(--accent-fg);
}

.small-btn,
.btn.small-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- Inputs ------------------------------------------------------------- */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition-color), box-shadow .15s var(--ease);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input::placeholder, textarea::placeholder {
  color: var(--text-faint);
}

input[type="file"] {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Theme toggle ------------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-color), transform .25s var(--ease);
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.theme-toggle:active { transform: rotate(-12deg); }
.theme-toggle .moon { display: none; }
.theme-toggle .sun  { display: inline; }
[data-theme="light"] .theme-toggle .sun  { display: none; }
[data-theme="light"] .theme-toggle .moon { display: inline; }

/* Floating variant — used on auth pages with no header */
.theme-toggle.floating {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
}

/* =========================================================================
   App header — shared chrome on dashboard / admin-users / room.
   Auth pages and the landing keep the floating .theme-toggle instead.
   ========================================================================= */
.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header .brand {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  text-decoration: none;
  font-variation-settings: "opsz" 48;
  transition: color .15s var(--ease);
  white-space: nowrap;
}
.app-header .brand em {
  color: var(--accent);
  font-style: italic;
  font-family: var(--font-display);
}
.app-header .context {
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .user-cluster {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .user-cluster .user-name {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.app-header .user-cluster img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
}

/* Compact variant for the room editor toolbar */
.app-header.compact {
  padding: 0 14px;
  height: 48px;
  gap: 12px;
}
.app-header.compact .brand { font-size: 0.95rem; }
.app-header.compact .btn,
.app-header.compact select {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .app-header { padding: 12px 16px; gap: 10px; }
  .app-header .user-cluster .user-name { display: none; }
}

/* =========================================================================
   Landing page (index.html)
   ========================================================================= */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, var(--accent-soft), transparent 60%),
    var(--bg);
}

.landing h1 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}
.landing h1 em { color: var(--accent); }

.landing .tagline {
  color: var(--text-muted);
  margin-bottom: 36px;
  max-width: 32ch;
  font-size: 1rem;
}

.landing-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.landing-meta {
  margin-top: 32px;
  font-size: 0.78rem;
  color: var(--text-faint);
}

.join-form {
  display: flex;
  gap: 8px;
}

/* ---- Landing page — hero ------------------------------------------------ */
.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, var(--accent-soft), transparent 60%),
    var(--bg);
}

.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.landing-brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
}
.landing-brand em { color: var(--accent); font-style: normal; }

.landing-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.landing-hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
  max-width: 16ch;
}
.landing-hero h1 em { color: var(--accent); font-style: normal; }

.landing-hero .tagline {
  color: var(--text-muted);
  margin-bottom: 36px;
  max-width: 48ch;
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px 24px;
  margin-top: 12px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

/* ---- Landing page — features -------------------------------------------- */
.landing-features {
  padding: 80px 24px;
  background: var(--surface);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  max-width: 960px;
  margin: 0 auto;
}

.feature-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: left;
}

.feature-icon {
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.feature-card h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* ---- Landing page — how it works ---------------------------------------- */
.landing-steps {
  padding: 80px 24px;
  background: var(--surface-2);
}

.landing-steps h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 32px;
  text-align: center;
}

.steps-list {
  max-width: 640px;
  margin: 0 auto;
  list-style: decimal;
  padding-left: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 16px;
}


.steps-list li {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
}
.steps-list li strong {
  color: var(--text);
}

/* ---- Landing page — FAQ ------------------------------------------------- */
.landing-faq {
  padding: 80px 24px;
}

.landing-faq h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 32px;
  text-align: center;
}

.faq-list {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.faq-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.faq-item dt {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.faq-item dd {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
}

/* ---- Landing page — footer ---------------------------------------------- */
.landing-footer {
  padding: 32px 24px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}
.footer-links a {
  color: var(--text-faint);
  font-size: 0.82rem;
}
.footer-links a:hover {
  color: var(--accent);
}

/* ---- Landing responsive ------------------------------------------------- */
@media (max-width: 600px) {
  .landing-hero h1 { font-size: 1.8rem; }
  .hero-ctas { flex-direction: column; }
  .feature-grid { grid-template-columns: 1fr; }
}

/* =========================================================================
   Auth forms (login, login-google, join)
   ========================================================================= */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 40% at 50% 30%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.auth-card h1 {
  font-size: 1.75rem;
  margin-bottom: 6px;
  font-variation-settings: "opsz" 96;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.8125rem;
  text-align: center;
  min-height: 1.2em;
}

.link-back {
  display: inline-block;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.link-back:hover { color: var(--text); }

/* Google sign-in button */
.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 18px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-color), box-shadow .2s var(--ease), transform .15s var(--ease);
}
.google-btn:hover {
  background: var(--surface-3);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.google-btn:active { transform: translateY(1px); }
.google-btn svg { flex-shrink: 0; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--text-faint);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.admin-login-footer {
  margin-top: 22px;
  font-size: 0.78rem;
}
.admin-login-footer a { color: var(--text-faint); }
.admin-login-footer a:hover { color: var(--text-muted); }

/* =========================================================================
   Room editor (room.html + app.js)
   ========================================================================= */
.room-layout {
  display: grid;
  grid-template-rows: auto 1fr 230px;
  min-height: 100vh;
  height: 100vh;
}

/* Room toolbar lives inside .app-header.compact — these are extras */
.app-header.compact select {
  padding: 5px 10px;
  font-size: 12px;
  background: var(--surface-2);
}
.app-header.compact .editor-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

#room-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
#room-id span {
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s var(--ease);
}
#room-id span:hover {
  color: var(--accent);
  text-decoration: underline;
}

#users-list {
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.user-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

#editor-wrapper {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
#editor-container { height: 100%; }

#loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}
#loading-overlay.hidden { display: none; }

#io-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.io-section {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  overflow: hidden;
}
.io-section:first-child { border-right: 1px solid var(--border); }

.io-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.io-header h3 {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

#stdin-input,
#stdout-output {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
#stdin-input { flex: 1; resize: none; }
#stdout-output {
  flex: 1;
  overflow: auto;
  white-space: pre-wrap;
}

.stderr      { color: var(--danger); }
.status-msg  { color: var(--text-faint); font-style: italic; font-family: var(--font-display); }

#run-btn {
  padding: 6px 18px;
  font-weight: 600;
}
#run-btn.running { opacity: 0.55; cursor: wait; }

/* Yjs remote-cursor labels */
.yRemoteSelection { opacity: 0.3; }
.yRemoteSelectionHead {
  position: absolute;
  height: 100%;
  box-sizing: border-box;
}

/* =========================================================================
   Admin / dashboard shell
   ========================================================================= */
.admin-layout {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 28px 80px;
  min-height: 100vh;
}

/* Page title — used inside .admin-layout / .dash after the global .app-header */
.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.015em;
  margin-bottom: 28px;
}

.admin-section { margin-bottom: 36px; }
.admin-section h2 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.create-room-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.create-room-form input { flex: 1; }

/* ---- Room cards (legacy class kept for compatibility) ------------------- */
.room-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: var(--transition-color);
}
.room-card:hover { border-color: var(--border-strong); }

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.room-card-header strong {
  color: var(--text);
  margin-right: 8px;
  font-weight: 600;
}

.room-name[contenteditable] {
  cursor: text;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  outline: none;
}
.room-name[contenteditable]:hover { background: var(--surface-3); }
.room-name[contenteditable]:focus {
  background: var(--surface-2);
  outline: 1px solid var(--accent);
}

.room-id-label {
  color: var(--text-faint);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.room-card-actions { display: flex; gap: 6px; }

.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Step 17 — Room editor responsive layout */
@media (max-width: 980px) {
  .app-header.compact {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 8px 12px;
    row-gap: 8px;
  }
  .app-header.compact .editor-tools {
    flex-wrap: wrap;
    gap: 6px;
  }
  .app-header.compact .user-cluster {
    margin-left: auto;
  }
  /* The room id label is decorative — hide it before anything functional */
  .app-header.compact #room-id { display: none; }
}

@media (max-width: 900px) {
  /* Brand shrinks to just the icon-style mark; keeps the link clickable */
  .app-header.compact .brand { font-size: 0.85rem; }

  /* Drop the "← Dashboard" text label, keep the arrow */
  .app-header.compact .context .btn { font-size: 0; padding: 6px 10px; }
  .app-header.compact .context .btn::before {
    content: '←';
    font-size: 0.85rem;
  }

  /* Copy/Save/Cursors collapse to icon-ish single chars to save horizontal space */
  .app-header.compact #copy-code,
  .app-header.compact #download-code,
  .app-header.compact #toggle-cursors {
    font-size: 0;
    padding: 6px 10px;
  }
  .app-header.compact #copy-code::before     { content: '⧉'; font-size: 0.9rem; }
  .app-header.compact #download-code::before { content: '↓'; font-size: 0.9rem; }
  .app-header.compact #toggle-cursors::before{ content: '↻'; font-size: 0.9rem; }

  /* The user list (presence chips) is the next thing to drop — at this width
     the editor itself is what matters */
  .app-header.compact #users-list { display: none; }

  /* Stack stdin / stdout vertically so each gets the full width */
  #io-panel {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  #io-panel .io-section:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* ---- Legal pages -------------------------------------------------------- */
.legal-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.legal-page h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.legal-page h2 {
  font-size: 1.1rem;
  margin-top: 28px;
  margin-bottom: 8px;
}
.legal-page p {
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 12px;
}
.legal-updated {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-bottom: 24px;
}
.legal-back {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--accent);
  font-size: 0.9rem;
}

/* ---- Accessibility ------------------------------------------------------ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
}

/* Visible focus ring for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

