
:root {
  color-scheme: dark;

  --background: #000000;
  --panel: #181a1e;
  --surface: #202328;
  --border: #343840;
  --text: #e8eaed;
  --muted: #969da7;
  --accent: #3478f6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;

  background: var(--background);
  color: var(--text);
}

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

button {
  border: 0;
  border-radius: 9px;
  padding: 12px 15px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

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

button:hover:not(:disabled) {
  filter: brightness(1.15);
}

input,
textarea,
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #82aaff;
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
}

small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.error {
  color: #fca5a5;
  font-size: 13px;
  white-space: pre-wrap;
}

/* Impact Ballistics watermark */

.watermark {
  background: #000000;
  position: relative;
  isolation: isolate;
}

.watermark::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;

  background-image:
    url("https://www.impactballisticsapp.com/second_logo.png");

  background-position: center center;
  background-repeat: no-repeat;
  background-size: min(70%, 620px) auto;

  filter: grayscale(1) invert(1);
  opacity: 0.12;
}

/* Login screen */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.loginCard {
  width: min(100%, 400px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(24, 26, 30, 0.87);
}

.loginCard h1 {
  margin: 0;
  font-size: 30px;
}

.loginCard p {
  color: var(--muted);
  margin-bottom: 26px;
}

.loginCard form {
  display: grid;
  gap: 12px;
}

.loginCard small {
  margin-top: 24px;
  text-align: center;
}

.loginCard .error {
  margin-top: 12px;
}

/* Application layout */

.application {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

aside {
  width: 270px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.sideHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sideHeader h2 {
  font-size: 19px;
  margin: 4px 0;
}

#conversationList {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation {
  display: flex;
  border-radius: 8px;
  min-width: 0;
}

.conversation:hover,
.conversation.active {
  background: var(--surface);
}

.conversation button {
  background: transparent;
}

.conversation .title {
  flex: 1;
  text-align: left;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 10px;
}

.conversation .remove {
  color: var(--muted);
  padding: 8px;
}

.conversation .remove:hover {
  color: #fca5a5;
}

main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.88);
}

header small {
  margin-top: 4px;
}

header select {
  max-width: 55%;
  font-size: 13px;
}

/* Chat window */

#messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 26px 20px;
}

.welcome {
  text-align: center;
  margin: 12vh auto 0;
  max-width: 650px;
}

.welcome h1 {
  font-size: clamp(25px, 5vw, 38px);
}

.welcome p {
  color: var(--muted);
}

.message {
  max-width: 900px;
  margin: 0 auto 22px;
  line-height: 1.65;
}

.message small {
  margin-bottom: 6px;
}

.content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .content {
  background: var(--surface);
  padding: 16px;
  border-radius: 12px;
}

.message.assistant .content {
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  padding: 8px;
}

.tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.tools button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 5px 12px;
}

.tools small {
  margin: 0;
}

/* Message composer */

footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.9);
}

footer form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 900px;
  margin: auto;
}

textarea {
  flex: 1;
  min-width: 0;
  max-height: 240px;
  resize: vertical;
}

footer small {
  text-align: center;
  margin-top: 10px;
}

#chatError {
  max-width: 900px;
  margin: 0 auto 8px;
}

.mobile {
  display: none;
}

/* Mobile layout */

@media (max-width: 700px) {

  aside {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 5px 0 30px #0008;
  }

  aside.open {
    transform: translateX(0);
  }

  .mobile {
    display: inline-block;
  }

  header {
    padding: 10px;
  }

  header select {
    max-width: 48%;
    padding: 8px;
  }

  #messages,
  footer {
    padding: 12px;
  }

  .watermark::before {
    background-size: 85% auto;
  }

}
