:root {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: #222;
  background: #f4f2ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f2ed;
}

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

.app-shell {
  width: min(820px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows:
    auto auto 1fr auto auto;
  background: #fbfaf7;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding:
    calc(16px + env(safe-area-inset-top))
    18px
    14px;
  border-bottom: 1px solid #e2dfd8;
}

h1 {
  margin: 0;
  font-size: 21px;
}

.subtitle {
  margin-top: 3px;
  color: #8a857c;
  font-size: 12px;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #ebe8e1;
}

.controls select {
  min-width: 0;
  flex: 1;
  padding: 9px;
  border: 1px solid #d8d4cc;
  border-radius: 10px;
  background: white;
}

.memory-toggle {
  white-space: nowrap;
  color: #625e57;
  font-size: 14px;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 14px 30px;
}

.message {
  max-width: 86%;
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  margin-left: auto;
  background: #252421;
  color: white;
  border-bottom-right-radius: 5px;
}

.message.assistant {
  margin-right: auto;
  background: #ebe8e0;
  color: #24231f;
  border-bottom-left-radius: 5px;
}

.message.pending {
  opacity: 0.65;
}

.memory-status {
  min-height: 24px;
  padding: 0 16px 5px;
  color: #817b72;
  font-size: 12px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  align-items: end;
  padding:
    10px
    12px
    calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #e2dfd8;
  background: rgba(251, 250, 247, 0.96);
}

textarea {
  width: 100%;
  max-height: 160px;
  resize: none;
  padding: 11px 12px;
  border: 1px solid #d4d0c7;
  border-radius: 14px;
  outline: none;
  background: white;
}

textarea:focus {
  border-color: #8d877d;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 15px;
  background: #292824;
  color: white;
}

button.secondary {
  padding: 9px 12px;
  background: #e7e3db;
  color: #35332e;
}

button:disabled {
  opacity: 0.5;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f4f2ed;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  width: min(360px, 100%);
  padding: 25px;
  border: 1px solid #ddd9d0;
  border-radius: 18px;
  background: #fbfaf7;
}

.login-card p {
  color: #777168;
}

.login-card input {
  width: 100%;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid #d4d0c7;
  border-radius: 10px;
}

.login-card button {
  width: 100%;
}

.error {
  min-height: 20px;
  margin-top: 10px;
  color: #a13c35;
  font-size: 13px;
}
