:root {
  --bg: #0a0a0c;
  --surface: #14141a;
  --border: rgba(11, 137, 152, 0.35);
  --accent: #0B8998;
  --accent-light: #3FB8C6;
  --text: #f2efe6;
  --dim: #9a958a;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ------------------------------------------------------------------- header */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: linear-gradient(180deg, rgba(11, 137, 152, .12), transparent);
}
.logo { height: 18px; width: auto; }
.status { font-size: 11px; color: var(--dim); margin-left: auto; }
.status.ok { color: var(--accent-light); }
.status.bad { color: #f87171; }
.icon {
  width: 30px; height: 30px;
  border: none; background: transparent;
  color: var(--dim); font-size: 15px;
  cursor: pointer;
}

/* --------------------------------------------------------------- transcript */
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}
.msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.msg p { white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: rgba(11, 137, 152, .18); border: 1px solid var(--border); }
.msg.xela { align-self: flex-start; background: var(--surface); border: 1px solid rgba(255, 255, 255, .07); }
.msg.system { align-self: center; background: transparent; color: var(--dim); font-size: 11.5px; }
.msg .actions { display: flex; gap: 8px; margin-top: 7px; }
.msg .actions button {
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .05);
  color: var(--accent-light);
  border-radius: 8px; width: 28px; height: 24px;
  font-size: 12px; cursor: pointer;
}
.dots { display: flex; gap: 4px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-light); animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------- composer */
.composer { border-top: 1px solid rgba(255, 255, 255, .06); padding: 8px 12px 12px; }
.shell {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  padding: 6px 6px 6px 12px;
}
.shell textarea {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  padding: 5px 0;
}
.inline {
  width: 34px; height: 34px;
  border: none; background: transparent;
  color: var(--dim); font-size: 16px;
  display: grid; place-items: center;
  cursor: pointer;
}
.inline.send { color: var(--accent-light); }
.inline.rec { color: #f87171; }
.tools { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.tools button {
  border: 1px solid rgba(255, 255, 255, .08);
  background: transparent;
  color: var(--dim);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.voice-state { margin-left: auto; font-size: 11px; color: var(--accent-light); }

/* ------------------------------------------------------------ sheet/drawer */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  display: grid; place-items: center;
  z-index: 30;
}
.sheet-card {
  width: min(92vw, 380px);
  background: #16161c;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.sheet-card h2 { font-size: 14px; color: var(--accent-light); }
.sheet-card label { font-size: 11.5px; color: var(--dim); display: flex; flex-direction: column; gap: 4px; }
.sheet-card label.row { flex-direction: row; align-items: center; gap: 8px; }
.sheet-card input[type="url"] {
  height: 34px; padding: 0 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(0, 0, 0, .4);
  color: var(--text);
  font-size: 12.5px;
}
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.sheet-actions button {
  padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #0B8998, #076874);
  color: #fff; font-size: 12.5px; cursor: pointer;
}
.sheet-actions button.ghost { background: rgba(255, 255, 255, .06); color: var(--dim); border-color: rgba(255, 255, 255, .1); }

.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 62vh;
  background: #121218;
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
  z-index: 20;
}
.drawer-head { display: flex; align-items: center; }
.drawer-head strong { font-size: 13px; color: var(--accent-light); }
.drawer-head .icon { margin-left: auto; }
.list { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.list li {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 10px;
  font-size: 13px;
}
.list li span { flex: 1; }
.list li button {
  border: none; background: transparent; color: var(--dim);
  font-size: 13px; cursor: pointer;
}
.list li button.done { color: var(--accent-light); }
.drawer-form { display: flex; gap: 6px; }
.drawer-form input {
  flex: 1; height: 36px; padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(0, 0, 0, .35);
  color: var(--text);
  font-size: 13px;
}
.drawer-form button {
  padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #0B8998, #076874);
  color: #fff; font-size: 13px; cursor: pointer;
}
.empty { color: var(--dim); font-size: 12px; text-align: center; padding: 10px; }

/* --------------------------------------------------------------- room sheet */
.room-card {
  max-height: 86vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.room-card h3 {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 8px 0 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.room-meta { font-size: 10px; color: var(--dim); line-height: 1.4; }
.room-enrol { display: flex; gap: 6px; margin-top: 6px; }
.room-enrol input {
  flex: 1;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 0 9px;
  font-size: 12px;
}
.room-enrol button {
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}
.heard-list { max-height: 210px; overflow-y: auto; }
.heard-item {
  border-left: 2px solid rgba(255,255,255,.14);
  padding: 3px 0 3px 7px;
}
.heard-item.respond { border-left-color: var(--accent-light); }
.heard-item.hold { border-left-color: #d7a13a; }
.heard-item.silent { opacity: .78; }
.heard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.heard-who { font-size: 10.5px; color: var(--accent-light); }
.heard-text { font-size: 12px; line-height: 1.35; margin: 2px 0; }
.voice-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.voice-name { flex: 1; }
.ghost.tiny {
  background: transparent;
  border: 1px solid rgba(255,255,255,.14);
  color: var(--dim);
  border-radius: 6px;
  font-size: 10px;
  padding: 1px 6px;
}
/* The hidden attribute must win over the display rules above: .sheet/.drawer
   set display:grid/flex, which otherwise keeps them on screen permanently. */
[hidden] { display: none !important; }