:root {
  color-scheme: light;
  --ink: #152221;
  --muted: #657774;
  --page: #eef5f4;
  --line: #dce5e3;
  --surface: #ffffff;
  --teal: #087b78;
  --teal-dark: #06615f;
  --soft-teal: #e5f4f2;
  --light-bubble: #f0f4f3;
  --danger: #c84f44;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--page);
}

.app-root {
  width: min(100%, 480px);
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 16px;
  background: var(--page);
}

.chat-header {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.title-block {
  min-width: 0;
}

h1,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.start-view {
  min-height: 0;
  overflow: auto;
  padding: 4px 2px 24px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

input {
  min-height: 46px;
}

textarea {
  min-height: 124px;
  resize: vertical;
  line-height: 1.35;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 123, 120, 0.14);
}

.primary-action,
.secondary-action {
  min-height: 48px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
}

.primary-action {
  border: 0;
  background: var(--teal);
  color: #ffffff;
}

.primary-action:hover,
.primary-action:focus-visible {
  background: var(--teal-dark);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.secondary-action {
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
}

.status-line {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.chat-view {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

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

.message-row {
  display: flex;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-row.agent {
  justify-content: flex-start;
}

.message-bubble {
  width: 78%;
  max-width: 78%;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--light-bubble);
}

.message-row.mine .message-bubble {
  background: var(--soft-teal);
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.message-text {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.reply-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
}

.send-action {
  min-height: 48px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  width: min(420px, calc(100% - 32px));
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(21, 34, 33, 0.2);
}

@media (min-width: 700px) {
  .app-stage {
    padding: 22px;
  }

  .app-root {
    min-height: min(840px, calc(100dvh - 44px));
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}

@media (max-width: 360px) {
  .app-root {
    padding: 12px;
  }

  .chat-header {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .secondary-action {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .reply-bar {
    grid-template-columns: minmax(0, 1fr) 78px;
  }
}
