* { box-sizing: border-box; }

:root {
  --bg: #14110f;
  --ink: #f2ece4;
  --muted: #c7b7a8;
  --panel: rgba(31, 25, 22, 0.9);
  --bar: rgba(31, 25, 22, 0.88);
  --border: #3a3028;
  --border-strong: #4a3d34;
  --border-hover: #6c5a4c;
  --item: #211a16;
  --item-hover: #2a211c;
  --ok: #7d9b76;
  --bad: #a0625a;
  --fill: #6c5a4c;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

a { color: inherit; }

.page { width: min(1140px, 100%); margin: 0 auto; }

/* top bar — same treatment as luca-server.com */
.bar {
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  background: var(--bar);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.bar-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.12rem;
  text-transform: uppercase;
}
.bar-side { display: flex; align-items: baseline; gap: 14px; color: var(--muted); font-size: 0.9rem; }

.nav { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.nav-link {
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  background: var(--item);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
  cursor: pointer;
}
.nav-link:hover { background: var(--item-hover); border-color: var(--border-hover); }
.nav-link.active { color: var(--ink); border-color: var(--border-hover); background: var(--item-hover); }

.panel {
  padding: 22px;
  border: 1px solid var(--border);
  background: var(--panel);
  margin-bottom: 20px;
}
.panel h1 { margin: 0 0 18px; font-size: 1.35rem; font-weight: 500; }
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; font-weight: 500; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 20px; }
.grid .panel { margin-bottom: 0; }

.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.meter { border: 1px solid var(--border-strong); background: var(--item); height: 14px; position: relative; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--fill); }
.meter-fill.hot { background: var(--bad); }
.meter-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-bottom: 8px; }
.meter-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.92rem; margin-bottom: 4px; gap: 12px; }
.meter-label .strong { color: var(--ink); }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }

.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-top: 14px; }
.core { font-size: 0.8rem; color: var(--muted); }
.core .meter { height: 8px; margin-top: 3px; }

table { width: 100%; border-collapse: collapse; }
td .mono, td.mono { overflow-wrap: anywhere; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; letter-spacing: 0.08rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(42, 33, 28, 0.5); }
.num { text-align: right; white-space: nowrap; }

.btn {
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  background: var(--item);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn:hover { background: var(--item-hover); border-color: var(--border-hover); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
.btn.danger:hover { border-color: var(--bad); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.input {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--border-hover); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: var(--muted); vertical-align: baseline; }
.dot.running { background: var(--ok); }
.dot.failed { background: var(--bad); }
.dot.stopped { background: var(--border-hover); }

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.error-text { color: var(--bad); margin: 10px 0 0; }

/* files */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 14px; color: var(--muted); overflow-wrap: anywhere; }
.crumb { cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-hover); }
.crumb:hover { color: var(--ink); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h1 { margin: 0; }

.ctx-menu {
  position: fixed; z-index: 100; min-width: 190px;
  border: 1px solid var(--border-hover); background: #241d18;
  padding: 4px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
.ctx-item { padding: 8px 14px; cursor: pointer; font-size: 0.92rem; }
.ctx-item:hover { background: var(--item-hover); }
.ctx-item.danger { color: #c98a80; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

.rubber-band {
  position: fixed; z-index: 90; pointer-events: none;
  border: 1px solid var(--border-hover);
  background: rgba(108, 90, 76, 0.18);
}

.files-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 235px);
  user-select: none;
  -webkit-user-select: none;
}
.nav-row { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.path-wrap { position: relative; flex: 1; }
.path-input { width: 100%; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; user-select: text; -webkit-user-select: text; }
.btn.icon { padding: 8px 13px; line-height: 1; font-size: 0.95rem; }

.suggest {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 60;
  border: 1px solid var(--border-hover); background: #241d18;
  max-height: 260px; overflow-y: auto;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
.suggest-item { padding: 7px 12px; cursor: pointer; font-size: 0.8rem; overflow-wrap: anywhere; color: var(--muted); }
.suggest-item:hover, .suggest-item.active { background: var(--item-hover); color: var(--ink); }

.file-tile.hidden-file { opacity: 0.45; }
.files-panel.drop-target { border-color: var(--border-hover); background: rgba(42, 33, 28, 0.92); }

.file-grid {
  flex: 1;
  align-content: start;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
  min-height: 120px;
}
.file-tile { padding: 14px 8px 10px; border: 1px solid transparent; text-align: center; cursor: default; }
.file-tile:hover { background: var(--item-hover); border-color: var(--border); }
.file-tile.selected { background: var(--item-hover); border-color: var(--border-hover); }
.tile-icon svg { width: 46px; height: 46px; display: block; margin: 0 auto 8px; }
.tile-name {
  font-size: 0.82rem; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.file-tile:hover .tile-name, .file-tile.selected .tile-name { color: var(--ink); }

/* terminal */
#terminal-holder {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  padding: 10px;
  height: calc(100vh - 260px);
  min-height: 320px;
}
#terminal-holder .xterm { height: 100%; }

/* editor + dialogs */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 8, 7, 0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
}
.overlay .panel { width: min(900px, 100%); max-height: 90vh; display: flex; flex-direction: column; margin: 0; }
.editor-area {
  flex: 1; min-height: 300px; resize: none;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border-strong);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem; line-height: 1.5; padding: 12px;
}
.editor-area:focus { outline: none; border-color: var(--border-hover); }
.overlay .btn-row { margin-top: 14px; justify-content: flex-end; }

/* login */
.login-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; }
.login-panel { width: min(380px, 100%); }
.hidden { display: none !important; }

@media (max-width: 700px) {
  body { padding: 12px; }
  .panel { padding: 16px; }
  th, td { padding: 8px 8px; }
}
