/* Grundlayout */
body {
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  background: #87CEFA;
  font-family: Arial, sans-serif;
  line-height: 1.5;
  color: #222;
  overflow-y: auto;
}

html, body {
  margin: 0;
  padding: 0;
}

/* Header */
h2 {
  text-align: center;
  margin: 0;
}

.page {
  min-height: auto;
  padding: 0;
}




/* Entfernt – war wirkungslos und störend */
/* @media (min-height: 700px) {
  body {
    justify-content: center;
  }
} */

/* Chat aktiv → nie zentrieren */
.chat-active .page {
  display: block !important;
  justify-content: flex-start !important;
  align-items: flex-start !important;
  min-height: auto !important;
  padding-top: 0;
}



/* Chat-Container: Breite von .page übernehmen, Höhe = Inhalt */
.chat-container{
  width: 1200px;
  max-width: 100%;
  margin: 0;
  background: #BFE9FF;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);

  /* wichtig: keine feste Höhe */
  height: auto;
  min-height: 0;

  display: flex;
  flex-direction: column;
}

/* Chat-Window: wächst mit Inhalt, kein eigenes Scrollen */
#chat-window{
  height: auto;
  max-height: none;
  min-height: 0;

  overflow: visible;      /* statt auto */
  background: #BFE9FF;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 15px;

  flex: 0 0 auto;         /* nicht "auffüllen" */
}

/* Eingabebereich */
.input-area {
  display: flex;
  gap: 10px;
  width: 600px
}

input {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 15px;
}

button {
  padding: 12px 20px;
  background: #0077cc;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}

button:hover {
  background: #005fa3;
}

/* Clear Button */
.clear-btn {
  margin-top: 10px;
  width: 100%;
  background: #444;
}

.clear-btn:hover {
  background: #222;
}

/* Model Select */
#modelSelect {
  width: 260px;
  padding: 8px;
  margin-bottom: 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
}

/* Nachrichten */
.message {
  display: flex;
  align-items: flex-start;
  margin: 10px 0;
}

.message.user { justify-content: flex-end; }
.message.ai   { justify-content: flex-start; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin: 0 8px;
}

.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f5f5f5;
  color: #333;
  font-size: 14px;
}

.message.user .bubble {
  background: #0077cc;
  color: white;
}

.message.ai .bubble {
  background: #e6e6e6;
  color: #222;
}

/* Mobile */
@media (max-width: 600px) {
  body {
    justify-content: flex-start;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .chat-container {
    padding: 15px;
  }


  .input-area {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .bubble {
    max-width: 85%;
    font-size: 15px;
  }

  input {
    font-size: 16px;
  }
}
textarea#userInput {
  flex: 1;
  width: 1200px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 15px;
  resize: none; /* verhindert manuelles Ziehen */
  box-sizing: border-box;
}
.hg-input-shell {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

.hg-input-shell textarea {
    flex: 1;
    resize: none;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 15px;
    box-sizing: border-box;
}

.hg-file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: #e6e6e6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
}

.hg-file-input {
    display: none;
}

.hg-input-send {
    width: 42px;
    height: 42px;
    border-radius: 8px;
}
/* Start + Chat aktiv: identisches Layout (nicht zentrieren) */
.chat-active .page,
body:not(.chat-active) .page {
  display: block !important;
  width: 100%;
  max-width: 1200px;      /* gewünschte maximale Breite */
  margin: 0 auto;         /* zentriert */
  box-sizing: border-box; /* verhindert Überbreite durch Padding */
  padding: 0 16px;        /* optional: etwas Rand innen/außen */
}

/* NICHT übernehmen:
   width, max-width, margin-left/right, flex-basis, grid-column
   → diese machen es breiter */
pre {
  background: #0d1117;
  color: #c9d1d9;
  padding: 12px 14px;
  border-radius: 10px;
  overflow: auto;
  line-height: 1.45;
  white-space: pre;
  tab-size: 2; /* oder 4 */
  border: 1px solid #30363d;
  font-size: 14px;
}
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}
pre code {
  font-size: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
}

:not(pre) > code {
  background: transparent;
  padding: 0.15em 0.35em;
  border-radius: 6px;
}
.code-wrap {
  position: relative;
  display: inline-block; /* passt sich der Codebreite an */
  max-width: 100%;
}

.code-wrap pre {
  margin: 0;
  padding: 12px 48px 12px 12px; /* Platz rechts für Button */
  overflow: auto;
}

.code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}
.code-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}

.code-wrap:hover .code-btn,
.code-wrap:focus-within .code-btn {
  opacity: 1;
  pointer-events: auto;
}

.hg-chat-window{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.hg-msg{
  position:relative;
  max-width: 1200px;
  width: 100%;
  border:1px solid black;
  border-radius:12px;
  padding:14px 44px 14px 14px; /* rechts Platz für Button */
  background: white;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
}

.hg-msg__content{
  white-space:pre-wrap; /* Zeilenumbrüche behalten */
  word-wrap:break-word;
  font-size: 15px;
  line-height: 1.45;
}

.hg-copy-btn{
  position:absolute;
  top:10px;
  right:10px;
  width:30px;
  height:30px;
  border:1px solid #e2e2e2;
  border-radius:8px;
  background:#fafafa;
  cursor:pointer;
  display:grid;
  place-items:center;
}

.hg-copy-btn:hover{ background:#f0f0f0; }

.hg-copy-btn svg{
  width:16px;
  height:16px;
  fill:#333;
}


/* ============ Mobile Fix: nichts darf breiter als der Viewport sein ============ */
/* Tablets & kleiner (<= 768px) */
@media (max-width: 768px) {

  /* Grundregel: feste Breiten killen */
  .chat-container,
  .hg-msg,
  .input-area,
  textarea#userInput {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Entfernt/überschreibt deine 600px-Regeln */
  .hg-msg {
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
  }

  /* falls Eltern-Flex/Grid das Schrumpfen verhindert */
  .hg-chat-window,
  .hg-input-shell,
  .chat-container,
  .page {
    min-width: 0;
  }

  /* verhindert horizontales Overflow durch lange Wörter/Links */
  .hg-msg__content {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Codeblöcke dürfen horizontal scrollen, aber nicht Layout sprengen */
  pre {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
  }
}

/* Optional: globaler Sicherheitsgurt gegen 1px-Overflows */
* { box-sizing: border-box; }