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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
  background: #0a0a1a;
  color: #f0f0ff;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --bg2: #12122a;
  --surf: #1e1e48;
  --muted: #555577;
  --dim: #8888aa;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

.screen {
  display: none;
  height: 100%;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ── setup ── */
#setup {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, .08), transparent 60%), #0a0a1a;
}

.setup-box {
  text-align: center;
  padding: 2rem;
  width: 100%;
  max-width: 340px;
}

.logo {
  font-size: 3.5rem;
  margin-bottom: .5rem;
  animation: bob 3s ease-in-out infinite;
}

@keyframes bob {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-8px)
  }
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#setup form {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  margin-top: 1.8rem;
}

#setup input {
  width: 100%;
  padding: 1rem 1.2rem;
  border: 2px solid var(--surf);
  border-radius: 50px;
  background: var(--bg2);
  color: #f0f0ff;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border .2s, box-shadow .2s;
}

#setup input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, .25);
}

#setup input::placeholder {
  color: var(--muted);
}

#setup button {
  padding: 1rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s;
}

#setup button:active {
  transform: scale(.97);
}

#setup-form button {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: transform 0.2s, background 0.2s;
}

#setup-form button:active {
  transform: scale(0.98);
}

.room-input {
  margin-top: 1rem;
  margin-bottom: 0 !important;
}

/* ── header ── */
header {
  height: 60px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.hdr-right {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.hdr-icon {
  font-size: 1.5rem;
}

.hdr-left strong {
  font-size: 1.05rem;
}

.hdr-left small {
  display: block;
  font-size: .7rem;
  color: #00e676;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background .15s;
}

.icon-btn:hover {
  background: var(--surf);
}

/* ── video strip ── */
.video-strip {
  display: flex;
  gap: .5rem;
  padding: .5rem;
  overflow-x: auto;
  background: rgba(10, 10, 26, .9);
  border-bottom: 1px solid rgba(108, 92, 231, .08);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.video-strip::-webkit-scrollbar {
  display: none;
}

.video-strip.hidden {
  display: none;
}

.video-card {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 75px;
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  border: 2px solid rgba(108, 92, 231, .2);
}

.video-card.local {
  border-color: var(--accent);
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.video-label {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: .6rem;
  color: #fff;
  background: rgba(0, 0, 0, .6);
  padding: 1px 0;
}

.video-card {
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}

.video-card:active {
  transform: scale(.93);
}

/* ── cam hint on setup ── */
.cam-hint {
  margin-top: 1rem;
  font-size: .75rem;
  color: var(--muted);
}

/* ── camera on indicator ── */
.icon-btn.cam-on {
  background: rgba(108, 92, 231, .2);
  border-radius: 8px;
}

/* ── expanded video overlay ── */
.video-expand {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fadeIn .2s ease;
}

.video-expand.hidden {
  display: none;
}

.video-expand video {
  width: 90%;
  max-width: 500px;
  max-height: 70vh;
  border-radius: 16px;
  object-fit: cover;
  transform: scaleX(-1);
}

.expanded-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent2);
  margin-top: .8rem;
}

.expand-hint {
  font-size: .7rem;
  color: var(--muted);
  margin-top: .3rem;
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

/* ── drawer ── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 240px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid rgba(108, 92, 231, .12);
  z-index: 100;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1rem;
  padding-top: calc(1.2rem + var(--safe-t));
  border-bottom: 1px solid rgba(108, 92, 231, .08);
}

.drawer-head button {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 1.5rem;
  cursor: pointer;
}

.drawer-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.drawer-bg.open {
  opacity: 1;
  pointer-events: auto;
}

#user-list {
  list-style: none;
  padding: .5rem;
  overflow-y: auto;
  flex: 1;
}

#user-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .7rem;
  border-radius: 8px;
  font-size: .88rem;
}

#user-list li:hover {
  background: var(--surf);
}

#user-list li.me {
  color: var(--accent2);
  font-weight: 600;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00e676;
  box-shadow: 0 0 6px rgba(0, 230, 118, .4);
  display: inline-block;
  flex-shrink: 0;
}

/* ── messages ── */
main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#msgs {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: .3rem;
  min-height: 100%;
  justify-content: flex-end;
}

.sys {
  align-self: center;
  color: var(--muted);
  font-size: .72rem;
  margin: .25rem 0;
}

.bubble {
  max-width: 80%;
  padding: .55rem .85rem;
  border-radius: 14px;
  animation: pop .2s cubic-bezier(.4, 0, .2, 1);
  word-break: break-word;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, #6c5ce7, #5a4bd1);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.other {
  align-self: flex-start;
  background: var(--surf);
  border: 1px solid rgba(108, 92, 231, .06);
  border-bottom-left-radius: 4px;
}

.bubble b {
  display: block;
  font-size: .68rem;
  color: var(--accent2);
  margin-bottom: .1rem;
  font-weight: 600;
}

.bubble .msg-text {
  font-size: .9rem;
  line-height: 1.35;
  display: block;
}

.bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
  margin-top: .15rem;
}

.bubble time {
  font-size: .58rem;
  opacity: .45;
}

.mine time {
  color: rgba(255, 255, 255, .55);
}

/* ── translate button on messages ── */
.translate-btn {
  background: none;
  border: none;
  font-size: .7rem;
  cursor: pointer;
  opacity: .35;
  padding: 0;
  line-height: 1;
  transition: opacity .15s;
}

.translate-btn:hover,
.translate-btn:active {
  opacity: .9;
}

/* ── translate popup ── */
.translate-popup {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid rgba(108, 92, 231, .2);
  border-radius: 16px;
  padding: 1rem;
  z-index: 80;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
  animation: slideUp .25s cubic-bezier(.4, 0, .2, 1);
}

.translate-popup.hidden {
  display: none;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px)
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
  }
}

.translate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .6rem;
}

.translate-header span {
  font-size: .85rem;
  font-weight: 600;
}

.translate-header button {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 1.3rem;
  cursor: pointer;
}

.translate-original {
  font-size: .8rem;
  color: var(--dim);
  font-style: italic;
  margin-bottom: .5rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid rgba(108, 92, 231, .08);
}

.translate-result {
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent2);
  min-height: 1.4rem;
}

.translate-result.error {
  color: #ff5252;
  font-size: .85rem;
}

.translate-actions {
  display: flex;
  gap: .4rem;
  margin-top: .7rem;
}

.lang-btn {
  padding: .35rem .7rem;
  border-radius: 20px;
  border: 1px solid rgba(108, 92, 231, .2);
  background: transparent;
  color: var(--dim);
  font-size: .75rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.lang-btn:not(.active):hover {
  border-color: var(--accent2);
  color: var(--accent2);
}

/* ── suggestions bar ── */
.suggestions {
  display: flex;
  gap: .4rem;
  padding: .4rem .7rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(18, 18, 42, .9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(108, 92, 231, .08);
  scrollbar-width: none;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.suggestions.hidden {
  display: none;
}

.sug-btn {
  flex-shrink: 0;
  padding: .4rem .8rem;
  border-radius: 20px;
  border: 1px solid rgba(162, 155, 254, .2);
  background: rgba(108, 92, 231, .1);
  color: var(--accent2);
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}

.sug-btn:active {
  background: var(--accent);
  color: #fff;
  transform: scale(.95);
}

/* ── typing ── */
.typing {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 0 1rem .4rem;
  font-size: .72rem;
  color: var(--muted);
  transition: opacity .2s;
}

.typing.hidden {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}

.dots {
  display: inline-flex;
  gap: 3px;
}

.dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent2);
  display: inline-block;
  animation: bop 1.2s infinite ease-in-out;
}

.dots i:nth-child(2) {
  animation-delay: .15s;
}

.dots i:nth-child(3) {
  animation-delay: .3s;
}

@keyframes bop {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: .4
  }

  30% {
    transform: translateY(-3px);
    opacity: 1
  }
}

/* ── input ── */
footer {
  padding: .55rem .7rem;
  padding-bottom: calc(.55rem + var(--safe-b));
  background: rgba(18, 18, 42, .85);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(108, 92, 231, .1);
}

#chat-form {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg2);
  border-radius: 50px;
  padding: .25rem .25rem .25rem .9rem;
  border: 1px solid rgba(108, 92, 231, .08);
  transition: border .2s;
}

#chat-form:focus-within {
  border-color: var(--accent);
}

#msg-input {
  flex: 1;
  border: none;
  background: none;
  color: #f0f0ff;
  font-size: .92rem;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

#msg-input::placeholder {
  color: var(--muted);
}

#send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s, opacity .15s;
}

#send-btn:disabled {
  opacity: .25;
  cursor: default;
}

#send-btn:not(:disabled):active {
  transform: scale(.88);
}

main::-webkit-scrollbar {
  width: 3px;
}

main::-webkit-scrollbar-thumb {
  background: var(--surf);
  border-radius: 3px;
}

@media(min-width:768px) {
  #msgs {
    max-width: 650px;
    margin: 0 auto;
  }

  .bubble {
    max-width: 60%;
  }
}
/* ── inline translation ── */
.trans-box {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  color: #ffd700;
  font-style: italic;
  animation: fadeIn 0.3s ease;
}
.trans-box.loading {
  color: rgba(255, 255, 255, 0.5);
}
.trans-box.error {
  color: #ff4444;
  font-style: normal;
}
.translate-btn.active {
  color: #ffd700;
  opacity: 1;
  transform: scale(1.1);
}

/* ── lang selector ── */
.lang-select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  margin-right: 8px;
  font-size: 0.8rem;
  outline: none;
  appearance: none;
  text-align: center;
}
.lang-select option {
  background: #1a1a2e;
  color: #fff;
}
