.app {
  display: grid;
  grid-template-rows: 54px 1fr 28px;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--titlebar-bg);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 14px;
  color: #cccccc;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button,
select {
  font-family: var(--sans);
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--ink);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover,
select:hover {
  border-color: var(--accent);
  background: rgba(90, 93, 94, 0.4);
}

button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover {
  background: #1a8ad4;
}

button.secondary {
  background: var(--panel-2);
}

.workarea {
  display: grid;
  grid-template-columns: 240px minmax(360px, 1fr) minmax(320px, 38%);
  gap: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  padding: 12px 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  animation: rise 0.5s ease;
}

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.file-tree {
  flex: 1;
  overflow: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
  user-select: none;
}

.tree-item:hover {
  background: rgba(44, 49, 55, 0.8);
}

.tree-item.active {
  background: rgba(4, 57, 94, 0.6);
  font-weight: 600;
}

.tree-item.dir {
  cursor: pointer;
  color: var(--muted);
}

.tree-item.dir .tree-chevron {
  display: inline-block;
  width: 16px;
  font-size: 10px;
  text-align: center;
  transition: transform 0.15s ease;
  color: var(--muted);
  flex-shrink: 0;
}

.tree-item.dir.collapsed .tree-chevron {
  transform: rotate(-90deg);
}

.explorer-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.explorer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.explorer-toolbar button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explorer-toolbar button:hover {
  background: rgba(90, 93, 94, 0.4);
  color: var(--ink);
}

.tree-inline-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--accent);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 3px;
  outline: none;
  margin-left: 4px;
}

.tree-item .tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item.drag-over {
  background: rgba(0, 120, 212, 0.25) !important;
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}

.tree-item.dragging {
  opacity: 0.4;
}

.file-tree.drag-over-root {
  background: rgba(0, 120, 212, 0.08);
  outline: 1px dashed rgba(0, 120, 212, 0.3);
  outline-offset: -2px;
}

.tree-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(75, 156, 211, 0.2);
  color: #75beff;
}

.tree-icon.asset {
  background: rgba(220, 220, 170, 0.15);
  color: #dcdcaa;
}

.tree-icon.dir {
  background: rgba(133, 133, 133, 0.15);
  color: var(--muted);
}

.sidebar-footer {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.editor-pane {
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--panel);
  border-right: 1px solid var(--border);
  animation: rise 0.6s ease;
  overflow: hidden;
  min-height: 0;
}

.editor-head {
  background: var(--panel);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--tab-inactive-bg);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 0;
  background: var(--tab-inactive-bg);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

.tab:hover {
  background: rgba(44, 49, 55, 0.6);
  border-color: var(--border);
}

.tab.active {
  background: var(--tab-active-bg);
  border-bottom: 1px solid var(--tab-active-bg);
  color: #ffffff;
  font-weight: 500;
}

.tab .close {
  font-weight: 700;
  opacity: 0.5;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.editor-wrapper {
  position: relative;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.editor-code-area {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  contain: layout style;
}

.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  color: #d4d4d4;
  background: transparent;
  tab-size: 2;
  border: none;
  word-wrap: normal;
  overflow-wrap: normal;
  contain: layout style paint;
}

/* VS Code Dark+ token colors */
.hl-tag {
  color: #569cd6;
}

.hl-attr {
  color: #9cdcfe;
}

.hl-attr-value {
  color: #ce9178;
}

.hl-string {
  color: #ce9178;
}

.hl-comment {
  color: #6a9955;
  font-style: italic;
}

.hl-keyword {
  color: #c586c0;
}

.hl-keyword2 {
  color: #569cd6;
}

.hl-function {
  color: #dcdcaa;
}

.hl-number {
  color: #b5cea8;
}

.hl-operator {
  color: #d4d4d4;
}

.hl-punctuation {
  color: #808080;
}

.hl-property {
  color: #9cdcfe;
}

.hl-selector {
  color: #d7ba7d;
}

.hl-css-prop {
  color: #9cdcfe;
}

.hl-css-value {
  color: #ce9178;
}

.hl-css-unit {
  color: #b5cea8;
}

.hl-doctype {
  color: #808080;
}

.hl-entity {
  color: #569cd6;
}

.hl-special {
  color: #569cd6;
}

.hl-regexp {
  color: #d16969;
}

.hl-template {
  color: #569cd6;
}

.hl-template-expr {
  color: #d4d4d4;
}

.hl-json-key {
  color: #9cdcfe;
}

.hl-boolean {
  color: #569cd6;
}

.hl-null {
  color: #569cd6;
}

.hl-error-line {
  background: rgba(255, 0, 0, 0.12);
  display: inline-block;
  width: 100%;
}

.errors-panel {
  border-top: 1px solid var(--border);
  padding: 0;
  font-size: 12px;
  max-height: 140px;
  overflow: auto;
  display: none;
  background: #1e1e1e;
  font-family: var(--mono);
}

.errors-panel.active {
  display: block;
}

.errors-panel .error-header {
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cccccc;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.errors-panel .error-count {
  background: #f14c4c;
  color: white;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
}

.errors-panel .error-item {
  padding: 4px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-bottom: 1px solid rgba(60, 60, 60, 0.4);
  cursor: pointer;
}

.errors-panel .error-item:hover {
  background: rgba(44, 49, 55, 0.6);
}

.errors-panel .error-icon {
  color: #f14c4c;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.errors-panel .error-icon.warning {
  color: #cca700;
}

.errors-panel .error-msg {
  color: #cccccc;
  flex: 1;
}

.errors-panel .error-loc {
  color: #858585;
  flex-shrink: 0;
  font-size: 11px;
}

/* Error indicator in the status bar */
.status-errors {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.status-errors .err-icon {
  color: #f14c4c;
}

.status-errors .warn-icon {
  color: #cca700;
}

.line-numbers {
  width: 48px;
  min-width: 48px;
  padding: 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #858585;
  background: var(--panel);
  border-right: none;
  user-select: none;
  overflow: hidden;
  white-space: pre;
  flex-shrink: 0;
  position: relative;
  contain: layout style paint;
}

.editor-pane textarea#editor {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: none;
  resize: none;
  outline: none;
  padding: 16px;
  padding-left: 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  background: transparent;
  color: transparent;
  caret-color: #aeafad;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto;
  tab-size: 2;
}

.editor-pane textarea#editor::selection {
  background: var(--selection);
  color: transparent;
}

.editor-pane textarea#editor::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.editor-pane textarea#editor::-webkit-scrollbar-track {
  background: transparent;
}

.editor-pane textarea#editor::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 0;
}

.editor-pane textarea#editor::-webkit-scrollbar-corner {
  background: var(--panel);
}

.media-preview {
  position: absolute;
  inset: 0;
  display: none;
  background: #1e1e1e;
  z-index: 3;
  align-items: center;
  justify-content: center;
  overflow: auto;
  flex-direction: column;
  gap: 16px;
}

.media-preview.visible {
  display: flex;
}

.media-preview img {
  max-width: 100%;
  max-height: 80%;
  object-fit: contain;
  image-rendering: auto;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#333 0% 25%, #2a2a2a 0% 50%) 50% / 16px 16px;
}

.media-preview video,
.media-preview audio {
  max-width: 95%;
  max-height: 80%;
  border-radius: 4px;
  outline: none;
}

.media-preview .media-info {
  font-family: var(--mono);
  font-size: 12px;
  color: #858585;
  display: flex;
  gap: 16px;
  align-items: center;
}

.media-preview .media-info span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.media-preview .media-filename {
  font-family: var(--sans);
  font-size: 11px;
  color: #858585;
  letter-spacing: 0.02em;
}

.media-preview .media-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.media-preview .media-actions button {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: #cccccc;
  cursor: pointer;
}

.media-preview .media-actions button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Base64 detected banner (injected dynamically) */
.b64-detected-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(0, 120, 212, 0.12);
  border-top: 1px solid rgba(0, 120, 212, 0.3);
  font-size: 12px;
  margin-top: 6px;
}

.b64-detected-bar .b64d-badge {
  background: rgba(0, 120, 212, 0.25);
  color: #75beff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.b64-detected-bar .b64d-msg {
  flex: 1;
  color: #cccccc;
  font-size: 12px;
}

.b64-detected-bar .b64d-btn {
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: #cccccc;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--sans);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.b64-detected-bar .b64d-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.b64-detected-bar .b64d-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.b64-detected-bar .b64d-btn.primary:hover {
  background: #1a8ad4;
}

/* Base64 viewer overlay */
.base64-viewer {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #1e1e1e;
  z-index: 5;
}

.base64-viewer.visible {
  display: flex;
}

.base64-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.base64-viewer-header .b64-title {
  font-size: 12px;
  color: #cccccc;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.base64-viewer-header .b64-size {
  font-size: 11px;
  color: #858585;
  font-family: var(--mono);
}

.base64-viewer-header .b64-actions {
  display: flex;
  gap: 6px;
}

.base64-viewer-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: #ce9178;
  word-break: break-all;
  white-space: pre-wrap;
  position: relative;
}

.base64-viewer-body::-webkit-scrollbar {
  width: 10px;
}

.base64-viewer-body::-webkit-scrollbar-track {
  background: transparent;
}

.base64-viewer-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
}

.base64-viewer-body .b64-loading {
  color: #858585;
  font-style: italic;
}

.base64-viewer-body .b64-prefix {
  color: #858585;
}

.base64-viewer-body .b64-data {
  color: #ce9178;
}

/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: 100;
  background: #252526;
  border: 1px solid #454545;
  border-radius: 5px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-family: var(--sans);
  font-size: 12px;
  display: none;
}

.ctx-menu.visible {
  display: block;
}

.ctx-menu-item {
  padding: 6px 24px;
  color: #cccccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctx-menu-item:hover {
  background: #04395e;
}

.ctx-menu-sep {
  height: 1px;
  background: #454545;
  margin: 4px 0;
}

.editor-empty {
  position: absolute;
  inset: 0;
  display: none;
  padding: 32px;
  color: #5a5a5a;
  font-size: 14px;
  background: var(--panel);
  z-index: 2;
  align-items: center;
  justify-content: center;
}

.editor-empty.visible {
  display: flex;
}

.output-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel);
  animation: rise 0.7s ease;
}

.output-tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--tab-inactive-bg);
}

.output-tabs-left {
  display: flex;
  gap: 6px;
}

.output-tabs-right {
  display: flex;
  gap: 6px;
}

.fullscreen-btn {
  font-size: 14px;
  padding: 6px 8px;
  display: none;
}

.fullscreen-btn.visible {
  display: block;
}

.preview-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: white;
}

.preview-fullscreen iframe {
  width: 100%;
  height: 100%;
}

.output-tabs button {
  border-radius: 8px;
}

.output-tabs button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Scrollbar global para sidebar y file-tree */
.file-tree::-webkit-scrollbar {
  width: 8px;
}

.file-tree::-webkit-scrollbar-track {
  background: transparent;
}

.file-tree::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
}

/* Selects dark */
select {
  background: var(--input-bg);
  color: var(--ink);
}

select option {
  background: #252526;
  color: #cccccc;
}

.output-view {
  display: none;
  height: 100%;
}

.output-view.active {
  display: grid;
  grid-template-rows: 1fr auto auto;
}

#output {
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  outline: none;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  background: #1e1e1e;
  color: #d4d4d4;
}

#output::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#output::-webkit-scrollbar-track {
  background: transparent;
}

#output::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
}

#preview {
  border: none;
  width: 100%;
  height: 100%;
  background: white;
}

.warnings {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 12px;
  color: #cca700;
  max-height: 120px;
  overflow: auto;
  display: none;
  background: rgba(204, 167, 0, 0.1);
}

.warnings.active {
  display: block;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--statusbar-text);
  background: var(--statusbar-bg);
  border-top: none;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 120, 212, 0.15);
  border: 2px dashed var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  z-index: 10;
  backdrop-filter: blur(3px);
}

.drop-overlay.active {
  display: flex;
}

/* ═══ AUTH MODAL & CLOUD STYLES ═══ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.auth-overlay.visible {
  display: flex;
}

.auth-modal {
  background: #252526;
  border: 1px solid #454545;
  border-radius: 8px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: rise 0.3s ease;
}

.auth-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.auth-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #cccccc;
}

.auth-modal-close {
  background: none;
  border: none;
  color: #858585;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.auth-modal-close:hover {
  background: rgba(90, 93, 94, 0.4);
  color: #cccccc;
}

.auth-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-field label {
  font-size: 12px;
  color: #858585;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-field input {
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #cccccc;
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-field input:focus {
  border-color: var(--accent);
}

.auth-error {
  color: #f14c4c;
  font-size: 12px;
  min-height: 16px;
}

.auth-success {
  color: #89d185;
  font-size: 12px;
}

.auth-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auth-switch {
  font-size: 12px;
  color: #858585;
}

.auth-switch a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
}

.user-menu-toggle:hover {
  background: rgba(90, 93, 94, 0.4);
}

.user-menu-toggle .chevron {
  font-size: 10px;
  color: #858585;
  transition: transform 0.2s;
}

.user-menu.open .user-menu-toggle .chevron {
  transform: rotate(180deg);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-name {
  font-size: 12px;
  color: #cccccc;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #252526;
  border: 1px solid #454545;
  border-radius: 8px;
  min-width: 240px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: rise 0.2s ease;
  overflow: hidden;
}

.user-menu.open .user-dropdown {
  display: block;
}

.user-dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-dropdown-header .dropdown-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-dropdown-header .dropdown-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.user-dropdown-header .dropdown-name {
  font-size: 13px;
  color: #cccccc;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-header .dropdown-email {
  font-size: 11px;
  color: #858585;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-items {
  padding: 6px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: #cccccc;
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
}

.user-dropdown-item:hover {
  background: rgba(90, 93, 94, 0.3);
}

.user-dropdown-item .dd-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-dropdown-item.logout-item {
  color: #f14c4c;
}

.user-dropdown-item.logout-item:hover {
  background: rgba(241, 76, 76, 0.12);
}

/* Cloud projects panel */
.cloud-panel {
  position: fixed;
  top: 54px;
  right: 0;
  width: 380px;
  height: calc(100vh - 54px - 28px);
  background: #252526;
  border-left: 1px solid var(--border);
  z-index: 50;
  display: none;
  flex-direction: column;
  animation: slideIn 0.2s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.cloud-panel.visible {
  display: flex;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.cloud-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--titlebar-bg);
}

.cloud-panel-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #cccccc;
}

.cloud-project-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.cloud-project-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cloud-project-item:hover {
  background: rgba(44, 49, 55, 0.8);
}

.cloud-project-item .cp-name {
  font-size: 13px;
  color: #cccccc;
  font-weight: 500;
}

.cloud-project-item .cp-meta {
  font-size: 11px;
  color: #858585;
  display: flex;
  gap: 12px;
}

.cloud-project-item .cp-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.cloud-project-item .cp-actions button {
  font-size: 11px;
  padding: 2px 8px;
}

.cp-publish-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.cp-publish-row .cp-link {
  font-size: 11px;
  color: var(--accent);
  background: rgba(0, 120, 212, 0.1);
  border: 1px solid rgba(0, 120, 212, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.15s;
}

.cp-publish-row .cp-link:hover {
  background: rgba(0, 120, 212, 0.2);
}

.cp-publish-row .cp-copied {
  font-size: 10px;
  color: #89d185;
  opacity: 0;
  transition: opacity 0.2s;
}

.cp-publish-row .cp-copied.show {
  opacity: 1;
}

.cp-actions .cp-publish-btn {
  background: #2ea043;
  border-color: #2ea043;
  color: white;
}

.cp-actions .cp-publish-btn:hover {
  background: #3fb950;
  border-color: #3fb950;
}

.cp-actions .cp-unpublish-btn {
  background: rgba(241, 76, 76, 0.15);
  border-color: rgba(241, 76, 76, 0.4);
  color: #f14c4c;
}

.cp-actions .cp-unpublish-btn:hover {
  background: rgba(241, 76, 76, 0.25);
}




.cloud-empty {
  padding: 32px 16px;
  text-align: center;
  color: #858585;
  font-size: 13px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .workarea {
    grid-template-columns: 220px 1fr;
    grid-template-rows: 1fr 320px;
  }

  .output-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
  }
}

/* 📱 TABLET LAYOUT (< 820px) */
@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    padding: 4px;
  }

  .toolbar {
    justify-content: center;
  }

  .brand {
    display: none;
  }

  .workarea {
    display: grid;
    grid-template-columns: 200px 1fr;
    /* Hide preview on tablet portrait? */
    grid-template-rows: 1fr;
  }

  .output-pane {
    display: none;
  }

  /* On tablet, prioritize code */
  .sidebar {
    border-right: 1px solid var(--border);
  }
}

/* 📱 MOBILE LAYOUT (< 768px) - The Real Mobile App Experience */
.mobile-nav {
  display: none;
}

/* Default hidden */

@media (max-width: 768px) {

  /* 1. App Layout Adjustment */
  .app {
    display: grid;
    grid-template-rows: 50px 1fr 60px !important;
    /* Header | Content | Mobile Nav */
    height: 100vh;
    overflow: hidden;
  }

  /* 2. Hide Status Bar & Desktop Elements */
  .statusbar {
    display: none !important;
  }

  .brand {
    display: none !important;
  }

  #userMenuContainer {
    display: none !important;
  }

  /* 3. Mobile Navigation Bar */
  .mobile-nav {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr;
    background: #1e1e1e;
    border-top: 1px solid #333;
    z-index: 9999;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .nav-item {
    background: none;
    border: none;
    color: #858585;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    gap: 4px;
    padding: 8px 0;
    cursor: pointer;
  }

  .nav-item.active {
    color: #0078d4;
    background: rgba(0, 120, 212, 0.1);
  }

  .nav-icon {
    font-size: 20px;
    line-height: 1;
  }

  .nav-label {
    font-size: 10px;
    font-weight: 500;
  }

  /* 4. Single View Workarea */
  .workarea {
    display: block !important;
    position: relative;
    grid-template-columns: unset !important;
    grid-template-rows: unset !important;
    background: #1e1e1e;
  }

  .sidebar,
  .editor-pane,
  .output-pane {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: none !important;
    border: none;
    background: #1e1e1e;
  }

  /* View Switching Logic */
  .workarea.view-files .sidebar {
    display: flex !important;
    z-index: 20;
  }

  .workarea.view-editor .editor-pane {
    display: grid !important;
    z-index: 20;
  }

  .workarea.view-preview .output-pane {
    display: flex !important;
    z-index: 20;
  }

  /* Default View: Files */
  .workarea:not(.view-files):not(.view-preview):not(.view-editor) .sidebar {
    display: flex !important;
  }

  /* 5. Topbar Simplification */
  .topbar {
    padding: 0 8px;
    grid-template-columns: 1fr auto !important;
    height: 50px;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
  }

  .toolbar {
    gap: 8px;
    flex-wrap: nowrap;
  }

  .toolbar button {
    padding: 6px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }

  /* Hide non-essential buttons on mobile */
  #newProjectBtn,
  #loadDemoBtn,
  #importFolderBtn,
  #copyBtn,
  #downloadBtn {
    display: none !important;
  }

  #entrySelect {
    max-width: 100px;
  }

  /* 6. Editor Tweaks */
  .line-numbers {
    width: 32px;
    min-width: 32px;
    font-size: 11px;
  }

  #editor {
    font-size: 13px;
    padding-left: 6px;
  }
}