:root{
  /* TOP placeholder */
  --topbar-h: 52px;

  /* outer spacing around CRT */
  --outer-pad-x: 22px;
  --outer-pad-y: 14px;

  /* CRT look */
  --crt-radius: 22px;
  --crt-border: rgba(120, 255, 180, 0.18);

  --crt-green: #49ff7a;
  --crt-green-soft: rgba(73, 255, 122, 0.18);
  --crt-inner-glow: rgba(0,255,65,0.18);

  /* glass */
  --glass-dark-1: rgba(0, 40, 10, 0.85);
  --glass-dark-2: rgba(0,  0,  0, 0.93);
  --glass-dark-3: rgba(0,  0,  0, 0.985);

  /* typography */
  --base-font: 12px;
  --menu-font: 12px;

  /* padding INSIDE CRT */
  --pad-x: 18px;
  --pad-y: 36px;

  --menu-h: 72px;

  --menu-gap: calc((var(--menu-h) - var(--menu-font)) / 2);
  /* red private mode */
  --crt-red: rgba(255,60,60,0.90);
  --crt-red-soft: rgba(255,60,60,0.12);
}

html, body{ height:100%; }

body.crt-layout{
  margin:0;
  background:#000;
  color: var(--crt-green);
  overflow:hidden;
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--base-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Matrix canvas behind everything */
body.crt-layout #matrix-bg{
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* TOP placeholder outside CRT */
body.crt-layout .top{
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--outer-pad-y));
  z-index: 100;
  display:flex;
  align-items:center;
  background: transparent;
}

/* align logo start to CRT text start: outer pad + border + CRT padding */
body.crt-layout .top-inner{
  width: 100%;
  height: 100%;
  display:flex;
  align-items:center;

  padding-left: calc(var(--outer-pad-x) + var(--pad-x) + 1px);
  padding-right: calc(var(--outer-pad-x) + var(--pad-x) + 1px);
  box-sizing: border-box;
}

body.crt-layout .top .logo{ padding: 0 !important; margin: 0 !important; display:flex; align-items:center; }
body.crt-layout .top .logo-text{
  display:inline-flex;
  align-items:center;
  line-height: 1;
  margin: 0;
  padding: 0;

  /* less “stretched” mono */
  font-family: "DejaVu Sans Mono", "Liberation Mono", "Menlo", "Monaco", "Consolas", "Lucida Console", "Courier New", monospace;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.05em;

  color: rgba(73,255,122,0.92);
  text-shadow:
    0 0 12px rgba(73,255,122,0.14),
    0 0 2px rgba(73,255,122,0.18);

  user-select: none;
}

/* MIDDLE area */
body.crt-layout .main{
  position: fixed;
  left: 0; right: 0;
  top: calc(var(--topbar-h) + var(--outer-pad-y));
  bottom: var(--outer-pad-y);
  z-index: 10;

  padding-left: var(--outer-pad-x);
  padding-right: var(--outer-pad-x);
  box-sizing: border-box;

  display:flex;
  align-items: stretch;
}

body.crt-layout .main-inner{
  width:100%;
  height:100%;
  max-width:none;
  display:flex;
  align-items: stretch;
}

/* CRT screen */
body.crt-layout .crt-screen{
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: var(--crt-radius);
  overflow: hidden;

  background:
    radial-gradient(120% 90% at 50% 45%, var(--glass-dark-1) 0%, var(--glass-dark-2) 55%, var(--glass-dark-3) 100%);

  border: 1px solid var(--crt-border);

  box-shadow:
    0 0 0 2px rgba(0,0,0,0.90) inset,
    0 0 0 1px rgba(255,255,255,0.04) inset,
    inset 0 0 26px var(--crt-inner-glow),
    0 18px 55px rgba(0,0,0,0.75),
    0 0 45px var(--crt-green-soft);
}

/* scanlines */
body.crt-layout .crt-screen::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.020) 0px,
      rgba(255,255,255,0.020) 1px,
      rgba(0,0,0,0.000) 2px,
      rgba(0,0,0,0.000) 4px
    );
  opacity: 0.12;
  mix-blend-mode: overlay;
  pointer-events:none;
}

/* vignette + reflection */
body.crt-layout .crt-screen::after{
  content:"";
  position:absolute;
  inset:-1px;
  background:
    radial-gradient(120% 90% at 50% 50%, rgba(0,0,0,0.00) 40%, rgba(0,0,0,0.78) 100%),
    linear-gradient(135deg,
      rgba(255,255,255,0.06) 0%,
      rgba(255,255,255,0.00) 35%,
      rgba(255,255,255,0.03) 62%,
      rgba(255,255,255,0.00) 100%
    );
  opacity: 0.85;
  pointer-events:none;
}

/* scroll area inside CRT (tighter line spacing) */
body.crt-layout .crt-content{
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: auto;

  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
  padding-top: var(--pad-y);
  padding-bottom: calc(var(--pad-y) + var(--menu-h));

  background: rgba(0,0,0,0.70);

  color: rgba(73,255,122,0.66);
  text-shadow:
    0 0 8px rgba(73,255,122,0.14),
    0 0 1px rgba(73,255,122,0.18);

  line-height: 1.22;

  scrollbar-color: var(--crt-green) rgba(0,0,0,0.55);
  scrollbar-width: thin;
}

/* reduce paragraph vertical gaps */
body.crt-layout .crt-content p{ margin: 0 0 2px 0; }
body.crt-layout .crt-content p:last-child{ margin-bottom: 0; }

/* Menu inside CRT */
body.crt-layout .crt-screen .bottom{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--menu-h);
  z-index: 200;
  display:flex;
  align-items:center;

  background: rgba(0,0,0,0.85);
  border-top: 1px solid rgba(120,255,180,0.18);
}

body.crt-layout .crt-screen .bottom-inner{
  width: 100%;
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
  overflow: visible;
}

/* DOS menu */
body.crt-layout .dosbar{
  display:flex;
  align-items:center;
  gap: 14px;
  user-select:none;
  font-size: var(--menu-font);
  color: var(--crt-green);
}

body.crt-layout .dosbar-left{
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.08em;
  min-width: 5ch;
}

body.crt-layout .dos-cursor{
  display:inline-block;
  margin-left: 0.15ch;
  animation: dosCursorBlink 1s steps(1,end) infinite;
}
@keyframes dosCursorBlink{ 50%{ opacity: 0; } }

body.crt-layout .dosbar-right{ flex:1; overflow: visible; }

body.crt-layout .dosbar-rightinfo{
  margin-left: auto;
  display:flex;
  align-items:center;
  gap: 10px;
  white-space: nowrap;
}

/* >> chevrons (ON: > then >> then nothing) */
body.crt-layout .sys-chevrons{
  display:inline-flex;
  align-items:center;
  margin-right: 6px;
}
body.crt-layout .sys-chevrons .chev{
  display:inline-block;
  width: 1ch;
  text-align: center;
  opacity: 0;
}
body.crt-layout .sys-chevrons .c1{ animation: chev1 900ms steps(1,end) infinite; }
body.crt-layout .sys-chevrons .c2{ animation: chev2 900ms steps(1,end) infinite; }

/* 0-33%: only first ">" visible
   33-66%: both visible (">>")
   66-100%: none visible */
@keyframes chev1{
  0%, 66%{ opacity: 1; }
  66.01%, 100%{ opacity: 0; }
}
@keyframes chev2{
  0%, 33%{ opacity: 0; }
  33.01%, 66%{ opacity: 1; }
  66.01%, 100%{ opacity: 0; }
}

/* system/version label (glitches) */
body.crt-layout .dos-sys{
  position: relative;
  display: inline-block;
  padding: 0 2px;
  letter-spacing: 0.06em;
  opacity: 0.82;
  color: rgba(73,255,122,0.82);
  text-shadow:
    0 0 10px rgba(73,255,122,0.12),
    0 0 1px rgba(73,255,122,0.18);
}
body.crt-layout .dos-sys.glitching{
  opacity: 0.96;
  text-shadow:
    -1px 0 rgba(0,255,65,0.55),
     1px 0 rgba(0,180,60,0.35),
     0 0 14px rgba(73,255,122,0.22);
  animation: sysFlicker 220ms steps(1,end) infinite;
}
body.crt-layout .dos-sys.glitching::before{
  content:"";
  position:absolute;
  left:-2px; right:-2px; top:-2px; bottom:-2px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0.00) 0px,
    rgba(0,0,0,0.00) 2px,
    rgba(0,0,0,0.25) 3px,
    rgba(0,0,0,0.25) 3.5px
  );
  opacity: 0.45;
  pointer-events:none;
  mix-blend-mode: overlay;
}
@keyframes sysFlicker{
  0%{ transform: translateY(0); filter: blur(0.0px); }
  50%{ transform: translateY(0.5px); filter: blur(0.25px); }
  100%{ transform: translateY(0); filter: blur(0.0px); }
}

/* power dot */
body.crt-layout .crt-power{
  width: var(--menu-font);
  height: var(--menu-font);
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid rgba(73,255,122,0.78);
  background: #000;
  padding: 0;
  margin: 0;
  cursor: pointer;
  box-shadow: none;
}
body.crt-layout .crt-power.on{
  background: rgba(73,255,122,0.90);
  box-shadow:
    0 0 10px rgba(73,255,122,0.55),
    0 0 26px rgba(73,255,122,0.22);
}
body.crt-layout .crt-power.on.pulse{ animation: crtPowerOn 240ms ease-out; }
@keyframes crtPowerOn{
  0%{ transform: scale(0.65); background: rgba(73,255,122,0.00); box-shadow: none; }
  100%{
    transform: scale(1);
    background: rgba(73,255,122,0.90);
    box-shadow:
      0 0 10px rgba(73,255,122,0.55),
      0 0 26px rgba(73,255,122,0.22);
  }
}

/* tier menus (unchanged) */
body.crt-layout .dos-tier1,
body.crt-layout .dos-tier2,
body.crt-layout .dos-tier3{
  list-style:none;
  padding:0;
  margin:0;
}
body.crt-layout .dos-tier1{
  display:flex;
  gap: 2.0ch;
  align-items:center;
  overflow: visible;
}
body.crt-layout .dos-tier1 > li{ position: relative; }
body.crt-layout .dos-tier2 > li{ position: static; }

body.crt-layout .dosbar a{
  color: var(--crt-green);
  text-decoration:none;
  display:inline-block;
  padding: 2px 2px;
}
body.crt-layout .dos-tier1 > li:hover > a,
body.crt-layout .dos-tier2 > li:hover > a{
  background: var(--crt-green);
  color:#000;
}
body.crt-layout .dos-tier2{
  position:absolute;
  left: 0;
  bottom: 100%;

  min-width: 24ch;
  background: rgba(0,0,0,0.90);
  border: 1px solid rgba(73,255,122,0.35);
  border-radius: 0;
  box-shadow: 0 0 18px rgba(73,255,122,0.10);
  padding: 6px 0;

  opacity: 0;
  transform: translateY(6px);
  pointer-events:none;
  z-index: 220;
}
body.crt-layout .dos-tier1 > li:hover > .dos-tier2{
  opacity:1;
  transform: translateY(0);
  pointer-events:auto;
}
body.crt-layout .dos-tier2 > li > a{
  display:block;
  padding: 3px 10px;
  width: 100%;
}
body.crt-layout .dos-tier3{
  position:absolute;
  left: 100%;
  top: auto;
  bottom: -1px;

  min-width: 24ch;
  background: rgba(0,0,0,0.90);
  border: 1px solid rgba(73,255,122,0.35);
  border-radius: 0;
  box-shadow: 0 0 18px rgba(73,255,122,0.10);
  padding: 6px 0;

  opacity: 0;
  transform: translateX(-6px);
  pointer-events:none;
  z-index: 230;
}
body.crt-layout .dos-tier2 > li:hover > .dos-tier3{
  opacity:1;
  transform: translateX(0);
  pointer-events:auto;
}
body.crt-layout .dos-tier3 > li > a{
  display:block;
  padding: 3px 10px;
  width: 100%;
}

/* Scrollbar (WebKit) */
body.crt-layout .crt-content::-webkit-scrollbar{ width: 10px; }
body.crt-layout .crt-content::-webkit-scrollbar-track{
  background: rgba(0,0,0,0.55);
  border-left: 1px solid rgba(73,255,122,0.18);
}
body.crt-layout .crt-content::-webkit-scrollbar-thumb{
  background: var(--crt-green);
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,0.75);
}
body.crt-layout .crt-content::-webkit-scrollbar-thumb:hover{
  background: rgba(73,255,122,0.85);
}

/* --------- Hidden console UI --------- */
body.crt-layout .crt-normal{ display:block; }
body.crt-layout .crt-console{ display:none; }

body.crt-layout .crt-console{
  color: var(--crt-red);
  text-shadow: 0 0 10px var(--crt-red-soft);
}

body.crt-layout .crt-console-log{
  white-space: pre-wrap;
}

body.crt-layout .crt-console-line{
  padding: 1px 0;
}

body.crt-layout .crt-console-prefix{
  font-weight: 700;
  letter-spacing: 0.06em;
}

body.crt-layout .crt-console-inputrow{
  margin-top: 8px;
  display:flex;
  align-items: baseline;
  gap: 8px;
}

body.crt-layout .crt-console-input{
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--crt-red);
  font: inherit;
  padding: 0;
  margin: 0;
  min-width: 10ch;
}

body.crt-layout .crt-console-hint{
  opacity: 0.55;
  margin-top: 6px;
}

/* OFF mode:
   - sys turns red
   - chevrons freeze as ">>"
   - normal content hidden, console shown
*/
body.crt-layout.crt-off .dos-sys{
  color: var(--crt-red);
  text-shadow: 0 0 10px var(--crt-red-soft);
}
body.crt-layout.crt-off .sys-chevrons{ color: var(--crt-red); }
body.crt-layout.crt-off .sys-chevrons .chev{
  animation: none !important;
  opacity: 1 !important; /* shows ">>" */
  color: var(--crt-red);
}
body.crt-layout.crt-off .dos-sys.glitching{ animation: none; }
body.crt-layout.crt-off .dos-sys.glitching::before{ display:none; }

/* keep crt-content visible for console */
body.crt-layout.crt-off .crt-content{
  background: #000;
  color: var(--crt-red);
  text-shadow: 0 0 10px var(--crt-red-soft);

  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

body.crt-layout.crt-off .crt-normal{ display:none; }
body.crt-layout.crt-off .crt-console{ display:block; }

/* crt41 console symmetry:
   - make crt-content a flex column in OFF mode
   - console log scrolls; input row stays pinned above the menu divider
   - reserve menu space + symmetric gap via --menu-gap
*/
body.crt-layout.crt-off .crt-console{
  display:flex;
  flex-direction:column;
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: calc(var(--menu-h) + var(--menu-gap));
}

body.crt-layout.crt-off .crt-console-log{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

body.crt-layout.crt-off .crt-console-inputrow{
  margin-top: 0;
}


/* make the screen darker in off mode */
body.crt-layout.crt-off .crt-screen::before,
body.crt-layout.crt-off .crt-screen::after{
  opacity: 0;
}
body.crt-layout.crt-off .crt-screen{
  background: rgba(0,0,0,0.97);
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.94) inset,
    0 0 0 1px rgba(255,255,255,0.03) inset,
    0 18px 55px rgba(0,0,0,0.85);
}
body.crt-layout.crt-off .crt-power{
  background: #000;
  box-shadow: none;
}
/* --- Green mode split panes (independent scroll) --- */
body.crt-layout .crt-normal{
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.crt-layout .crt-toprow{ flex: 0 0 auto; }

body.crt-layout .crt-split{
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--crt-left-w, 52ch) 1fr;
  gap: 18px;
}

body.crt-layout .crt-pane{
  min-height: 0;
  overflow: auto;
}

body.crt-layout .crt-pane pre{
  margin: 0;
  white-space: pre;
}

/* scrollbars for panes (match CRT look) */
body.crt-layout .crt-pane::-webkit-scrollbar{
  width: 10px;
}
body.crt-layout .crt-pane::-webkit-scrollbar-track{
  background: rgba(0,0,0,0.55);
  border-left: 1px solid rgba(73,255,122,0.18);
}
body.crt-layout .crt-pane::-webkit-scrollbar-thumb{
  background: var(--crt-green);
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,0.75);
}
body.crt-layout .crt-pane::-webkit-scrollbar-thumb:hover{
  background: rgba(73,255,122,0.85);
}


/* --- Green mode: disable outer scroll (panes scroll) --- */
body.crt-layout:not(.crt-off) .crt-content{
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
body.crt-layout:not(.crt-off) .crt-normal{
  flex: 1 1 auto;
  min-height: 0;
}
body.crt-layout.crt-off .crt-content{
  overflow: auto;
  display: block;
}
/* --- Split panes polish (divider + stable scrollbars) --- */
/* keep layout stable when scrollbars appear */
body.crt-layout .crt-pane{
  scrollbar-gutter: stable both-edges;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-color: var(--crt-green) rgba(0,0,0,0.55);
  scrollbar-width: thin;
}

/* --- copy-to-clipboard addresses --- */
body.crt-layout .copy-addr{
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
body.crt-layout .copy-addr:hover{
  text-shadow: 0 0 12px rgba(73,255,122,0.18);
}
body.crt-layout .copy-addr:focus{
  outline: 1px dotted rgba(73,255,122,0.55);
  outline-offset: 2px;
}
body.crt-layout .copy-addr.copied{
  text-shadow:
    0 0 18px rgba(73,255,122,0.35),
    0 0 6px rgba(73,255,122,0.18);
}




body.crt-layout{
}

/* clickable UI */
body.crt-layout a,
body.crt-layout button,
body.crt-layout [role="button"]{
}

/* keep text caret for inputs */
body.crt-layout input,
body.crt-layout textarea{
  cursor: text;
}

45%  { left: calc(100% - 10px); opacity: 1; }
  50%  { left: calc(100% - 10px); opacity: 0; }
  100% { left: 0; opacity: 0; }
}

/* === CRT_MOBILE_MINIMAL (hide all CRT content on mobile; show MC server list only) === */
@media (max-width: 900px), (hover: none) and (pointer: coarse){
  body.crt-layout .top{ display:none !important; }
  body.crt-layout .main{ display:none !important; }
  body.crt-layout #matrix{ display:none !important; }
  body.crt-layout .crt-mobile-only{ display:block !important; }
}

/* default: hidden on desktop */
body.crt-layout .crt-mobile-only{
  display:none;
  padding: 16px 14px 18px;
}

body.crt-layout .crt-mobile-wrap{
  max-width: 560px;
  margin: 0 auto;
  border: 1px solid rgba(73,255,122,0.22);
  background: rgba(0,0,0,0.35);
  box-shadow: 0 0 22px rgba(73,255,122,0.10);
  border-radius: 12px;
  padding: 14px 14px 12px;
}

body.crt-layout .crt-mobile-logo{
  font-family: "Press Start 2P", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 18px;
  line-height: 1.1;
  color: rgba(55,235,125,0.85);
  text-shadow: 0 0 10px rgba(55,235,125,0.12);
  margin: 2px 0 10px;
}

body.crt-layout .crt-mobile-pre{
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(207,232,214,0.90);
}

body.crt-layout .crt-mobile-foot{
  margin-top: 10px;
  font-size: 11px;
  opacity: 0.75;
  letter-spacing: .06em;
}
/* === END CRT_MOBILE_MINIMAL === */

/* === CRT_MOBILE_MINIMAL_OVERRIDE (force-hide CRT shell/menu on mobile) === */
@media (max-width: 900px), (hover: none) and (pointer: coarse){
  body.crt-layout #matrix{ display:none !important; }

  /* nuke everything inside the CRT shell */
  body.crt-layout .shell > *{
    display:none !important;
  }

  /* ...then allow only the minimal mobile block */
  body.crt-layout .crt-mobile-only{
    display:block !important;
  }
}
/* === END CRT_MOBILE_MINIMAL_OVERRIDE === */

/* agent-fixed-prompt-v1: keep top padding visible; scroll log only; prompt fixed above bottom bar */
:root{
  --menu-gap: calc((var(--menu-h) - var(--menu-font)) / 2);
}

body.crt-off .crt-content{
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* keep prompt symmetric with bottom menu text spacing */
  padding-bottom: calc(var(--menu-h) + var(--menu-gap));
}

body.crt-off .crt-console{
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body.crt-off .crt-console-log{
  flex: 1;
  min-height: 0;
  overflow: auto;
}
/* end agent-fixed-prompt-v1 */
