:root {
  color-scheme: light dark;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f3f1eb;
  color: #1d2524;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(225, 97, 74, 0.16), transparent 36%),
    linear-gradient(240deg, rgba(38, 113, 116, 0.16), transparent 42%),
    #f3f1eb;
}

.chat-panel {
  width: min(960px, 100%);
  height: min(820px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(29, 37, 36, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 48px rgba(29, 37, 36, 0.14);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(29, 37, 36, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: #596260;
  font-size: 14px;
}

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

.empty {
  margin: auto;
  max-width: 520px;
  color: #596260;
  text-align: center;
  line-height: 1.6;
}

.message {
  max-width: min(720px, 88%);
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: #1f6f72;
  color: white;
}

.message.assistant {
  align-self: flex-start;
  background: #eef0ed;
  color: #1d2524;
}

.message.error {
  align-self: center;
  color: #8c251b;
  background: #ffe9e4;
}

.composer {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border-top: 1px solid rgba(29, 37, 36, 0.12);
  background: #ffffff;
}

label {
  display: grid;
  gap: 6px;
  color: #596260;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(29, 37, 36, 0.18);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fbfbf8;
  color: #1d2524;
  outline: none;
}

textarea {
  min-height: 68px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: #1f6f72;
  box-shadow: 0 0 0 3px rgba(31, 111, 114, 0.14);
}

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

button:hover {
  background: #bf4f3c;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

#resetButton {
  background: #e7e3d8;
  color: #1d2524;
}

@media (max-width: 720px) {
  .shell {
    padding: 0;
  }

  .chat-panel {
    min-height: 100vh;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 94%;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    background: #101817;
    color: #f2f4ef;
  }

  .shell {
    background:
      linear-gradient(120deg, rgba(219, 98, 76, 0.18), transparent 36%),
      linear-gradient(240deg, rgba(66, 156, 160, 0.18), transparent 42%),
      #101817;
  }

  .chat-panel,
  .topbar,
  .composer {
    background: #17211f;
    border-color: rgba(242, 244, 239, 0.12);
  }

  p,
  label {
    color: #acb7b3;
  }

  input,
  textarea {
    background: #101817;
    color: #f2f4ef;
    border-color: rgba(242, 244, 239, 0.16);
  }

  .message.assistant {
    background: #22302d;
    color: #f2f4ef;
  }

  #resetButton {
    background: #293632;
    color: #f2f4ef;
  }
}

.owner-panel {
  grid-template-rows: auto auto 1fr;
}

.owner-login {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border-bottom: 1px solid rgba(29, 37, 36, 0.12);
  background: #ffffff;
}

.requests {
  overflow-y: auto;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.request {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(29, 37, 36, 0.12);
  border-radius: 8px;
  background: #fbfbf8;
}

.request.answered {
  opacity: 0.78;
}

.request-meta {
  color: #596260;
  font-size: 13px;
}

.request-question {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  line-height: 1.55;
  color: #1d2524;
}

.request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.answer-box {
  display: grid;
  gap: 6px;
}

.link-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  background: #1f6f72;
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.link-button:hover {
  background: #185b5e;
}

@media (max-width: 720px) {
  .owner-login {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  .owner-login,
  .request {
    background: #17211f;
    border-color: rgba(242, 244, 239, 0.12);
  }

  .request-question {
    color: #f2f4ef;
  }
}
