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

:root {
  --bg-app: #151515;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --blue: #0a84ff;
  --header-height: 60px;
  --radius-l: 18px;
  --radius-m: 12px;
  --radius-s: 8px;
  --red: #ff453a;
  --separator: #38383a;
  --text-primary: #ffffff;
  --text-secondary: #8e8e93;
  --z-drag: 2000;
  --z-modal: 100;
  --z-tooltip: 1000;
}

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

html {
  background-color: var(--bg-app);
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  font-size: 15px;
  height: 100vh;
  height: 100dvh;
  opacity: 0;
  overflow-y: auto;
  transition: opacity 0.6s ease;
  width: 100vw;
}

.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
  inset: 0;
  position: fixed;
  width: 100%;
}

@media (min-width: 900px) {
  .app-layout {
    grid-template-columns: var(--left-pane-width, calc(450px + (100vw - 900px) / 4)) 4px 1fr;
  }
}

.chat-pane,
.preview-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.chat-pane {
  background-color: var(--bg-app);
  isolation: isolate;
}

.preview-pane {
  background-color: #0d0d0d;
  display: none;
}

@media (min-width: 900px) {
  .preview-pane {
    display: flex;
  }
}

.chat-pane header {
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

header {
  align-items: center;
  backdrop-filter: blur(20px);
  background: rgba(28, 28, 30, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-shrink: 0;
  height: var(--header-height);
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

.chat-header {
  backdrop-filter: blur(50px);
  background: rgba(28, 28, 30, 0.7);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}

.header-left {
  display: flex;
  justify-content: flex-start;
}

.header-center {
  display: flex;
  justify-content: center;
}

.header-right {
  display: flex;
  justify-content: flex-end;
}

.header-center h1 {
  font-size: 16px;
  font-weight: 600;
}

.preview-header h2 {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
}

.logo-container {
  align-items: center;
  display: flex;
  position: relative;
}

.logo-btn {
  align-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  transition: background 0.2s;
  width: 32px;
}

@media (hover: hover) {
  .logo-btn:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

.logo-icon {
  background: linear-gradient(135deg, #0a84ff, #007aff);
  -webkit-background-clip: text;
  color: transparent;
  font-size: 20px;
  transform: rotate(0deg);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}

.logo-container.armed .logo-icon {
  transform: rotate(180deg);
}

.logo-btn.spinning .logo-icon {
  animation: spin-cycle 0.6s linear infinite;
  transform: rotate(180deg);
  transition: none;
}

@keyframes spin-cycle {
  0% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(540deg);
  }
}

.reset-tooltip {
  backdrop-filter: blur(10px);
  background: rgba(30, 30, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  color: white;
  font-size: 12px;
  font-weight: 500;
  left: 100%;
  margin-left: 8px;
  opacity: 0;
  padding: 6px 12px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  z-index: 20;
}

.logo-container.armed .reset-tooltip {
  opacity: 1;
  transform: translateX(0);
}

.debug-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  margin-right: 12px;
  padding: 4px;
  transition: color 0.2s;
}

.debug-btn:hover {
  color: var(--text-primary);
}

.online-badge {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  color: #fff;
  cursor: default;
  display: flex;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  padding: 6px 14px;
  transition: all 0.2s;
}

.online-badge:hover {
  background: rgba(255, 255, 255, 0.12);
}

.online-badge i {
  color: var(--blue);
  font-size: 14px;
}

.loader-bar {
  background-color: var(--blue);
  bottom: 0;
  height: 2px;
  left: 0;
  opacity: 0;
  position: absolute;
  transition: width 0.2s, opacity 0.3s;
  width: 0%;
}

.loader-bar.active {
  opacity: 1;
}

.loader-spinner {
  color: var(--text-secondary);
  font-size: 14px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  padding: 80px 16px 90px 16px;
  position: absolute;
}

.message-list.destructing {
  pointer-events: none;
}

.message-list::-webkit-scrollbar,
.preview-content::-webkit-scrollbar {
  width: 4px;
}

.message-list::-webkit-scrollbar-thumb,
.preview-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.timestamp-separator {
  color: var(--text-secondary);
  font-size: 11px;
  margin: 24px 0 12px 0;
  opacity: 0.8;
  text-align: center;
  transition: opacity 0.5s ease;
}

.chat-notification {
  animation: toastIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  left: 50%;
  padding: 8px 16px;
  pointer-events: none;
  position: absolute;
  text-align: center;
  top: 0;
  transform: translate(-50%, 0);
  z-index: 9;
}

.chat-notification.error {
  background: rgba(255, 69, 58, 0.9);
}

.chat-notification.closing {
  animation: toastOut 0.5s cubic-bezier(0.7, 0, 1, 0.5) forwards;
}

@keyframes toastIn {
  from {
    transform: translate(-50%, 0);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 75px);
    opacity: 1;
  }
}

@keyframes toastOut {
  from {
    transform: translate(-50%, 75px);
    opacity: 1;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 0;
  }
}

.message-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.message-group.me {
  align-items: flex-end;
}

.message-group.them {
  align-items: flex-start;
}

.group-timestamp {
  color: var(--text-secondary);
  font-size: 10px;
  margin: 2px 0px;
  opacity: 0;
  transition: opacity 0.2s;
}

.message-group:hover .group-timestamp {
  opacity: 1;
}

@media (hover: none) {
  .message-group.show-timestamp .group-timestamp {
    opacity: 1;
  }

  .bubble {
    cursor: pointer;
  }
}

.bubble {
  animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: calc(85% - 40px);
  position: relative;
  transform-origin: bottom left;
}

.bubble::before {
  bottom: 0;
  content: "";
  left: -100vw;
  position: absolute;
  right: -100vw;
  top: 0;
  z-index: -1;
}

.bubble + .bubble {
  margin-top: 3px;
}

.file-bubble + .file-bubble {
  margin-top: 4px;
}

.embed-bubble + .embed-bubble {
  margin-top: 5px;
}

.bubble:hover .bubble-actions,
.bubble.show-actions .bubble-actions {
  opacity: 1;
  pointer-events: auto;
}

.bubble-actions {
  bottom: 2px;
  display: flex;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.me .bubble-actions {
  left: -32px;
}

.them .bubble-actions {
  right: -32px;
}

.bubble-copy-btn {
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  height: 28px;
  justify-content: center;
  transition: color 0.2s, transform 0.2s;
  width: 28px;
}

.bubble-copy-btn:hover {
  color: var(--text-primary);
  transform: scale(1.1);
}

.bubble-copy-btn:active {
  transform: scale(0.92);
}

.me .bubble {
  transform-origin: bottom right;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bubble-text {
  background-color: var(--user-color, #262628);
  border-radius: 4px 18px 18px 4px;
  min-width: 34px;
  overflow-wrap: break-word;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

.me .bubble-text {
  border-radius: 18px 4px 4px 18px;
  color: white;
}

.bubble:first-child .bubble-text {
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
}

.bubble:last-child .bubble-text {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}

.bubble.pending {
  opacity: 0.6;
}

.bubble a {
  color: white;
  cursor: pointer;
  pointer-events: auto;
  text-decoration: underline;
}

.embed-bubble {
  max-width: 65%;
}

.bubble-embed-container {
  border: 2px solid var(--user-color);
  border-radius: var(--radius-m);
  cursor: pointer;
  max-height: 320px;
  overflow: hidden;
  position: relative;
  transition: transform 0.2s;
  will-change: transform;
}

.embed-media {
  background: transparent;
  display: block;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  width: 100%;
}

.play-icon-overlay {
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  height: 48px;
  justify-content: center;
  left: 50%;
  padding-left: 2px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
}

.audio-player {
  align-items: center;
  background-color: var(--user-color, var(--bg-tertiary));
  border-radius: var(--radius-m);
  display: flex;
  gap: 16px;
  min-width: 280px;
  padding: 12px 16px;
  position: relative;
  transition: background-color 0.2s, transform 0.2s;
  will-change: transform;
}

.audio-control-btn {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  font-size: 16px;
  height: 44px;
  justify-content: center;
  padding: 0;
  padding-left: 3px;
  transition: background 0.2s, transform 0.1s;
  width: 44px;
}

.playing .audio-control-btn {
  padding-left: 0;
}

.audio-control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.audio-control-btn:active {
  transform: scale(0.95);
}

.audio-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  min-width: 0;
}

.audio-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  line-height: 1;
}

.audio-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-time {
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-left: 12px;
}

.audio-slider-wrapper {
  align-items: center;
  display: flex;
  height: 12px;
  position: relative;
  width: 100%;
}

.audio-track-bg {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  height: 4px;
  position: absolute;
  width: 100%;
}

.audio-progress-fill {
  background: white;
  border-radius: 2px;
  height: 4px;
  left: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.audio-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 100%;
  margin: 0;
  position: absolute;
  width: 100%;
  z-index: 2;
}

.audio-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  height: 12px;
  width: 12px;
}

.audio-slider::-moz-range-thumb {
  background: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  height: 12px;
  width: 12px;
}

.file-card {
  align-items: center;
  background-color: var(--user-color, var(--bg-tertiary));
  border-radius: var(--radius-m);
  cursor: pointer;
  display: flex;
  gap: 12px;
  min-width: 200px;
  padding: 12px;
  transition: transform 0.2s;
  will-change: transform;
}

.file-icon-wrapper {
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: flex;
  font-size: 20px;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.file-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 12px;
  opacity: 0.7;
}

.input-area-container {
  backdrop-filter: blur(50px);
  background: rgba(28, 28, 30, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  bottom: 0;
  left: 0;
  padding: 12px 16px;
  position: absolute;
  right: 0;
  z-index: 20;
}

.input-bar {
  align-items: flex-end;
  display: flex;
  gap: 12px;
}

.icon-btn,
.send-btn {
  align-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--blue);
}

.send-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  transition: background-color 1s, color 1s, transform 0.5s;
}

.send-btn:active {
  transform: scale(0.92);
}

.text-field-wrapper {
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: 20px;
  display: flex;
  flex: 1;
  min-height: 38px;
  padding: 8px 18px;
}

textarea {
  background: transparent;
  border: none;
  color: white;
  font-family: inherit;
  font-size: 15px;
  max-height: 120px;
  padding: 0;
  resize: none;
  width: 100%;
}

.resizer {
  background: var(--separator);
  cursor: col-resize;
  display: none;
  width: 4px;
  z-index: 50;
}

.resizer:hover,
.resizer.dragging {
  background: var(--blue);
}

@media (min-width: 900px) {
  .resizer {
    display: block;
  }
}

.preview-actions,
.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions {
  gap: 16px;
}

.action-btn,
.modal-actions button,
.modal-close-btn {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.modal-actions button,
.modal-close-btn {
  backdrop-filter: blur(10px);
  background: rgba(40, 40, 40, 0.8);
  border-radius: 50%;
  height: 40px;
  pointer-events: auto;
  width: 40px;
}

.action-btn:hover:not(:disabled),
.modal-actions button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.action-btn:disabled {
  cursor: default;
  opacity: 0.3;
}

.preview-content {
  align-items: center;
  display: flex;
  flex: 1;
  justify-content: center;
  overflow: auto;
  padding: 24px;
}

@media (min-width: 900px) {
  .preview-content {
    padding: 12px;
  }
}

.empty-state {
  align-items: center;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state i {
  font-size: 48px;
  opacity: 0.3;
}

.preview-item,
.modal-preview-item {
  border-radius: 8px;
  object-fit: contain;
}

.preview-item {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.layout-fit {
  height: auto;
  max-height: calc(100% - 36px);
  max-width: calc(100% - 36px);
  width: auto;
}

.layout-fill {
  border: none;
  height: calc(100% - 36px);
  width: calc(100% - 36px);
}

img.layout-fill {
  background: #cdcdcd;
}

iframe.layout-fill {
  background: transparent;
}

@media (min-width: 900px) {
  .layout-fit {
    max-height: calc(100% - 24px);
    max-width: calc(100% - 24px);
  }

  .layout-fill {
    height: calc(100% - 24px);
    width: calc(100% - 24px);
  }
}

.text-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  color: var(--text-primary);
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow: auto;
  padding: 20px;
  white-space: pre-wrap;
  word-break: break-all;
}

.layout-fill.text-preview {
  background: var(--bg-secondary);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  background: #333;
  border-radius: 6px;
  color: white;
  content: attr(data-tooltip);
  font-size: 12px;
  left: 50%;
  margin-top: 8px;
  opacity: 0;
  padding: 5px 10px;
  pointer-events: none;
  position: absolute;
  top: 100%;
  transform: scale(0.95) translateX(-50%);
  transition: 0.2s;
  visibility: hidden;
  white-space: nowrap;
  z-index: var(--z-tooltip);
}

@media (hover: hover) {
  [data-tooltip]:hover::after,
  [data-tooltip].tooltip-visible::after {
    opacity: 1;
    transform: scale(1) translateX(-50%);
    transition-delay: 0s;
    visibility: visible;
  }

  [data-tooltip]:hover::after {
    transition-delay: 0.5s;
  }
}

[data-tooltip].tooltip-visible::after {
  opacity: 1;
  transform: scale(1) translateX(-50%);
  transition-delay: 0s;
  visibility: visible;
}

.tooltip-error[data-tooltip]::after {
  background: var(--red);
}

.modal-viewer {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  transition: visibility 0.3s;
  visibility: hidden;
  z-index: var(--z-modal);
}

.modal-viewer.active {
  visibility: visible;
}

.modal-overlay {
  backdrop-filter: blur(15px);
  background: rgba(0, 0, 0, 0.6);
  inset: 0;
  opacity: 0;
  position: absolute;
  transition: opacity 0.3s;
}

.modal-viewer.active .modal-overlay {
  opacity: 1;
}

.modal-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  opacity: 0;
  position: relative;
  transform: scale(0.96);
  transition: 0.3s;
  width: 100%;
  z-index: 1;
}

.modal-viewer.active .modal-container {
  opacity: 1;
  transform: scale(1);
}

.modal-header {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: transparent;
  border-bottom: none;
  height: auto;
  left: 0;
  padding: 18px;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 20;
}

.modal-content {
  align-items: center;
  display: flex;
  flex: 1;
  height: 100%;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  padding-top: 56px;
  width: 100%;
}

#drop-overlay {
  align-items: center;
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.2s;
  z-index: var(--z-drag);
}

#drop-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.drop-content {
  align-items: center;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drop-icon-wrapper {
  align-items: center;
  background: var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(10, 132, 255, 0.4);
  display: flex;
  font-size: 32px;
  height: 80px;
  justify-content: center;
  width: 80px;
}

.preview-card {
  align-items: center;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
  max-width: 100%;
  text-align: center;
  width: fit-content;
}

.card-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.card-label {
  font-size: 16px;
  font-weight: 500;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-sub {
  color: var(--text-secondary);
  font-size: 13px;
  opacity: 0.8;
}

.card-action {
  margin-top: 16px;
}

.fallback-action-link {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: white;
  display: flex;
  gap: 8px;
  height: 36px;
  justify-content: center;
  padding: 0 20px;
  text-decoration: none;
  transition: background 0.2s;
}

.fallback-action-link:hover {
  background: rgba(255, 255, 255, 0.2);
}

.long-pressing {
  transform: scale(0.95) !important;
  transition: transform 0.15s ease-out;
}
