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

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --secondary: #a855f7;
  --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
  --bg: #09090f;
  --bg-card: rgba(18, 22, 30, 0.65);
  --bg-surface: #0d0d16;
  --border: rgba(99, 102, 241, 0.12);
  --border-active: rgba(99, 102, 241, 0.35);
  --text: #e2e4e9;
  --text-muted: #8b8fa3;
  --text-dim: #4a4e5a;
  --tab-bg: #0a0a14;
  --tab-active-bg: #12121e;
  --tab-hover-bg: #11111d;
}

html { scrollbar-width: thin; scrollbar-color: #1e2030 transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e2030; border-radius: 4px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 100% 0%, #120f24 0%, transparent 50%),
                    radial-gradient(circle at 0% 100%, #0d0f24 0%, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ===== Three-panel layout ===== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Resize handles ===== */
.resize-handle {
  width: 4px; flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  position: relative; z-index: 10;
}
.resize-handle:hover,
.resize-handle.active {
  background: rgba(99, 102, 241, 0.25);
}

/* ===== Sidebar ===== */
.sidebar {
  width: 220px; min-width: 160px; flex: none;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header h2 {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
}
.sidebar-header-actions {
  display: flex; align-items: center; gap: 8px;
}
.sidebar-help {
  font-size: 11px; color: var(--primary-light);
  text-decoration: none; font-weight: 600;
  transition: opacity 0.15s; white-space: nowrap;
  opacity: 0.8;
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid rgba(99,102,241,0.25);
  background: rgba(99,102,241,0.06);
}
.sidebar-help:hover { opacity: 1; background: rgba(99,102,241,0.12); border-color: var(--primary-light); }
.sidebar-search {
  padding: 6px 10px;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%; padding: 5px 8px; border-radius: 5px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text); font-size: 11px; outline: none;
  font-family: inherit; transition: border-color 0.15s;
}
.sidebar-search input:focus {
  border-color: var(--primary-light);
}
.sidebar-search input::placeholder { color: var(--text-dim); }
.file-count { font-size: 10px; color: var(--text-dim); }
.file-tree {
  flex: 1; overflow-y: auto; padding: 4px 0;
  font-size: 12px; font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
}
.tree-placeholder { color: var(--text-dim); padding: 16px; font-size: 11px; text-align: center; }
.tree-item {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 14px; cursor: pointer; color: var(--text-muted);
  transition: none; white-space: nowrap; position: relative;
}
.tree-item::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(99,102,241,0.06) 0%, transparent 100%);
  opacity: 0; transition: opacity 0.15s;
}
.tree-item:hover::before { opacity: 1; }
.tree-item:hover { color: var(--text); }
.tree-item .icon { flex-shrink: 0; font-size: 11px; width: 14px; text-align: center; position: relative; }
.tree-item .name { overflow: hidden; text-overflow: ellipsis; position: relative; }
.tree-item .output-badge {
  font-size: 8px; padding: 1px 5px; border-radius: 6px;
  background: rgba(35, 134, 54, 0.15); color: #3fb950; margin-left: auto; flex-shrink: 0;
}
.tree-item.file-output { color: #3fb950; }
.tree-item.file-output .name { color: #3fb950; }
.tree-children { padding-left: 14px; }

/* ===== Editor panel ===== */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* ===== Tab bar ===== */
.tab-bar {
  display: flex;
  align-items: center;
  height: 34px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.tab-bar-scroll {
  display: flex;
  align-items: center;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tab-bar-scroll::-webkit-scrollbar { display: none; }
.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border-right: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.tab-item:hover { background: var(--tab-hover-bg); color: var(--text); }
.tab-item.active {
  background: var(--tab-active-bg);
  color: var(--text);
}
.tab-item.active::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 1.5px;
  background: var(--gradient);
}
.tab-item .tab-icon { font-size: 10px; opacity: 0.6; }
.tab-item .tab-name { font-size: 12px; }
.tab-item .tab-dirty {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary-light);
  flex-shrink: 0;
}
.tab-item .tab-close {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 3px;
  font-size: 11px; color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
  margin-left: 2px;
}
.tab-item .tab-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.tab-item .tab-close svg { width: 10px; height: 10px; }

/* ===== Editor area ===== */
.editor-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.editor-area .cm-editor {
  height: 100%;
  font-size: 13px;
}
.editor-area .cm-editor .cm-scroller {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
}
.editor-area .cm-editor.cm-focused { outline: none; }
.editor-area .cm-editor .cm-gutters {
  background: transparent;
  border-right: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
}
.editor-area .cm-editor .cm-activeLineGutter { background: rgba(99,102,241,0.08); }

/* ===== Welcome state ===== */
.welcome-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  user-select: none;
  z-index: 5;
}
.welcome-state[hidden] { display: none !important; }
.welcome-icon svg { width: 72px; height: 72px; }
.welcome-icon svg rect {
  animation: welcomePulse 3s ease-in-out infinite;
}
@keyframes welcomePulse {
  0%, 100% { stroke-opacity: 0.4; }
  50% { stroke-opacity: 1; }
}
.welcome-title {
  font-size: 18px; font-weight: 600;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-desc {
  font-size: 13px; color: var(--text-dim);
  max-width: 300px; text-align: center; line-height: 1.5;
}

/* ===== Function panel ===== */
.func-panel {
  width: 33vw; min-width: 280px; max-width: 700px; flex: none;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.func-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.func-header h2 {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
}
.func-body {
  flex: 1; overflow-y: auto;
  padding: 16px 18px 24px;
}

.func-body label {
  display: block; font-size: 10px; color: var(--text-dim);
  margin-bottom: 5px; font-weight: 500; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.func-body select,
.func-body input[type="text"] {
  width: 100%; padding: 10px 12px; border-radius: 6px;
  background: #12121e;
  border: 1px solid var(--border);
  color: var(--text); font-size: 13px; outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.func-body select option {
  background: #12121e;
  color: var(--text);
  padding: 6px;
}
.func-body select option:checked {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
}
.func-body select:focus,
.func-body input[type="text"]:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(99,102,241,0.1);
}
.func-env { margin-bottom: 12px; }

/* func tabs */
.tabs {
  display: flex; position: relative;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.tabs .tab {
  flex: 1; padding: 8px; text-align: center; cursor: pointer;
  background: none; border: none; color: var(--text-muted); font-size: 12px;
  position: relative; transition: color 0.2s; font-family: inherit;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--text); }
.tab-indicator {
  position: absolute; bottom: -1px; left: 0; height: 2px;
  background: var(--gradient); border-radius: 2px;
  transition: left 0.25s cubic-bezier(0.25,0.46,0.45,0.94), width 0.25s cubic-bezier(0.25,0.46,0.45,0.94);
}
select.shake {
  border-color: #f85149 !important;
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* upload zone */
.panel { display: none; margin-bottom: 10px; }
.panel.active { display: block; }
.drop-zone {
  border-radius: 8px; padding: 18px 14px; text-align: center;
  transition: all 0.2s; color: var(--text-muted);
  border: 1.5px dashed rgba(99,102,241,0.2);
  animation: dropPulse 4s ease-in-out infinite;
  background: rgba(0,0,0,0.15);
}
@keyframes dropPulse {
  0%, 100% { border-color: rgba(99,102,241,0.2); }
  50% { border-color: rgba(99,102,241,0.4); }
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary-light);
  background: rgba(99,102,241,0.04);
  color: var(--text);
  animation-play-state: paused;
}
.drop-zone p { font-size: 12px; }
.upload-buttons { display: flex; gap: 5px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.btn-upload {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 12px; font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.btn-upload:hover {
  border-color: var(--primary-light); color: var(--text);
  background: rgba(99,102,241,0.08);
}
.upload-status { margin-top: 8px; font-size: 11px; min-height: 1.2em; }

/* url panel row */
.url-row { display: flex; gap: 6px; }
.url-row input { flex: 1; min-width: 0; }
.btn-confirm {
  flex-shrink: 0; padding: 10px 16px; border-radius: 6px;
  background: linear-gradient(135deg, #4fc3f7, #29b6f6);
  color: #fff; border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  white-space: nowrap;
}
.btn-confirm:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(41, 182, 246, 0.3);
}
.btn-confirm.shake {
  border-color: #f85149 !important;
  animation: shake 0.4s ease-in-out;
}

/* build buttons */
.btn-build, .btn-stop {
  display: block; width: 100%; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer; border: none;
  font-family: inherit; transition: all 0.2s;
  margin-bottom: 8px;
}
.btn-build {
  background: var(--gradient); color: #fff;
  background-size: 200% 100%;
  animation: shimmerBg 3s ease-in-out infinite;
  position: relative; overflow: hidden;
}
.btn-build::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmerSlide 3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shimmerBg {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes shimmerSlide {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}
.btn-build:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.25);
}
.btn-build:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-stop {
  background: linear-gradient(135deg, #da3633, #f85149); color: #fff;
  background-size: 200% 100%;
  animation: shimmerBg 3s ease-in-out infinite;
}
.btn-stop:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(248,81,73,0.25); }

/* log */
.func-log { margin-top: 8px; }
.func-log[hidden] { display: none; }
.func-log-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.func-log-header span { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.badge {
  font-size: 9px; padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,0.04); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.3px;
  border: 1px solid var(--border);
}
.badge.running { background: rgba(31,111,235,0.12); color: #58a6ff; border-color: rgba(31,111,235,0.25); }
.badge.completed { background: rgba(35,134,54,0.12); color: #3fb950; border-color: rgba(35,134,54,0.25); }
.badge.failed { background: rgba(218,54,51,0.12); color: #f85149; border-color: rgba(218,54,51,0.25); }
#logOutput {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  line-height: 1.6; max-height: 400px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
  color: var(--text-muted);
}

/* result */
.func-result { margin-top: 8px; text-align: center; }
.func-result[hidden] { display: none; }
.func-result p { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.btn-download {
  display: inline-block; padding: 8px 20px; border-radius: 8px;
  background: var(--gradient); color: #fff; text-decoration: none;
  background-size: 200% 100%;
  animation: shimmerBg 3s ease-in-out infinite;
  font-size: 13px; font-weight: 600; cursor: pointer;
  position: relative; overflow: hidden;
}
.btn-download::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmerSlide 3s ease-in-out infinite;
  pointer-events: none;
}
.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.25);
}

/* ===== Admin ===== */
.func-admin { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.func-admin[hidden] { display: none; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.admin-header h3 { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.badge-admin { background: rgba(99,102,241,0.1); color: var(--primary-light); border-color: rgba(99,102,241,0.2); }
.admin-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.stat-card {
  background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 4px; text-align: center;
}
.stat-card .num { font-size: 16px; font-weight: 700; color: var(--text); }
.stat-card .lbl { font-size: 9px; color: var(--text-muted); margin-top: 1px; }
.stat-card.active .num { color: var(--primary-light); }
.stat-card.ok .num { color: #3fb950; }
.stat-card.fail .num { color: #f85149; }
.stat-card.views .num { color: #d29922; }
.uptime { color: var(--text-dim); font-size: 10px; text-align: center; margin-bottom: 10px; }
.admin-sub h4 { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 4px 6px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px; }
td { color: var(--text-muted); font-family: 'SF Mono', 'Fira Code', monospace; }
.status-badge { display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 9px; }
.status-pending { background: rgba(255,255,255,0.03); color: var(--text-dim); }
.status-running { background: rgba(31,111,235,0.12); color: #58a6ff; }
.status-completed { background: rgba(35,134,54,0.12); color: #3fb950; }
.status-failed { background: rgba(218,54,51,0.12); color: #f85149; }

/* ===== Dev trigger ===== */
.dev-trigger {
  position: fixed; bottom: 14px; right: 14px; z-index: 100;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(18,22,30,0.7);
  border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; opacity: 0.4;
  backdrop-filter: blur(8px);
}
.dev-trigger:hover { opacity: 1; color: var(--text-muted); border-color: var(--primary-light); }
.dev-trigger.active { opacity: 1; color: var(--primary-light); border-color: var(--primary-light); }

/* ===== Modal (password only) ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: rgba(18,22,30,0.85);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; width: 300px; backdrop-filter: blur(12px);
}
.modal h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.modal-hint { font-size: 11px; color: var(--text-dim); margin: 4px 0 12px; }
.modal input[type="password"] {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text); font-size: 13px; outline: none;
  font-family: inherit; transition: border-color 0.2s;
}
.modal input[type="password"]:focus { border-color: var(--primary-light); }
.modal-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; }
.modal-actions button {
  padding: 6px 16px; border-radius: 6px; font-size: 12px;
  font-weight: 500; cursor: pointer; border: none; font-family: inherit;
  transition: all 0.15s;
}
.btn-sec {
  background: rgba(255,255,255,0.04); color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-sec:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.btn-pri {
  background: var(--gradient); color: #fff;
}
.btn-pri:hover { opacity: 0.9; }
.modal-error { color: #f85149; font-size: 11px; margin-top: 8px; }

/* ===== Navigation Bar ===== */
.nav-bar {
  display: flex;
  align-items: center;
  height: 42px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  flex-shrink: 0;
  gap: 20px;
  z-index: 50;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.nav-brand svg { width: 18px; height: 18px; }
.nav-tabs {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.nav-tab {
  padding: 6px 14px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.nav-tab:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-tab.active {
  color: var(--text);
  background: rgba(99,102,241,0.1);
  color: var(--primary-light);
}
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-help {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.nav-help:hover { color: var(--text); border-color: var(--primary-light); }
.nav-theme-toggle {
  width: 28px; height: 28px; border-radius: 6px;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; transition: all 0.15s; flex-shrink: 0;
  line-height: 1;
}
.nav-theme-toggle:hover {
  border-color: var(--primary-light); color: var(--text);
  background: rgba(255,255,255,0.04);
}
.nav-username {
  font-size: 12px;
  color: var(--primary-light);
  font-weight: 500;
}

#editorView { height: calc(100vh - 42px); }
#editorView[hidden] { display: none; }

/* ===== Community Layout ===== */
#communityView {
  height: calc(100vh - 42px);
  overflow: hidden;
}
#communityView[hidden] { display: none; }
.community-container {
  display: flex;
  height: 100%;
}
.community-sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.community-user-section {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.community-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.community-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.community-user-info span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-logout:hover { color: #f85149; border-color: #f85149; }
.btn-login-register {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  background: var(--gradient);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-login-register:hover { opacity: 0.9; }

.community-categories h3 {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-bottom: 6px;
}
.community-cat {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border-radius: 5px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.community-cat:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.community-cat.active {
  color: var(--primary-light);
  background: rgba(99,102,241,0.08);
}

.btn-new-post {
  margin-top: auto;
  width: 100%;
  padding: 9px;
  border-radius: 6px;
  background: var(--gradient);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-new-post:hover { opacity: 0.9; }

/* Community Main */
.community-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.community-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.community-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.community-search input {
  width: 200px;
  padding: 6px 10px;
  border-radius: 5px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.community-search input:focus { border-color: var(--primary-light); }
.community-search input::placeholder { color: var(--text-dim); }

#communityContent {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}
.community-loading,
.community-error,
.community-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}

/* Post Cards */
.post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 8px;
}
.post-card:hover {
  border-color: var(--border-active);
  background: rgba(99,102,241,0.03);
}
.post-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.post-cat {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.cat-discussion { background: rgba(99,102,241,0.1); color: var(--primary-light); }
.cat-feedback { background: rgba(210,153,34,0.1); color: #d29922; }
.cat-bug { background: rgba(248,81,73,0.1); color: #f85149; }
.post-date { font-size: 10px; color: var(--text-dim); }
.post-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
.post-author { font-weight: 500; }
.post-comments { color: var(--text-dim); }

/* Pagination */
.community-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.page-btn {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary-light); color: var(--text); }
.page-btn.active { background: var(--gradient); color: #fff; border-color: transparent; }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* Post Detail */
.post-detail { max-width: 800px; margin: 0 auto; }
.btn-back {
  background: none;
  border: none;
  color: var(--primary-light);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  margin-bottom: 14px;
  transition: opacity 0.15s;
}
.btn-back:hover { opacity: 0.8; }
.post-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.post-detail-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}
.post-detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.admin-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99,102,241,0.12);
  color: var(--primary-light);
  font-weight: 500;
}
.btn-delete-post, .btn-delete-comment {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-delete-post:hover, .btn-delete-comment:hover { color: #f85149; border-color: #f85149; }
.post-detail-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 24px;
}

/* Comments */
.comment-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.comment-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.comment-list { margin-bottom: 16px; }
.comment-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.comment-item:last-child { border-bottom: none; }
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-author { font-size: 11px; font-weight: 600; color: var(--text); }
.comment-date { font-size: 10px; color: var(--text-dim); }
.comment-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 16px 0;
  text-align: center;
}
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comment-form textarea {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s;
}
.comment-form textarea:focus { border-color: var(--primary-light); }
.btn-submit-comment {
  align-self: flex-end;
  padding: 6px 16px;
  border-radius: 6px;
  background: var(--gradient);
  color: #fff;
  border: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-submit-comment:hover { opacity: 0.9; }
.comment-login-hint {
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.comment-login-hint a { color: var(--primary-light); cursor: pointer; }

/* Post Form */
.post-form {
  max-width: 700px;
  margin: 0 auto;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary-light); }
.form-group textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Auth Modal */
.modal-auth { width: 340px; }
.modal-auth input[type="text"],
.modal-auth input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  margin-bottom: 10px;
}
.modal-auth input[type="text"]:focus,
.modal-auth input[type="password"]:focus { border-color: var(--primary-light); }
.auth-switch {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 10px;
  text-align: center;
}
.auth-switch a { color: var(--primary-light); cursor: pointer; }

/* Admin community section */
#adminCommunityContent {
  margin-top: 8px;
  font-size: 11px;
}
#adminUsersContent {
  margin-top: 8px;
  font-size: 11px;
}
#adminUsersContent table td,
#adminUsersContent table th {
  padding: 3px 4px;
  font-size: 10px;
}
.admin-role-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
}
.admin-role-badge.role-admin {
  background: rgba(99,102,241,0.12);
  color: var(--primary-light);
}
.admin-community-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-community-item .admin-cat {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  flex-shrink: 0;
}
.admin-community-item .admin-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}
.admin-community-item .admin-del {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.admin-community-item .admin-del:hover { color: #f85149; border-color: #f85149; }

/* ===== Light Theme ===== */
[data-theme="light"] {
  --primary: #6366f1;
  --primary-light: #4f46e5;
  --secondary: #7c3aed;
  --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
  --bg: #f3f4f6;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-surface: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --border-active: rgba(99, 102, 241, 0.3);
  --text: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --tab-bg: #f9fafb;
  --tab-active-bg: #ffffff;
  --tab-hover-bg: #f3f4f6;
}
[data-theme="light"] body {
  background: var(--bg);
  background-image: radial-gradient(circle at 100% 0%, #e8e4ff 0%, transparent 50%),
                    radial-gradient(circle at 0% 100%, #e0e7ff 0%, transparent 50%);
}
[data-theme="light"] .drop-zone { background: rgba(255,255,255,0.5); }
[data-theme="light"] .sidebar-search input,
[data-theme="light"] .func-body select,
[data-theme="light"] .func-body input[type="text"],
[data-theme="light"] .modal input[type="password"],
[data-theme="light"] .modal-auth input[type="text"],
[data-theme="light"] .modal-auth input[type="password"],
[data-theme="light"] .comment-form textarea,
[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select,
[data-theme="light"] .form-group textarea,
[data-theme="light"] .community-search input {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .func-body select option { background: #ffffff; }
[data-theme="light"] #logOutput { background: #ffffff; }
[data-theme="light"] .stat-card { background: rgba(0,0,0,0.03); }
[data-theme="light"] .tree-item:hover::before {
  background: linear-gradient(90deg, rgba(99,102,241,0.04) 0%, transparent 100%);
}
[data-theme="light"] .post-card { background: #ffffff; }
[data-theme="light"] .comment-form textarea { background: #ffffff; }
[data-theme="light"] .nav-theme-toggle:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .nav-tab:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .nav-tab.active { background: rgba(99,102,241,0.08); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d1d5db; }
[data-theme="light"] html { scrollbar-color: #d1d5db transparent; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .sidebar { width: 180px; min-width: 140px; }
  .func-panel { width: 36vw; min-width: 240px; }
  .community-sidebar { width: 170px; min-width: 170px; }
}
@media (max-width: 768px) {
  .community-container { flex-direction: column; }
  .community-sidebar {
    width: 100%;
    min-width: 0;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .community-user-section { border-bottom: none; padding-bottom: 0; }
  .community-categories { display: flex; gap: 4px; flex-wrap: wrap; }
  .community-categories h3 { display: none; }
  .community-cat { width: auto; font-size: 11px; padding: 4px 8px; margin-bottom: 0; }
  .btn-new-post { margin-top: 0; width: auto; }
  .community-search input { width: 140px; }
}
