:root {
  color-scheme: light dark;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #f5f7f8;
  color: #182026;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(52, 92, 125, 0.08), transparent 38%),
    #f5f7f8;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  width: min(960px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #d9e0e4;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: #5d6870;
}

.connect {
  display: flex;
  gap: 8px;
}

input,
select,
textarea {
  border: 1px solid #c9d2d8;
  border-radius: 8px;
  background: #ffffff;
  color: #182026;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #287d73;
  box-shadow: 0 0 0 3px rgba(40, 125, 115, 0.16);
}

input {
  width: 180px;
  padding: 10px 12px;
}

select {
  min-width: 220px;
  max-width: 100%;
  height: 38px;
  padding: 0 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #287d73;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.log {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 360px;
  padding: 4px 0;
}

.line {
  width: fit-content;
  max-width: min(760px, 100%);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #d9e0e4;
  background: #ffffff;
  line-height: 1.5;
}

.line.user {
  align-self: flex-end;
  background: #e7f4f1;
  border-color: #b8ddd6;
}

.line.agent {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.line.system {
  align-self: center;
  color: #64717a;
  background: transparent;
  border-color: transparent;
  padding: 2px 8px;
}

.line.error {
  color: #8a2d2d;
  background: #fff0ef;
  border-color: #f0c4c0;
}

.composer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
  padding-top: 14px;
  border-top: 1px solid #d9e0e4;
}

.targetbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: #5d6870;
}

.targetbar label {
  font-weight: 700;
}

.iconButton {
  min-height: 38px;
  padding: 0 12px;
}

.attachmentTray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.attachmentTray[hidden] {
  display: none;
}

.attachmentChip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid #c9d2d8;
  border-radius: 8px;
  padding: 0 8px 0 10px;
  background: #ffffff;
  color: #34424b;
}

.attachmentChip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachmentRemove {
  min-width: 26px;
  min-height: 26px;
  border-radius: 50%;
  padding: 0;
  background: #e7ecef;
  color: #34424b;
  font-weight: 800;
}

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

.attachButton {
  width: 46px;
  min-width: 46px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.visuallyHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  padding: 12px;
}

@media (max-width: 640px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .connect,
  .composer,
  .targetbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  input,
  select {
    width: 100%;
  }

  .composeRow {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .attachButton,
  #sendButton {
    align-self: stretch;
  }
}
