:root {
  --bg: #efeae2;
  --panel: #ffffff;
  --top: #0b141a;
  --accent: #00a884;
  --accent-dark: #008069;
  --mine: #d9fdd3;
  --theirs: #ffffff;
  --text: #111b21;
  --muted: #667781;
  --line: #d1d7db;
  --danger: #b42318;
  --danger-bg: #fde7e9;
  --warn: #8a5a00;
  --warn-bg: #fff3cf;
  --shadow: 0 6px 28px rgba(11, 20, 26, 0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--accent) 0 120px, var(--bg) 120px 100%);
}
button, input { font: inherit; }
button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.ghost { background: #e7f7f3; color: var(--accent-dark); }
button.small, .tiny { font-size: 12px; padding: 7px 10px; }
button.danger { background: var(--danger-bg); color: var(--danger); }
button.warn { background: var(--warn-bg); color: var(--warn); }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  outline: none;
}
input:focus { border-color: #9dd7cb; box-shadow: 0 0 0 3px rgba(0,168,132,.12); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app {
  width: min(100vw, 520px);
  height: 100vh;
  margin: 0 auto;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.page {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.auth-page {
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(0,168,132,.08), rgba(0,168,132,0)),
    var(--bg);
}
.auth-card {
  background: var(--panel);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
}
.brand-block h1 { margin: 0 0 4px; }
.brand-block p { margin: 0; color: var(--muted); }
.auth-form { display: grid; gap: 12px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.topbar {
  padding: 14px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.home-topbar h2, .chat-topbar h2 { margin: 0; font-size: 18px; }
.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f7f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}
#meLine { margin: 4px 0 0; font-size: 12px; }

.panel {
  background: var(--panel);
  margin: 10px;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.section-head h3 { margin: 0 0 12px; }
.profile-name { font-size: 30px; font-weight: 700; margin-bottom: 4px; }
.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.stack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
}
.result-item, .conversation-item {
  background: #fff;
  border: 1px solid #eef1f3;
  border-radius: 14px;
  padding: 12px;
}
.result-item .top, .conversation-item .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.conversation-item { cursor: pointer; }
.conversation-item.active {
  background: #f0fdf9;
  border-color: #bfeade;
}
.badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  font-size: 12px;
  padding: 0 6px;
}
.chat-page {
  background: #efeae2;
  background-image:
    radial-gradient(rgba(255,255,255,0.18) 1px, transparent 1px),
    radial-gradient(rgba(0,0,0,0.03) 1px, transparent 1px);
  background-position: 0 0, 20px 20px;
  background-size: 40px 40px;
}
.chat-user-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.typing-status {
  color: var(--accent-dark);
  font-size: 12px;
  max-width: 100px;
  text-align: right;
}
.message-list {
  flex: 1;
  overflow: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.message { display: flex; }
.message.mine { justify-content: flex-end; }
.bubble {
  max-width: 82%;
  background: var(--theirs);
  border-radius: 10px 10px 10px 2px;
  padding: 8px 10px 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.message.mine .bubble {
  background: var(--mine);
  border-radius: 10px 10px 2px 10px;
}
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.sender { font-size: 12px; color: var(--accent-dark); }
.meta { font-size: 11px; color: var(--muted); }
.text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.photo {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 8px;
}
.actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.composer {
  padding: 10px;
  background: #f0f2f5;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #1f2c34;
  color: white;
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 10;
}
