* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0d10;
  --panel: #11151a;
  --panel-2: #171c22;
  --border: #252c34;
  --border-soft: #1d232a;
  --text: #e7edf3;
  --muted: #93a0ad;
  --accent: #57e389;
  --accent-2: #67b7ff;
  --danger: #ff8f8f;
  --mine: #163126;
  --other: #181d24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top, rgba(103, 183, 255, 0.08), transparent 30%),
    radial-gradient(circle at bottom, rgba(87, 227, 137, 0.07), transparent 28%),
    var(--bg);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.chat-shell {
  width: min(980px, 100%);
  height: min(92vh, 900px);
  background: rgba(17, 21, 26, 0.96);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
}

.header-left {
  min-width: 0;
}

.logo {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(87, 227, 137, 0.45);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: #34404c;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-messages::-webkit-scrollbar {
  width: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #2a323c;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.message-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(78%, 720px);
}

.message-row.mine {
  align-self: flex-end;
}

.message-row.other {
  align-self: flex-start;
}

.message-bubble {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  background: var(--other);
}

.message-row.mine .message-bubble {
  background: var(--mine);
  border-color: #28533f;
}

.message-author {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 15px;
  color: var(--text);
}

.message-time {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.8;
  padding: 0 4px;
}

.message-row.mine .message-time {
  text-align: right;
}

.file-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.file-image {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
  background: #0d1116;
  border: 1px solid var(--border);
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #1d2430;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #2b3440;
  flex-shrink: 0;
}

.file-info {
  min-width: 0;
  flex: 1;
}

.file-name {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}

.file-size {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.file-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-2);
  text-decoration: none;
  font-size: 13px;
}

.file-link:hover {
  text-decoration: underline;
}

.preview-wrap {
  padding: 0 18px 14px;
}

.preview-card {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 18px;
  padding: 12px;
}

.preview-title {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-thumb {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0d1116;
}

.preview-file-box {
  width: 68px;
  height: 68px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #1d2430;
  color: var(--accent-2);
  border: 1px solid #2b3440;
  font-size: 12px;
  font-weight: 700;
}

.preview-info {
  min-width: 0;
  flex: 1;
}

.preview-name {
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}

.preview-size {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.remove-file-btn {
  border: 1px solid #5b3131;
  background: rgba(255, 143, 143, 0.08);
  color: var(--danger);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
}

.composer {
  padding: 16px 18px 18px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.attach-btn {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--accent-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.attach-btn span {
  font-size: 30px;
  line-height: 1;
  transform: translateY(-1px);
}

.attach-btn:hover {
  border-color: #3a4653;
}

.message-input {
  flex: 1;
  min-width: 0;
  height: 54px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 16px;
  outline: none;
  font: inherit;
  font-size: 15px;
}

.message-input:focus {
  border-color: #3a4653;
}

.message-input::placeholder {
  color: var(--muted);
}

.hidden,
.hidden-input {
  display: none !important;
}

@media (max-width: 720px) {
  .app {
    padding: 0;
  }

  .chat-shell {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .chat-header {
    padding: 14px;
    align-items: flex-start;
  }

  .logo {
    font-size: 21px;
  }

  .subtitle {
    font-size: 12px;
  }

  .chat-messages {
    padding: 14px;
  }

  .preview-wrap {
    padding: 0 14px 10px;
  }

  .composer {
    padding: 12px 14px 14px;
    gap: 10px;
  }

  .attach-btn,
  .message-input {
    height: 50px;
    border-radius: 14px;
  }

  .attach-btn {
    width: 50px;
  }

  .message-row {
    max-width: 92%;
  }
}

@media (max-width: 520px) {
  .chat-header {
    flex-direction: column;
    gap: 12px;
  }

  .header-right {
    width: 100%;
    align-items: flex-start;
  }

  .message-row {
    max-width: 96%;
  }
}