:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1a1a24;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text2: #8888a0;
  --purple: #8b5cf6;
  --purple-dim: #6d3fcf;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app { max-width: 480px; margin: 0 auto; padding: 0 16px 80px; }

/* Header */
.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--border);
}
.header h1 { font-size: 22px; font-weight: 700; }
.header-status { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* Tabs */
.tabs {
  display: flex; gap: 4px; padding: 12px 0; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; padding: 10px 6px; border: none; border-radius: 10px;
  background: var(--surface); color: var(--text2); font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
  font-weight: 500;
}
.tab.active { background: var(--purple); color: #fff; }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-top: 12px;
}
.card-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); margin-bottom: 12px;
}

/* Gauge */
.gauge-wrap { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: var(--surface2); stroke-width: 8; }
.gauge-fill { fill: none; stroke: var(--purple); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.8s; }
.gauge-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 24px; font-weight: 700;
}

/* Bars */
.bar-wrap { margin-top: 4px; }
.bar { height: 12px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.8s; }
.bar-fill.ram { background: linear-gradient(90deg, var(--purple), var(--cyan)); }
.bar-fill.disk { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.bar-text { font-size: 13px; color: var(--text2); margin-top: 6px; text-align: right; }

/* Stat row */
.stat-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text2); margin-top: 8px; }
.stat-row b { color: var(--text); }

/* OpenClaw status */
.oc-status { display: flex; flex-direction: column; gap: 8px; }
.oc-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.badge {
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge.online { background: #22c55e22; color: var(--green); }
.badge.offline { background: #ef444422; color: var(--red); }
.path { font-size: 12px; color: var(--text2); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Apps */
.apps-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.app-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.app-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.app-name { font-size: 15px; font-weight: 600; }
.app-desc { font-size: 12px; color: var(--text2); line-height: 1.3; }
.app-meta { font-size: 11px; color: var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.app-badge { font-size: 12px; font-weight: 600; }
.app-badge.on { color: var(--green); }
.app-badge.off { color: var(--red); }
.app-toggle {
  padding: 8px 20px; border-radius: 20px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.app-toggle.on { background: var(--red); color: #fff; }
.app-toggle.off { background: var(--green); color: #000; }

/* File browser */
.file-switch { display: flex; gap: 4px; margin-top: 12px; }
.switch-btn {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: var(--surface); color: var(--text2); font-size: 13px;
  cursor: pointer; transition: all 0.2s;
}
.switch-btn.active { background: var(--purple); color: #fff; }

.breadcrumb {
  display: flex; gap: 4px; padding: 10px 0; flex-wrap: wrap;
  font-size: 12px; color: var(--text2);
}
.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { color: var(--purple); }
.breadcrumb .sep { color: var(--border); }

.file-list { margin-top: 4px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 6px; cursor: pointer;
  transition: background 0.15s;
}
.file-item:active { background: var(--surface2); }
.file-icon { font-size: 20px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11px; color: var(--text2); }

/* Overlay */
.overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 100; display: flex; flex-direction: column;
}
.overlay.hidden { display: none; }
.overlay-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}
.overlay-actions { display: flex; gap: 6px; }
.btn-sm {
  padding: 6px 12px; border: none; border-radius: 8px;
  background: var(--purple); color: #fff; font-size: 12px;
  cursor: pointer; font-weight: 500;
}
#fileEditor {
  flex: 1; padding: 16px; background: var(--surface); color: var(--text);
  border: none; outline: none; font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 13px; resize: none; line-height: 1.5;
}

/* Upload */
.upload-area { margin-top: 12px; }
.upload-label {
  display: block; padding: 20px; text-align: center;
  background: var(--surface); border: 2px dashed var(--border);
  border-radius: var(--radius); color: var(--text2); cursor: pointer;
  font-size: 14px; transition: border-color 0.2s;
}
.upload-label:active { border-color: var(--purple); }

/* Tasks */
.tasks-list { margin-top: 12px; }
.task-day {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
}
.task-date { font-size: 13px; color: var(--purple); font-weight: 600; margin-bottom: 8px; }
.task-entry {
  font-size: 13px; color: var(--text2); padding: 4px 0;
  border-bottom: 1px solid var(--border); line-height: 1.4;
}
.task-entry:last-child { border-bottom: none; }

/* Loading */
.loading { text-align: center; color: var(--text2); padding: 40px 0; font-size: 14px; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }