/* Barbarosa — a one-operator console for a workspace that lives on your own
   server. Deep-water navy rather than the usual editor near-black, with a
   single brass accent for the things that carry state. No external fonts:
   the spec requires this page to work behind a restrictive proxy, so the
   type personality comes from scale, weight and tracking instead. */

:root {
  --hull:   #0b1520;  /* page ground */
  --deck:   #111e2b;  /* panels */
  --rail:   #1d2f41;  /* borders */
  --fog:    #7f94aa;  /* secondary text */
  --chart:  #dbe6f1;  /* primary text */
  --brass:  #d9a441;  /* accent: selection, focus, the one bright thing */
  --signal: #4fb286;  /* saved */
  --flare:  #e2685f;  /* failed */

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

/* The hidden attribute must beat the id selectors below. Without this, both
   panes render stacked at 100vh each: the page scrolls and the login form
   never disappears after signing in. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;          /* only the tree and the editor scroll */
}

body {
  background: var(--hull);
  color: var(--chart);
  font: 13px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* Small caps-y labels, the way instrument panels label their dials. */
.field-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fog);
}
.field-label.inline { margin-left: 8px; }

.mark-name {
  font-weight: 620;
  letter-spacing: -.01em;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ---------- sign in ---------- */

#login {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 24px;
}

#login form {
  display: grid;
  gap: 8px;
  width: min(320px, 100%);
}

.mark { display: grid; gap: 2px; margin-bottom: 18px; }
.mark .mark-name { font-size: 26px; }
.mark-sub {
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fog);
}

#login input {
  padding: 10px 12px;
  background: var(--deck);
  border: 1px solid var(--rail);
  border-radius: 3px;
  color: var(--chart);
  font: 14px var(--mono);
}
#login input:focus { border-color: var(--brass); outline: none; }

#login button {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--brass);
  color: #21160a;
  border: 0;
  border-radius: 3px;
  font: 600 13px var(--sans);
  letter-spacing: .02em;
  cursor: pointer;
}
#login button:hover { filter: brightness(1.08); }

#login-error {
  margin: 2px 0 0;
  min-height: 2.6em;
  color: var(--flare);
  font-size: 12px;
}

/* ---------- workspace ---------- */

#workspace {
  display: grid;
  grid-template-columns: 288px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top  top"
    "side main";
  height: 100%;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 44px;
  background: var(--deck);
  border-bottom: 1px solid var(--rail);
}
.topbar-mark { font-size: 14px; margin-right: 4px; }

#project-picker {
  padding: 5px 8px;
  background: var(--hull);
  color: var(--chart);
  border: 1px solid var(--rail);
  border-radius: 3px;
  font: 12px var(--sans);
  max-width: 320px;
}

/* The one piece of ambient state: a brass lamp when saving, green when saved. */
#status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fog);
  min-height: 16px;
}
#status:not(:empty)::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
#status.is-saved { color: var(--signal); }
#status.is-error { color: var(--flare); }

.sidebar {
  grid-area: side;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  background: var(--deck);
  border-right: 1px solid var(--rail);
}

.rail-label {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fog);
  border-bottom: 1px solid var(--rail);
}

#file-tree { overflow: auto; padding: 6px 0; min-height: 0; }

/* The tree is a flat list of full paths. Dimming the directory and keeping the
   filename bright is what makes it scannable — it reads as a manifest. */
.row {
  display: block;
  width: 100%;
  padding: 3px 12px;
  font: 12px/1.5 var(--mono);
  color: var(--chart);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
}
.row:hover { background: #16283a; }
.row[aria-selected="true"] {
  background: #16283a;
  border-left-color: var(--brass);
}
.row .dir { color: var(--fog); }
.row .bin { color: var(--fog); font-style: italic; }

#file-tree .empty {
  margin: 0;
  padding: 16px 14px;
  color: var(--fog);
  font-size: 12px;
  line-height: 1.7;
}
#file-tree .empty strong { color: var(--chart); font-weight: 600; }
#file-tree .empty kbd {
  padding: 1px 5px;
  background: var(--hull);
  border: 1px solid var(--rail);
  border-radius: 3px;
  font: 11px var(--mono);
}

.pane {
  grid-area: main;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
}

.filebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 38px;
  border-bottom: 1px solid var(--rail);
}

#current-path {
  flex: 1;
  min-width: 0;
  font: 12px var(--mono);
  color: var(--fog);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#current-path.has-file { color: var(--chart); }

#save {
  padding: 5px 14px;
  background: transparent;
  color: var(--brass);
  border: 1px solid var(--brass);
  border-radius: 3px;
  font: 600 12px var(--sans);
  cursor: pointer;
}
#save:hover:not(:disabled) { background: var(--brass); color: #21160a; }
#save:disabled { color: var(--fog); border-color: var(--rail); cursor: default; }

#editor { min-width: 0; min-height: 0; }

@media (max-width: 720px) {
  #workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 180px 1fr;
    grid-template-areas: "top" "side" "main";
  }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--rail); }
  .topbar-mark { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
