@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f3ede4;
  --bg-soft: #ece4d7;
  --surface: rgba(255, 252, 247, 0.88);
  --surface-strong: rgba(255, 250, 243, 0.98);
  --text: #2b241d;
  --muted: #6f6558;
  --line: rgba(138, 116, 91, 0.24);
  --accent: #ab6138;
  --accent-2: #5d7542;
  --danger: #b74b4b;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 430px at 0% -20%, rgba(171, 97, 56, 0.12), transparent 58%),
    radial-gradient(900px 460px at 100% 0%, rgba(93, 117, 66, 0.1), transparent 60%),
    linear-gradient(180deg, #f7f1e8 0%, var(--bg) 100%);
}

[hidden] {
  display: none !important;
}

body.page-channel {
  height: 100svh;
  overflow: hidden;
  overscroll-behavior: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.landing {
  width: min(1040px, 92%);
  margin: 3.2rem auto 2rem;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 14px 30px rgba(68, 49, 29, 0.06);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 700;
}

h1 {
  margin: 0.6rem 0 1rem;
  line-height: 1.1;
  font-size: clamp(1.9rem, 3.2vw, 3rem);
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 64ch;
}

.room-form {
  margin-top: 1.8rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr auto;
  align-items: end;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field span {
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.78rem 0.95rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  font: inherit;
}

#channelbox input::placeholder {
  color: #bcaea0;
  opacity: 1;
}

textarea {
  min-height: 3rem;
  resize: vertical;
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-strong);
  cursor: pointer;
  transition: 120ms ease;
}

button,
.icon,
#buttons,
#buttons *,
#extra,
#extra *,
.room-header,
.meta,
.name-title,
.name-help {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

button,
#extra .action,
#buttons button {
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #b96e43, var(--accent));
  color: #fffaf1;
  font-weight: 800;
  padding: 0.8rem 1.2rem;
}

.btn-ghost {
  border-color: var(--line);
  background: rgba(255, 248, 239, 0.96);
  padding: 0.5rem 0.9rem;
}

.small-note {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.quick-return {
  margin-top: 0.9rem;
  padding: 0.7rem 0.8rem;
  border: 1px dashed rgba(93, 117, 66, 0.35);
  border-radius: 12px;
  background: rgba(93, 117, 66, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.quick-return-label {
  margin: 0;
  color: #4e613a;
  font-size: 0.88rem;
  font-weight: 600;
}

.quick-return-btn {
  white-space: nowrap;
  font-weight: 700;
  border-color: rgba(93, 117, 66, 0.45);
  background: rgba(255, 253, 249, 0.95);
}

.quick-return-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.quick-return-dismiss-btn {
  white-space: nowrap;
  font-weight: 600;
}

.error-text {
  color: #9f3131;
  font-weight: 600;
}

.feature-grid {
  margin-top: 1.3rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.feature-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  background: rgba(255, 250, 243, 0.84);
}

.feature-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.app-footer {
  margin-top: 1.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-footer nav {
  display: flex;
  gap: 1rem;
}

.build-marker {
  opacity: 0.52;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

.content-page {
  width: min(880px, 92%);
  margin: 2.2rem auto;
  padding: 1.7rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(68, 49, 29, 0.05);
}

.content-shell {
  width: min(880px, 92%);
  margin: 2.2rem auto;
}

.content-shell .content-page {
  width: 100%;
  margin: 0;
}

.content-shell .app-footer {
  margin-top: 1rem;
  padding: 0 0.1rem;
}

.content-page h1 {
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.content-page h3 {
  margin: 1.3rem 0 0.45rem;
}

.content-page p,
.content-page li {
  color: #4e4439;
}

.content-page ul {
  margin-top: 0.2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.back-link-icon {
  width: 1rem;
  height: 1rem;
  display: inline-flex;
}

.back-link-icon svg {
  width: 100%;
  height: 100%;
}

.back-link-icon svg path {
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#app {
  min-height: 100vh;
}

.call-shell {
  width: min(1320px, 96%);
  margin: 0 auto;
  padding: 0.8rem 0 5.6rem;
}

body.page-channel #app {
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
}

body.page-channel .call-shell {
  height: 100%;
  padding-bottom: 5.2rem;
}

.room-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  width: fit-content;
  margin-left: auto;
  margin-bottom: 0.7rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.95);
}

.room-header p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.room-header-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  margin-right: 0.25rem;
}

.btn-ghost.compact {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

#video-stage {
  height: calc(100svh - 12.3rem);
  overflow: hidden;
}

#toast {
  position: fixed;
  inset: 0 0 auto;
  margin: 0 auto;
  width: min(680px, 92%);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  text-align: center;
  border-radius: 0 0 12px 12px;
  background: var(--danger);
  color: white;
  font-weight: 700;
  z-index: 110;
  transition: max-height 0.2s ease, padding 0.2s ease;
}

#toast.show {
  padding: 0.72rem;
  max-height: 4rem;
}

#toast.success {
  background: #4e7e4d;
}

#videos {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  gap: 0.7rem;
  grid-auto-rows: minmax(0, 1fr);
  align-content: center;
  justify-content: center;
}

#videos.balanced-layout {
  place-items: stretch;
}

#videos.layout-1 {
  grid-template-columns: 1fr;
}

#videos.layout-2 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

#videos.layout-3,
#videos.layout-4 {
  grid-template-columns: repeat(2, 1fr);
}

#videos.layout-3 .video:last-child {
  grid-column: 1 / -1;
}

#videos.layout-5,
#videos.layout-6 {
  grid-template-columns: repeat(3, 1fr);
}

#videos.layout-7-plus {
  grid-template-columns: repeat(4, 1fr);
}

.video {
  position: relative;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(140, 117, 91, 0.36);
  background: #02060f;
}

.video-frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #17120d;
}

.video.self .video-frame.mirrored {
  transform: rotateY(180deg);
}

.meta {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.8rem;
  background: rgba(22, 17, 12, 0.76);
  border: 1px solid rgba(194, 174, 154, 0.28);
  color: #f7eadb;
}

.talk-indicator {
  margin-left: 0.4rem;
  color: var(--accent-2);
}

.fullscreen-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(243, 229, 212, 0.32);
  background: rgba(14, 10, 8, 0.36);
  color: rgba(252, 245, 235, 0.88);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.fullscreen-btn:hover {
  transform: none;
  background: rgba(14, 10, 8, 0.48);
  border-color: rgba(255, 240, 224, 0.44);
}

.fullscreen-icon {
  width: 1rem;
  height: 1rem;
  display: inline-flex;
}

.fullscreen-icon svg {
  width: 100%;
  height: 100%;
}

.fullscreen-icon svg path {
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#blanket {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 40;
}

#leave-confirm {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(33, 24, 16, 0.4);
  backdrop-filter: blur(3px);
}

.leave-confirm-card {
  width: min(430px, 100%);
  border-radius: 14px;
  border-width: 2px;
  border-style: solid;
  border-color: rgba(171, 97, 56, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 247, 237, 0.98), rgba(255, 251, 245, 0.97)),
    rgba(255, 250, 244, 0.97);
  box-shadow: 0 0 0 1px rgba(171, 97, 56, 0.18), 0 10px 22px rgba(171, 97, 56, 0.16);
  padding: 0.95rem 0.95rem 0.9rem;
  animation: leave-confirm-in 160ms ease-out;
}

.leave-confirm-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #493629;
}

.leave-confirm-card p {
  margin: 0;
  color: #6a5240;
  font-size: 0.83rem;
  font-weight: 600;
  line-height: 1.45;
}

.leave-confirm-actions {
  margin-top: 0.95rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.leave-confirm-submit {
  background: linear-gradient(135deg, #bf7448, var(--accent));
  color: #fff8ef;
  font-weight: 700;
}

@keyframes leave-confirm-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#controls {
  position: fixed;
  inset: auto 0 0;
  z-index: 60;
  width: min(1100px, 96%);
  margin: 0 auto 0.8rem;
  left: 0;
  right: 0;
}

#buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.44rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 249, 241, 0.93);
  box-shadow: 0 10px 24px rgba(68, 49, 29, 0.08);
}

#buttons button {
  min-width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
}

#buttons .join {
  min-width: 6.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #bf7448, var(--accent));
  color: #fff8ef;
}

#buttons .back {
  min-width: 2.5rem;
  width: 2.5rem;
  font-weight: 700;
}

#buttons button.active-media {
  border-color: rgba(93, 117, 66, 0.5);
  background: linear-gradient(135deg, #6f8a50, #5d7542);
  color: #fffaf1;
  box-shadow: 0 0 0 2px rgba(93, 117, 66, 0.2);
}

#toggle-chat-btn.active-toggle {
  border-color: #56713b;
  background: linear-gradient(135deg, #6f8a50, #5d7542);
  color: #fffaf1;
  box-shadow: 0 0 0 2px rgba(93, 117, 66, 0.24);
}

#toggle-extra-btn.active-toggle {
  border-color: rgba(74, 102, 132, 0.62);
  background: linear-gradient(135deg, #6383a5, #4a6684);
  color: #f5f9ff;
  box-shadow: 0 0 0 2px rgba(74, 102, 132, 0.24);
}

#toggle-chat-btn {
  position: relative;
}

#toggle-chat-btn.has-unread::after {
  content: attr(data-unread);
  position: absolute;
  top: -0.42rem;
  right: -0.35rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.22rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 246, 237, 0.85);
  background: #b74b4b;
  color: #fff;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1.05rem;
  text-align: center;
}

#buttons .danger {
  border-color: rgba(183, 75, 75, 0.42);
  background: rgba(183, 75, 75, 0.12);
  color: #883636;
}

#buttons .exit-room {
  border-color: rgba(183, 75, 75, 0.62);
  background: linear-gradient(135deg, #d36666, #b74b4b);
  color: #fff8ef;
  box-shadow: 0 0 0 2px rgba(183, 75, 75, 0.2);
}

#reload-btn {
  border-color: rgba(93, 117, 66, 0.45);
  background: rgba(93, 117, 66, 0.12);
  color: #4b6334;
}

#buttons button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

#buttons button.is-loading {
  opacity: 0.92;
}

#buttons button.is-loading .icon svg {
  animation: button-spinner-rotate 0.8s linear infinite;
}

.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon {
  width: 1.15rem;
  height: 1.15rem;
  display: inline-flex;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.icon svg path,
.icon svg rect,
.icon svg circle {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes button-spinner-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#extra,
#chats,
#name {
  width: min(420px, 100%);
  margin: 0 auto 0.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 244, 0.97);
}

#extra {
  background: rgba(255, 250, 244, 0.995);
}

#name input {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

#name {
  position: relative;
  border-width: 2px;
  border-color: rgba(171, 97, 56, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 247, 237, 0.98), rgba(255, 251, 245, 0.97)),
    rgba(255, 250, 244, 0.97);
  box-shadow: 0 0 0 1px rgba(171, 97, 56, 0.18), 0 8px 20px rgba(171, 97, 56, 0.1);
}

#name::before {
  content: none;
}

#name:focus-within {
  border-color: rgba(171, 97, 56, 0.68);
  box-shadow: 0 0 0 3px rgba(171, 97, 56, 0.2), 0 10px 22px rgba(171, 97, 56, 0.16);
}

.name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.95rem 0.75rem;
}

.name-row input {
  flex: 1;
}

.join-inline {
  min-width: 6rem;
  font-weight: 700;
  background: linear-gradient(135deg, #bf7448, var(--accent));
  color: #fff8ef;
}

.name-row input,
.name-row .join-inline {
  height: 2.85rem;
}

.name-title {
  display: block;
  padding: 0.15rem 0.95rem 0.2rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #493629;
}

.name-help {
  margin: 0;
  padding: 0 0.95rem 0.55rem;
  font-size: 0.8rem;
  color: #6a5240;
  font-weight: 600;
}

#extra ul {
  margin: 0;
  padding: 0.45rem;
  list-style: none;
}

#extra .action {
  padding: 0.55rem 0.6rem;
  border-radius: 9px;
  cursor: pointer;
}

#extra .action:hover {
  background: rgba(172, 142, 111, 0.14);
}

#extra .indent {
  padding-left: 1rem;
  font-size: 0.86rem;
  opacity: 0.92;
}

#extra .danger {
  color: #ff96a0;
}

#scroll {
  max-height: 34vh;
  overflow-y: auto;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem 0.35rem;
  border-bottom: 1px solid rgba(153, 169, 207, 0.16);
  font-weight: 700;
}

.chat-panel-header .compact {
  padding: 0.32rem 0.6rem;
  font-size: 0.8rem;
}

.chat {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(153, 169, 207, 0.16);
}

.chat:last-child {
  border-bottom: none;
}

.chat .name {
  font-weight: 700;
}

.chat .date {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.chat textarea {
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 2.6rem;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.chat-input-row textarea {
  flex: 1;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(138, 116, 91, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  min-height: 2.85rem;
  resize: none;
}

.chat-send-btn {
  width: 100%;
  min-height: 2.85rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border-color: rgba(138, 116, 91, 0.34);
  background: linear-gradient(135deg, #bf7448, var(--accent));
  color: #fff8ef;
  font-weight: 700;
}

@media (max-width: 920px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .room-form {
    grid-template-columns: 1fr;
  }

  .quick-return {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-return-actions {
    display: flex;
    width: 100%;
  }

  .quick-return-actions button {
    flex: 1 1 auto;
    min-width: 0;
  }

  #videos.layout-2,
  #videos.layout-3,
  #videos.layout-4,
  #videos.layout-5,
  #videos.layout-6,
  #videos.layout-7-plus {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .landing {
    margin-top: 1.4rem;
  }

  .room-header {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    border-radius: 14px;
  }

  .hero-card {
    padding: 1.2rem;
  }

  #controls {
    width: 94%;
    margin-bottom: 0.5rem;
  }

  .leave-confirm-actions {
    flex-direction: column-reverse;
  }

  .leave-confirm-actions button {
    width: 100%;
    min-height: 2.75rem;
  }

  #buttons {
    justify-content: space-between;
  }

  #buttons button {
    min-width: 2.35rem;
    height: 2.35rem;
    font-size: 0.95rem;
  }

  #buttons .join {
    min-width: 5.7rem;
  }

  .join-inline {
    min-width: 5.4rem;
  }

  .chat-input-row {
    gap: 0.5rem;
  }

  .chat-send-btn {
    min-height: 2.8rem;
  }

  .app-footer {
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
  }

  #video-stage {
    height: calc(100svh - 14rem);
  }

  #videos.layout-2 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  #videos.layout-3,
  #videos.layout-4,
  #videos.layout-5,
  #videos.layout-6,
  #videos.layout-7-plus {
    grid-template-columns: 1fr;
  }
}
