/* ==========================================================================
   Agent Deck - instrument panel
   One ground, one ink, one accent. Surfaces separate by tone, never by lines.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/geist-mono-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ground */
  --bg: #0a0c0e;
  --rail: #0c0f12;
  --surface: #14181d;
  --surface-2: #1b2027;
  --surface-3: #232932;

  /* ink */
  --ink: #eef1f4;
  --ink-2: #a2abb6;
  --ink-3: #7c8794;

  /* signal */
  --live: #57d38c;
  --live-dim: rgba(87, 211, 140, 0.16);
  --danger: #ff7a76;
  --danger-dim: rgba(255, 122, 118, 0.12);
  --warn: #f0b429;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01" on, "cv01" on;
}

a { color: var(--ink); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }

::selection { background: rgba(87, 211, 140, 0.22); }

:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 2px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease,
              transform 140ms var(--ease-out), opacity 160ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn:disabled { opacity: 0.45; transform: none; cursor: default; }

.btn-primary { background: var(--ink); color: #0a0c0e; font-weight: 600; }
.btn-primary:hover { background: #fff; }

.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface); color: var(--ink); }

.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); }

.btn-block { width: 100%; }
.btn-lg { height: 42px; font-size: 14px; padding: 0 18px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: inline-grid;
  place-items: center;
  color: var(--ink-2);
  background: transparent;
  transition: background-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid transparent;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.input::placeholder { color: var(--ink-3); }
.input:hover { background: var(--surface-2); }
.input:focus {
  outline: none;
  border-color: rgba(87, 211, 140, 0.55);
  background: var(--surface-2);
}

select.input { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--danger-dim);
  color: #ffc9c7;
  font-size: 13px;
}
.error:empty { display: none; }

.note { color: var(--ink-3); font-size: 12.5px; line-height: 1.55; }

/* ------------------------------------------------------------------ login */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 42px;
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ink);
  color: #0a0c0e;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.03em;
}

.wordmark { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

.auth h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 600;
}

.auth p { margin: 0 0 28px; color: var(--ink-2); font-size: 14px; }

.qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
  border-radius: var(--r-sm);
  background: #fff;
  padding: 8px;
}

.secret {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 10px;
  margin-bottom: 16px;
  word-break: break-all;
  text-align: center;
}

.code-input {
  height: 54px;
  font-family: var(--mono);
  font-size: 24px;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------- app */

.app {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  height: 100dvh;
}

.rail {
  background: var(--rail);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0;
  min-height: 0;
  padding: 22px 14px 14px;
}

.rail-head { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.rail-head .host { margin-left: auto; color: var(--ink-3); font-size: 11.5px; }

.rail-actions { padding: 0 0 16px; }
.rail-actions .btn { width: 100%; justify-content: space-between; padding: 0 12px; }
.rail-actions .btn .kbd { color: var(--ink-3); font-size: 11px; font-weight: 500; }
.btn-primary .kbd { color: rgba(10, 12, 14, 0.45); }

.list {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -6px;
  padding: 0 6px;
}

.list-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px 8px;
  color: var(--ink-3);
  font-size: 12px;
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--ink-2);
  transition: background-color 150ms ease, color 150ms ease;
  animation: row-in 260ms var(--ease-out) both;
}
.row:hover { background: var(--surface); color: var(--ink); }
.row.on { background: var(--surface-2); color: var(--ink); }
.row:active { transform: scale(0.995); }

@keyframes row-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.dot.on { background: var(--live); box-shadow: 0 0 0 0 rgba(87, 211, 140, 0.5); animation: pulse 2.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(87, 211, 140, 0.34); }
  60%, 100% { box-shadow: 0 0 0 7px rgba(87, 211, 140, 0); }
}

.row-body { min-width: 0; display: block; }
.row-name {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.row-act { color: var(--ink-3); font-size: 11.5px; opacity: 0; transition: opacity 140ms ease; }
.row:hover .row-act, .row.on .row-act { opacity: 1; }
.row.new { display: none; }

.sys {
  display: grid;
  align-self: end;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--surface);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-top: 12px;
}
.sys { align-self: end; }
.sys div {
  background: var(--rail);
  padding: 9px 10px;
}
.sys span { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 2px; }
.sys b { font-size: 12.5px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- main */

.main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 26px;
  min-height: 68px;
}
.top-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.top-sub { color: var(--ink-3); font-size: 12.5px; }
body[data-view="home"] .top-left { display: none; }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.home {
  overflow-y: auto;
  padding: 8px 26px 60px;
}

.home-head, .deck { max-width: 940px; }

@media (min-width: 861px) {
  /* on the dashboard the cards are the navigation - the rail list only appears in a session */
  body[data-view="home"] .rail .list { display: none; }
}

.home-head { max-width: 720px; padding: 30px 0 34px; }
.home-head h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-weight: 600;
}
.home-head p { margin: 0; color: var(--ink-2); font-size: 14.5px; max-width: 46ch; }

.deck { display: flex; flex-direction: column; gap: 2px; }

.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 18px 20px;
  border-radius: var(--r);
  background: var(--rail);
  transition: background-color 160ms ease, transform 140ms var(--ease-out);
  animation: row-in 300ms var(--ease-out) both;
}
.card:hover { background: var(--surface); }
.card-main { min-width: 0; }
.card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 550;
  letter-spacing: -0.02em;
}
.card-line {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-line .fresh { color: var(--ink-2); }
.card-actions { display: flex; align-items: center; gap: 8px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: 0;
  white-space: nowrap;
}
.tag.live { background: var(--live-dim); color: var(--live); }
.tag.off { background: var(--surface); color: var(--ink-3); }

/* --------------------------------------------------------------- terminal */

.term-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 0 26px 22px;
}

.term-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 14px;
}
.term-name { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.term-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.term-shell {
  min-height: 0;
  min-width: 0;
  border-radius: var(--r);
  background: #07090b;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.022);
}
.term-bar .sep { color: var(--ink-3); opacity: 0.5; }
.term-host { padding: 10px 12px 4px; min-height: 0; min-width: 0; overflow: hidden; }
.term-host .xterm { height: 100%; }

/* ------------------------------------------------------------------ modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 10, 0.62);
  animation: fade-in 180ms ease both;
}
.modal[data-closing="1"] { animation: fade-out 130ms ease both; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

.sheet {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 26px;
  animation: sheet-in 220ms var(--ease-out) both;
}
.modal[data-closing="1"] .sheet { animation: sheet-out 130ms ease both; }

@keyframes sheet-in {
  from { opacity: 0; transform: scale(0.98) translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.99); }
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.sheet .sub { margin: 0 0 22px; color: var(--ink-3); font-size: 13px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.presets:empty { display: none; }
.preset {
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12.5px;
  transition: background-color 150ms ease, color 150ms ease, transform 140ms var(--ease-out);
}
.preset:hover { background: var(--surface-3); color: var(--ink); }
.preset:active { transform: scale(0.97); }
.preset[aria-pressed="true"] { background: var(--ink); color: #0a0c0e; font-weight: 550; }

.sheet-actions { display: flex; gap: 8px; margin-top: 22px; }
.sheet-actions .btn { flex: 1; }

/* -------------------------------------------------------------- minecraft */

.mc { max-width: 900px; margin: 0 auto; padding: 30px 26px 90px; }

.mc-head { margin-bottom: 34px; }
.mc-head h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.04em;
  font-weight: 600;
  line-height: 1.1;
}
.mc-head p { margin: 0; color: var(--ink-2); font-size: 14px; max-width: 54ch; }

.paste {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border-radius: var(--r);
  padding: 8px 8px 8px 4px;
}
.paste input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
}
.paste input::placeholder { color: var(--ink-3); }

.mc-section { margin-top: 46px; }
.mc-section h2 {
  margin: 0 0 12px;
  padding-left: 16px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0;
}

.pack {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
  border-radius: var(--r);
  background: var(--rail);
}
.pack img { width: 64px; height: 64px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-2); }
.pack .nm { font-size: 18px; font-weight: 550; letter-spacing: -0.02em; }
.pack .sm { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 12px;
  margin-top: 20px;
}
.create-row .field { margin: 0; }

.srv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--rail);
  margin-bottom: 3px;
  transition: background-color 160ms ease;
}
.srv:hover { background: var(--surface); }
.srv .nm { font-size: 14.5px; font-weight: 550; letter-spacing: -0.01em; }
.srv .sm { color: var(--ink-3); font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.srv-actions { display: flex; align-items: center; gap: 4px; }

.job {
  padding: 20px;
  border-radius: var(--r);
  background: var(--rail);
}
.job .nm { font-size: 16px; font-weight: 550; letter-spacing: -0.02em; }
.job .sm { color: var(--ink-2); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }

.bar {
  height: 3px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 16px;
}
.bar > i {
  display: block;
  height: 100%;
  width: 34%;
  background: var(--live);
  border-radius: 99px;
  animation: slide 1.5s var(--ease-in-out) infinite;
}
@keyframes slide { 0% { margin-left: -34%; } 100% { margin-left: 100%; } }

.done { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.addr {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--r-sm);
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }

  /* the rail collapses to a single bar: brand + new session */
  .rail {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    min-height: 56px;
  }
  .rail-head { padding: 0; flex: 1; }
  .rail-head .host { display: none; }
  .rail-actions { padding: 0; }
  .rail-actions .btn { width: auto; padding: 0 13px; gap: 8px; height: 32px; }
  .rail-actions .btn .kbd { display: none; }
  .rail .list, .rail .sys { display: none; }

  /* the top bar keeps only the app links - the title lives in the page body */
  .top {
    padding: 4px 8px 0;
    min-height: 0;
    justify-content: flex-end;
  }
  .top-title, .top-sub { display: none; }
  .top-right { gap: 2px; margin-left: 0; }
  .top-right .btn { height: 32px; padding: 0 9px; font-size: 12.5px; }
  .top-right .hide-sm { display: inline-flex; }

  .home { padding: 10px 14px 76px; }
  .home-head { padding: 14px 0 20px; }
  .home-head h1 { font-size: 27px; }
  .home-head p { font-size: 13.5px; }

  .term-view { padding: 0 10px 12px; }
  .term-head { padding: 2px 2px 10px; gap: 8px; flex-wrap: wrap; row-gap: 8px; }
  .term-name { font-size: 16px; flex: 1 1 auto; }
  .term-actions { width: 100%; margin-left: 0; justify-content: flex-end; gap: 4px; }
  .term-actions .btn { height: 30px; padding: 0 10px; font-size: 12.5px; }
  #term-scroll { display: none; }
  .term-shell { border-radius: 10px; }

  .card { padding: 15px 16px; gap: 14px; grid-template-columns: minmax(0, 1fr); }
  .card-title { font-size: 15.5px; }
  .card-actions { justify-content: flex-start; }
  .card-actions .btn { height: 32px; }

  .input, .paste input, .code-input { font-size: 16px; }

  .modal { padding: 12px; align-items: end; }
  .sheet { padding: 20px; max-width: none; }

  .mc { padding: 18px 14px 76px; }
  .create-row { grid-template-columns: 1fr; }
  .srv { grid-template-columns: auto minmax(0, 1fr); padding: 13px 14px; }
  .srv-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 2px; }
  .pack { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 16px; }
  .pack img { width: 52px; height: 52px; }
  .job { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .row, .card { animation: none; }
}

@media (hover: none) {
  .row:hover { background: transparent; }
  .card:hover { background: var(--rail); }
}
