/* ===== Basalt ===== */
html, body { height:100%; margin:0; }
body { height:100vh; font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif; color:#111; }

/* ===== To hovedkolonner – lige brede ===== */
main{
  display:grid;
  grid-template-columns: 1fr 1fr;   /* venstre | højre */
  gap:12px;
  height:100%;
  padding:8px 12px 12px;            /* lille top-padding */
  box-sizing:border-box;
  align-items:stretch;
}

/* ===== Venstre kolonne: overskrift + stack + (picker/intro) ===== */
.left-grid{
  display:grid;
  grid-template-areas:
    "head head"
    "stack picker"
    "stack intro";         /* intro står lige under picker */
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto 1fr; /* tæt under overskrift */
  gap:12px;
  min-height:0; overflow:hidden;
  align-content:start;
}

/* Overskrift kompakt */
.left-header{ grid-area: head; margin:0; padding:0; }
.left-header h1{ margin:0; line-height:1.15; }
.left-header .sub{ margin:2px 0 0 0; color:#444; }

/* Stack: AI + Refleksion uden mellemrum */
.left-stack{ grid-area: stack; display:flex; flex-direction:column; gap:0; min-height:0; }
.left-stack .ai-panel{
  border-bottom-left-radius:0; border-bottom-right-radius:0; margin:0;
}
.left-stack .refl-panel{
  border-top-left-radius:0; border-top-right-radius:0; margin:0;
}

/* Højre del af venstre kolonne */
#taskPicker { grid-area: picker; }
#intro      { grid-area: intro; display:flex; flex-direction:column; min-height:0; }

/* ===== Højre kolonne =====
   Editor har mest plads. Test og Konsol deler resten lige. */
.right-grid{
  display:grid;
  grid-template-rows:
    minmax(34vh, 2fr)   /* editor */
    auto                /* knapper */
    minmax(0, 1fr)      /* test */
    minmax(0, 1fr);     /* konsol */
  gap:8px;
  min-height:0; overflow:hidden;
}

/* ===== Paneler / knapper ===== */
.panel{
  border:1px solid #eee; border-radius:8px; padding:12px;
  min-height:0; display:flex; flex-direction:column; background:#fff;
}
.panel-header{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:6px; }
.row{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.btn{ padding:8px 12px; border:1px solid #ccc; background:#fafafa; border-radius:6px; cursor:pointer; user-select:none; }
.btn:hover{ background:#f3f3f3; } .btn:disabled{ opacity:.6; cursor:not-allowed; }
.btn.danger{ border-color:#e88; background:#fff6f6; } .btn.danger:hover{ background:#ffecec; }
.btn.sm{ padding:6px 10px; font-size:.9rem; }
.flex-spacer{ flex:1 1 auto; }

/* Tabs i testpanelet */
.tabs{ display:flex; gap:6px; align-items:center; }
.tab{
  padding:6px 10px; border:1px solid #ccd; background:#f7f8fb;
  border-radius:6px; cursor:pointer; user-select:none; font-size:.95rem;
}
.tab:hover{ background:#f0f2f7; }
.tab:disabled{ opacity:.6; cursor:not-allowed; }
.tab.active{ background:#e9eefc; border-color:#b8c3ff; }

/* Tekstområder */
.desc{ color:#333; margin:4px 0 8px; }
.term{ background:#0f172a; color:#e6eef7; padding:8px; border-radius:6px; white-space:pre-wrap;
       font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Courier New",monospace; line-height:1.35; }

/* Scrollbare mørke områder */
#ai, #console{
  flex:1; min-height:0; overflow:auto;
  background:#0f172a; color:#e6eef7; padding:12px; border-radius:6px; white-space:pre-wrap;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Courier New",monospace; line-height:1.45;
}

/* Editor */
#editor-wrap{
  position:relative; border:1px solid #ddd; border-radius:6px;
  min-height:34vh; height:100%; overflow:hidden;
}
#editor{ position:absolute; inset:0; width:100%; height:100%; overflow:hidden; }

/* Testresultat (samme hjælp som editor) */
.tests{ height:100%; overflow:hidden; }
.tests-body{ flex:1 1 auto; min-height:0; overflow:auto; }
#testExplain{ white-space:pre-wrap; }
.is-hidden{ display:none !important; }

/* Konsol */
.console-panel{ height:100%; overflow:hidden; }

/* Status / spinner */
.ok{ color:#0a0; } .fail{ color:#b00; }
.spinner{ width:16px; height:16px; border:3px solid currentColor; border-right-color:transparent; border-radius:50%; display:inline-block; vertical-align:middle; animation:spin .8s linear infinite; opacity:.8; margin-left:6px; }
@keyframes spin{ to { transform: rotate(360deg); } }
.muted{ color:#666; }

/* Responsivt */
@media (max-width:1200px){
  main{ grid-template-columns: 1fr; }
  .left-grid{
    grid-template-areas:
      "head"
      "picker"
      "intro"
      "stack";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr;
  }
  .right-grid{ grid-template-rows: 40vh auto 1fr 1fr; }
}

/* Skjul evt. gamle stdin-elementer */
#stdinPanel, #stdinDetails, #stdin{ display:none !important; }
