:root {
  color-scheme: light;
  --bg: #edf2f7;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --ink: #172033;
  --muted: #65758b;
  --line: #d9e2ec;
  --accent: #0f8b8d;
  --accent-dark: #0a6f72;
  --danger: #c2410c;
  --shadow: 0 20px 60px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(242, 153, 74, 0.16), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  width: min(1180px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  margin: 16px auto;
}

.sidebar,
.chat {
  min-height: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 226, 236, 0.9);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1;
}

.brand p,
.chat-header p,
.field span,
.panel-title {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
}

.field input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.field input {
  height: 42px;
  padding: 0 12px;
}

.field input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

.panel {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.presence-list {
  display: grid;
  gap: 8px;
  overflow: auto;
}

.presence {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.presence-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a34a;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 8px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.88);
}

.chat-header h2 {
  font-size: 22px;
}

.icon-button,
.file-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  overflow-y: auto;
}

.message {
  align-self: flex-start;
  width: min(620px, 88%);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.message.mine {
  align-self: flex-end;
  border-color: rgba(15, 139, 141, 0.28);
  background: #eaf8f7;
}

.message-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.burn-badge {
  color: var(--danger);
  font-weight: 700;
}

.file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

.burned {
  align-self: center;
  width: auto;
  color: var(--muted);
  background: transparent;
  border-style: dashed;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

textarea {
  min-height: 58px;
  max-height: 160px;
  resize: vertical;
  padding: 12px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  cursor: pointer;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.composer button[type="submit"] {
  height: 40px;
  margin-left: auto;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.composer button[type="submit"]:hover {
  background: var(--accent-dark);
}

.file-preview {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.file-preview[hidden] {
  display: none;
}

.file-preview button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: 100vw;
    height: 100vh;
    margin: 0;
    gap: 0;
  }

  .sidebar {
    min-height: 180px;
    border-radius: 0;
    box-shadow: none;
  }

  .chat {
    border-radius: 0;
    box-shadow: none;
  }

  .message {
    width: 94%;
  }
}
