:root {
  --bg: #10131a;
  --panel: #171c26;
  --panel-2: #1e2533;
  --line: #2b3446;
  --text: #e8ecf4;
  --muted: #93a0b8;
  --accent: #4da3ff;
  --accent-2: #2b7fd4;
  --warm: #ffb454;
  --bad: #ff6b6b;
  --good: #55d18e;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 50% -10%, #1b2333 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  /* Rögzített magasságú oldal: így a beszélgetés panele kapja a maradék helyet, és
     ő görget — nem az egész oldal csúszik el a képernyő aljára. */
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(16, 19, 26, .8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
h1 { font-size: 17px; margin: 0; letter-spacing: .3px; font-weight: 600; }
h2 { font-size: 19px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 0 0 6px; color: var(--accent); letter-spacing: .3px; }
.modes { display: flex; gap: 6px; margin-left: auto; background: var(--panel); padding: 4px; border-radius: 999px; }
.mode {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 7px 16px; border-radius: 999px; font: inherit; font-size: 14px;
}
.mode.active { background: var(--accent-2); color: #fff; }
button { font: inherit; }
.ghost {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
.ghost:hover { border-color: var(--accent); }
.primary {
  background: var(--accent-2); border: 1px solid var(--accent); color: #fff;
  padding: 9px 18px; border-radius: 10px; cursor: pointer; font-weight: 600;
}
main {
  flex: 1;
  min-height: 0;               /* enélkül a grid nem enged zsugorodni, és nincs görgetés */
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  padding: 24px;
  align-items: stretch;
}
@media (max-width: 980px) {
  body { height: auto; overflow: auto; }
  main { grid-template-columns: 1fr; }
  .panel { max-height: 50vh; }
}

#stage { display: flex; flex-direction: column; align-items: center; gap: 14px; min-height: 0; overflow-y: auto; }
.avatar-frame {
  position: relative; width: min(460px, 70vw); aspect-ratio: 1;
  border-radius: 50%; overflow: hidden;
  background: var(--panel-2);
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px rgba(0, 0, 0, .5);
}
.avatar-frame img, .avatar-frame video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.tag { color: var(--accent); font-weight: 500; }
/* Beszéd közben a kép helyett egy egyszerű hangkijelző mozog. */
.idle-face { position: absolute; inset: 0; display: grid; place-items: center; font-size: 96px; opacity: .25; }
.idle-face[hidden] { display: none; }
.avatar-frame.talking { box-shadow: 0 0 0 2px var(--accent), 0 24px 60px rgba(0, 0, 0, .5); }
/* A hangkijelző a kép alsó sávjában ül, sötét átmenettel — az arcra ráúsztatva
   eltakarná azt, amiért a képet feltették. */
.speaking {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  display: flex; align-items: flex-end; justify-content: center; gap: 7px;
  padding-bottom: 18px;
  background: linear-gradient(transparent, rgba(8, 11, 18, .8));
}
.speaking[hidden] { display: none; }     /* a display:flex különben felülírná a rejtést */
.speaking span {
  width: 7px; height: 14px; border-radius: 99px; background: var(--accent);
  animation: talk 900ms ease-in-out infinite;
}
.speaking span:nth-child(2) { animation-delay: .12s; }
.speaking span:nth-child(3) { animation-delay: .24s; }
.speaking span:nth-child(4) { animation-delay: .36s; }
.speaking span:nth-child(5) { animation-delay: .48s; }
@keyframes talk { 0%, 100% { height: 12px; opacity: .55; } 50% { height: 44px; opacity: 1; } }
.pulse {
  position: absolute; inset: -3px; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 107, 107, .8); animation: breathe 1.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.status { color: var(--muted); min-height: 22px; margin: 0; text-align: center; }
.status.error { color: var(--bad); max-width: 620px; }
.controls { display: flex; gap: 10px; align-items: center; }
.talk {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  border: 0; color: #fff; font-size: 16px; font-weight: 600;
  padding: 14px 38px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(45, 127, 212, .35);
}
.talk:disabled { background: var(--panel-2); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.talk.recording { background: linear-gradient(180deg, #ff7b7b 0%, #d23b3b 100%); box-shadow: 0 8px 24px rgba(210, 59, 59, .4); }
.hint { color: var(--muted); font-size: 13px; margin: 0; text-align: center; max-width: 460px; }
.auto { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.auto input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
/* Hangerő-kijelző: enélkül nem derül ki, hogy a figyelés hall-e egyáltalán valamit. */
.level { width: min(320px, 70vw); height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
#level-bar { width: 0; height: 100%; background: var(--accent-2); border-radius: 99px; transition: width .08s linear; }
#level-bar.loud { background: var(--good); }

#side {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: transparent; border: 0; color: var(--muted); padding: 12px; cursor: pointer; }
.tab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.panel {
  padding: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #3d4a63 transparent;
}
/* Látható görgetősáv: a rendszer alapértelmezett vékony sávja sötét háttéren
   gyakorlatilag láthatatlan, és úgy tűnik, mintha nem lehetne görgetni. */
.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: #3d4a63; border-radius: 6px; border: 2px solid var(--panel); }
.panel::-webkit-scrollbar-thumb:hover { background: #4f6183; }
.bubble { padding: 10px 13px; border-radius: 12px; background: var(--panel-2); font-size: 14px; }
.bubble.user { background: #223049; align-self: flex-end; max-width: 88%; }
.bubble.bot { background: var(--panel-2); align-self: flex-start; max-width: 92%; }
.bubble .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; letter-spacing: .4px; }
.bubble.pending { opacity: .55; }
.note { border-left: 3px solid var(--warm); padding: 9px 12px; background: var(--panel-2); border-radius: 0 10px 10px 0; font-size: 14px; }
.note .said { color: var(--muted); text-decoration: line-through; }
.note .fixed { color: var(--good); }
.note .why { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 6px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  color: var(--text); max-width: 620px; width: calc(100vw - 32px); padding: 0;
  max-height: 88vh;                 /* alacsony ablakon is elférjen */
}
dialog::backdrop { background: rgba(6, 8, 12, .7); }
dialog form {
  padding: 22px; display: flex; flex-direction: column; gap: 18px;
  max-height: 88vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: #3d4a63 transparent;
}
dialog form::-webkit-scrollbar { width: 10px; }
dialog form::-webkit-scrollbar-thumb { background: #3d4a63; border-radius: 6px; border: 2px solid var(--panel); }
dialog section { border-top: 1px solid var(--line); padding-top: 14px; }
dialog section:first-of-type { border-top: 0; padding-top: 0; }
.help { color: var(--muted); font-size: 13px; margin: 4px 0; }
.or { color: var(--muted); font-size: 13px; }
.row.wrap { flex-wrap: wrap; }
.row button.recording, .filepick.recording {
  background: linear-gradient(180deg, #ff7b7b 0%, #d23b3b 100%); border-color: #d23b3b; color: #fff;
}
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.row.check { gap: 8px; }
.row input[type="text"], .row input[type="password"], .row input[type="number"], .row select { flex: 1; }
input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 8px 10px; font: inherit;
}
menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 0; }
.error { color: var(--bad); font-size: 14px; margin: 0; }
audio { width: 100%; margin-top: 8px; }
/* A display:flex-es sorok különben felülírnák a hidden attribútumot. */
[hidden] { display: none !important; }

/* ---- webes kiegészítések ---- */
.header-actions { display: flex; gap: 8px; }
.modes[hidden] + .header-actions { margin-left: auto; }
button:not(.mode):not(.tab):not(.talk):not(.ghost):not(.primary):not(.linkish) {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
button:disabled { opacity: .55; cursor: not-allowed; }
.auth { flex: 1; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.card input { width: 100%; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-align: left; }
dialog.wide { max-width: 860px; }
.key-row { display: grid; grid-template-columns: 170px 1fr auto auto; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.key-row .state { font-size: 12px; color: var(--muted); min-width: 70px; }
.key-row .state.set { color: var(--good); }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.list th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px; border-bottom: 1px solid var(--line); }
table.list td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td button { padding: 4px 10px; font-size: 12px; }
.invite-new { background: var(--panel-2); border: 1px solid var(--accent-2); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.image-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.image-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thumb { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.filepick {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.filepick:hover { border-color: var(--accent); }
.filepick input { display: none; }
.table-wrap { overflow-x: auto; }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }
.event-fail { color: var(--bad); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.badge.ok { color: var(--good); } .badge.off { color: var(--bad); }
@media (max-width: 640px) {
  header { flex-wrap: wrap; padding: 10px 14px; }
  .modes { margin-left: 0; order: 3; width: 100%; justify-content: center; }
  .key-row { grid-template-columns: 1fr; }
  main { padding: 14px; gap: 14px; }
  .avatar-frame { width: min(280px, 68vw); }
  .controls { flex-wrap: wrap; justify-content: center; }
  .controls .ghost { white-space: nowrap; }
  .talk { padding: 12px 30px; }
}
