:root {
  color-scheme: dark;
  --bg: #0b141a;
  --surface: #1f2c33;
  --panel: #202c33;
  --panel-soft: #22313a;
  --ink: #e9edef;
  --muted: #a7bbc6;
  --line: #334752;
  --accent: #25d366;
  --accent-strong: #34e67a;
  --danger: #ff6b6b;
  --bubble-me: #005c4b;
  --bubble-peer: #1e313a;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, #0b141a 0%, #101c22 100%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.018) 0 6px,
      rgba(255, 255, 255, 0.008) 6px 12px
    );
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #111f26;
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: #6f8796;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #092018;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  background: var(--accent-strong);
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.22);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button.ghost {
  background: #2a3942;
  color: #d8e3e8;
}

button.control-on {
  background: #0f8f74;
  color: #e9fff6;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.16);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-btn i {
  width: 16px;
  height: 16px;
}

a.profile-link {
  color: var(--accent);
  font-weight: 700;
}

a.link-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  text-decoration: none;
}

.shell {
  width: min(1200px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0;
}

.hidden {
  display: none !important;
}

.login-panel {
  min-height: calc(100vh - 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 30px;
  align-items: center;
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(31px, 5vw, 60px);
  line-height: 1.06;
}

.topbar h1 {
  font-size: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lede {
  max-width: 660px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.6;
}

.form,
.panel {
  background: rgba(32, 44, 51, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: panelIn 0.35s ease;
}

.form {
  display: grid;
  gap: 15px;
  padding: 22px;
}

.form h2 {
  margin: 0;
  font-size: 22px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.oauth-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.hint,
.muted {
  color: var(--muted);
}

.error {
  margin: 0;
  color: var(--danger);
  min-height: 20px;
}

.topbar,
.account,
.controls,
.send-row,
.agent-row,
.tabs {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 15px;
}

.tabs {
  margin-bottom: 15px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.send-row {
  align-items: stretch;
}

.send-row input {
  flex: 1;
  min-width: 0;
}

.chat-toolset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-only {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.controls.wrap {
  flex-wrap: wrap;
}

.tab {
  background: #172329;
  color: #9ab0be;
  border-radius: 8px;
}

.tab.active {
  background: #24363f;
  color: var(--ink);
  border: 1px solid #314750;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chat-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chat-sidebar,
.chat-main {
  min-height: 320px;
}

.chat-sidebar .peer-list {
  max-height: 340px;
  overflow: auto;
}

.chat-main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-main-header h2 {
  margin: 0;
}

.avatar-pill {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #26d367, #159d7e);
  color: #062318;
  font-weight: 800;
  letter-spacing: 0;
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.peer-list,
.messages,
.session-list,
.activity,
.downloads,
.file-list {
  display: grid;
  gap: 10px;
}

.messages {
  height: 300px;
  overflow: auto;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background-color: var(--surface);
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.03) 0 4px,
      rgba(255, 255, 255, 0.012) 4px 8px
    );
}

.message,
.peer,
.session,
.activity-item,
.download,
.file-row {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17252c;
}

.message {
  border-color: #29414c;
  background: var(--bubble-peer);
  max-width: 92%;
  position: relative;
  animation: messageIn 0.22s ease;
}

.message.mine {
  justify-self: end;
  background: var(--bubble-me);
  border-color: #0f7c66;
}

.message.peer::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 11px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 7px solid var(--bubble-peer);
}

.message.mine::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 11px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 7px solid var(--bubble-me);
}

.peer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  animation: messageIn 0.2s ease;
}

.peer-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17252c;
  padding: 10px;
}

.peer-pick-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.peer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #042116;
  background: linear-gradient(145deg, #25d366, #1bbd83);
  flex: 0 0 auto;
}

.peer-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.peer-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-subtitle {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #91c8b0;
}

.peer-online::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #687a85;
}

.peer-online.online::before {
  background: #25d366;
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.15);
}

.peer-pick input {
  width: 18px;
  height: 18px;
}

.toggle-field {
  margin: 8px 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  display: inline-flex;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #3f4f59;
  border: 1px solid #51646f;
  transition: background 0.2s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #f5f8fa;
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: #0f8f74;
  border-color: #0f8f74;
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.file-list {
  max-height: 520px;
  overflow: auto;
}

.file-row {
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  overflow-wrap: anywhere;
}

.file-row input {
  width: 18px;
  height: 18px;
}

.report-editor {
  min-height: 360px;
  font-family: Consolas, "Cascadia Code", ui-monospace, monospace;
}

.peer.selected {
  border-color: var(--accent);
  outline: 2px solid rgba(0, 168, 132, 0.3);
}

.status,
.status-line,
.progress,
.agent-answer {
  color: var(--muted);
  font-weight: 700;
}

.emoji-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.emoji-btn {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #3b4d57;
  background: #1b2a30;
  color: #ffffff;
  line-height: 1;
}

.emoji-btn:hover {
  background: #273941;
}

.agent-answer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #152127;
  padding: 10px;
  min-height: 46px;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  border: 1px solid #2f474f;
  border-radius: 999px;
  background: rgba(19, 37, 43, 0.8);
  color: #b6d1da;
  padding: 6px 10px;
  font-size: 12px;
  width: fit-content;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25d366;
  animation: typingPulse 1s ease-in-out infinite;
}

.typing-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing-icons i {
  width: 13px;
  height: 13px;
  opacity: 0.85;
}

@keyframes typingPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.6;
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.profile-row {
  display: grid;
  gap: 10px;
}

.profile-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17252c;
  padding: 12px;
}

.profile-item strong {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.monitor-list {
  display: grid;
  gap: 10px;
}

.monitor-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17252c;
  padding: 12px;
}

.settings {
  display: grid;
  gap: 10px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.setting-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
}

.limit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  align-items: end;
  gap: 10px;
  margin: 12px 0;
}

.limit-row label {
  margin: 0;
}

.limit-row input {
  min-width: 0;
}

video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f1b21;
  border-radius: 8px;
  border: 1px solid var(--line);
}

video.local-preview {
  margin-top: 10px;
  max-height: 180px;
}

#remoteCallPanel:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  background: var(--bg);
}

#remoteCallPanel:fullscreen #remoteVideo {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

#remoteCallPanel:fullscreen .local-preview {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(280px, 36vw);
  max-height: 30vh;
  box-shadow: var(--shadow);
}

.remote-control-pointer {
  position: fixed;
  z-index: 9999;
  width: 18px;
  height: 18px;
  border: 2px solid #25d366;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.18);
  box-shadow: 0 0 0 7px rgba(37, 211, 102, 0.1);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.remote-control-pointer.clicking {
  border-color: #e9fff6;
  background: rgba(233, 255, 246, 0.24);
}

#fileSharePanel:fullscreen {
  padding: 24px;
}

#fileSharePanel:fullscreen #downloads {
  max-height: 40vh;
  overflow: auto;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #122028;
}

.monitor-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1050px;
  font-size: 13px;
}

.monitor-table th,
.monitor-table td {
  border-bottom: 1px solid #2d4049;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.monitor-table th {
  background: #172830;
  color: #9fc4ce;
  position: sticky;
  top: 0;
  z-index: 1;
}

.monitor-table tr:last-child td {
  border-bottom: 0;
}

.history-list {
  display: grid;
  gap: 9px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #16262d;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.history-item .meta {
  color: var(--muted);
  font-size: 12px;
}

.user-delete-btn {
  min-height: 34px;
  padding: 0 10px;
  background: #3a2529;
  color: #ffadb3;
  border: 1px solid #7a3d45;
}

.user-delete-btn:hover {
  background: #4b2a30;
}

.online-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.online-badge.online {
  background: rgba(37, 211, 102, 0.15);
  color: #8cf0b8;
  border-color: rgba(37, 211, 102, 0.45);
}

.online-badge.offline {
  background: rgba(167, 187, 198, 0.12);
  color: #b9ccd5;
  border-color: rgba(167, 187, 198, 0.34);
}

@media (max-width: 900px) {
  .chat-workspace,
  .grid.two,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .chat-sidebar .peer-list {
    max-height: 240px;
  }
}

@media (max-width: 760px) {
  .login-panel {
    grid-template-columns: 1fr;
  }

  .topbar,
  .account,
  .send-row,
  .agent-row {
    align-items: stretch;
    flex-direction: column;
  }

  .limit-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .oauth-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .chat-toolset {
    width: 100%;
    justify-content: flex-end;
  }
}
