:root {
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --bg-elev-2: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #2496ed;
  --accent-hover: #1d7fcc;
  --service: #2496ed;
  --network: #94a3b8;
  --error: #ef4444;
  --mono: "JetBrains Mono", "Courier New", ui-monospace, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo {
  font-size: 20px;
  color: var(--accent);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--mono);
}

.tag {
  color: var(--text-dim);
  font-size: 12px;
}

.tag code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.repo-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.repo-link:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.input-pane, .output-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}

.pane-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.ph-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--mono);
  line-height: 1.2;
}

.header-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

#lint.collapsed { display: none; }

.export-wrap {
  position: relative;
}

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  min-width: 90px;
  z-index: 10;
  overflow: hidden;
}

.export-menu[hidden] { display: none; }

.export-menu button {
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text);
  text-align: left;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}

.export-menu button:hover {
  background: var(--bg-elev-2);
  color: var(--accent);
}

.sample-wrap {
  position: relative;
}

.sample-toggle {
  font-family: var(--sans);
}

.sample-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  min-width: 180px;
  z-index: 10;
  overflow: hidden;
}

.sample-menu[hidden] { display: none; }

.sample-menu button {
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text);
  text-align: left;
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

.sample-menu button:hover {
  background: var(--bg-elev-2);
  color: var(--accent);
}

.files-loaded {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  font-family: var(--mono);
  font-size: 11px;
}

.files-loaded[hidden] { display: none; }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
}

.file-chip:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.file-chip.main {
  border-color: var(--accent);
  color: var(--accent);
}

.file-chip.dockerfile {
  border-color: #a16207;
  color: #fde68a;
  cursor: default;
}

.file-chip.dockerfile:hover {
  border-color: #d97706;
  color: #fde68a;
}

.file-chip.manifest {
  border-color: #047857;
  color: #6ee7b7;
  cursor: default;
}

.file-chip.manifest:hover {
  border-color: #059669;
  color: #6ee7b7;
}

.file-chip .x {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
}

.file-chip .x:hover {
  color: var(--error);
}

.actions {
  display: flex;
  gap: 8px;
}

button {
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--text-dim);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.textarea-wrap {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 300px;
}

#compose-input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

.drop-overlay {
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(36, 150, 237, 0.12);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

.drop-overlay[hidden] { display: none; }

.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border-top: 1px solid var(--error);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
  align-items: center;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.service { background: var(--service); }
.dot.network { background: var(--network); border: 1px dashed var(--bg); outline: 1px dashed var(--network); outline-offset: -1px; }
.dot.volume { background: #334155; border: 1px solid #64748b; border-radius: 2px; }
.dot.bind { background: #1e293b; border: 1px solid #a16207; border-radius: 2px; }

.edge {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px solid var(--service);
}

.edge.depends { border-top-style: solid; border-color: var(--service); }
.edge.net { border-top-style: dashed; border-color: var(--network); }

#graph {
  flex: 1;
  min-height: 360px;
  background:
    radial-gradient(circle, rgba(148, 163, 184, 0.08) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--bg);
}

.bottom-panels {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  max-height: 50vh;
  border-top: 1px solid var(--border);
}

#ports {
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
}

#lint {
  padding: 14px;
  font-size: 13px;
}

#dockerfiles, #stack {
  padding: 14px;
  font-size: 13px;
}

.lint-empty {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--sans);
}

.lint-summary {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.lint-summary.ok { color: #22c55e; }
.lint-summary.has-warn { color: #f59e0b; }
.lint-summary.has-error { color: #ef4444; }

.lint-group {
  margin-bottom: 14px;
}

.lint-group h3 {
  margin: 0 0 6px 0;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--mono);
}

.lint-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lint-group li {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg);
  border-left: 3px solid var(--text-dim);
}

.lint-group li.lint-warn {
  border-left-color: #f59e0b;
}

.lint-group li.lint-error {
  border-left-color: #ef4444;
}

.lint-group li .icon {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.lint-group li.lint-warn .icon { color: #f59e0b; }
.lint-group li.lint-error .icon { color: #ef4444; }

.lint-group li .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.lint-group li .msg {
  color: var(--text);
  font-family: var(--sans);
}

.lint-group li .msg code,
.lint-group li .hint code {
  font-family: var(--mono);
  background: var(--bg-elev-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.lint-group li .hint {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
}

.lint-group li .rule {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 2px;
}

.ports-empty {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--sans);
}

.port-group {
  margin-bottom: 12px;
}

.port-group h3 {
  margin: 0 0 6px 0;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--mono);
}

.port-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.port-group li {
  padding: 3px 0;
  color: var(--text);
}

.port-group li .arrow {
  color: var(--text-dim);
  margin: 0 6px;
}

.port-group li .proto {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 6px;
}

.dockerfiles-empty {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--sans);
}

.dockerfile-group {
  margin-bottom: 14px;
}

.dockerfile-group h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dockerfile-group .badge {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  background: rgba(36, 150, 237, 0.12);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
}

.dockerfile-group dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-size: 12px;
}

.dockerfile-group dt {
  color: var(--text-dim);
  font-family: var(--sans);
  font-weight: 500;
}

.dockerfile-group dd {
  margin: 0;
  color: var(--text);
}

.dockerfile-group dd code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}

.dockerfile-group dd .arrow {
  color: var(--text-dim);
  margin: 0 4px;
}

.dockerfile-group dd .stage-tag {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--sans);
}

.stack-empty {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--sans);
}

.stack-empty code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-dim);
}

.stack-group {
  margin-bottom: 14px;
}

.stack-group h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--mono);
}

.stack-group dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-size: 12px;
}

.stack-group dt {
  color: var(--text-dim);
  font-family: var(--sans);
  font-weight: 500;
}

.stack-group dd {
  margin: 0;
  color: var(--text);
}

.stack-group dd code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}

.stack-group dd .stage-tag {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--sans);
}

.bottombar {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
}

.bottombar a {
  color: var(--text-dim);
  text-decoration: none;
}

.bottombar a:hover {
  color: var(--text);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* Pop-out mode: graph fills the whole window. The OS handles moving it
 * between monitors. Triggered by ?popout=graph in the URL. */
body.popout-graph {
  overflow: hidden;
}

body.popout-graph .topbar,
body.popout-graph .bottombar,
body.popout-graph .input-pane,
body.popout-graph .lint-header,
body.popout-graph #lint,
body.popout-graph .ports-header,
body.popout-graph #ports,
body.popout-graph .dockerfiles-header,
body.popout-graph #dockerfiles,
body.popout-graph .stack-header,
body.popout-graph #stack,
body.popout-graph .bottom-panels,
body.popout-graph #popout-graph {
  display: none !important;
}

body.popout-graph .layout {
  grid-template-columns: 1fr;
  padding: 0;
  gap: 0;
  height: 100vh;
}

body.popout-graph .output-pane {
  border: none;
  border-radius: 0;
  height: 100vh;
}

body.popout-graph .graph-header {
  border-radius: 0;
}

body.popout-graph #graph {
  flex: 1 1 auto;
  min-height: 0;
}
