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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid #ccd3df;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  padding: 10px 14px;
  cursor: pointer;
}

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

.primary {
  border-color: #1f6feb;
  background: #1f6feb;
  color: #fff;
}

.app {
  width: min(920px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.setup,
.chat {
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 32px);
}

.setup {
  display: grid;
  align-content: center;
  gap: 16px;
  max-width: 460px;
  margin: 0 auto;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

p {
  color: #637083;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
}

input {
  width: 100%;
  border: 1px solid #ccd3df;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: #172033;
  font-size: 16px;
}

fieldset {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 12px;
  border: 1px solid #ccd3df;
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: #637083;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.radio input {
  width: auto;
}

.row {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.chat.hidden {
  display: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dfe5ef;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 8px 0 16px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: min(72%, 620px);
}

.message.mine {
  align-self: flex-end;
}

.meta {
  margin-bottom: 4px;
  color: #637083;
  font-size: 13px;
}

.bubble {
  overflow-wrap: anywhere;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e0e6ef;
  padding: 10px 12px;
  line-height: 1.5;
}

.good .bubble {
  border-left: 4px solid #22a06b;
}

.other .bubble {
  border-left: 4px solid #f97316;
}

.mine .bubble {
  background: #eaf2ff;
  border-color: #bdd4ff;
}

.bubble img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: 6px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #dfe5ef;
}

.fileButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  border: 1px solid #ccd3df;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.fileButton input {
  display: none;
}

@media (max-width: 640px) {
  .app {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .setup,
  .chat {
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 24px);
  }

  header {
    align-items: flex-start;
  }

  header button {
    flex: 0 0 auto;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: 1fr auto;
    align-items: stretch;
  }

  .composer .primary {
    grid-column: span 2;
  }

  .fileButton,
  .composer button {
    min-height: 44px;
  }
}
