:root {
      --bg: #ffffff; --border: #000000; --text: #000000;
      --accent: #eeeeee; --danger: #cc0000; --highlight: #b3d9ff;
      --unsaved: #ff9900; --ai-blue: #007bff; --ai-green: #28a745;
      --overlay: rgba(0,0,0,0.5);
      --request-pending: #ff6600;
    }
	

.editor-wrapper {
  position: relative;
  display: flex;
  height: 100%;
  overflow: hidden;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 15px;
  background: #fcfcfc;
}

/* mirror layer (line numbers) */
.mirror {
  position: absolute;
  inset: 0;
  padding: 6px 12px 6px 60px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  color: transparent;
  overflow: hidden;
  pointer-events: none;
  line-height: 1.6em;
  font-size: inherit;
  font-family: inherit;
  counter-reset: linenumber;
  user-select: none;
  background: linear-gradient(to right, #f0f0f0 60px, transparent 60px);
}

.mirror div {
  position: relative;
}

/* line numbers on LEFT with gold divider */
.mirror div::before {
  counter-increment: linenumber;
  content: counter(linenumber);

  position: absolute;
  left: -52px;

  width: 44px;
  text-align: right;

  color: #6e6e6e;
  font-size: 14px;

  padding-right: 8px;

  /* gold divider */
  border-right: 5px solid grey;
}

/* textarea (editor) */
textarea {
  position: absolute;
  inset: 0;
  padding: 6px 12px 6px 70px;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #1a1a1a;
  resize: none;
  line-height: 1.6em;
  font-size: inherit;
  font-family: inherit;
  overflow: auto;
  z-index: 2;
  box-sizing: border-box;
}

/* scrollbar styling */
textarea::-webkit-scrollbar {
  width: 10px;
}

textarea::-webkit-scrollbar-track {
  background: #f0f0f0;
}

textarea::-webkit-scrollbar-thumb {
  background: #aaa;
}
	
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: 'Courier New', monospace; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }
    .app { height: 100vh; display: flex; flex-direction: column; border: 2px solid var(--border); }
 

 .header { border-bottom: 2px solid var(--border); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: bold; text-transform: uppercase; height: 50px; }
    #p-wrap { display: none; width: 100%; height: 4px; background: #eee; position: absolute; top: 50px; z-index: 100; }
    #p-bar { height: 100%; background: var(--ai-blue); width: 0%; transition: width 0.3s; }
    .workspace-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; }
    .top-split { display: flex; height: 35%; border-bottom: 2px solid var(--border); min-height: 120px; }
    .selector-zone { width: 50%; border-right: 1px solid var(--border); padding: 10px; overflow-y: auto; background: #fdfdfd; }
    .button-zone { width: 50%; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
    .control-btn { background: #fff; border: 2px solid var(--border); padding: 10px; cursor: pointer; font-size: 11px; font-weight: bold; text-transform: uppercase; text-align: center; }
    .control-btn:hover { background: #000; color: #fff; }
    .control-btn.active-mode { background: var(--highlight); }
    .control-btn.pending-requests { border-color: var(--request-pending) !important; color: var(--request-pending) !important; box-shadow: 0 0 6px var(--request-pending); }
    .dropdown-row { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; padding: 2px; position: relative; }
    .dropdown-row.hidden-row { display: none; }
    .adjust-mode .dropdown-row.hidden-row { display: flex; opacity: 0.4; }
    .custom-dropdown { flex: 1; border: 1px solid var(--border); height: 32px; display: flex; align-items: center; position: relative; background: #fff; }
    .dropdown-value { flex: 1; padding: 6px; border-right: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-size: 13px; }
    .dropdown-value.unsaved { border-bottom: 3px solid var(--unsaved); }
    .dropdown-arrow { padding: 6px 10px; font-size: 10px; cursor: pointer; }
    .dropdown-options { display: none; position: fixed; background: #fff; border: 1px solid var(--border); max-height: 200px; overflow-y: auto; z-index: 9999; }
    .option { padding: 8px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 12px; }
    .bottom-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
    .resizer-horizontal { height: 8px; background: #444; cursor: ns-resize; user-select: none; }
    .resizer-horizontal:hover, .resizer-horizontal:active { background: var(--ai-blue); }
    #editor-container { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
    #editor { flex: 1; padding: 12px; border: none; outline: none; background: #f9f9f9; font-size: 14px; resize: none; font-family: monospace; width: 100%; min-height: 0; }
    .editor-history { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.7); color: white; padding: 4px 10px; border-radius: 6px; font-size: 12px; z-index: 10; }
    .editor-history button { background: #555; color: white; border: none; border-radius: 4px; width: 28px; height: 28px; font-size: 16px; cursor: pointer; }
    .editor-history button:hover { background: var(--ai-blue); }
    .editor-history button:disabled { opacity: 0.4; cursor: not-allowed; }
    .ai-panel { display: none; border-top: 2px solid var(--border); padding: 12px; background: #fff; flex-direction: column; max-height: 400px; overflow-y: auto; position: relative; }
   


   .ai-panel.visible { display: flex; }
    .ai-header { display: flex; align-items: center; font-weight: bold; margin-bottom: 12px; font-size: 12px; gap: 50px; }
    .ai-modes span { cursor: pointer; margin-right: 12px; }
    .ai-modes span.active { color: blue; border-bottom: 2px solid blue; }
    .ai-section { display: none; }
    .ai-section.active { display: flex; flex-direction: column; gap: 10px; }
    .chat-container { display: flex; flex-direction: column; gap: 10px; }
    @media (min-width: 300px) { .chat-container { flex-direction: row; } .chat-container textarea { width: 50% !important; } }
    .hi-container { display: flex; flex-direction: column; gap: 10px; }
    @media (min-width: 1000px) { .hi-container { flex-direction: row; align-items: flex-start; } }
    .hi-grabs { width: 100%; border: 1px solid #ccc; background: #f0f0f0; max-height: 140px; overflow-y: auto; padding: 6px; }
    @media (min-width: 1000px) { .hi-grabs { width: 160px; max-height: none; height: 100%; } }
    .hi-main { flex: 1; display: flex; flex-direction: column; gap: 10px; }
    @media (min-width: 1000px) { .hi-main { flex-direction: row; } .hi-main textarea { width: calc(50% - 5px); } }
    .ai-text { width: 100%; height: 120px; padding: 8px; font-family: monospace; font-size: 12px; border: 1px solid var(--border); }
    .grab-item { font-size: 11px; padding: 6px 8px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; background: #fff; margin-bottom: 3px; border-radius: 3px; }
    .grab-item span { color: red; cursor: pointer; font-weight: bold; margin-left: 8px; }
    .viewer-modal, .requests-modal { position: fixed; bottom: 0; left: 0; right: 0; height: 70%; background: white; border-top: 2px solid var(--border); box-shadow: 0 -4px 20px rgba(0,0,0,0.3); z-index: 1000; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.3s ease; }
    .viewer-modal.active, .requests-modal.active { transform: translateY(0); }
    .viewer-overlay, .requests-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 999; display: none; }
    .viewer-overlay.active, .requests-overlay.active { display: block; }
    .viewer-header, .requests-header { padding: 12px 16px; background: #f8f8f8; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: bold; }
    .viewer-toolbar { padding: 10px; background: #eee; border-bottom: 1px solid var(--border); display: flex; gap: 12px; font-size: 11px; font-weight: bold; text-transform: uppercase; }
    .viewer-content, .requests-content { flex: 1; overflow-y: auto; padding: 15px; }
    #viewer-path { padding: 8px 16px; background: #f8f8f8; border-bottom: 1px solid var(--border); font-size: 13px; }
    #viewer-path span { cursor: pointer; color: #0066cc; text-decoration: underline; margin: 0 4px; }
    .tree-item { padding: 6px; cursor: pointer; font-size: 14px; border-bottom: 1px solid #f0f0f0; }
    .tree-item:hover { background: var(--accent); }
    .tree-item.selected { background: var(--highlight); font-weight: bold; }
    .folder::before { content: "📁 "; } .file::before { content: "📄 "; }
    .action-btn { padding: 4px 12px; cursor: pointer; border: 1px solid #000; background: #fff; font-weight: bold; font-size: 10px; }
    .action-btn:hover { background: #000; color: #fff; }
    #workspace-name { font-size: 16px; }
    #chat-refresh-timer { font-size: 11px; color: #666; margin-left: auto; }

#rights-toast {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  color: #000;
  padding: 20px;
  font-family: monospace;
  font-size: 1em;
  border: none;
  z-index: 999999999;
  display: none;
  box-shadow: none;
  white-space: pre-line;
  text-align: left;
  box-sizing: border-box;
}

.option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: black;
}

.file-name {
  text-align: left;
}

.file-label {
  text-align: right;
  color: black;
  font-size: 12px;
}


#session-closed-screen{
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background:#fff;
display:none;
z-index:999999;
align-items:center;
justify-content:center;
font-family:monospace;
}

.session-message{
text-align:center;
}

.session-message h1{
font-size:28px;
margin-bottom:20px;
}

.session-message a{
color:#1a73e8;
text-decoration:underline;
font-size:16px;
cursor:pointer;
}

/* =====================================================================
   NEW ADDITIONS BELOW — nothing above this line was changed
   ===================================================================== */

/* ── BUTTON ZONE: always scrollable so buttons never get squashed ────── */
.button-zone {
  overflow-y: auto;
}

/* ── TOP-SPLIT: horizontal resize handle between selector and buttons ───
   #resizer-v sits between .selector-zone and .button-zone inside
   .top-split. It is only shown/active in TOP mode (default).
   In side mode it is hidden because the whole panel becomes vertical.   */
#resizer-v {
  width: 6px;
  height: 100%;
  background: #444;
  cursor: ew-resize;
  user-select: none;
  flex-shrink: 0;
}
#resizer-v:hover,
#resizer-v:active { background: var(--ai-blue); }

/* hide the vertical inner resizer when in side mode */
.workspace-layout.side-mode #resizer-v {
  display: none;
}

/* ── AI PANEL FIX ────────────────────────────────────────────────────────
   The original panel has no explicit height so textareas collapse.
   We give it a sensible min/max, keep it as a flex column, and let the
   textareas fill their section rather than defaulting to 0.             */

/* ai-panel: when visible, allow it to scroll its own content naturally.
   The textareas are now in normal flow (not absolute) so overflow-y:auto
   lets the user scroll if the panel is taller than the viewport slice.  */
.ai-panel.visible {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 45vh;
}

/* active section: plain flex column, gap between its children */
.ai-section.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* chat container — matches original style but respects new flow */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 1000px) {
  .chat-container { flex-direction: row; }
  .chat-container .ai-text { flex: 1; }
}

/* highlight container */
.hi-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 1000px) {
  .hi-container { flex-direction: row; align-items: flex-start; }
  .hi-grabs     { width: 160px; flex-shrink: 0; max-height: none; height: auto; }
  .hi-main      { flex: 1; display: flex; flex-direction: row; gap: 8px; }
  .hi-main .ai-text { flex: 1; }
}

/* ── AI TEXTAREAS: escape the global textarea { position:absolute } rule ──
   The global rule sets position:absolute;inset:0 for the CODE editor
   textareas. The AI panel textareas (.ai-text) must opt out of that or
   they collapse to 0 because they have no positioned ancestor with
   a real height. Reset them to normal document flow here.               */
.ai-text {
  position: relative !important;  /* NOT absolute — must flow normally    */
  inset: auto !important;         /* cancel the global inset:0            */
  z-index: auto !important;
  width: 100%;
  min-height: 120px;
  height: 120px;
  padding: 8px;
  font-family: monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  resize: vertical;               /* let user resize vertically           */
  box-sizing: border-box;
  background: #fff;
  color: #000;
}

/* ── SIDE PANEL MODE ─────────────────────────────────────────────────────
   Flip the main layout to row so .top-split becomes a left sidebar.     */

.workspace-layout.side-mode {
  flex-direction: row;
}

.workspace-layout.side-mode .top-split {
  flex-direction: column;
  width: 260px;         /* JS drag-resizer overrides this inline */
  min-width: 160px;
  max-width: 520px;
  height: 100%;
  min-height: 0;
  border-bottom: none;
  border-right: 2px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.workspace-layout.side-mode .selector-zone {
  width: 100%;
  border-right: none;
  border-bottom: 1px solid var(--border);
  flex: 1;
  min-height: 0;
}

.workspace-layout.side-mode .button-zone {
  width: 100%;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 55%;      /* cap so selector-zone always shows      */
  grid-template-columns: 1fr 1fr;
}

/* The horizontal top-resizer (ns-resize bar) is meaningless in side mode */
.workspace-layout.side-mode > #resizer-top {
  display: none;
}

/* The editing area fills remaining horizontal space */
.workspace-layout.side-mode .bottom-area {
  flex: 1;
  min-width: 0;
}

/* ── SIDE-PANEL DRAG HANDLE (ew-resize between sidebar and editor) ──────
   Hidden by default; becomes visible only in .side-mode.                */
#resizer-side {
  display: none;
  width: 8px;
  height: 100%;
  background: #444;
  cursor: ew-resize;
  user-select: none;
  flex-shrink: 0;
  z-index: 5;
}
#resizer-side:hover,
#resizer-side:active { background: var(--ai-blue); }

.workspace-layout.side-mode #resizer-side {
  display: block;
}

/* Orient button pressed state */
#orient-btn.side-active { background: #000; color: #fff; }

/* Snippet grab item — preview text wraps, doesn't overflow the box */
.grab-item {
  flex-wrap: wrap;
  align-items: flex-start;
  cursor: default;
}
.grab-preview {
  flex: 1;
  word-break: break-all;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 11px;
  color: #222;
  line-height: 1.4em;
}

/* In ADJUST mode, dropdown rows stack vertically to show the file list */
.adjust-mode .dropdown-row {
  flex-direction: column;
  align-items: stretch;
  height: auto;
}
.adjust-mode .dropdown-row > div:first-child {
  /* the top bar (dropdown + X button) stays as a row */
  flex-direction: row;
}