* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #111;
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; }
.screen[hidden] { display: none; }

.login-box {
  max-width: 320px;
  margin: 15vh auto 0;
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-box h1 { font-size: 18px; margin: 0 0 8px; }
.login-box input {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
.login-box button {
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #25d366;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.error { color: #d33; font-size: 13px; margin: 0; min-height: 16px; }

#app-screen {
  display: flex;
}

#conversation-list {
  width: 320px;
  border-right: 1px solid #ddd;
  background: #fff;
  overflow-y: auto;
  flex-shrink: 0;
}

.conv-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.conv-item:hover { background: #f7f7f7; }
.conv-item.active { background: #e9f7ef; }
.conv-name { font-weight: 600; font-size: 14px; }
.conv-preview { font-size: 12px; color: #666; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-badge {
  background: #25d366;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 7px;
  min-width: 18px;
  text-align: center;
}

#thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#thread-empty {
  margin: auto;
  color: #888;
}
#thread-active {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#thread-header {
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#thread-name { font-weight: 600; }
.pause-toggle { font-size: 13px; display: flex; align-items: center; gap: 6px; color: #444; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #efeae2;
}

.msg {
  max-width: 60%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.msg-in { align-self: flex-start; background: #fff; }
.msg-out { align-self: flex-end; background: #d9fdd3; }
.msg-time { display: block; font-size: 10px; color: #999; margin-top: 2px; text-align: right; }

#window-notice {
  padding: 8px 16px;
  background: #fff3cd;
  color: #856404;
  font-size: 13px;
}

#send-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #ddd;
}
#send-body {
  flex: 1;
  resize: none;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}
#send-form button {
  padding: 0 16px;
  border: none;
  border-radius: 6px;
  background: #25d366;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
#send-form button:disabled, #send-body:disabled {
  background: #ccc;
  cursor: not-allowed;
}
