:root {
  color-scheme: light;
  --bg: #e7ebf0;
  --panel: #ffffff;
  --surface: #f8fafc;
  --text: #18212f;
  --muted: #667085;
  --line: #d6dde7;
  --primary: #167260;
  --primary-dark: #0d5548;
  --accent: #2f6fed;
  --sent: #167260;
  --received: #ffffff;
  --error: #b42318;
  --shadow: 0 16px 36px rgba(24, 33, 47, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(231, 235, 240, 0.94)),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  padding: max(28px, env(safe-area-inset-top)) 20px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  background: #f4f7fa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 2px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(22, 114, 96, 0.24);
}

.brand h1,
.chat-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.brand p,
.room-label {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.tabs {
  display: none;
}

.tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 40px;
}

.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(31, 41, 55, 0.12);
}

label {
  display: block;
  margin-top: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfe;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 111, 95, 0.14);
}

.primary-button,
.send-button,
.ghost-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(22, 114, 96, 0.2);
}

.primary-button:active,
.send-button:active {
  background: var(--primary-dark);
}

.error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--error);
  font-size: 14px;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chat-view {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #edf2f6;
}

.chat-header {
  min-height: 76px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 8px 20px rgba(24, 33, 47, 0.06);
}

.chat-header h1 {
  font-size: 18px;
}

.room-label {
  font-size: 12px;
}

.ghost-button {
  flex: 0 0 auto;
  padding: 0 14px;
  color: var(--primary);
  background: #e4f3ef;
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px 20px;
  scroll-behavior: smooth;
}

.empty-state {
  margin: 22vh auto 0;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 12px 0;
}

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

.message-meta {
  margin: 0 4px 4px;
  color: var(--muted);
  font-size: 12px;
}

.bubble {
  max-width: min(78%, 330px);
  padding: 10px 13px;
  border-radius: 12px;
  background: var(--received);
  border: 1px solid var(--line);
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 4px 14px rgba(24, 33, 47, 0.06);
}

.mine .bubble {
  background: var(--sent);
  border-color: var(--sent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(22, 114, 96, 0.2);
}

.message-form {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 8px;
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(24, 33, 47, 0.07);
}

.message-form input {
  min-height: 44px;
}

.send-button {
  background: var(--primary);
  color: #fff;
}

.scroll-bottom-button {
  position: absolute;
  right: 14px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 3;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(22, 114, 96, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--primary);
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 10px 26px rgba(24, 33, 47, 0.18);
}

@media (min-width: 481px) {
  body {
    background: #dfe4ea;
  }

  .app-shell {
    min-height: 100vh;
    box-shadow: 0 0 0 1px rgba(31, 41, 55, 0.08);
  }
}
