/* instance screens — design/canvas/Console-Instance-Overview.dc.html, Console-Instance-Terminal.dc.html
   and design/STYLE.md. Shared components are in /app.css; everything here is prefixed inst-. */

/* ---------- header + tab bar (shared by every instance tab) ---------- */
.inst-head { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.inst-head .crumbs .inst-crumb { color: var(--text); overflow-wrap: anywhere; }
.inst-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; }
.inst-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-width: 0; }
.inst-name h1 { line-height: 1.2; letter-spacing: -0.01em; }
.inst-meta { display: contents; }
.inst-meta .badge { color: var(--text); }
.inst-meta .badge.suspended, .inst-meta .badge.error, .inst-meta .badge.deleting { color: var(--bad); }
.inst-id { color: var(--muted); }
.inst-host { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.inst-host svg { flex: none; }
.inst-msg { font-size: 13px; color: var(--muted); }
.inst-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inst-actions > button, .inst-actions > .btn { padding: 0 14px; }
.inst-actions .ghost.icon { color: var(--text-2); }

.inst-more { position: relative; }
.inst-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 240px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line-3);
  border-radius: 10px; box-shadow: 0 24px 64px var(--shadow); max-width: calc(100vw - 32px);
}
.inst-menu.flip { right: auto; left: 0; }
.inst-menu[hidden] { display: none; }
.inst-menu button { justify-content: flex-start; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; background: none; color: var(--text-2); font-weight: 500; }
.inst-menu button:hover, .inst-menu button:focus-visible { background: var(--raised); color: var(--text); }
.inst-menu button .hint { margin-left: auto; font-size: 12px; }
.inst-menu button.bad, .inst-menu button.bad:hover { color: var(--bad); }

.inst-tabs { gap: 24px; }
.inst-tabs a { padding: 10px 2px; color: var(--muted); font-weight: 400; }
.inst-tabs a.on { color: var(--text); font-weight: 600; }
.inst-banners { display: flex; flex-direction: column; gap: 12px; }
.inst-banners:empty { display: none; }

/* ---------- shared bits ---------- */
.inst-card { min-width: 0; display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; }
.inst-card h2 { margin: 0; }
.inst-card h3 { margin: 0; }
.inst-card-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.inst-card-head { display: flex; flex-direction: column; gap: 4px; }
.inst-p { margin: 0; }
.inst-wide { grid-column: 1 / -1; }
.inst-loading { padding: 8px 0; font-size: 13px; }
.inst-empty { padding: 32px 20px; text-align: center; margin: 0; }
.inst-note { margin: 4px 0 0; padding: 12px 14px; background: var(--bg); border-radius: var(--r); font-size: 13px; color: var(--muted); }
.inst-note code, .inst-steps code, .inst-term-hint code { background: none; padding: 0; color: var(--text-2); }
.inst-card .bad, .inst-dl .bad { color: var(--bad); }
.inst-nw { white-space: nowrap; }
.inst-b2 { color: var(--text-2); }

/* command / URL well with a copy button */
.inst-well {
  flex: 1 1 220px; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 40px; padding: 0 4px 0 12px; background: var(--well); border: 1px solid var(--line-2); border-radius: var(--r);
}
.inst-well code { background: none; padding: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.inst-well .pr { color: var(--faint); }
.inst-well .copy, .inst-dl .copy { border-color: transparent; }

.inst-spin { animation: inst-rot 0.9s linear infinite; }
.inst-spin .trk { stroke: var(--line-2); }
.inst-spin .arc { stroke: var(--accent-text); }
@keyframes inst-rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .inst-spin { animation: none; } }

/* ---------- overview ---------- */
.inst-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 20px; align-items: start; }
.inst-grid > .card { margin: 0; }
.inst-dl { margin: 0; display: grid; grid-template-columns: minmax(110px, 140px) minmax(0, 1fr); }
.inst-dl dt { padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.inst-dl dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.inst-dl dd.cp { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 7px 0; }
.inst-dl dt:last-of-type, .inst-dl dd:last-of-type { border-bottom: 0; }
.inst-dl .trunc { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-dl dd.cp .trunc { flex: 0 1 auto; }
.inst-dl dd.cp.nw { flex-wrap: nowrap; }

.inst-rows { display: flex; flex-direction: column; }
.inst-row { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.inst-row:first-child { padding-top: 0; }
.inst-row:last-child { border-bottom: 0; padding-bottom: 0; }
.inst-row-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.inst-row .t { font-weight: 500; }
.inst-row .nm { display: flex; flex-direction: column; }
.inst-row .v { font-size: 12px; }
.inst-row .hint { margin: 0; }
.badge.inst-ok { color: var(--ok-text); }
.badge.inst-hollow::before { background: none; border: 1.5px solid var(--faint); }
.inst-login { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inst-login .btn { padding: 0 14px; }
.inst-meter { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.inst-meter > span { display: block; height: 100%; background: var(--info); border-radius: 999px; }
.inst-meter.warn > span { background: var(--warn); }
.inst-meter.bad > span { background: var(--bad); }
.inst-jobs { display: inline-flex; align-items: center; gap: 12px; }
.inst-asleep { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.inst-asleep p { margin: 0; color: var(--text-2); }
.inst-asleep .ic, .inst-wait .ic { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r); background: var(--raised); color: var(--info); }

.inst-port { display: flex; flex-direction: column; gap: 14px; }
.inst-port-fields { display: flex; flex-wrap: wrap; gap: 16px; }
.inst-port-num { flex: 0 1 140px; }
.inst-port-num input { width: 100%; font-family: var(--mono); }
.inst-seg-field { margin: 0; padding: 0; border: 0; min-width: 0; flex: 1 1 220px; display: flex; flex-direction: column; }
.inst-seg-field legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.inst-seg { display: inline-flex; align-self: flex-start; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r); }
.inst-seg label {
  position: relative; flex-direction: row; align-items: center; gap: 6px; min-height: 32px; padding: 0 14px; border: 1px solid transparent;
  border-radius: 6px; color: var(--body); font-size: 14px; font-weight: 400; cursor: pointer;
}
.inst-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.inst-seg label:has(input:checked) { background: var(--raised); border-color: var(--line-3); color: var(--text); font-weight: 600; }
.inst-seg label:has(input:focus-visible) { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.inst-url { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inst-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

.inst-gs-t { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.inst-gs-t .eyebrow { font-size: 12px; }
.inst-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.inst-steps li { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.inst-steps li:first-child { padding-top: 0; }
.inst-steps li:last-child { border-bottom: 0; padding-bottom: 0; }
.inst-steps .mk { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-3); }
.inst-steps li.done .mk { border: 0; background: var(--raised); color: var(--ok); }
.inst-steps li.done .mk svg { stroke-width: 2.4; }
.inst-steps .tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inst-steps .t { font-weight: 500; }
.inst-steps li.done .t { font-weight: 400; color: var(--body); }
.inst-steps .d { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.inst-log { min-width: 760px; }
.inst-log th:first-child, .inst-log td:first-child { padding-left: 0; }
.inst-log th:last-child, .inst-log td:last-child { padding-right: 0; }
.inst-log td { height: 50px; padding-top: 8px; padding-bottom: 8px; }
.inst-log td.det { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.inst-log tr.outsider td { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.inst-log tr.outsider td:first-child { padding-left: 10px; }
.inst-out { display: block; font-size: 12px; color: var(--bad); }
.inst-log-foot { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

.inst-danger { border-color: var(--bad-line); gap: 4px; }
.inst-danger > .inst-card-top { margin-bottom: 8px; }
.inst-danger h2 { color: var(--bad); }
.inst-zone { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; padding: 16px 0; border-bottom: 1px solid var(--line); margin: 0; }
.inst-zone:last-child { border-bottom: 0; padding-bottom: 0; }
.inst-zone .tx { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.inst-zone .tx p { margin: 0; font-size: 13px; color: var(--muted); max-width: 560px; }
.inst-zone .ctl { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; min-width: 0; }
.inst-zone select { min-width: min(220px, 100%); max-width: 100%; }
.inst-zone label { min-width: 0; max-width: 100%; }

/* ---------- waiting panel (tab needs a running instance) ---------- */
.inst-wait { display: flex; align-items: center; justify-content: center; min-height: 320px; padding: 32px 24px; background: var(--panel); border: 1px solid var(--line-card); border-radius: var(--r-card); }
.inst-wait.term { background: var(--well); border-color: var(--line-2); min-height: min(560px, max(360px, calc(100vh - 340px))); }
.inst-wait .in { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.inst-wait h2 { margin: 0; }
.inst-wait p { margin: 0; color: var(--body); }

/* ---------- terminal ---------- */
.inst-term { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.inst-term-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.inst-term-bar .l { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-width: 0; }
.inst-term-bar .r { display: flex; align-items: center; gap: 4px; }
.inst-term-bar .r button { min-height: 36px; color: var(--text-2); }
.inst-term-bar .sep { width: 1px; height: 20px; background: var(--line-2); }
.inst-sessions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.inst-chip {
  min-height: 32px; padding: 0 12px; gap: 8px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent;
  color: var(--body); font: 400 13px var(--mono); max-width: 100%;
}
.inst-chip[aria-pressed="true"] { background: var(--raised); border-color: var(--line-3); color: var(--text); font-weight: 500; }
.inst-chip.add { border-style: dashed; border-color: var(--line-3); font-family: var(--sans); color: var(--text-2); gap: 6px; }
.inst-conn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.inst-conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.inst-conn.ok .dot { background: var(--ok); }
.inst-conn.warn .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.inst-conn.bad .dot { background: var(--bad); }

.inst-term-panel {
  position: relative; display: flex; flex-direction: column; height: min(560px, max(360px, calc(100vh - 340px)));
  background: var(--well); border: 1px solid var(--line-2); border-radius: var(--r-card); overflow: hidden; min-width: 0;
}
.inst-term-panel .top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.inst-term-panel .top span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.inst-term-panel .scr { flex: 1; min-height: 0; padding: 10px 6px 6px 14px; }
#inst-xterm { height: 100%; }
.inst-term-panel .xterm .xterm-viewport { background-color: var(--well) !important; scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
.inst-term-panel:fullscreen { height: 100vh; border: 0; border-radius: 0; }
.inst-term-panel:fullscreen .inst-term-over { top: 0; }
.inst-term-err { padding: 14px 4px; }
.inst-term-over {
  position: absolute; top: 35px; right: 0; bottom: 0; left: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(9, 11, 14, 0.82);
}
.inst-term-over[hidden] { display: none; }
.inst-term-over .box { max-width: 440px; display: flex; flex-direction: column; gap: 12px; padding: 22px 24px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-card); box-shadow: 0 24px 64px var(--shadow); }
.inst-term-over .box p { margin: 0; }
.inst-term-over .h { display: flex; align-items: center; gap: 10px; font: 600 18px var(--display); }
.inst-term-over .h svg { color: var(--bad); flex: none; }
.inst-term-over .rs { font-size: 12px; }
.inst-term-over .row { padding-top: 4px; }
.inst-term-hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line-card); border-radius: var(--r-card); }
.inst-term-hint p { margin: 0; font-size: 13px; }
.inst-term-hint .tip { flex: 1 1 520px; min-width: 0; display: flex; align-items: flex-start; gap: 10px; color: var(--body); }
.inst-term-hint .tip svg { flex: none; margin-top: 2px; color: var(--info); }
.inst-term-hint .kbd { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.inst-term-hint kbd { font: 12px var(--mono); color: var(--text); background: var(--raised); border: 1px solid var(--line-3); border-radius: 6px; padding: 1px 7px; }

/* ---------- files ---------- */
.inst-files { display: flex; flex-direction: column; }
.inst-files.drop { border-color: var(--accent-text); }
.inst-files-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.inst-files-head input { flex: 1 1 240px; font-family: var(--mono); font-size: 13px; }
.inst-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; padding: 10px 20px; border-bottom: 1px solid var(--line); font: 13px var(--mono); color: var(--text); }
.inst-crumbs .sl { color: var(--faint); }
.inst-crumbs .inst-lnk { min-height: 28px; padding: 0 4px; font: 13px var(--mono); color: var(--muted); }
.inst-lnk { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent-text); font: inherit; text-align: left; white-space: normal; }
.inst-lnk:hover { background: none; color: var(--text); text-decoration: underline; }
.inst-ftable td, .inst-ftable th, .inst-envtable td, .inst-envtable th { padding-left: 20px; padding-right: 20px; }
.inst-ftable td.nm { min-width: 0; }
.inst-ftable .dir, .inst-ftable .fl { display: inline-flex; align-items: center; gap: 10px; min-height: 32px; color: var(--text); overflow-wrap: anywhere; }
.inst-ftable .dir svg { color: var(--accent-text); flex: none; }
.inst-ftable .fl svg { color: var(--muted); flex: none; }
.inst-ftable .dir:hover span, .inst-ftable .fl:hover span { color: var(--accent-text); }
.inst-ftable td.act, .inst-envtable td.act { width: 1%; white-space: nowrap; text-align: right; }
.inst-ftable td.act button:hover, .inst-envtable td.act button[data-k]:hover { color: var(--bad); }
.inst-files-foot { margin: 0; padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- env ---------- */
.inst-env { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 980px; }
.inst-env-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inst-env-form label { flex: 1 1 220px; min-width: 0; }
.inst-env-form input { width: 100%; font-family: var(--mono); font-size: 13px; }
.inst-env > .card.flush { gap: 0; padding: 0; }
.inst-env-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.inst-envtable td.k { color: var(--text); overflow-wrap: anywhere; }
.inst-envtable td.v { color: var(--text-2); }
.inst-envtable td.v > span { overflow-wrap: anywhere; margin-right: 8px; }
.inst-envtable td.v .copy { vertical-align: middle; }
.inst-env-note { margin: 0; padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- API ---------- */
.inst-api { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 1080px; }
.inst-api-base { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: 760px; }
.inst-ex { gap: 12px; }
.inst-ex pre.code { font-size: 13px; overflow-wrap: anywhere; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .inst-card { padding: 18px 16px; }
  .inst-dl { grid-template-columns: 1fr; }
  .inst-dl dt { padding: 10px 0 0; border-bottom: 0; }
  .inst-dl dd, .inst-dl dd.cp { padding: 2px 0 10px; }
  .inst-tabs a, .inst-chip, .inst-term-bar .r button, .inst-crumbs .inst-lnk { min-height: 44px; }
  .inst-seg label { min-height: 40px; }
  .inst-term-bar .sep { display: none; }
  .inst-term-panel { height: max(360px, calc(100vh - 300px)); }
  .inst-term-panel .scr { padding-left: 8px; }
  .inst-files-head, .inst-crumbs, .inst-files-foot { padding-left: 16px; padding-right: 16px; }
  .inst-ftable td, .inst-ftable th, .inst-envtable td, .inst-envtable th { padding-left: 12px; padding-right: 12px; }
}

/* a copy the instance sent on its own, offered to the viewer */
.inst-clip { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 14px; background: var(--raised); border: 1px solid var(--accent); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); color: var(--text-2); font-size: 13px; }
.inst-clip[hidden] { display: none; }
.inst-clip > svg { flex: none; color: var(--accent); }
.inst-clip .t { flex: 1 1 260px; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.inst-clip code { font: 12px var(--mono, "JetBrains Mono", monospace); color: var(--text); background: none; padding: 0; }
