:root {
  --bg: #f8f1e6;
  --bg-2: #f2e7d4;
  --ink: #1f1c17;
  --ink-2: #3d352b;
  --accent: #d76c2a;
  --accent-2: #1d6c8f;
  --card: #fff8ef;
  --card-2: #fef4e2;
  --shadow: rgba(28, 20, 12, 0.18);
  --line: rgba(31, 28, 23, 0.16);
  --mono: "Fira Code", "Consolas", "Courier New", monospace;
  --sans: "Trebuchet MS", "Verdana", "Geneva", sans-serif;
}

/* ===== Basalt ===== */
html, body { height:100%; margin:0; }
body {
  height:100vh;
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg), var(--bg-2));
}

/* ===== 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; font-family: "Palatino", "Book Antiqua", "Times New Roman", serif; }
.left-header .sub{ margin:2px 0 0 0; color:var(--ink-2); }

/* 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 var(--line);
  border-radius:14px;
  padding:12px;
  min-height:0;
  display:flex;
  flex-direction:column;
  background:linear-gradient(140deg, var(--card), var(--card-2));
  box-shadow: 0 16px 28px -24px var(--shadow);
}
.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 rgba(31, 28, 23, 0.2);
  background:#fff8ee;
  border-radius:999px;
  cursor:pointer;
  user-select:none;
  color: var(--ink-2);
  font-weight:700;
}
.btn:hover{ background:#ffefdc; }
.btn:disabled{ opacity:.6; cursor:not-allowed; }
.btn.danger{ border-color:#d7a3a3; background:#fff1ef; }
.btn.danger:hover{ background:#ffe3df; }
.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 rgba(31, 28, 23, 0.18);
  background:#f8efe2;
  border-radius:999px;
  cursor:pointer;
  user-select:none;
  font-size:.95rem;
}
.tab:hover{ background:#efe1cd; }
.tab:disabled{ opacity:.6; cursor:not-allowed; }
.tab.active{ background:#dfeef6; border-color:rgba(29, 108, 143, 0.35); }

/* Tekstområder */
.desc{ color:var(--ink-2); margin:4px 0 8px; }
.term{
  background:#10100f;
  color:#f9f4e7;
  padding:8px;
  border-radius:10px;
  white-space:pre-wrap;
  font-family:var(--mono);
  line-height:1.35;
  border: 1px solid rgba(249, 244, 231, 0.18);
}

/* Scrollbare mørke områder */
#ai, #console{
  flex:1; min-height:0; overflow:auto;
  background:#10100f;
  color:#f9f4e7;
  padding:12px;
  border-radius:10px;
  white-space:pre-wrap;
  font-family:var(--mono);
  line-height:1.45;
  border:1px solid rgba(249, 244, 231, 0.18);
}

/* Editor */
#editor-wrap{
  position:relative;
  border:1px solid var(--line);
  border-radius:12px;
  min-height:34vh;
  height:100%;
  overflow:hidden;
  background: #161513;
}
#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:#2f7a45; }
.fail{ color:#9f2b2b; }
.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:#6b5d4d; }

.main-footer {
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--ink-2);
  border-top: 1px solid rgba(31, 28, 23, 0.14);
  background: rgba(255, 248, 239, 0.75);
}

/* 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; }
