* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #1e1e1e;
  color: #e0e0e0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  min-width: 0;
}

.header {
  background-color: #252525;
  border-bottom: 1px solid #333;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  color: #e0e0e0;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.copy-btn {
  background-color: #0078d4;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.2s;
}

.copy-btn:hover {
  background-color: #0066b3;
}

.copy-btn:active {
  background-color: #004a8a;
}

.user-count {
  background-color: #1e1e1e;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #444;
  font-size: 12px;
  color: #a0a0a0;
  white-space: nowrap;
}

.editor-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  background-color: #1e1e1e;
  min-width: 0;
}

.line-numbers {
  background-color: #252525;
  color: #666;
  border-right: 1px solid #333;
  padding: 20px 10px;
  text-align: right;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  user-select: none;
  overflow: hidden;
  min-width: 40px;
}

.editor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #1e1e1e;
  color: #e0e0e0;
  border: none;
  padding: 20px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  tab-size: 2;
  min-width: 0;
}

.editor::selection {
  background-color: #333;
}

/* ─── Language selector ──────────────────────────────────────────────────── */

.lang-select {
  background-color: #1e1e1e;
  color: #a0a0a0;
  border: 1px solid #444;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23a0a0a0' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.lang-select:hover {
  border-color: #666;
}

.lang-select:focus {
  border-color: #0078d4;
}

.lang-select--hidden {
  display: none;
}

/* ─── Highlight overlay ──────────────────────────────────────────────────── */

.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 20px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  pointer-events: none;
  color: #e0e0e0;
  background: transparent;
}

.highlight-layer code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  tab-size: inherit;
}

.editor--highlighted {
  color: transparent;
  caret-color: #e0e0e0;
}

.editor--highlighted::selection {
  background-color: rgba(51, 51, 51, 0.8);
}

/* ─── Syntax token colors (VS Code dark theme) ──────────────────────────── */

.tok-keyword { color: #569cd6; }
.tok-string { color: #ce9178; }
.tok-comment { color: #6a9955; font-style: italic; }
.tok-number { color: #b5cea8; }
.tok-builtin { color: #dcdcaa; }
.tok-type { color: #4ec9b0; }
.tok-operator { color: #d4d4d4; }
.tok-decorator { color: #dcdcaa; }
.tok-punctuation { color: #d4d4d4; }

.cursor-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.remote-cursor {
  position: absolute;
  width: 2px;
  height: 21px;
  border-radius: 1px;
}

.cursor-flag {
  position: absolute;
  bottom: 100%;
  left: 0px;
  transform: translateY(5px);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 6px;
  border-radius: 4px 4px 4px 0;
  font-size: 11px;
  font-weight: 600;
  color: white;
  line-height: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

/* Cursor colors for different users */
.cursor-color-0 {
  background-color: #ff6b6b;
  border-color: #ff6b6b;
}

.cursor-color-1 {
  background-color: #4ecdc4;
  border-color: #4ecdc4;
}

.cursor-color-2 {
  background-color: #ffe66d;
  border-color: #ffe66d;
  color: #000;
}

.cursor-color-3 {
  background-color: #95e1d3;
  border-color: #95e1d3;
}

.cursor-color-4 {
  background-color: #f38181;
  border-color: #f38181;
}

.cursor-color-5 {
  background-color: #aa96da;
  border-color: #aa96da;
}

.cursor-flag.cursor-color-0 {
  background-color: #ff6b6b;
}

.cursor-flag.cursor-color-1 {
  background-color: #4ecdc4;
}

.cursor-flag.cursor-color-2 {
  background-color: #ffe66d;
  color: #000;
}

.cursor-flag.cursor-color-3 {
  background-color: #95e1d3;
  color: #000;
}

.cursor-flag.cursor-color-4 {
  background-color: #f38181;
}

.cursor-flag.cursor-color-5 {
  background-color: #aa96da;
}

@media (max-width: 768px) {
  .header {
    padding: 10px 12px;
  }

  .header h1 {
    font-size: 18px;
  }

  .session-info {
    gap: 8px;
  }

  .line-numbers {
    min-width: 34px;
    padding: 16px 8px;
    font-size: 13px;
  }

  .editor {
    padding: 16px;
    font-size: 13px;
  }

  .highlight-layer {
    padding: 16px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .header {
    align-items: flex-start;
  }

  .session-info {
    width: 100%;
    justify-content: space-between;
  }

  .copy-btn,
  .user-count {
    font-size: 11px;
    padding: 6px 10px;
  }

  .line-numbers {
    min-width: 30px;
    padding: 14px 6px;
    font-size: 12px;
  }

  .editor {
    padding: 14px;
    font-size: 12px;
  }

  .highlight-layer {
    padding: 14px;
    font-size: 12px;
  }

  .lang-select {
    font-size: 11px;
    padding: 6px 8px;
    padding-right: 22px;
  }
}

/* ── Anonymous session banner ────────────────────────────────────────────── */

.anon-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 20px;
  font-size: 12px;
  background-color: #252525;
  border-bottom: 1px solid #333;
  color: #888;
  transition: background-color 0.4s, color 0.4s, border-color 0.4s;
  flex-shrink: 0;
}

.anon-banner--hidden {
  display: none;
}

/* Warning state: 3 min or less remaining */
.anon-banner--warning {
  background-color: #2a2200;
  border-color: #4a3800;
  color: #c89a00;
}

/* Expired state */
.anon-banner--expired {
  background-color: #2a1010;
  border-color: #4a1a1a;
  color: #d06060;
}

.anon-banner-cta {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.anon-banner-cta:hover {
  opacity: 1;
}

/* Read-only overlay shown when session expires */
.readonly-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 20, 0.82);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.readonly-overlay-title {
  font-size: 15px;
  font-weight: 600;
  color: #e0e0e0;
}

.readonly-overlay-sub {
  font-size: 12px;
  color: #888;
  text-align: center;
  max-width: 300px;
  line-height: 1.6;
}

.readonly-overlay-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0078d4;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  margin-top: 4px;
}

.readonly-overlay-btn:hover {
  background: #0066b3;
}

/* ── Rename display name (inside auth dropdown) ──────────────────────────── */

.auth-rename-form {
  padding: 10px 14px;
  border-bottom: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-rename-label {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-rename-row {
  display: flex;
  gap: 6px;
}

.auth-rename-input {
  flex: 1;
  background: #1e1e1e;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}

.auth-rename-input:focus {
  border-color: #0078d4;
}

.auth-rename-save {
  background: #0078d4;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.auth-rename-save:hover {
  background: #0066b3;
}

.auth-rename-save:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Auth section ────────────────────────────────────────────────────────── */

.auth-section {
  display: flex;
  align-items: center;
  position: relative;
}

/* "Sign in with Google" ghost button */
.auth-signin-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: #c0c0c0;
  border: 1px solid #444;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
  text-decoration: none;
}

.auth-signin-btn:hover {
  border-color: #888;
  color: #e0e0e0;
}

.auth-signin-btn svg {
  flex-shrink: 0;
}

/* Signed-in pill */
.auth-user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid #444;
  padding: 4px 10px 4px 5px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: #c0c0c0;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
  user-select: none;
}

.auth-user-pill:hover {
  border-color: #888;
  color: #e0e0e0;
}

/* Avatar circle */
.auth-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.auth-avatar-initials {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: #0078d4;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.auth-user-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dropdown caret */
.auth-caret {
  opacity: 0.5;
  font-size: 10px;
}

/* Dropdown menu */
.auth-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  overflow: hidden;
  animation: authDropIn 0.12s ease;
}

@keyframes authDropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-dropdown-email {
  padding: 10px 14px 8px;
  font-size: 11px;
  color: #666;
  border-bottom: 1px solid #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.auth-signout-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: #c0c0c0;
  font-size: 12px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-signout-btn:hover {
  background: #333;
  color: #e0e0e0;
}

/* ─── Run / Replay / Export / Dashboard buttons ──────────────────────────── */

.run-btn,
.replay-btn,
.export-btn,
.dashboard-btn {
  padding: 4px 10px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2a2a2a;
  color: #ccc;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.run-btn:hover, .replay-btn:hover, .export-btn:hover, .dashboard-btn:hover {
  background: #333;
  border-color: #555;
}
.run-btn { color: #4ec9b0; border-color: #3a8a78; }
.run-btn:hover { background: #2b3a36; }
.run-btn--hidden, .replay-btn--hidden, .export-btn--hidden, .dashboard-btn--hidden {
  display: none;
}
.run-btn--loading { opacity: 0.6; pointer-events: none; }

/* ─── Document size indicator ────────────────────────────────────────────── */

.doc-size-indicator {
  font-size: 11px;
  color: #777;
  margin-left: 4px;
}
.doc-size-indicator--hidden { display: none; }
.doc-size-indicator--warning { color: #e8a838; }
.doc-size-indicator--limit { color: #e85050; }

/* ─── Replay bar ─────────────────────────────────────────────────────────── */

.replay-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: #1a2a3a;
  border-bottom: 1px solid #2a4a6a;
  font-size: 12px;
}
.replay-bar--hidden { display: none; }
.replay-control {
  background: #2a3a4a;
  border: 1px solid #3a5a7a;
  color: #8ac;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.replay-control:hover { background: #3a4a5a; }
.replay-scrubber { flex: 1; accent-color: #4a8abf; }
.replay-version { color: #8ac; min-width: 60px; text-align: center; }
.replay-speed {
  background: #2a3a4a;
  color: #8ac;
  border: 1px solid #3a5a7a;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 12px;
}
.replay-author { color: #6a9; font-style: italic; }
.replay-exit {
  background: #3a2a2a;
  border: 1px solid #6a3a3a;
  color: #c88;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  margin-left: auto;
}
.replay-exit:hover { background: #4a3a3a; }

/* ─── Execution panel ────────────────────────────────────────────────────── */

.exec-panel {
  background: #1a1a1a;
  border-top: 1px solid #333;
  max-height: 250px;
  display: flex;
  flex-direction: column;
}
.exec-panel--hidden { display: none; }
.exec-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #222;
  border-bottom: 1px solid #333;
  font-size: 12px;
}
.exec-tabs { display: flex; gap: 2px; }
.exec-tab {
  background: transparent;
  border: none;
  color: #888;
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.exec-tab--active { color: #ccc; border-bottom-color: #4ec9b0; }
.exec-tab:hover { color: #aaa; }
.exec-status { color: #888; margin-left: auto; }
.exec-status--running { color: #e8a838; }
.exec-status--error { color: #e85050; }
.exec-rate-limit { color: #666; font-size: 11px; }
.exec-close {
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.exec-close:hover { color: #ccc; }
.exec-output {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  min-height: 60px;
}
.exec-stdout {
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #c8e6c9;
}
.exec-stdout--error { color: #ef9a9a; }
.exec-input { padding: 8px 12px; }
.exec-input--hidden { display: none; }
.exec-stdin {
  width: 100%;
  background: #252525;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

/* ─── Dashboard modal ────────────────────────────────────────────────────── */

.dashboard-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.dashboard-modal--hidden { display: none; }
.dashboard-content {
  background: #252525;
  border: 1px solid #444;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #333;
}
.dashboard-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #e0e0e0;
}
.dashboard-close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
}
.dashboard-close:hover { color: #ccc; }
.dashboard-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}
.dashboard-empty { color: #666; text-align: center; padding: 20px; }
.dashboard-item {
  display: block;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #ccc;
  text-decoration: none;
  transition: border-color 0.15s;
}
.dashboard-item:hover { border-color: #555; }
.dashboard-item-id { color: #4ec9b0; font-weight: 600; }
.dashboard-item-preview {
  color: #888;
  font-size: 12px;
  margin-top: 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dashboard-item-date { color: #666; font-size: 11px; margin-top: 4px; }
.dashboard-new-session {
  margin: 12px 20px 16px;
  padding: 10px;
  background: #2a3a2a;
  border: 1px solid #3a5a3a;
  border-radius: 6px;
  color: #4ec9b0;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.dashboard-new-session:hover { background: #3a4a3a; }

/* ─── PRO badge ──────────────────────────────────────────────────────────── */

.pro-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: #1e1e1e;
  background: linear-gradient(135deg, #f0c040, #e8a020);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

/* ─── Upgrade prompt ─────────────────────────────────────────────────────── */

.upgrade-prompt {
  text-align: center;
  padding: 8px 12px;
  background: #2a2a1a;
  border: 1px solid #4a4a2a;
  border-radius: 6px;
  color: #c8b040;
  font-size: 12px;
  margin-top: 8px;
}
.upgrade-prompt a {
  color: #e8c840;
  text-decoration: underline;
}

